
if( document.captureEvents ) { 
	
    if( Event.MOUSEOUT ) {	
	document.captureEvents( Event.MOUSEOUT);
    }
    
}


	
	

var keepSub = 0;
var closeInterval ;
var resFix = 0;

allSubs = ['1','2','3','4'];
// this array holds the total width from the left of the father buttons
fathersLoc = [270,360,418,476];
fathersWidthAr = [100,100,133,176];



var fatherNames = ["","tb_profile","tb_mainActivities","tb_news","tb_contactUs","tb_home" ];
var fatherOnImgs = [];
var fatherOffImgs = [];
var lastSubNum = 0;
var fixFatherNum = 0;

fatherOnImgs [1] = new Image ();
fatherOnImgs [2] = new Image ();
fatherOnImgs [3] = new Image ();
fatherOnImgs [4] = new Image ();
fatherOnImgs [5] = new Image ();

fatherOffImgs [1] = new Image ();
fatherOffImgs [2] = new Image ();
fatherOffImgs [3] = new Image ();
fatherOffImgs [4] = new Image ();
fatherOffImgs [5] = new Image ();

hpPrefix = "";
	
fatherOnImgs [1].src = "images/" + hpPrefix + "tb_profileON.gif";
fatherOnImgs [2].src = "images/" + hpPrefix + "tb_mainActivitiesON.gif";
fatherOnImgs [3].src = "images/" + hpPrefix + "tb_newsON.gif";
fatherOnImgs [4].src = "images/" + hpPrefix + "tb_contactUsON.gif";
fatherOnImgs [5].src = "images/" + hpPrefix + "tb_homeON.gif";

fatherOffImgs [1].src = "images/" + hpPrefix + "tb_profile.gif";
fatherOffImgs [2].src = "images/" + hpPrefix + "tb_mainActivities.gif";
fatherOffImgs [3].src = "images/" + hpPrefix + "tb_news.gif";
fatherOffImgs [4].src = "images/" + hpPrefix + "tb_contactUs.gif";
fatherOffImgs [5].src = "images/" + hpPrefix + "tb_home.gif";



function flipFatherImg(fatherNum){

	
	hpPrefix = "";
	
	if ( fixFatherNum!=lastSubNum && lastSubNum>0){		
		document.images[ fatherNames[lastSubNum] ].src = fatherOffImgs[lastSubNum].src ;		
	}
	
	
	if (document.images[ fatherNames[fatherNum] ]){	
		document.images[ fatherNames[fatherNum] ].src =  fatherOnImgs[fatherNum].src ;
	}
	
}


function openSub(num){
	var subObj = document.getElementById("sub" + num);
	if (subObj){ 

	
		keepSub = num ;		 
		// closes all menus and children, except for keepSub		
		closeAllSub();
	
		// displays the correct div
		subObj.style.display = "block";
			
		// father is the images that trigger the subMenu
	
		fatherWidth = fathersWidthAr [num-1];				
		subObj.style.width = fatherWidth ;			
			
		if (isIE){
			resFix = (document.body.clientWidth - 780) /2 ;	
		}else if (isNS6){
			resFix = (window.innerWidth - 780) /2 ;				
		}		
		if (resFix<0) resFix=0;		
		
		fatherLeft = fathersLoc[num-1];		
		if (!isIE){
			fatherLeft -= 5; 		
			subObj.style.top = 144; 
		}
		subObj.style.left = resFix + fatherLeft ;
		
		flipFatherImg(num);
		lastSubNum = num;
		
	}
}

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 , evt  ){			
	
		e = (isIE)? (window.event):(evt);	
		if (e){						
			eEl = (isIE)?(e.toElement):(e.relatedTarget);
			
			if (eEl){
				eId = eEl.id; 
				
				if (eId.indexOf ("ditem")==-1 && eId.indexOf ("menuRow")==-1  && eId.indexOf ("subTable")==-1 && eId.indexOf ("menuFather")==-1 ){							
					keepSub = 0;	
					closeAllSub();
				}				
			}
		}
	
}


