﻿
var intervals=new Array();

var keepSub = 0;

function doTrans(subNum , endVal ) {
        subObj = document.getElementById ("sub"+subNum);
	if (subObj.filters[0].opacity < endVal){
		subObj.filters[0].opacity = parseInt (subObj.filters[0].opacity) + 10;
		setTimeout ("doTrans("+subNum+","+endVal+")" , 25);

	}
}

function openSub(subNum){
	var subObj = document.getElementById("sub" + subNum);
	if (subObj){


		keepSub = subNum ;
		// closes all menus and children, except for keepSub
		closeAllSub();
		if (ie55up && subObj.filters){
			subObj.filters[0].opacity = 0;
		}
		subObj.style.visibility = "visible";

		if (allSubs[subNum]=="0"){

			subObj.style.top = getOffsetTop (document.getElementById("menuFather" + subNum))+25;
			subObj.style.left = getOffsetLeft (document.getElementById("menuFather" + subNum)) ;
			//subObj.style.width = document.getElementById("menuFather" + subNum).scrollWidth;
		}else{
			e = (isIE)? (window.event):(evt);

			subObj.style.top = getOffsetTop (e.srcElement) ;
			subObj.style.left = getOffsetLeft (e.srcElement)+e.srcElement.scrollWidth ;
		}

		lastSubNum = subNum;

		if (ie55up && subObj.filters){
			doTrans(subNum , 100);
		}

	}
}

function closeAllSub(){
	for (var i in allSubs){
		if (document.getElementById("sub" + i)){


			if (i!=keepSub ) {

				document.getElementById("sub" + i).style.visibility= "hidden";
			}
		}
	}
}


var closeTimeoutAr = [] ;
var lastTimeoutId = 0;
function checkIfClose (num, evt){
		clearAllClosings ()
		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 ("sub")==-1 && eId.indexOf ("topMenu")==-1 && eId.indexOf ("menuSeper")==-1 ){
					keepSub = 0;

					closeTimeoutAr.push (lastTimeoutId);
					lastTimeoutId = setTimeout ("closeAllSub()" ,100 );

				}
			}
		}
}


function clearAllClosings(){
	do {
		clearTimeout (closeTimeoutAr.shift ());
	}
	while (closeTimeoutAr.length>0);
}






function getOffsetLeft (el) {
	if (!el)return ;
  var ol = el.offsetLeft;
  while ((el = el.offsetParent) != null)
    ol += el.offsetLeft;
  return ol;
}


function getOffsetTop (el) {
if (!el)return ;
  var ol = el.offsetTop;
  while ((el = el.offsetParent) != null)
    ol += el.offsetTop;
  return ol;
}

if( document.captureEvents ) {

    if( Event.MOUSEOUT ) {
	document.captureEvents( Event.MOUSEOUT);
    }

}

