var isIE = ((document.all)? true  : false );
var isNS6 = ((document.getElementById && !document.all)? true: false );
var isHome = false;

var keepSub = 0;
var resFix = 0;
onMenu = false;


allSubs = ['1','2','3','4'];

// this array holds the total width from the left of the father buttons
fathersLoc = [0,300,366,420];
fathersWidth = [350,115,185,130];

function openSub(num){

	onMenu = true;
	
	keepSub = num ;		 
	// closes all menus and children, except for keepSub		
	closeAllSub();
	
	

	// displays the correct div
	if (isIE){
			
			document.all["sub" + num].style.visibility = "visible";

			// father is the images that trigger the subMenu

			fatherWidth = fathersWidth[num-1];
		
			document.all["sub" + num].style.width = fatherWidth;
							
			resFix = (document.body.clientWidth - 779) /2 ;				
			if (resFix<0) resFix=0;
			
			fatherLeft = fathersLoc[num-1];
			
			document.all["sub" + num].style.posLeft = resFix + fatherLeft;	
			
			//alert(resFix + fatherLeft)
								
			if (!isHome){
				document.all["sub" + num].style.posTop = 179;			
			}					
			else {
				document.all["sub" + num].style.posTop = 252;			
			}
	
	
	}else if (isNS6){
		document.getElementById("sub" + num).style.visibility = "visible";
			
		// father is the images that trigger the subMenu

		fatherWidth = fathersWidth[num-1];
				
		document.getElementById("sub" + num).style.width = fatherWidth + 30;			
			
		resFix = (window.innerWidth - 779) /2 ;				
		if (resFix<0) resFix=0;
			
		fatherLeft = fathersLoc[num-1];
		
		document.getElementById("sub" + num).style.left = resFix + fatherLeft - 10
	
		if (!isHome){
			document.getElementById("sub" + num).style.top = 179;			
		}		
		else {
			document.getElementById("sub" + num).style.top = 252;
		}
	
	}	



}



// ******************************************************************************************




function closeAllSub(){ 
	for (i=0; i<allSubs.length; i++){
		if (isIE){			
			if (document.all["sub" + allSubs[i]]){		
				if (allSubs[i]!=keepSub) {
					if (document.all){
						//alert(i)
						document.all["sub" + allSubs[i]].style.visibility = "hidden";
					}
				}		
			}
		}else if (isNS6){
			if (document.getElementById("sub" + allSubs[i])){		
				if (allSubs[i]!=keepSub ) {					
					document.getElementById("sub" + allSubs[i]).style.visibility = "hidden";
				}		
			}
		}
	}
	
	
}



function isMenu(toClose){
	// recieved "true" from the main TD - so reseting the keepSub and closing all subs	
	
	if (toClose){
		keepSub="";
		closeAllSub();
	}
}


