﻿var m1mn1=new Array(
175
,"נופש פסח","/passover_resorts/",0,""
,"תיירות בישראל","/israel_travel/",1,"m1mn1_2"
,"חופשות","/vacations/",1,"m1mn1_3"
,"טיולים","/tours/",1,"m1mn1_4"
,"שייט כשר","/kosher_cruises/",0,""
,"חתונות ובר מצווה","/jewish_weddings_bar_bat_mitzvah/",0,""
,"חופשות סקי","/vacations/ski_and_mountain/",0,""
,"בתי מלון כשרים","/vacations/kosher_hotels_and_resorts/",0,""
,"פנויים פנויות","/tours/singles/",0,"");

var m1mn1_1=new Array(
60
,"Main","/main/",0,""
,"Areas + Cruises","/main/",0,"");

var m1mn1_2=new Array(
165
,"בתי מלון","/israel_hotels/",1,"m1mn1_2_1"
,"טיולים ומדריכים","/israel_tours_tour_guides/",0,""
,"אטרקציות","/israel_attractions/",0,""
,"צימרים ונופש כפרי","/vacations/israel_rural/",0,""
,"סוכני נסיעות ודירות נופש","/israel_travel_agents_rentals/",0,""
,"נדלן","/real_estate/",0,"");

var m1mn1_2_1=new Array(
165
,"ירושלים","/israel_hotels/jerusalem/",0,""
,"תל אביב","/israel_hotels/tel_aviv/",0,""
,"אילת","/israel_hotels/eilat/",0,""
,"ים המלח","/israel_hotels/jerusalem/",0,""
,"חיפה והכרמל","/israel_hotels/haifa_carmel/",0,""
,"קיסריה ונתניה","/israel_hotels/netanya/",0,""
,"הגליל והגולן","/israel_hotels/galilee_golan/",0,""
,"אשדוד ואשקלון","/israel_hotels/ashdod_ashkelon/",0,""
,"הרצליה","/israel_hotels/herzliya/",0,""
,"נגב","/israel_hotels/negev/",0,"");

var m1mn1_3=new Array(
165
,"בריאות","/vacations/health/",0,""
,"חופשות סקי","/vacations/ski_and_mountain/",0,""
,"חופשות קיץ","/vacations/summer_and_winter_sun/",0,""
,"חופשות חורף","/vacations/summer_and_winter_sun/",0,"");

var m1mn1_4=new Array(
165
,"טיולים כשרים","/tours/kosher/",0,""
,"נוער וסטודנטים","/tours/student_and_youth/",0,""
,"מסורת","/tours/heritage/",0,""
,"משלחות","/tours/solidarity_missions/",0,"");

var m1mn2=new Array(
175
,"הודעות וטיפים","/message_boards/",0,""
,"קופונים למסעדות","/kosher_restaurants/",0,""
,"זמני שבת","/shabbat_times/",0,""
,"שאלות ותשובות","/kosher_travel_faq/",0,"");
//,"שירותי תיירות","/",1,"m1mn2_5");

var m1mn2_1=new Array(
85
,"Area","/bb_area/",0,""
,"Subject","/bb_subject/",0,"");

//var m1mn2_5=new Array(
//175
//,"ביטוחי נסיעות","/travel_insurance/",0,""
//,"השכרת רכב","/car_rental/",0,""
//,"סוכני נסיעות","/travel_agents/",0,""
//,"דירות להשכרה","/apartments/",0,"");

var m1mn3=new Array(
175
,"מדריך הערים","/city_guides/",0,""
,"מסעדות כשרות","/kosher_restaurants/",0,""
,"בתי מלון כשרים","/directory/?top_category_id=140&location_id_1=&location_id_2=&location_id_3=&location_id_4=&search=",0,""
,"בתי כנסת","/directory/?top_category_id=141&location_id_1=&location_id_2=&location_id_3=&location_id_4=&search=",0,""
,"מקוואות","/directory/?top_category_id=142&location_id_1=&location_id_2=&location_id_3=&location_id_4=&search=",0,""
,"מרכזים קהילתיים","/directory/?top_category_id=143&location_id_1=&location_id_2=&location_id_3=&location_id_4=&search=",0,""
,"נציגויות ישראליות","/directory/?top_category_id=201&location_id_1=&location_id_2=&location_id_3=&location_id_4=&search=",0,""
,"עדכנו אותנו","/directory/add/?package_id=",0,"");

