
// News - Accordion function

window.addEvent('domready', function() {
	
	//create our Accordion instance
	var newsAccordion = new Accordion($('news_accordion'), '#news_accordion h2.toggler', '#news_accordion div.element', {
		opacity: false,
		onActive: function(toggler, element){
			toggler.setStyle('color', '#404040');
		},
		onBackground: function(toggler, element){
			toggler.setStyle('color', '#b2b81a');
		}
	});

	
});


// Carrers - Accordion function

window.addEvent('domready', function() {
	
	//create our Accordion instance
	var careersAccordion = new Accordion($('careers_accordion'), '#careers_accordion h2.toggler', '#careers_accordion div.element', {
		opacity: false,
		onActive: function(toggler, element){
			toggler.setStyle('color', '#404040');
		},
		onBackground: function(toggler, element){
			toggler.setStyle('color', '#b2b81a');
		}
	});

	
});

//MENU - Controls Left Menu highlight

window.addEvent('domready', function(){
	
	$$('.MGroupContent').setStyle('display', 'block');
	
	var selected = $('MSelected');
	
	var current = (selected) ? selected.getParent() : false;

	$$('div.MGroup').each(function(div){
		var link = div.getElement('a');
		var block = link.getNext();
		
		var fx = new Fx.Slide(block);
		
		if (block != current) fx.hide();

		link.addEvent('click', function(){
			fx.toggle();
		});
		
	});
	
	$$('.CTitle').each(function(heading){
		new Element('a', {
			'href': '#MainTopic',
			'class': 'toTop'
		}).setHTML('top').injectBefore(heading.getFirst());
	});
	
	new SmoothScroll();
	
});

document.write('<style type="text/css" media="screen">div.MGroupContent{display: none}</style>');



//EQUALIZER - makes elements with the same class equal height

matchColumns=function(){ 
     var divs,contDivs,maxHeight,divHeight,d; 
     divs=document.getElementsByTagName('p'); 
     contDivs=[]; 
     maxHeight=0;  
     for(var i=0;i<divs.length;i++){  
          // make collection with <p> elements with class attribute "equal"
          if(/\bequal\b/.test(divs[i].className)){ 
                d=divs[i]; 
                contDivs[contDivs.length]=d;  
                if(d.offsetHeight){ 
                     divHeight=d.offsetHeight; 					
                } 
                else if(d.style.pixelHeight){ 
                     divHeight=d.style.pixelHeight;					 
                } 
                maxHeight=Math.max(maxHeight,divHeight); 
          } 
     } 
     for(var i=0;i<contDivs.length;i++){ 
          contDivs[i].style.height=maxHeight + "px"; 
     } 
}  
window.onload=function(){ 
     if(document.getElementsByTagName){ 
          matchColumns();			 
     } 
}

//IEHOVER - Hover of elements other than <a> :hover in IE

ieHover = function() {
   
	var sfEls = document.getElementById("nav_header").getElementsByTagName("LI");
	
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" iehover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" iehover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", ieHover);
