

/**
 * Fix email addresses!
 * @version:	0.2
 * @date: 		23 October 2006
 * @author: 	aluis@corefactor.pt | www.corefactor.pt
 *
 * @description:
 * Independent script that attaches itself to the document (unobtrusively) backing up the window.onLoad function
 * and after executing that, runs through the <a> in the DOM searching for "reversed" links and correcting them. 
 *
 */
 
 function fixEmails() {
	
	var as = window.document.getElementsByTagName( "a" );
	for( i=0;i<as.length;i++ ) {
			if( as[i].href.match( /mailto/ ) && as[i].className.match(/reversed/) ) {
					mail_reversed = as[i].innerHTML;

					mail_ok = "";
					salt ="REVERSETHIS";
					
					for( j = mail_reversed.length - salt.length-1;j>=0;j--) {
						if( mail_ok.charAt)
							mail_ok += ((mail_reversed.charAt( j )=='@')?"@":mail_reversed.charAt( j ));
						else
							mail_ok += ((mail_reversed[j]=='@')?"@":mail_reversed[j]);
					}

					as[i].innerHTML = mail_ok;
					as[i].href = "mailto:" + mail_ok;
			}
	}
	
 }
 
// var backupOnload = false;
// if ( typeof( window.onload ) == "function" ) {
//	 core_old_onload = window.onload;
//	 backupOnload = true;
// }

	 
// window.onload = function() {

//	if( backupOnload)
//		core_old_onload();
//	fixEmails();	
// }
