Cufon.replace('#jobsCounter, .page-careers .inspira');
Cufon.replace('#job_search_form_advanced');	

document.write('<style type="text/css" media="screen">.page-meet_our_people dl.dropdown, .leadership_program.eclp .spotlight {display: none;} .leadership_program.eclp .spotlight:first-child { display: block; }</style>');
// Dropdowns
var GE_CareersDropDown = Class.create( GE_DropDown, {
	initialize:function($super, el) {
		$super(el);
		this.items.each(
			function(el) {
				var a = el.down('a');
				if (document.location.href.indexOf(a.href) >= 0) this.titleEl.update(a.innerHTML);
			}.bind(this)
		);
	}
});
GE_Main.mapCSSToFn('dropdown_list', GE_CareersDropDown);

var GE_JobSearchDropDown = Class.create( GE_DropDown, {
	initialize:function($super, el) {
		$super(el);
		// this.titleEl.update(items[0].down('a').innerHTML);
	}
});
GE_Main.mapCSSToFn('job-search-form', function(){
	
});



// Profiles Dropdown
var GE_ProfilesDropDown = Class.create( GE_DropDown, {
	profile_list:null,
	profiles:null,
	initialize:function($super, el) {
		$super(el);
		el.addClassName('dropdown_list');
		el.up('dl').setStyle({display:'block'});

		this.profile_list = $('profile_list');
		this.profiles = this.profile_list.childElements();

		// Deep linking filter
		var targetRegExp = /#(.+)$/;
		var targets = targetRegExp.exec(window.location);
		((targets && targets[1]) && (this.ulEl.select('li.'+targets[1])[0])) ? this.filter(targets[1], this.ulEl.select('li.' + targets[1] + ' a')[0].innerHTML) : this.filter('featured', 'Featured');

		var self = this;
		this.items.each(
			function(el) {
				var a = el.down('a');
				a.observe('click',function(e){
					e.stop();
					var c = e.target.up('li').className;
					if (c) { c = c.substr(c.indexOf('abstract_item ')+15,c.length); }
					self.filter(c, e.target.innerHTML);
					self.toggleSelect();
					Cufon.refresh();
				});
			}
		);
	},
	filter:function(c, t) {
		//alert(c+'::'+t);
		var ads_on = [];
		this.titleEl.update(t);
		this.profiles.each(function(el){
			el.removeClassName('clear');
			el.removeClassName('last');
			if (el.hasClassName(c) || c=='All Formats') {
				ads_on.push(el);
			}
			if (/MSIE/i.test(navigator.userAgent)) el.remove();
		});
		if (!/MSIE/i.test(navigator.userAgent)) this.profile_list.update('');
		ads_on.each(function(el){
			var i = this.ads_on.indexOf(el);
			if (i%2==0) el.addClassName('clear');
			if (i==this.ads_on.length-1) el.addClassName('last');
			this.profile_list.insert(el);
		}.bind({ads_on:ads_on,profile_list:this.profile_list}));
	}
});

GE_Main.mapCSSToFn('profile_dropdown', GE_ProfilesDropDown);



// Media Profiles
GE_Main.addInitFn(
	function() {
		var audio_vide_container="";
		if ($$('.page-meet_our_people ul.abstract_list h3').toString()!="")
			{
				audio_vide_container= $$('.page-meet_our_people ul.abstract_list h3');
			}
		else
			{
				if ($$('.leadership_program ul.abstract_list h3').toString()!="")
					{
						audio_vide_container= $$('.leadership_program ul.abstract_list h3');
					}
			}
		if (audio_vide_container)
			{
				audio_vide_container.each(function(h3){
					var a = h3.down('a');
					if (!a) return;
					var title = a.readAttribute('title');
					var list = h3.next('ul');
					if (!list) return;
					list.hide();
					var media_link = list.getElementsBySelector('li:first-child a')[0].readAttribute('href');
					if(media_link.endsWith('.mp3')){
						list.insert({after:
							new Element('a',{href:media_link,title:'Listen Now - ' + title}).addClassName('button_link bhv_audioPlayer').insert('Listen Now')
						});
					} else {
						list.up().down('h3').down('a').addClassName('lightbox').setAttribute('rel','video');
						list.insert({after:
							new Element('a',{href:media_link,title:'Watch Now - ' + title,rel:'video'}).addClassName('button_link lightbox').insert('Watch Now')
						});
					}
				});
			}
		Cufon.replace('.button_link');	
	}
);

// randomize ECLP profiles (for all pages)
GE_Main.addInitFn(
	function() {
		var spotlights = $('ge_content').down('div.eclp');
		if (spotlights) {
			var spot = $$('.secondary_content .spotlight');
			spot.each( function(el){ el.hide();} );
			spot[Math.floor(Math.random()*4)].show();
		}
	}
);

// randomize EEDP profiles (for index page)
GE_Main.addInitFn(
	function() {
		var spotlights_EEDP = $('ge_content').down('.secondary_content .profile_carolyn');
		if (spotlights_EEDP) {
			var spot = $$('.secondary_content .spotlight');
				spot.each( function(el){ 
					el.hide();
				} 
			);
			spot.last().show();
			spot[Math.floor(Math.random()*10)].show();
		}
	}
);


// randomize OMLP profiles (for index page)
GE_Main.addInitFn(
	function() {
		var spotlights_EEDP = $('ge_content').down('.secondary_content .profile_caitlin');
		if (spotlights_EEDP) {
			var spot = $$('.secondary_content .spotlight');
				spot.each( function(el){ 
					el.hide();
				} 
			);
			spot[Math.floor(Math.random()*2)].show();  
		}
	}
);


// randomize IMLP profiles (for UK page)
GE_Main.addInitFn(
	function() {
		var spotlights_IMLP = $('ge_content').down('.secondary_content .profile_amy');
		if (spotlights_IMLP) {
			var spot = $$('.secondary_content .spotlight');
				spot.each( function(el){ 
					el.hide();
				} 
			);
			spot.last().show();
			spot[Math.floor(Math.random()*6)].show();
		}
	}
);

GE_Main.addInitFn(
	function() {
		
		var ge_content = document.getElementById("ge_content");
		
			var primary_content = ge_content.childNodes[1];
			var firstChild = primary_content.childNodes[0];
				firstChild.className += ' first_child';
			if( firstChild ){
				var hdr = firstChild.childNodes[0];
				if(hdr.nodeType == 1){
					hdr.className += ' inspira';
				}
			}
			
				//Cufon.replace('.inspira');
			
			var lastChild = primary_content.childNodes[primary_content.childNodes.length - 1];
			if(lastChild){
				lastChild.className += " featured-job-opportunities";
			}
		
	}
);