var disappeardelay=500;  //menu disappear speed onMouseout (in miliseconds)
var delayhide=0;
var hideMnu = new Array();

/////No further editting needed

var ie4=document.all;
var ns6=document.getElementById&&!document.all;

if (ie4||ns6){
	document.write('<div id="mnulvl_10" class="menuitem" onMouseover="clearHideMe(1)" onMouseout="dynamichide(event)"></div>');
	document.write('<div id="mnulvl_20" class="menuitem" onMouseover="clearHideMe(2)" onMouseout="dynamichide(event)"></div>');
	document.write('<div id="mnulvl_30" class="menuitem" onMouseover="clearHideMe(3)" onMouseout="dynamichide(event)"></div>');
	document.write('<div id="mnulvl_40" class="menuitem" onMouseover="clearHideMe(4)" onMouseout="dynamichide(event)"></div>');
}

function getposOffset(curObj, offsettype){
	var totaloffset = (offsettype=="left")?curObj.offsetLeft : curObj.offsetTop;
	var parentEl = curObj.offsetParent;
	while (parentEl!=null){
		totaloffset=(offsettype == "left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
		parentEl=parentEl.offsetParent;
	}
	if(offsettype=="left"){
		totaloffset +=  curObj.offsetWidth;
	}
	return totaloffset;
}

function showhide(divObj, e, visible, hidden, menuwidth){
	if (ie4||ns6){
		divObj.style.left = divObj.style.top="-500px";
	}
	if (menuwidth!=""){
		divObj.widthobj=divObj.style;
		//divObj.widthobj.width=menuwidth;
	}
	if (e.type=="click" && divObj.style.visibility==hidden || e.type=="mouseover"){
		divObj.style.visibility=visible;
	}else if (e.type=="click"){
		divObj.style.visibility=hidden;
	}
}

function populatemenu(divObj, menuArray, newHrefID){
	if (!(ie4||ns6)){
		return;
	}
	var strCurMenu;
	var strEvents;
	var strImage;
	strCurMenu = "";
	mnuInd = 1;
	for(i = 1; i<menuArray.length; i+=4){
		strEvents = "";
		strImage = "";
		if(menuArray[i+2] > 0){
			strEvents = ' onMouseover="dropdownmenu(this, event, '+ menuArray[i+3] +')" onMouseout="dynamichide(event)"';
			strImage = '<img  id="imglvl_'+newHrefID+mnuInd+'" src="/images/tmnu_arwrt.gif" />';
		}
		strCurMenu = strCurMenu + '<a  id="anclvl_'+newHrefID+mnuInd+'" class="menuitem" href="' + menuArray[i+1] + '"' + strEvents + '>' + menuArray[i] + strImage + '</a>';		
		mnuInd++;
	}
	divObj.innerHTML=strCurMenu;
}

function dropdownmenu(ancObj, e, menucontents){
	if (window.event){
		event.cancelBubble=true;
	}else if (e.stopPropagation){
		e.stopPropagation();
	}
	clearhidemenu("dropdownmenu");
	hrehNum = getLvlNum(ancObj.id);
	if(hrehNum == 0){
		dropmenuobj = document.getElementById("mnulvl_10");
		topOffSet = ancObj.offsetHeight;
		rightOffSet = 0;
	}else{
		dropmenuobj = document.getElementById("mnulvl_"+(hrehNum+1)+"0");
		topOffSet = 2;
		rightOffSet = 4-dropmenuobj.offsetWidth;
	}
	hrehNum += 1;
	populatemenu(dropmenuobj, menucontents, hrehNum);
	forseHideSons(hrehNum);
	if (ie4||ns6){
		showhide(dropmenuobj, e, "visible", "hidden", menucontents[0]);
		dropmenuobj.x=getposOffset(ancObj, "left")+rightOffSet-dropmenuobj.offsetWidth;
		dropmenuobj.y=getposOffset(ancObj, "top")+topOffSet;
		dropmenuobj.style.left=dropmenuobj.x+"px";
		dropmenuobj.style.top=dropmenuobj.y+"px";
	}
}

function containsElement(src, trgt){
	if(!trgt) return false;
	if(ie4) return(src.contains(trgt));
	if(ns6){
		while (trgt.parentNode){
			if ((trgt = trgt.parentNode) == src) return true;
		}
		return false;
	}
}

function getFromElement(e){
	if(ie4)	return (e.fromElement);
	if(ns6)	return (e.currentTarget);
	return (null);
}

function getToElement(e){
	if(ie4)	return (e.toElement);
	if(ns6)	return (e.relatedTarget);
	return (null);
}

function isMenuElement(el){
	if(el == null) return false;
	return ((el.id.indexOf("anclvl") == 0) || (el.id.indexOf("mnulvl") == 0) || (el.id.indexOf("imglvl") == 0));
}

function getLvlNum(elID){
	elNum = (elID.substr(elID.indexOf("_")+1))*1;
	return (Math.floor(elNum / 10));
}

function getSubNum(elID){
	elNum = (elID.substr(elID.indexOf("_")+1))*1;
	return (elNum%10);
}

function forseHideSons(parentNum){
	if (!(ie4||ns6)) return;
	parentNum ++;
	childStrDiv = ("mnulvl_"+parentNum+"0");
	objDiv = document.getElementById(childStrDiv);
	while((typeof objDiv != "undefined") && (objDiv != null)){
		objDiv.style.visibility="hidden";
		parentNum++;
		childStrDiv = ("mnulvl_"+parentNum+"0");
		objDiv = document.getElementById(childStrDiv);
	}
}

function hideUntilToEl(fl, tl){
	for(i=fl; i>tl; i--){
		delayhidemenu("mnulvl_"+i+"0");
	}
}

function hideAll(fl){
	for(i=fl; i>0; i--){
		delayhidemenu("mnulvl_"+i+"0");
	}
	hideMnu = new Array();
}

function dynamichide(e){
	if(!(ie4||ns6)) return;
	if (window.event){
		event.cancelBubble=true;
	}else if (e.stopPropagation){
		e.stopPropagation();
	}
	fromElment = getFromElement(e);
	toElement = getToElement(e);
	fl = getLvlNum(fromElment.id);
	fs = getSubNum(fromElment.id);
	if(!isMenuElement(toElement)){
		hideAll(fl+1);		//	hide all menues - from child up to base level
		return;
	}
	tl = getLvlNum(toElement.id);
	ts = getSubNum(toElement.id);
	if(fl < tl) return;
	if(fl == tl){
		if(fs == ts){
			return;
		}else{
			objImg = document.getElementById("imglvl_"+(fl)+(fs));
			if(containsElement(fromElment, objImg)){
				delayhidemenu("mnulvl_"+(fl+1)+"0");	//	hide child menu
			}
			return;
		}
	}
	hideUntilToEl(fl+1, tl);	//hide all menues - from child up to to menu
	return;
}

function hidemenu(strDivID){
	if (!(ie4||ns6)) return;
	objDiv = document.getElementById(strDivID);
	if((typeof objDiv != "undefined")&&(objDiv != null)){
		objDiv.style.visibility="hidden";
	}
}

function delayhidemenu(strDivID){
	if (!(ie4||ns6)) return;
	mnuLvl = getLvlNum(strDivID);
	delayhide=setTimeout("hidemenu(\'"+strDivID+"\')",disappeardelay);
	hideMnu[mnuLvl] = delayhide;
}

function clearHideMe(mnuLvl){
	if (typeof hideMnu[mnuLvl] != "undefined"){
		clearTimeout(hideMnu[mnuLvl]);		
	}
}

function clearhidemenu(from){
	clearTimeout(delayhide);
}
