//Delay content visibility
function showContent(obj) {
	document.getElementById(obj).style.visibility = 'visible';
}
function delayContent(layer){
	setTimeout("showContent('" + layer + "')", 2200);
	//setTimeout("showContent('" + layer + "')", 0);
	
}
function delayContentBG(layer){
	setTimeout("showContent('" + layer + "')", 2000);
	//setTimeout("showContent('" + layer + "')", 0);
}

//show/hide the content
function showHideContent(layer){
	if (document.getElementById(layer).style.display == 'none'){
		document.getElementById(layer).style.display = 'block'
	}else{
		document.getElementById(layer).style.display = 'none'
	}
}

//All this is for the Flash background fullscreen resize and positioning the footer.
//listner for the resize event
var isIE = !window.opera && navigator.userAgent.indexOf('MSIE') != -1;
//portable add event listener
function addEvent(elm, evType, fn, useCapture) {
	if(elm.addEventListener) {
		elm.addEventListener(evType, fn, useCapture);
		return true;
	}
	else if (elm.attachEvent) {
		var r = elm.attachEvent('on' + evType, fn);
		return r;
	}
	else {
		elm['on' + evType] = fn;
	}
}
function cancelClick(e) {
	if (window.event && window.event.returnValue) {
		window.event.returnValue = false;
	}
	if (e && e.preventDefault) {
		e.preventDefault();
	}
}
// Returns element's y co-ordinate
function findPosY(obj) {
	var curtop = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop;
			obj = obj.offsetParent;
		}
	} else if (obj.y) {
		curtop += obj.y;
  }
	return curtop;
}
// Attaches functions to the window's load event
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

//Position the footer to the bottom of the page
function positionFooter() {
	var footerY = findPosY("footerContainer");
	var windowH = document.body.clientHeight;
	var contentH;
	if (document.getElementById("contentBG")) {
		contentH = 111 + parseInt(document.getElementById("contentBG").style.height);
	} else if (document.getElementById("contentBG2")){
		contentH = 111 + parseInt(document.getElementById("contentBG2").style.height);
	} else{
		contentH = 111 + parseInt(document.getElementById("mainContainer").style.height);
	}
	if (isNaN(contentH)) {
		footerY = (document.body.clientHeight < 630) ? "600px" : document.body.clientHeight - 40 + "px";
	} else {
		if (contentH >= windowH) {
			footerY = contentH + "px";
		} else {
			footerY = document.body.clientHeight - 40 + "px";
		}
	}
	document.getElementById("footerContainer").style.top = footerY;
}

//Make the Flash fullscreen on resize, then position the footer
function fullscreenFlash()
{
	//IE6 min-width/height workaround
	document.getElementById("bgFlash").width = (document.body.clientWidth < 875) ? "885px" : "100%";
	document.getElementById("bgFlash").height = (document.body.clientHeight < 630) ? "640px" : "100%";
	positionFooter();
}
addEvent(window,'resize',fullscreenFlash,false);

addLoadEvent(positionFooter);	
addLoadEvent(fullscreenFlash);	


//function to match the height of the content and white background on the careers and news pages
//for this to work properly the objects needs to have class="matchHeight"
matchHeight=function(){
     var divs,contDivs,maxHeight,divHeight,d;
     // get all <div> elements in the document
     divs=document.getElementsByTagName('div');
     contDivs=[];

     // initialize maximum height value
     maxHeight=0;

     // iterate over all <div> elements in the document
     for(var i=0;i<divs.length;i++){

          // make collection with <div> elements with class attribute 'matchHeight'
          if(/\bmatchHeight\b/.test(divs[i].className)){
                d=divs[i];
                contDivs[contDivs.length]=d;

                // determine height for <div> element
                if(d.offsetHeight){
                     divHeight=d.offsetHeight;
                }
                else if(d.style.pixelHeight){
                     divHeight=d.style.pixelHeight;
                }

                // calculate maximum height
                maxHeight=Math.max(maxHeight,divHeight);
          }
     }

     // assign maximum height value to all of container <div> elements
     for(var i=0;i<contDivs.length;i++){
          contDivs[i].style.height=maxHeight;
     }
}
// execute function when page loads
window.onload=function(){
     if(document.getElementsByTagName){
          matchHeight();
     }
} 

/******************************************************************** 
Open Windows
********************************************************************/
function openPopup(URL, width, height){
  myWindow = window.open(URL,'myWindow','toolbar=no,location=no,directories=no,status=no,resizable=yes,menubar=yes,scrollbars=yes,width='+width+',height='+height);
  myWindow.focus();
}

//FAV ICON
	fa_image = new Image();
	fa_image.src="/favicon.ico";
	