// JavaScript Document
/*function $(id) {
	return document.getElementById(id);
}
function addLoadEvent (func) {
//alert ("addLoadEvent: func="+func);
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function () {
			oldonload();
			func();
		}
	}
}*/
function embedEmail( idName ) {
	// Assumptions: 
	//   idName exists
	// 	 idName has links
	//	 email link has a title where the '@' is a '+' and the '.' is a '-'
	//	 email link rel='email'
//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 = $( 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 = 'mai'+'lto:' + newTitle;
				thisLink.firstChild.nodeValue = newTitle;
				thisLink.title = newTitle;
			}
		}
	}
}
function setExternalTargets() {
//alert ("external invoked");
	if ( !document.getElementsByTagName ) return;
	var a = document.getElementsByTagName('a');
	for (var i=0; i < a.length; i++) if (a[i].getAttribute('href') && a[i].getAttribute('rel') == 'external') a[i].target = '_blank';
};
function setCopyrightDate ( copyrightYear ) {
	if ( !document.getElementById ) return;
	if ( !document.getElementById( copyrightYear )) return;
	var copy = document.getElementById( copyrightYear );
	var copyText = document.createTextNode( new Date().getFullYear() );
	copy.replaceChild( copyText, copy.firstChild );
};
function animateLinks( thisOne ) {
	if ( thisOne ) {
		var list = $$( '#' + thisOne + ' a' );
		list.each( function( element ) {
			if ( !element.hasClass( 'image' )) {
				var fx = new Fx.Morph( element, { duration:350, wait:false });
				element.addEvent( 'mouseenter', function() {
					fx.start({ 'color': '#ffffff', 'background-color': '#303030' }); });
				element.addEvent('mouseleave', function(){
					fx.start({ 'color': '#5D9FB3', 'background-color': '#141414' }); });
			};
		});
	};
};
function animateNavigation ( terms ) {
	var list = $$( terms );
	list.each( function( element ) {
		if ( document.body.id != element.className ) {
			var fx = new Fx.Morph( element, { duration:200, wait:false });
			element.addEvent( 'mouseenter', function() {
				fx.start({ 'margin-left': 10, 'background-color': '#ffffff' });
			});
			element.addEvent('mouseleave', function(){
				fx.start({ 'margin-left': 0, 'background-color': '#12759F' });
			});
		};	
	});
};
function setHTMLValidateLink ( thisOne ) {
	if ( !document.getElementById ) return;
	if ( !document.getElementById( thisOne )) return;
	var validateLink = $( thisOne );
	validateLink.href = validateLink.href + 'check?uri=' + window.location.href;
};
function setCSSValidateLink ( thisOne ) {
	if ( !document.getElementById ) return;
	if ( !document.getElementById( thisOne )) return;
	var validateLink = $( thisOne );
	validateLink.href = validateLink.href + 'validator?uri=' + window.location.href;
};