<!--

var mCategoryIndex=0,ageIndex=0,zoneIndex=0, catIndex=0;
var mCatName='Categories',zoneName='',ageName='',wordName='',catName='';
var ageLetch=0 //prvent age when parents activity is chosen
var catId=0;
var tm, currentTopMenu;
var kidsleisure_menu_left = 610; kidsleisure_menu_top = 175;
var aboutTooty_menu_left = 510; aboutTooty_menu_top = 175;
var logo_h,buble,buttons;
//var adds_search = false; // turns to True when it's an adds search from the engine (mCat = 4)


stdbrowser=(document.getElementById)? true: false;


function starttimeout(flag){	
setTimeout("popDown("+flag+")", 200);
}


function init(){

pageOnload = true; //located in imgload.js
	
	engineDefaults();

	
}


function engineDefaults(){
	
	loadCatMenu(5);
	mCategoryIndex=5;
	engine('categoryM','כל הקטגוריות');
	parentCheck();
	
}


function gCenter()
{
	var linksCoordinate = 0;
	
		if (document.getElementById) 
		{
			if (document.all) {
			var winWidth = document.body.clientWidth; //     
			}
			else {
			var winWidth=window.innerWidth
			}
		}
			var linksCoordinate = (winWidth > 770 ? (eval(winWidth - 762)) / 2 : 10)
			
	return linksCoordinate;
}



function coordinate(leftPos, topPos)
{
		if (document.getElementById)
		{

		/*
		logo_h = document.getElementById("logo_h");
		logo_h.style.left = gCenter() + 15 + "px";
		logo_h.style.top = 40 + "px";
		logo_h.style.visibility="visible";
		*/
		
		//alert(page)
		
		if (page=="addsView" || page=="index" || page=="busView_adds"){
			document.getElementById("adds_button_td").style.visibility="hidden";
			}
		
		buble = document.getElementById("buble");
		buble.style.left = gCenter() + 310 + "px";
		buble.style.top = -0 + "px";
		buble.style.visibility="visible";
		
		buttons = document.getElementById("buttons");
		buttons.style.left = gCenter() + 160 + "px";
		buttons.style.top = 125 + "px";
		buttons.style.visibility="visible";
		
		
		if (page=="index"){

			var emb = gCenter() + 90;

			engineCords = new Obj_rectangle(document.getElementById("engine_td"));
			embLeft = engineCords.ObjLeft + 90;
			embTop =  engineCords.ObjTop;
			
			//document.getElementById("menuBack").style.left = gCenter();
			//document.getElementById("subMenu"+mainQ).style.left = gCenter();
			//document.getElementById("engineMenus").style.left= gCenter()+169 + "px"
			
			document.getElementById("ageLable").style.left= embLeft + 70 + "px"	
			document.getElementById("engineBack").style.left= embLeft  + "px"	
			document.getElementById("engineMenus").style.left= embLeft + 72 + "px"
			document.getElementById("ageLable").style.visibility="visible"
			
			document.getElementById("engineMenus").style.top=embTop + 32 + "px";
			document.getElementById("engineBack").style.top=embTop + "px";
			document.getElementById("ageLable").style.top=embTop + 13 + "px";
			
			document.getElementById("engineMenus").style.visibility="visible"
			document.getElementById("engineBack").style.visibility="visible"
			
			document.getElementById("searchWord1").focus();
			//document.getElementById("ageLable").style.visibility="visible"
	
	/*
			if  (document.getElementById("searchWord1").style.display=='block' && document.getElementById("searchWord1").style.visibility=='visible')
				 document.getElementById("searchWord1").focus();
			*/
		}
		
		else{//not an index page
			if (true){	
				
				var nMode = 0;
				var mMode = 10;
				
				if (sMode=='menu'){mMode=10} else {mMode=8};
				
				if (page=='tooty'){
						nMode = -8;
						mMode -= 8;
						
					}
				
					//document.getElementById("miniEngine").style.left= gCenter()-miniEngineLeft+8 + nMode + "px"
					//document.getElementById("miniEngine").style.visibility="visible"
					//document.getElementById("miniEngineMenus").style.left= gCenter()-miniEngineLeft+mMode + "px"
					//document.getElementById("miniEngineMenus").style.visibility="visible"
					//document.getElementById("categoryMtable").width="110"
					//document.getElementById("agetable").width="41"
					//document.getElementById("miniEngineTablesPOS").style.width= 9-mMode + "px";
					
					//alert(ynetLogo);
					if (ynetLogo=='ynet') {ynetLogoShow()};
					
					/*
					document.getElementById("miniReturnToHomePage").style.left= gCenter()-miniEngineLeft+8 + "px"
					document.getElementById("miniReturnToHomePage").style.visibility="visible"
					*/
					
					
				}
			}

		}

}


