function encode_now(formfield)
{
	toEncode = formfield.email_address.value;
	textInLink = formfield.link_text.value
	encodedAddress = "";

	for( ii = 0; ii < toEncode.length; ii++)
	{
		
		encodedAddress = encodedAddress +"&#" + toEncode.charCodeAt(ii) + ';';
	}

	textInLink = Trim(textInLink); // remove spaces from either side of the text

	if ( textInLink == "" )
	{
		textInLink = encodedAddress;
	}


	completeEmailAddressCode = '<a href="m&#97;&#105;&#108;&#116;&#111;&#58;' + encodedAddress +'">' + textInLink + '</a>';
	formfield.encoded_email_address.value = completeEmailAddressCode;
}

function encode_url(toEncode, textInLink)
{
	encodedAddress = "";

	for( ii = 0; ii < toEncode.length; ii++)
	{
		
		encodedAddress = encodedAddress +"&amp;#" + toEncode.charCodeAt(ii)  + ';';
	}

	textInLink = Trim(textInLink); // remove spaces from either side of the text

	if ( textInLink == "" )
	{
		textInLink = encodedAddress;
	}

	completeEmailAddressCode = '&lt;a href="m&amp;#97;&amp;#105;&amp;#108;&amp;#116;&amp;#111;&amp;#58;' + encodedAddress +'"&gt;' + textInLink + '&lt;/a&gt;';

	document.write('<h1>The Email Address Encoded From The URL</h1>' + completeEmailAddressCode);
}

function Trim(TRIM_VALUE)
{
	if(TRIM_VALUE.length < 1)
	{
		return"";
	}
	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);
	if(TRIM_VALUE==""){
	return "";
	}
	else
	{
		return TRIM_VALUE;
	}
} //End Function

function RTrim(VALUE){
var w_space = String.fromCharCode(32);
var v_length = VALUE.length;
var strTemp = "";
if(v_length < 0){
return"";
}
var iTemp = v_length -1;

while(iTemp > -1){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(0,iTemp +1);
break;
}
iTemp = iTemp-1;

} //End While
return strTemp;

} //End Function

function LTrim(VALUE){
var w_space = String.fromCharCode(32);
if(v_length < 1){
return"";
}
var v_length = VALUE.length;
var strTemp = "";

var iTemp = 0;

while(iTemp < v_length){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(iTemp,v_length);
break;
}
iTemp = iTemp + 1;
} //End While
return strTemp;
} //End Function
// -->


//
// Code to get the URL variables
//
var qs = location.search.substring(1);
var nv = qs.split('&');
var url = new Object();

for(i = 0; i < nv.length; i++)
{
	eq = nv[i].indexOf('=');
	url[nv[i].substring(0,eq).toLowerCase()] = unescape(nv[i].substring(eq + 1));
}


//+------------------------
// Check to see the email is set, then encode it
//+------------------------
if ( url['email'] > '')
{
	if( url['text'] > '')
		encode_url(url['email'], url['text']);
	else
		encode_url(url['email'], "");
}