function emailDecode(){
	var anchors = document.getElementsByTagName("a"); 				// Get all the anchor tags.
	var number_of_anchors = anchors.length; 						// Find out how many there are.
	for(anchor = 0; anchor<number_of_anchors; anchor++){ 			// Loop through them.
		if(anchors[anchor].className.indexOf('encoded') == 0){		// We only want those with class 'encoded'.
			var full_url = anchors[anchor].getAttribute('href'); 	// Grab the href.
			var url_prefix = 'http://www.et.byu.edu/obfuscation/index.php?';	// The URL should start with this.
			if(full_url.indexOf(url_prefix)!=0) return false;
			var get_request = full_url.substring(url_prefix.length); 	// Strip off the prefix.
			var get_parts = get_request.split('&'); 					// Split into individual variable/value pairs
   
			var address_get_prefix = 'address='; 		// Here's how the address get piece should start.
			var link_text_get_prefix = 'linktext='; 	// Here's how the link text get piece should start.

			var number_of_get_parts = get_parts.length;	// The number of GET variables
			var obfuscated_address = ''; 	// This will hold the obfuscated address at then end
			var obfuscated_link_text = ''; 	// And this will hold the obfuscated link text, if any

			// For each GET variable
			for(part = 0; part < number_of_get_parts; part++){
				// If it's the address, strip off name and store in obfuscated_address
				if(get_parts[part].indexOf(address_get_prefix)==0){
					obfuscated_address = get_parts[part].substring(address_get_prefix.length); 
				}
				// If it's the link text, strip off name and store in obfuscated_link_text
				if(get_parts[part].indexOf(link_text_get_prefix)==0){
					obfuscated_link_text = get_parts[part].substring(link_text_get_prefix.length); 
				}
			}

			var address = ''; // For the unobfuscated email address
			obfuscated_address_length = obfuscated_address.length;
			
			// Loop through, two characters at a time, and decode the characters
			// (they're two digit hexadecimal ASCII codes, perfect for decoding via unescape).
			for(character_position = 0; character_position < obfuscated_address_length; character_position+=2){
				address += unescape("%" + obfuscated_address.substr(character_position,2) ); 
			}

			var link_text = ''; // For the unobfuscated link text
			obfuscated_link_text_length = obfuscated_link_text.length;
			for(character_position = 0; character_position < obfuscated_link_text_length; character_position+=2){
				link_text += unescape("%" + obfuscated_link_text.substr(character_position,2));
			}

			anchors[anchor].setAttribute('href','mailto:' + address); // Set the href attribute
			
			// Set tag content to link_text (if it exists) or address
			if(link_text=='') { anchors[anchor].firstChild.data = address; }
			else { anchors[anchor].firstChild.data = link_text; }
		}
	}
}

// This prevents us from overwriting anything already in windows.onload
function makeDoubleDelegate(function1, function2) {
    return function() {
        if (function1)
            function1();
        if (function2)
            function2();
    }
}

window.onload = makeDoubleDelegate(window.onload, emailDecode )
