
var intervals=new Array();

var keepSub = 0;
var keepSubFather = 0;
var e;

function doTrans(subNum , endVal ) {
	subObj = document.getElementById ("menuSub"+subNum);
	if (subObj){
		if (subObj.filters[0].opacity < endVal){
			subObj.filters[0].opacity = parseInt (subObj.filters[0].opacity) + 33;
			setTimeout ("doTrans("+subNum+","+endVal+")" , 20);
		}else{
			subObj.filters[0].opacity = endVal;
		}
	}else{

	}
}

function openSub(subNum){
	if (is_ie5)return;
	var add;
	var subObj = document.getElementById("menuSub" + subNum);

	if (subObj && allSubs[subNum]){
		clearAllClosings ();
		keepSub = subNum ;
		keepSubFather = allSubs[subNum] ;
		// closes all menus and children, except for keepSub
		closeAllSub();
		if (is_ie && ie55up){
			if (subObj.filters.length>0){
				subObj.filters[0].opacity = 0;
			}
		}
		subObj.style.visibility = "visible";

		if (allSubs[subNum]=="0"){
			var add = (!is_opera)?(0):(-20);
			subObj.style.top = ( getOffsetTop (document.getElementById("menuFather" + subNum)) + add) + "px";

			add = (!is_opera)?(-5):(-200);
			subObj.style.left = ( document.getElementById("menuFather" + subNum).offsetLeft + add ) + "px";

			fatherWidth = document.getElementById("menuFather" + subNum).scrollWidth;
			subObj.style.width =  (fatherWidth ) + "px";


		}else{
			e = (isIE)? (window.event):(evt);

			subObj.style.top = getOffsetTop (e.srcElement) + "px" ;
			subObj.style.left = getOffsetLeft (e.srcElement) + "px";//+e.srcElement.scrollWidth ;
		}

		lastSubNum = subNum;

		if (ie55up && subObj.filters){
			if (subObj.filters.length>0){
				doTrans(subNum , 100);
			}
		}


	}
}

function closeAllSub(){
	for (var i in allSubs){
		if (document.getElementById("menuSub" + i)){
			if (i!=keepSub && i!=keepSubFather ) {
				document.getElementById("menuSub" + i).style.visibility= "hidden";
			}
		}
	}
}

var closeTimeoutAr = [] ;
var lastTimeoutId = 0;
function checkIfClose (num, evt){
	if (is_ie5)return;
	clearAllClosings ();
	e = (isIE)? (window.event):(evt);

	if (e){
		eEl = (isIE)?(e.toElement):(e.relatedTarget);
		if (eEl){
			eId = eEl.id.toLowerCase();
			// every html element must have an id with prefix "menu" to avoid automatic closnig when rolling out from it.
			if (eId.indexOf ("menu")!=0 ){

				keepSub = 0;
				keepSubFather = 0;

				lastTimeoutId = setTimeout ("closeAllSub()" ,500 );
				closeTimeoutAr[closeTimeoutAr.length] = lastTimeoutId;


			}
		}
	}
}


function clearAllClosings(){
	do {
		//alert (closeTimeoutAr[0]);
		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);
	}
	if(Event.KEYDOWN ){
		document.captureEvents( Event.KEYDOWN );
	}
	if(Event.CLICK){
		document.captureEvents( Event.CLICK);
	}
}

function Array_shift() {
  var A_s = 0
  var response = this[0]
  for (A_s = 0; A_s < this.length-1; A_s++) {
   this[A_s] = this[A_s + 1]
   }
  this.length--
  return response
  }

if (typeof (Array.prototype.shift) == "undefined") {
  Array.prototype.shift = Array_shift;
  }