function nextPage(t,page,pageURL){

var url = page + "?pageCurrent="+t+"&" + pageURL;

location.href=url;
//alert(url);	
}





function reloadM(q){
eval("loadMenu"+q+".window.location.reload();")
}



function checkEngine(){

if (page=="index"){
	
					var wString
				
					wString=document.form1.searchWord1.value;
					
					if (InStr(wString,'"')>0) {
												alert("!תו אסור")
												return false;
												}
					
					//alert(mCategoryIndex+" "+ageIndex+" "+zoneIndex+" "+document.form1.searchWord1.value)
					
					

					if (mCategoryIndex==0 && ageIndex==0 && zoneIndex==0 && wString=='')
						{
							
							//alert("יש לבחור קטגוריה לחיפוש")
							return false;
						}
					else
					{
						return true;
					}
				}
else{
	return true;
	}
	
}
	

function formAction(){

	if (checkEngine()){
	
		//alert(mCategoryIndex)
	    
		if (page=="index"){
			wString=document.getElementById("searchWord1").value;
			//document.getElementById("counter").src="count.asp?param1=engine&param2="+engineNum+"&param3="+wString;
			if (ageName=='5 +') {ageName="5."};

			if (mCategoryIndex!=4){
			    location.href="catView.asp?mCatId="+mCategoryIndex+"&ageId="+ageIndex+"&zoneId="+zoneIndex+"&mCatName="+mCatName+"&zoneName="+zoneName+"&ageName="+ageName+"&word="+wString+"&sMode=engine&catName="+catName+"&catIndex="+catIndex;
			}
			else{
				location.href="addsView.asp?mCatId="+mCategoryIndex+"&ageId="+ageIndex+"&zoneId="+zoneIndex+"&mCatName="+mCatName+"&zoneName="+zoneName+"&ageName="+ageName+"&word="+wString+"&sMode=engine&catName="+catName+"&catIndex="+catIndex;
				}
		}
		
		else{
				//alert(catId);
				if (ageName=='5 +') {ageName="5."};
				//if (engineNum==4) {document.getElementById("counter").src="count.asp?param1=engine&param2="+engineNum} // only if filter 
					
				if (mCategoryIndex!=4){
				location.href="catView.asp?mCatId="+mCategoryIndex+"&ageId="+ageIndex+"&zoneId="+zoneIndex+"&catId="+catId+"&mCatName="+mCatName+"&sMode=engine"+"&zoneName="+zoneName+"&ageName="+ageName+"&catName="+catName+"&catIndex="+catIndex;
				}
				else{
				location.href="addsView.asp?mCatId="+mCategoryIndex+"&ageId="+ageIndex+"&zoneId="+zoneIndex+"&catId="+catId+"&mCatName="+mCatName+"&sMode=engine"+"&zoneName="+zoneName+"&ageName="+ageName+"&catName="+catName+"&catIndex="+catIndex;
				}
			
			}
	}

}


/* q == menu index 
   mCategoryIndex - main category
*/

