/* 
   FormMailMask.js 
   generates encrypted formmail component
   author: David P. Leader 2007
*/


// look up the encrypted address from id
function makeformmail(id)
{
	var crypto = new String("");		
	if(id == "100")
	{
		crypto = "=GLA5L@A?76L@9;E76UC^D7=3?753>30";	// jean's demon address
	}
	else
	{
		crypto = "35u@w8wz=54R?v5t5418";	// nobody
	}
    decode(crypto);
}

// decodes the encrypted address 
function decode(inString)
{
    // get input string
	var coded = new String("");
    coded  = inString;
	var decoded = new String("");
  
    //strip last two chars off and make into a number
    var offset = coded.substring(coded.length-2, coded.length);
    coded = coded.substring(0, coded.length-2);

	for(i = coded.length-1; i>-1; i--)
	{
		var x = coded.charCodeAt(i);
		if((x-offset)<46)
		{
		 	x = (x-offset) -46 + 122;
		}
		else
		{
		    x -= offset;
		}
		decoded += String.fromCharCode(x);
	}
	writeIt(decoded);       
}

// generates the final output: value="decoded"
function writeIt(decoded)
{
	var first = '<input type="hidden" name="recipient" value="';
	var second = decoded;
	var third = '" />';

	
	var outString = first + second + third;	
	document.write(outString);
}