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 setExternalLinkage() {
//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 ( element ) {
	if ( !document.getElementById ) return;
	var copy = $( element );
	var copyText = document.createTextNode( new Date().getFullYear() );
	copy.replaceChild( copyText, copy.firstChild );
};
function animateNav ( thisOne ) {
	if ( $( thisOne )) {
		$$( '#' + thisOne + ' a' ).each( function( element ) {
			if (( element.className != document.body.className ) && ( element.className != document.body.id )) {
				var fx = new Fx.Morph( element, { duration:350, wait:false });
				element.addEvent( 'mouseenter', function() {
					fx.start({ 'padding-left': 10, 'color': '#3b68c7', 'background-color': '#deeeff' });
				});
				element.addEvent('mouseleave', function(){
					fx.start({ 'padding-left': 0, 'color': '#4ea7e6', 'background-color': '#ffffff' });
				});
			};
		});
	};
};
function animateLinks( thisOne ) {
	if ( $( thisOne )) {
		var list = $$( '#' + thisOne + ' a' );
		list.each( function( element ) {
			if ( !element.hasClass( 'image' )) {
				if (document.body.id == 'home') {
					var fx = new Fx.Morph( element, { duration:350, wait:false });
					element.addEvent( 'mouseenter', function() {
						fx.start({ 'color': '#3b68c7', 'background-color': '#deeeff' }); });
					element.addEvent('mouseleave', function(){
						fx.start({ 'color': '#4ea7e6', 'background-color': '#000000' }); });
				} else {
					var fx = new Fx.Morph( element, { duration:350, wait:false });
					element.addEvent( 'mouseenter', function() {
						fx.start({ 'color': '#3b68c7', 'background-color': '#deeeff' }); });
					element.addEvent('mouseleave', function(){
						fx.start({ 'color': '#4ea7e6', 'background-color': '#ffffff' }); });					
				};
			};
		});
	};
};
function fadeIn( thisOne ) {
	if ( $( thisOne )) {
		var myHeight = $( thisOne ).getStyle('height').toInt();	
		$( thisOne ).set('morph',{ duration: 3000 });
		$( thisOne ).morph( {opacity:[ 0, 1 ], height:[ 0, myHeight ]});
	};
};

function fadeInSecNav( thisOne ) {
	if ( $( thisOne )) {
		var myHeight = $( thisOne ).getStyle('height').toInt();	
		$( thisOne ).set('morph',{ duration: 3000 });
		$( thisOne ).morph( {opacity:[ 0, 1 ], height:[ 0, myHeight ]});
		
		var list = $$( '#' + thisOne + ' li' );
		list.each( function( element, index ) {
			var fx = new Fx.Tween( element, { property: 'opacity', duration:1000 }).set(0);
			fx.start.pass( [ 0, 1 ], fx ).delay( 2750 + 250 * index );	
		});
	};
};
function addSecondaryAnimation ( thisOne ) {
	switch( thisOne ) {
		case 'news':
			fadeInSecNav( 'secondaryNav' );
			animateNav( 'secondaryNav' );		
			break;
		default:
			var logoPages = [ 'home', 'staff', 'careers', 'news' ];
			if ( logoPages.indexOf( document.body.id ) > -1 ) {
				fadeInSecNav( 'logos' );
			} else {
				fadeInSecNav( 'secondaryNav' );
				animateNav( 'secondaryNav' );
			};
			break;
	};
};
function embedHomeBanner( method ) {
	if( document.body.id=='home' ) {
		switch( method ) {
			case 'swiff':
				var obj = new Swiff('flash/flashBanner.swf', {
					id: 'flashBannerSWF',
					width: 1000,
					height: 287,
					container: 'flashBanner',
					params: {
						wmode: 'transparent'
					}
				});
				break;
			case 'swfObject':
//alert('embedHomeBanner( swfObject )');
				var flashvars = {};
				var params = { 'wmode': 'transparent'};
				var attributes = {};
				attributes.id = "flashBannerSWF";
				swfobject.embedSWF("/flash/flashBanner.swf", "flashBanner", "1000", "287", "9.0.0", "/flash/expressInstall.swf", flashvars, params, attributes);
				break;			
		};
	};
};
/*function embedHomeBanner () {
	if( document.body.id=='home' ) {
		var flashvars = {};
		var params = { 'wmode': 'transparent'};
		var attributes = {};
		attributes.id = "flashBannerSWF";
		swfobject.embedSWF("/flash/flashBanner.swf", "flashBanner", "1000", "287", "9.0.0", "/flash/expressInstall.swf", flashvars, params, attributes);
	};
};*/
function hideNav () {
	navAnim.start({
		opacity: [ 1, 0 ]
	});
};
function showNav () {
	navAnim.start({
		opacity: [ 0, 1 ]
	});
};
var navAnim;