var mainQengine;
function engineMenuOpen(q){

	if(mainQengine==q) {
	   closeEngineMenues();
	   mainQengine = 0;
	   return;
	}
	
	var id,offsetLeft=0,offsetTop=0;

    if (q==4 && mCategoryIndex==0) return;
	if (q==2 && mCategoryIndex==2) return;
	
	mainQengine=q;

	if (page=="index"){
		
		if (q==1) {id = "categoryM";offsetLeft=-18;offsetTop=2;}
		if (q==4) {id = "category";offsetLeft=-18;offsetTop=2;}
		if (q==2) {id = "age";offsetLeft=-19;offsetTop=2;}
		if (q==3) {id = "zone";offsetLeft=-18;offsetTop=2;}
	
	}
	else{
		
		if (q==1) {id = "miniCategoryM";offsetLeft=0;offsetTop=2;}
		if (q==4) {id = "category";offsetLeft=0;offsetTop=2;}
		if (q==2) {id = "miniAge";offsetLeft=0;offsetTop=2;}
		if (q==3) {id = "miniZone";offsetLeft=0;offsetTop=2;}
	}

		
		var ref = new Obj_rectangle(document.getElementById(id))
		var mnu=document.getElementById("engineMenu"+q);
		
		closeEngineMenues();
		
		mnu.style.top  = ref.ObjBottom + offsetTop + "px";
		mnu.style.left = ref.ObjLeft + offsetLeft + "px";
		mnu.style.visibility="visible";

}



function closeEngineMenues(){
	
	for (t=1;t<=4;t++){
		var obj1 = document.getElementById("engineMenu"+t);
		if (obj1) obj1.style.visibility="hidden";
		}			

}


function engineMenuClose(){
mnu=document.getElementById("engineMenu"+mainQengine).style
mnu.visibility="hidden"
}


// small engine category width
function setCategoryWidth(){

	//document.getElementById("menuInner").style.width="132px";
	document.getElementById("bottom-round-menu").style.width="132px";
	document.getElementById("EmenuBackTD").style.width="132px";
	document.getElementById("categoryBackTable").style.width="132px";
}


function engine(id,val){

if (id=='categoryM' || id=='miniCategoryM') {
		mCatName=val
		//page=='index' || page=='tooty_engine' || page=='catView.asp'
		if(true) if (document.getElementById("category")) document.getElementById("category").innerHTML='כל הפעילויות'
		};
		
if (id=='zone' || id=='miniZone') {zoneName=val};
if (id=='age' || id=='miniAge') {ageName=val; if (val=='5.') {val='5 +'}};
if (id=='category' || id=='miniCategory') {catName=val};

if (page!='index') {setCategoryWidth();}

val = val.replace("-",":");

if (document.getElementById(id)) document.getElementById(id).innerHTML=val;

for (t=0;t<=engineMenuTop;t++){
	 if (document.getElementById("engineMenu"+t)){
	 	 document.getElementById("engineMenu"+t).style.visibility="hidden";
		 }
	 }	
	 
				 
}



function parentCheck(){
	if (mCategoryIndex==2 || mCategoryIndex==6 || mCategoryIndex==7){
		document.getElementById(ageParam).style.color="#bbbbbb"
		document.getElementById(ageParam).innerHTML="גיל";
	ageIndex=0;
	ageLetch=1
	}
	else
	{
		if(document.getElementById(ageParam))   document.getElementById(ageParam).style.color="#000000"
		if(document.getElementById('category')) document.getElementById('category').style.color="#000000"
		ageLetch=0
    }

}


function Scrolling(Type,num)
{
	var mn
	clearTimeout(v);
	if (Type == "DOWN")
	{
		Scroll = 3;
	}
	else
	{
		Scroll = -3;
	}
	//alert("loadMenu"+num)
	mn=eval("loadMenu"+num)
	with (mn)
	{
		scrollBy(0, Scroll);
	}
	v = setTimeout("Scrolling('"+Type+"',"+num+")", 50);
}





function InStr(strSearch, charSearchFor)
{
	for (i=0; i < Len(strSearch); i++)
	{
	    if (charSearchFor == Mid(strSearch, i, 1))
	    {
			return i;
	    }
	}
	return -1;
}


function Mid(str, start, len)
{
		if (start < 0 || len < 0) return "";
		var iEnd, iLen = String(str).length;
		if (start + len > iLen)
				iEnd = iLen;
		else
				iEnd = start + len;
		return String(str).substring(start,iEnd);
}

function Len(str)
{  return String(str).length;  }



function loadCatMenu(ki){
	categoryFrame.location.href="getMenu.asp?mCatId="+ki+"&lang=heb";
	}



