
var SCRYPT={
	dec2hex:function(d){
		var hD="0123456789ABCDEF";
		var h = hD.substr(d&15,1);
		while(d>15) {d>>=4;h=hD.substr(d&15,1)+h;}
		return h;
		},
	hex2dec:function(h){return parseInt(h,16);},

	
	shiftChar:function(charIn,count){
		var decCode = charIn.charCodeAt(0);
		var resCode = decCode + count;
		if ( decCode >= 65 && decCode <= 90){
			if (resCode > 90) resCode = resCode - 26;
			if (resCode < 65) resCode = resCode + 26;
		} else if (decCode >= 97 && decCode <= 122) { 		
			if (resCode > 122) resCode = resCode - 26;
			if (resCode < 97) resCode = resCode + 26;
		} else { 
			resCode = decCode;
			}
	
		return String.fromCharCode(resCode);
		},

	unscrypt:function(strIn){
		var strOut = "";
		// since the id is always going to start with a forced character, we should be
		// able to start at position 1 for the real string
		for (var i=1; i<strIn.length; i++) {
			strOut += SCRYPT.shiftChar(strIn.charAt(i),((i % 25) * -1));	
	  		}
		hexRegEx = /\.([A-Za-z0-9]{2})/;
		foundHex = hexRegEx.exec(strOut);
		while (foundHex != null) {
			if (foundHex[1] == '2E'){
				strOut = strOut.replace(foundHex[0],"%%dotx%%");
			} else { 
	    		strOut = strOut.replace(foundHex[0],String.fromCharCode(SCRYPT.hex2dec(foundHex[1])));
			}
			foundHex = hexRegEx.exec(strOut);
	  		}	
		strOut = strOut.replace(/%%dotx%%/g,".");
		return strOut;
		
		},
	
	init:function(){
		var scryptObject=$.getByClass("scrypt");
		for(scryptCounter=0;scryptCounter<scryptObject.length;scryptCounter++){
			scryptObject[scryptCounter].innerHTML = SCRYPT.unscrypt(scryptObject[scryptCounter].id);
			}
		
		}
}

$.addOnload(SCRYPT.init);

