var isIE = ((document.all)? true  : false );
var isNS6 = ((document.getElementById && !document.all)? true: false );


if( document.captureEvents ) {

    if( Event.MOUSEOUT ) {
	document.captureEvents( Event.MOUSEOUT);
    }

}


function doTrans(subNum , endVal ,currVal) {
	subObj = document.getElementById ("sub"+subNum);
	if (currVal < endVal){
		//subObj.filters[0].opacity = parseInt (subObj.filters[0].opacity) + 10;
		subObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity=" + (currVal+25) + ")";
		setTimeout ("doTrans("+subNum+","+endVal+"," + (currVal+25) + ")" , 1);

	}
}


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;
  }


var keepSub = 0;
var closeInterval ;
var resFix = 0;
var currVal=50;

var lastSubNum = 0;
var fixFatherNum = 0;

function flipFatherImg2Off(fatherNum){
		if (fixFatherNum!=fatherNum) {
			//document.images[ "menuFatherIMG_"+fatherNum ].src = fatherOffImgs["fatherImg"+fatherNum].src ;
		}
}

function flipFatherImg(fatherNum){

	if (fixFatherNum!=fatherNum) {

	if ( fixFatherNum!=lastSubNum && lastSubNum>0){

	//	if (document.images[ "menuFatherIMG_"+lastSubNum ]){

	//		document.images[ "menuFatherIMG_"+lastSubNum ].src = fatherOffImgs["fatherImg"+lastSubNum].src ;
	//	}
	}
	//if (document.images[ "menuFatherIMG_"+fatherNum ]){
	//	document.images[ "menuFatherIMG_"+fatherNum ].src =  fatherOnImgs["fatherImg"+fatherNum].src ;
	//}
	}
}


function flipFatherImg2on(fatherNum){

	if (fixFatherNum!=fatherNum) {

	if (document.images[ "menuFatherIMG_"+fatherNum ]){
		document.images[ "menuFatherIMG_"+fatherNum ].src =  fatherOnImgs["fatherImg"+fatherNum].src ;
	}
	}
}


function getOffsetLeft (el) {
	var ol = el.offsetLeft;
	while ((el = el.offsetParent) != null)
		ol += el.offsetLeft;
	return ol;
}

function getOffsetTop (el) {
	var ol = el.offsetTop;
	while ((el = el.offsetParent) != null)
		ol += el.offsetTop;
	return ol;
}

function openSub(num){
	var subObj = document.getElementById("sub" + num);

	keepSub = num ;

	// closes all menus and children, except for keepSub
	closeAllSub();
	if (subObj){


		// displays the correct div
		subObj.style.display = "block";


		subObj.style.visibility = "visible";
		// father is the images that trigger the subMenu


		subObj.style.width = document.getElementById("menuFatherA_"+num).scrollWidth -8;

		switch(num)
		{
			case 1: subObj.style.left = resFix + getOffsetLeft(document.getElementById("menuFatherA_"+num)) - 31;
			break;
			case 2: subObj.style.left = resFix + getOffsetLeft(document.getElementById("menuFatherA_"+num)) - 18;
			break;
			case 3: subObj.style.left = resFix + getOffsetLeft(document.getElementById("menuFatherA_"+num)) - 9;
			break;
		}

		subObj.style.top = getOffsetTop(document.getElementById("menuFatherA_"+num))+31 ;

		//if (ie55up){
			doTrans(num , 0,0);
		//}

	}

	//flipFatherImg2on(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";
				if (i>0) {
				flipFatherImg2Off(allSubs[i])	;

				//alert(allSubs[i]);
				}
			}
		}
	}


}



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;
					//flipFatherImg2Off(num)	;
					//closeAllSub();
					tm=setTimeout("closeAllSub()",500);
					tm2=setTimeout("flipFatherImg2Off(" + num + ")",500);
				}
			}
		}
}

function cancelCloseFrame(){
	if(self.tm) clearTimeout(tm) // cancel delayed closing
	if(self.tm2) clearTimeout(tm2) // cancel delayed closing
}

function setSerchChoice(myvalue,id,target) {
document.getElementById(id).value=myvalue;
document.location.href=target
closeAllSub();
}


function showDetail()
{
	document.getElementById('detail').style.display='block';
}