function couponInit(){
	

	
	var sp = document.getElementsByTagName("span");
	var addObj;
	var cpnObj,ob,tbl;
	
	for (var t=0; t<sp.length; t++ )
	{
		 if (sp[t].id){ 
		 if (sp[t].id.split("_")[0]=="coupon"){
			 
			 //addObj = new Obj_rectangle(document.getElementById("tb"+sp[t].id.split("_")[1]));
			 cpnObj = document.getElementById("coupon_"+sp[t].id.split("_")[1]);
			 
			 tbl = document.getElementById("stripTable_"+sp[t].id.split("_")[1]);
			 ob = new Obj_rectangle(tbl);
			 
			 cpnObj.style.left = ob.ObjLeft -15 + "px";
			 cpnObj.style.top = ob.ObjTop -15  + "px";
			 //alert();
			 //cpnObj.style.left = addObj.ObjLeft - 665;
			 //cpnObj.style.top = addObj.ObjTop - 13;
			 cpnObj.style.visibility="visible";
			 
			 }
		 }
		 
	}
}


function Obj_rectangle(Obj)
{
	if (! Obj){return;};

	this.ObjLeft = findOffset(Obj, "offsetLeft");
	this.ObjWidth = Obj.offsetWidth;
	this.ObjRight = this.ObjLeft + this.ObjWidth;
	this.ObjTop = findOffset(Obj, "offsetTop");
	this.ObjHeight = Obj.offsetHeight;
	this.ObjBottom = this.ObjTop + this.ObjHeight;

	function findOffset(Obj, offset)
	{
		var NumValue = 0;
		
		var startOffsetDom = Obj;

		while (startOffsetDom.offsetParent)
		{
			NumValue = NumValue + startOffsetDom[offset];
			startOffsetDom = startOffsetDom.offsetParent;
		}
		return NumValue;
	}
}



//****************************************************************************************
			

	function openMenu(menu){
	
	//if (!pageOnload) return;
	closeM(currentTopMenu)
	
	window.clearTimeout(tm);
	//if (mainQ>0 && mainQ!=q){closeM(mainQ);}
	//mainQ=q;
	
	mnu=document.getElementById(menu);
	bak=document.getElementById("menuBack");
	
	document.getElementById(menu + "_img").src = "images/" + menu + "-over.gif";
	
	mnuButton = new Obj_rectangle(document.getElementById(menu + "_img"));

	mnu.style.left = mnuButton.ObjLeft - 30 + "px";				
	mnu.style.top  =  mnuButton.ObjBottom + 5 +  "px";
	mnu.style.visibility="visible";

	if (menu!='dobe_h' && menu!='adds_h') {
	bak.style.top	= mnuButton.ObjBottom + 5 + "px";
	bak.style.left 	= mnuButton.ObjLeft -30 +  "px";
	bak.style.visibility="visible";
	}
	
	if (menu=='adds_h') {
	var adds_h_background = document.getElementById("adds_h_background");
	adds_h_background.style.top		= mnuButton.ObjBottom + 0 + "px";
	adds_h_background.style.left 	= mnuButton.ObjLeft -40 +  "px";
	adds_h_background.style.visibility = "visible";
	adds_h_background.style.display = "block";
	
	//calendar
	mnu.style.left = mnuButton.ObjLeft - 28 + "px";				
	mnu.style.top  = mnuButton.ObjBottom + 85 +  "px";
	mnu.style.visibility="visible";	
	}
	
	
	
	currentTopMenu = menu;
	
	}
	
	
	function closeMenu(menu){

		window.clearTimeout(tm)
		tm=window.setTimeout("closeM('"+menu+"')",800)
	}
	
	
	function closeM(menu){
		
		if (document.getElementById(menu)){
		
			window.clearTimeout(tm);
			mnu=document.getElementById(menu);
			bak=document.getElementById("menuBack");
			mnu.style.visibility="hidden";
			bak.style.visibility="hidden";
			
			document.getElementById(menu+"_img").src = "images/"+menu+".gif";

			if (menu=='adds_h') {
			var adds_h_background = document.getElementById("adds_h_background");
			adds_h_background.style.visibility = "hidden";
			adds_h_background.style.display = "none";
			}
			
		}
	}


