//var section //= "menu3";
var homepage = false;


function getXY(el) {
	var coords = { x:el.offsetLeft, y:el.offsetTop,h:el.offsetTop }

	while (el.offsetParent) {
		el = el.offsetParent;
		coords.x += el.offsetLeft;
		coords.y += el.offsetTop;
		coords.h += el.scrollTop;
	}
	return coords;
}
//-----------------------------------------------------------------------------------------//
if(!Array.prototype.push) {
function array_push() {
for(var i=0;i<arguments.length;i++){
this[this.length]=arguments[i]
}
return this.length;
}
Array.prototype.push = array_push;
}
if(!Array.prototype.pop) {
	function array_pop(){
		lastElement = this[this.length-1];
		this.length = Math.max(this.length-1,0);
		return lastElement;
	}
Array.prototype.pop = array_pop;
}

var timerMenuRunning = false;
var timerMenuID = null;
//-----------------------------------------------------------------------------------------//
function hideAll() {

	if (timerMenuRunning == true){clearTimeout(timerMenuID); timerMenuRunning = false;}
		for(i=0; i<myDivArray.length; i++){
			if(ie){mySpan = document.all(myDivArray[i])}
			else if(dom){mySpan = document.getElementById(myDivArray[i])}
		//mySpan.style.visibility = "hidden";
		mySpan.style.display = "none";

		}
		for (i=0; i<spanArray.length; i++){
			if(ie){theButton = document.all(spanArray[i])}
			else if(dom){theButton = document.getElementById(spanArray[i])}
		}
	myDivArray = new Array();
	spanArray = new Array();


	//after hiding all the other menus then display the default one
	document.getElementById("navdefault").style.display="block";
}

function startMenuTimer() {timerMenuID = setTimeout('hideAll();', hideDelay); timerMenuRunning = true;}
function stopMenuTimer() {clearTimeout(timerMenuID);timerMenuRunning = false;}
//-----------------------------------------------------------------------------------------//

function show(divToShow, isDiv, e){

if(document.getElementById("pageDetails")){
	document.getElementById('pageDetails').style.visibility = "hidden"
}

if(browserName=="NS" && !document.layers){
	var divs = document.getElementById(divToShow);
	var srcElement = e.target; var clientX = e.clientX; var clientY = e.clientY
srcElement = srcElement.parentNode.parentNode;

if (srcElement.nodeType == 3){srcElement = srcElement.parentNode;}
	var c = getXY(srcElement);
	if(isDiv == 1){
		hideAll();
		//xPos = clientX - (clientX - c.x) - x1Offset + "px";
		//yPos = c.y + srcElement.offsetHeight - y1Offset + "px";
		//alert(srcElement.offsetHeight )
	}
	else if (isDiv > 1 ){
		//xPos = clientX - e.layerX + document.getElementById(srcElement.id).offsetWidth - x2Offset + "px";
		//yPos = clientY - e.layerY + srcElement.offsetTop + window.pageYOffset - y2Offset + "px";
	}
}
//-----------------------------------------------------------------------------------------//
if (browserName=="MSIE"){
	var divs = document.all(divToShow);
	var srcElement = event.srcElement.parentNode.parentNode;
	var clientX = event.clientX;
	var clientY = event.clientY;
	var c = getXY(event.srcElement.parentNode.parentNode);

	if(document.documentElement.scrollTop){	scrollTop = document.documentElement.scrollTop}
	else{scrollTop = document.body.scrollTop}

	if(isDiv == 1){
		hideAll();
		// Internet Explorer on the Mac
		if (userPlatform == "Mac" && browserName == "MSIE"){
			//lll = (document.body.clientWidth - srcElement.parentNode.parentNode.parentNode.parentNode.parentNode.width) / 2
			//xPos = c.x  - 9 +  "px"
			//yPos = c.y + 29 +  "px"
		}
		// Everything else
		else{
			//xPos = c.x + x1Offset + "px"
			//yPos = c.y + y1Offset + "px"
		}
	}
	else if (isDiv > 1 ){
		//xPos = (clientX - event.offsetX) +  document.all[srcElement.id].offsetWidth -x2Offset  + "px";
		//yPos = c.y + "px"
	}
}
//-----------------------------------------------------------------------------------------//
if (isDiv ==  myDivArray.length){
	if(ie){document.all[myDivArray.pop()].style.visibility = "hidden";}
	else {document.getElementById(myDivArray.pop()).style.visibility = "hidden"}
}
else if ( myDivArray.length > isDiv ){
	for(i=myDivArray.length + 1; i> isDiv; i-- ){
		if(ie){document.all[myDivArray.pop()].style.visibility = "hidden";}
		else{document.getElementById(myDivArray.pop()).style.visibility = "hidden"}
	}
}
if(divs){
	//divs.style.left = "22px"; //xPos;
	//divs.style.top = "139px";  //yPos;
	//divs.style.visibility = "visible";
	//hide the default menu
	document.getElementById("navdefault").style.display="none";
	divs.style.display = "block";
	myDivArray.push(divToShow);
if (browserName=="MSIE"){


}

}
//-----------------------------------------------------------------------------------------//
if(isDiv == spanArray.length){
	divToChange = spanArray.pop();
	if (ie){theButton = document.all[divToChange]}
	else if (dom){theButton = document.getElementById(divToChange)}
	}
else if (spanArray.length > isDiv ){
	for(i = spanArray.length + 1; i > isDiv; i--){
		divToChange = spanArray.pop();
	if (ie){theButton = document.all[divToChange]}
	else if (dom){theButton = document.getElementById(divToChange)}
	}
}


	spanArray.push(srcElement.id);
}
//-----------------------------------------------------------------------------------------//
function goTo(theURL){window.location.href = theURL;}
function goToPopUp(theURL, targetWindow){window.open(theURL, targetWindow,'scrollbars=yes,resizable=yes,width=400,height=400')}
//-----------------------------------------------------------------------------------------//
function menuBar(){}



