/**********************************************************************
 cross browser getElementById()
 **********************************************************************/
function returnObjById( id ) { 
    if (document.getElementById) 
        var returnVar = document.getElementById(id); 
    else if (document.all) 
        var returnVar = document.all[id]; 
    else if (document.layers) 
        var returnVar = document.layers[id]; 
    return returnVar; 
}

var mBasePath = "";
var mExpressPath = "flash/expressInstall.swf";
var mContainer = "header";
var mFlashContainer = "header";
var mWidth = "950";
var mHeight = "375";
var mHeightCollapse = "37";
var mVersion = "9.0.0";

function menuDisplay(pState) {
	var nav1 = returnObjById(mFlashContainer);
	var nav2 = returnObjById(mContainer);
	if (pState == "open") {
		nav1.style.zIndex = 100000;
		newMenuHeight(mHeight);
	}
	else if (pState == "close") {
		nav1.style.zIndex = 0;
		newMenuHeight(mHeightCollapse);
	}
}


// detect if flash is going to work
var playerVersion = swfobject.getFlashPlayerVersion(); // returns a JavaScript object
var flashEnabled = (playerVersion.major >= 9) ? true : false; // playerVersion.major + "." + playerVersion.minor + "." + playerVersion.release + " installed";

var headerHeightChange;
var checkExpand;
//var cE;
var lastH = 0;
var lastSubH = 0;

$(document).ready(function() {
	/*headerHeightChange = function(h, s){
		//$("#header").animate({ height: h }, s);
		$("#header").css({ height: h });
	}*/
	if(flashEnabled){
		changeMenuHeight("126", 0)
		changeSubMenuHeight("5", 0)
	}
	htmlNavPrepIE();
	//var cE = setTimeout("checkExpand()",3500)
	/*$('.readmore a').css( {backgroundPosition: "0px 0px"} )
	.mouseover(function(){
		$(this).stop().animate({backgroundPosition:"(0px 5px)"}, {duration:500})
	})
	.mouseout(function(){
		$(this).stop().animate({backgroundPosition:"(0px 0px)"}, {duration:200, complete:function(){
			$(this).css({backgroundPosition: "0px 0px"})
		}})
	});*/
});

function changeMenuHeight(h) {
	if(lastH != h){
		//if(h>lastH){
			//alert(h);
			lastH = h;
			/*if(arguments.length > 1){
				headerHeightChange(h, 0);
			}else{
				headerHeightChange(h, 500);
			}*/
			if(document.all && !document.getElementById) {
				document.all[mContainer].style.pixelHeight = h;
			}else{
				returnObjById(mContainer).style.height = h+"px";
			}
		//}
	}
}
function changeCalloutHeight(h) {
	if(document.all && !document.getElementById) {
		document.all["callout"].style.pixelHeight = h;
	}else{
		returnObjById("callout").style.height = h+"px";
	}
}
function changeSubMenuHeight(h) {
	if($("#subsidebar").length > 0){
		if(lastSubH != h){
			if(h>lastSubH){
				lastSubH = h;
				if(document.all && !document.getElementById) {
					document.all["subnav"].style.pixelHeight = h;
				}else{
					returnObjById("subnav").style.height = h+"px";
				}
			}
		}
	}
}
function checkTopExpand(){
	//alert(lastH);
	if(lastH == "126"){
		return false;
		//changeMenuHeight("500", 0)
	}
	return true;
}
function checkSideExpand(){
	if(lastSubH == "5"){
		return true;
		//changeSubMenuHeight("800", 0)
	}
	return true;
}

htmlNavPrepIE = function() {
	if (document.all&&document.getElementById) {
		var navRoot = document.getElementById("nav");
		if (navRoot) {
			for (i=0; i<navRoot.childNodes.length; i++) {
				node = navRoot.childNodes[i];
				if (node.nodeName=="LI") {
					node.onmouseover=function() {
						this.className+=" over";
					}
					node.onmouseout=function() {
						this.className=this.className.replace(" over", "");
					}
				}
			}
		}
		navRoot = document.getElementById("topNav");
		if (navRoot) {
			for (i=0; i<navRoot.childNodes.length; i++) {
				node = navRoot.childNodes[i];
				if (node.nodeName=="LI") {
					node.onmouseover=function() {
						this.className+=" over";
					}
					node.onmouseout=function() {
						this.className=this.className.replace(" over", "");
					}
				}
			}
		}
	}
}
window.onload=htmlNavPrepIE;