function ynetLogoShow(){
	
	return;
	
	if (ynetLogo=='ynet'){
	
	var obj = new Obj_rectangle(document.getElementById("logoRightCorner"));
	var ylogo = document.getElementById("ynetLayer");
	
	ylogo.style.display="block";
	ylogo.style.left = obj.ObjRight - 170 + "px";
	ylogo.style.top = obj.ObjTop + 2 + "px";
	
	ynetLogo = false;
	
	}
	
}


function changeImages() {
	if (!pageOnload) return;
	if (document.images) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}


function roundPositionSmallPic(){

	var rightRound,leftRound;

	if (ieBrowser==1){
		rightRound = 0
		leftRound = -8
	}
	else{
		rightRound = 8
		leftRound = 0
	}

	
	var imgId;
	
	var im = document.getElementById("addsContainer");

	if (im) {
	
	var images = im.getElementsByTagName("IMG");
	
	for (var t=0; t<images.length; t++){
			
		  imgId = images[t].id;	
			
		  if (imgId.indexOf("IMG_")>-1){
		  	   
			   var ref = new Obj_rectangle(images[t]);
			   
			   var id = imgId.split('_')[1]; 
			   
			   document.getElementById("topLeft_" + id).style.left = ref.ObjLeft - leftRound + "px";
			   document.getElementById("topLeft_" + id).style.top  = ref.ObjTop + "px";
			   document.getElementById("topLeft_" + id).style.display = "block";
			   
			   document.getElementById("topRight_" + id).style.left = ref.ObjRight - rightRound + "px";
			   document.getElementById("topRight_" + id).style.top  = ref.ObjTop + "px";
			   document.getElementById("topRight_" + id).style.display = "block";
			   
			   document.getElementById("bottomRight_" + id).style.left = ref.ObjRight -rightRound -1 + "px";
			   document.getElementById("bottomRight_" + id).style.top  = ref.ObjBottom -8 + "px";
			   document.getElementById("bottomRight_" + id).style.display = "block";
			   
			   document.getElementById("bottomLeft_" + id).style.left = ref.ObjLeft - leftRound + "px";
			   document.getElementById("bottomLeft_" + id).style.top  = ref.ObjBottom -8 + "px";
			   document.getElementById("bottomLeft_" + id).style.display = "block";
			   
		  }	
	}
  }
}


function roundPositionBigPic(){

	var rightRound,leftRound;

	if (ffBrowser==1 || ieBrowser==1){
		rightRound = 16
		leftRound = 1
	}
	else{
		rightRound = 15
		leftRound = 0
	}

	var im = document.getElementById("imgContainer");
	
	if (im) {
	
	var images = im.getElementsByTagName("IMG");
	
	for (var t=0; t<images.length; t++){
			
		  if (images[t].id.indexOf("img")>-1){
		  	   var id = images[t].id.split('_')[1]; 
			   var ref = new Obj_rectangle(document.getElementById(images[t].id));
			   
			   document.getElementById("topLeft_" + id).style.left = ref.ObjLeft - leftRound + "px";
			   document.getElementById("topLeft_" + id).style.top  = ref.ObjTop + "px";
			   document.getElementById("topLeft_" + id).style.display = "block";
			   
			   document.getElementById("topRight_" + id).style.left = ref.ObjRight - rightRound + "px";
			   document.getElementById("topRight_" + id).style.top  = ref.ObjTop + "px";
			   document.getElementById("topRight_" + id).style.display = "block";
			   
			   document.getElementById("bottomRight_" + id).style.left = ref.ObjRight -rightRound + "px";
			   document.getElementById("bottomRight_" + id).style.top  = ref.ObjBottom -15 + "px";
			   document.getElementById("bottomRight_" + id).style.display = "block";
			   
			   document.getElementById("bottomLeft_" + id).style.left = ref.ObjLeft - leftRound + "px";
			   document.getElementById("bottomLeft_" + id).style.top  = ref.ObjBottom -15 + "px";
			   document.getElementById("bottomLeft_" + id).style.display = "block";
			   
		  }	
	  }
	
   }
}

// -->
