// JavaScript Document
function email(addy,name)
{
	decoded = dec(addy)
	if(!name) {name = decoded}
	document.write('<a href="mailto:'+decoded)
	document.write('">'+name+'</a>')
}

function sendMail(text)
{
	location.href = "mailto:"+dec(text)
}

function toBin(text, foo)
{
	texten = ""
	for(i=0;i<text.length;i++)
	{
		for(j=0;j<foo;j++)
		{	
			if((text.charCodeAt(i) & Math.pow(2,(foo-1-j))) != 0)	
			{
				texten += "1"
			}
			else 
			{ 
				if((i != (text.length-1)) || (j >= ((text.length*foo)%23)) )
				{ 
					texten += "0";
				}
			}
		}
	}
	return texten;
}
function bin2numbers(text, foo)
{
	listan = new Array()
	for(i=0;((i+1)*foo-1) < text.length;i++)
	{
		listan[i] = 0
		for(j=0;j<foo;j++)
		{
			listan[i] += text.charAt(i*foo+j)*Math.pow(2,(foo-1-j)) 
		}
	}
	return listan;
}
function bin2text(text, base)
{
	texten = ""
	for(i=0;i<text.length;i++)
	{
		if(i%base==0)
		{
			foo = 0
		}	
		foo += text.charAt(i)*Math.pow(2,(base-1-i%base)) 
		if((i%base==(base-1))||(i==(text.length-1)))
		{
			if(base==6) {foo += 128}
			texten += String.fromCharCode(foo)
		}
	}
	return texten
}
function dec(text)
{
	bin_code = ""
	more_bin_code = ""
	guts = new Array()
	enc_letters = new Array()
	bin_code = toBin(text, 6)
	guts = bin2numbers(bin_code, 23)
	for(i=0;i<guts.length;i++)
	{
		guts[i] = Math.sqrt(2*guts[i]+1/4)-0.5
//		dump(guts[i]); 
		for(j=0;j<11;j++)
		{
			if((Math.floor(guts[i]) & Math.pow(2,10-j))!=0) {more_bin_code += "1"}
			else 
			{
				if((i != (guts.length-1)) || (j >= ((guts.length*11)%8)) )
				{ 
					more_bin_code += "0";
				}
			}
		}
	}
	more_bin_code = more_bin_code.replace(/00000000/ig,"")
	final_string = bin2text(more_bin_code, 8)
	return final_string
}

