// JavaScript Document
function embedEmail( idName ) {
	// Assumptions: 
	//   idName exists
	// 	 idName has links
	//	 idName.email has a title where the '@' is a '+' and the '.' is a '-'
//alert("embedEmail invoked. idName="+idName);
	if ( !document.getElementsByTagName ) return false;
	if ( !document.getElementById ) return false;
	if ( !document.getElementById( idName )) return false;
	
	// Get array of links
	var links = document.getElementById( idName ).getElementsByTagName( 'a' );
	// For all links
	for ( var i=0; i < links.length; i++ ) {
		var thisLink = links[i];
		if ( !thisLink.rel ) continue;
		// If the class is email
		if ( thisLink.getAttribute( 'rel' ).toUpperCase()=='EMAIL' && thisLink.title ){
			var title = thisLink.title;
			if ( title.indexOf( '+' )!=-1 && title.indexOf( '-' )!=-1) {
				var name = title.slice( 0, title.indexOf( '+' ) );
				var domain = title.slice( title.indexOf( '+' )+1, title.indexOf( '-' ) );
				var suffix = title.slice( title.indexOf( '-' )+1, title.length );
				newTitle = name + '@' + domain + '.' + suffix;
				thisLink.href = 'mailto:' + newTitle;
				thisLink.firstChild.nodeValue = newTitle;
				thisLink.title = newTitle;
			}
		}
	}
}
//addLoadEvent( function () {embedEmail('main');});

