var isIE = ((document.all)? true  : false );
var isNS6 = ((document.getElementById && !document.all)? true: false );


if (!document.getElementById){
	document.getElementById = function (id){
							if (document.all){
								return document.all[id];
							}
						}
}
function noErrorMessages () { return true; }
//window.onerror = noErrorMessages;

var keepSub = 0;
var closeInterval ;
var resFix = 0;

allSubs = ['1','2','3','4','5'];
// this array holds the total width from the left of the father buttons
fathersLoc = [15,70,140,255,300];
fathersWidthAr = [95,150,124,125,125];
var curPage =  self.location.href;

function openSub(num){

	
	keepSub = num ;		 
	// closes all menus and children, except for keepSub		
	closeAllSub();

// displays the correct div
	document.getElementById("sub" + num).style.display = "block";
		
	// father is the images that trigger the subMenu

	fatherWidth = fathersWidthAr [num-1];				
	document.getElementById("sub" + num).style.width = fatherWidth ;			
		
	if (isIE){
		resFix = (document.body.clientWidth - 750) /2 ;	
	}else if (isNS6){
		resFix = (window.innerWidth - 750) /2 ;				
	}		
	if (resFix<0) resFix=0;		
	fatherLeft = fathersLoc[num-1];		
	document.getElementById("sub" + num).style.left = resFix + fatherLeft ;
	
	//if (curPage.indexOf ("index.asp")>-1 || curPage.substr(curPage.length-1)=="/" ){	
	//	document.getElementById("sub" + num).style.top = 286 ;
	//}
}

function closeAllSub(){

	for (i=0; i<allSubs.length; i++){
		if (document.getElementById("sub" + allSubs[i])){		
			if (allSubs[i]!=keepSub ) {					
				document.getElementById("sub" + allSubs[i]).style.display = "none";
			}		
		}
	}
	
	
}

function checkIfClose (num){		
	e = window.event;
	
	if (e){
		eEl = e.toElement;
		if (eEl){
			eId = eEl.id; 
			if (eId.indexOf ("ditem")==-1 && eId.indexOf ("menuRow")==-1  && eId.indexOf ("subTable")==-1 && eId.indexOf ("menuFather")==-1 ){				
				//alert (eId);
				keepSub = 0;	
				closeAllSub();
			}
		}
	}
}





