//////////////////////////////////////////////////////////////////////////////////////
//By T.Rowland 2004
//www.cornish-pasty.com
//////////////////////////////////////////////////////////////////////////////////////
//feel free to modify/copy/etc.
//tested with IE6 NS7.0 opera7 firebird 0.7
//////////////////////////////////////////////////////////////////////////////////////
//simple functions to decrypt email encrypted addresses and make it harder for them to be
//gathered by spammers
//by t.rowland 2004
//exaple mailto hyperlink;
//<a href='javascript:mailMe("200000001B060C2E143C0208121C0D1B0B49300000","Something","subject")'>email me</a>
//email address needs to be encrypted before hand using some other routine like encryptMe()
function encryptMe()
{
 addr=prompt("Enter the email address to encrypt: ","someone@somewhere.com");
 key=prompt("Enter the encryption key: ","Something");
 var encode='';
 var al=addr.length;
 var kl=key.length;
 for(f=0;f<al;f++)
  encode+=(toHex(addr.charCodeAt(f)^key.charCodeAt(f%kl)));
 prompt("copy the encoded email address below",encode);
}
function toHex(val)
{
 var hexdat='0123456789ABCDEF';
 var hexstr=hexdat.charAt(val>>4)+hexdat.charAt(val&0x0f);
 return hexstr;
}
function mailMe(addr,key,sub)
{
 var mailsys="Netscape mail";
 var al=addr.length;
 var kl=key.length;
 var decoded='';
 for(f=0;f<al;f+=2)
  decoded+=String.fromCharCode(eval("0x"+addr.charAt(f)+addr.charAt(f+1))^key.charCodeAt((f>>1)%kl));
 parent.location.href='mailto:'+decoded+'?subject='+sub+'';
}
//////////////////////////////////////////////////////////////////////////////////////
//load border images & set them
var aniGif=new Image();
var bdrPics=new Array();
var bPicSrc=[
"black",
"white",
"bl2",
"br2",
"br2a",
"hb2",
"ht2",
"tb2",
"tl2",
"tr2",
"tr2a",
"vl2",
"vr2"
];
function loadBorderPics()
{
 aniGif.src="images/ani/ctdani1.gif"; //I added this image as it is used on all other pages
 //get the pictures in bPicSrc array & put into bdrPics array
 //this function is initiated on a page, but the version int the docs 'parent' is run
 //so that the parent should load the images once
 for(var f=0;f<bPicSrc.length;f++)
 {
  bdrPics[f]=new Image();
  bdrPics[f].src="borders/"+bPicSrc[f]+".gif";
  //docs and pics are in 'borders/' dir, but as image belongs to 'parent',
  //we need to supply the path rel to index.html.
 } 
}
function setBorderPics()
{
 if(picElements[0]==undefined)
  return; //nowhere to display pictures
 if(parent.bdrPics[0]==undefined)
 try{
  parent.loadBorderPics(); //this works even without a 'parent' frame!
 }catch(e){               
  localLoadBorderPics(e); //failed! umm.
  return;
 } 
 if(parent.bdrPics[0]==undefined)
 {
  localLoadBorderPics(); //still not defined! umm.....
  return;
 }
 for(var f in picElements) //for every picElement in doc
 {
 for(var t in bPicSrc) //compare with bPicSrc (use local as they are defined within this file)
  {
   if(picElements[f]==bPicSrc[t])
   {
    var str="document.images.el"+f+".src=\""+bPicSrc[t]+".gif\"";
    eval(str);
    break;  //no need to continue
   }
  }
 }
}
function localLoadBorderPics()
{
 document.write("X3<br>");
 for(var f in picElements) //for every picElement in doc
 {
 for(var t in bPicSrc) //compare with bPicSrc (use local as they are defined within this file)
  {
   if(picElements[f]==bPicSrc[t])
   {
    var str="document.images.el"+f+".src=\""+bPicSrc[t]+".gif\"";
    eval(str);
    break;  //no need to continue
   }
  }
 }
}
//addition to set animation gif
function setAniPic()
{
 if(parent.bdrPics[0]==undefined)
 try{
  parent.loadBorderPics();
 }catch(e){
// localLoadBorderPics(e); //failed! umm, and this don't work!
  return;
 }
 if(parent.aniGif.src!=undefined)
  document.images.tdAni.src=parent.aniGif.src;
}
