﻿// JScript File

/*
====================================================================
This function helps protect the email address from the evil spam-bots
that scan web pages for useful data such as (email addresses). 
Instead of using the data directly, the encoded value is stored in the
html and decoded when required.
====================================================================
*/
function decode(ServerEncoded)
{
// The ServerEncoded parameter is a string that contains the encoded data.
// Each character in the ServerEncoded parameter has been converted into 
// a two digit number (hex / base16). This function converts the
// series of numbers back into the normal form and returns the 
// decoded string to the client

// holds the decoded string
var res = "";

// go through and decode the full input server encoded string
for (i=0; i < ServerEncoded.length;)
{
	// holds each letter (2 digits)
	var letter = "";
	letter = ServerEncoded.charAt(i) + ServerEncoded.charAt(i+1)

	// build the real decoded value
	res += String.fromCharCode(parseInt(letter,16));
	i += 2;
}
//return the new decoded string to allow it to be rendered to screen
return res;
}


/*
====================================================================
This function gets a reference to the server encrypted string and
then decrypts this using the decode() function and sets the
txtDecrypted value to the value return by the decode() function
====================================================================
*/


function ReplaceMailToLinksCareers()
{
	var anchors = document.getElementsByTagName('a');
	var x;
	var emailAddr;
	for (x = 0; x < anchors.length; x++)
	{
		if (anchors[x].name != '' && anchors[x].id != 'email')
		{
			emailAddr = anchors[x].innerHTML;
			anchors[x].href = "mailto:" + decode(emailAddr) + "?subject=" + anchors[x].name;
			anchors[x].innerHTML = "Apply for this job";
			anchors[x].style.display = "inline";
		}
		else if (anchors[x].id == 'email')
		{
			emailAddr = anchors[x].innerHTML;
			anchors[x].href = "mailto:" + decode(emailAddr);
			anchors[x].innerHTML = "EMAIL RESUME";
			anchors[x].style.display = "inline";
		}
	}
}

function ReplaceMailToLinks()
{	
	emailLink = document.getElementById('email');
	emailLink.innerHTML = decode(document.getElementById('email').innerHTML); //decode(emailAddr);
	emailLink.href = "mailto:" + emailLink.innerHTML;
	emailLink.style.display = "inline";
}