﻿// JScript File
////Global/////

var DdlCities = false;
var IsFireFox = false;
var IsChrome = false;
var xmlWallaShops = null;
var xmlWallaTours = null;
var xmlYad2Cat = null;
var xmlCurrency = null;
var RefreshPage = false;
var GalleryLength = false;
var txtSearchItem = false;
var DefaultdivCities = "divCitiesList";
var GeneralZones = new Zones();
var InnerZones = new Zones();
 
//////FUNCTIONS//////

 
function BookMarkIt(type)
{
	var arrUrl = new Array("","/Zap/","/Yad2/","/English/");
	var arrTitle = new Array("האתר הדתי הגדול בישראל","זאפ השוואת מחירים כשר","יד 2 כשר","for Torah Observant Jews");
	var url= "http://www.koogle.co.il" + arrUrl[type];
	var title = "Koogle " + arrTitle[type];
	if (window.sidebar)  // Mozilla Firefox Bookmark		
		window.sidebar.addPanel(title, url,"");	 
	else if( window.external )  // IE Favorite		
		window.external.AddFavorite( url, title);
} 
	
function GoToSelected(source, eventArgs )
{
	window.open("Subcategory.aspx?LocationID=" + eventArgs.get_value(),"_self");
}

function ClientPopulated(source, eventArgs)
{
		if (source._currentPrefix != null)
		{
				var list = source.get_completionList();
				var search = source._currentPrefix.toLowerCase();
				for (var i = 0; i < list.childNodes.length; i++)
				{
						var text = list.childNodes[i].innerHTML; 
						var index = text.toLowerCase().indexOf(search);
						if (index != -1)
						{
							var value = text.substring(0, index);
							value += '<b class="Suggestions_HiliteText">';
							value += text.substr(index, search.length);
							value += '</b>';
							value += text.substring(index + search.length);
							list.childNodes[i].innerHTML = value;
						}
				}
		}
}

function ClientItemSelected(source, e)
{
		source.get_element().value = (document.all) ? e._item.innerText : e._item.textContent;
		if($get("ctl00__kcSearch_hdnLocationID"))		
			$get("ctl00__kcSearch_hdnLocationID").value = e.get_value();
		else if($get("ctl00__hdnLocationID"))		
			$get("ctl00__hdnLocationID").value = e.get_value();		
}

function ShowHideCitiesDDL(divlist)
{
	if(divlist)
		DefaultdivCities =  divlist;
	document.getElementById(DefaultdivCities).style.display = DdlCities ? "none" : "block" ;
	DdlCities = !DdlCities;
}

function CitiesItem_MouseOver(element)
{
	if(!DdlCities)ShowHideCitiesDDL();
	element.id = 'CitiesListChosen';
}               




function getElementByClassName(Collection, RequestedClass)
{	
	for(i=0;i < Collection.length; i++)
	{		
		if(Collection[i].className && Collection[i].className == RequestedClass)
			return Collection[i];
	}	
}

function getElementByClassRecursive(Collection)
{
	var ArgsCount = 1;
	var Collection = document.childNodes;
	while(ArgsCount < arguments.length)
	{
		var e = getElementByClassName(Collection,arguments[ArgsCount]);
		if(e != null)
		{
			Collection = e.childNodes;
			ArgsCount++;
		}
		else
			return false;
	}
	
	return e;
	
}

function PromotedItemTabs_Hover(Parent, Index)
{
		if(Index != null)
		{
			var dc = getElementByClassName(getElementByClassName(Parent.childNodes, "TabsContainer").childNodes, "ItemDiv");																																								
			var DetailsDivs =  getElementByClassName(dc.childNodes,"Centers").childNodes;																					
	 		var ff = (IsFireFox)? 1:0;
	 		var indx = 0;
			for( dd = (0 + ff); dd < DetailsDivs.length ; dd += (1+ff))
			{
			 DetailsDivs[dd].style.display = (indx == Index)? "block": "none";
			 indx++;
			}		
		}						

}


function tabs_Hover(DefaultClassName , ChosenClassName , ChosenTab , TabsParent , TabsTagName)
{	
	if(ChosenTab.className != ChosenClassName)
	{
		if(!TabsParent)
			TabsParent = ChosenTab.parentNode;
		var Tabs = TabsParent.getElementsByTagName( TabsTagName);
		var Index = 0;
		for(x=0; x < Tabs.length ; x++)
		{																							
			Tabs[x].OldClass = Tabs[x].className;
			
			if(Tabs[x].className== ChosenClassName || Tabs[x].className== DefaultClassName)
			{
				if(!Tabs[x].Index)
				 Tabs[x].Index = Index;				
				Index++;
				Tabs[x].className = DefaultClassName;	
			}											
		}																																										
		ChosenTab.className = ChosenClassName;
		ChosenTab.onmouseout =	function() {tabs_Out( TabsParent , TabsTagName)}; 
	}
}

function tabs_Out( TabsParent , TabsTagName)
{
	var Tabs = TabsParent.getElementsByTagName(TabsTagName);
	for(x=0; x < Tabs.length ; x++)																										
		 Tabs[x].className = Tabs[x].OldClass;	
	
}

function InitSearchLinksFunctions(Container)
{			
	
	var Lists = Container.getElementsByTagName("li");
	for(i=0 ; i < Lists.length; i++)
	{
			
		Lists[i].onmouseover = function(){	
																				
																				var Lists = Container.getElementsByTagName("li");
																				for(x=0; x < Lists.length ; x++)
																				{																							
																					Lists[x].OldClass = Lists[x].className;
																					if(x < Lists.length - 1 )
																						Lists[x].className = "SearchLnk";
																					else 
																						Lists[x].className = "LastSearchLnk";
																					Lists[x].Index = x;								
																				}
																																																													
																				this.className = "ChosenSearchLnk";	
																				if(this.Index > 0) 
																					Lists[this.Index - 1].className = "BeforeChosenSearchLnk";																																						
																				if(Container.parentNode && Container.parentNode.className == "ItemTabs")
																					PromotedItemTabs_Hover(Container.parentNode.parentNode.parentNode, this.Index);											  
																																							
																			};
		Lists[i].onmouseout =	function() {
																				if(Container.parentNode.className != "ItemTabs")
																				{
																					var Lists = Container.getElementsByTagName("li");
																					for(x=0; x < Lists.length ; x++)																				
																						Lists[x].className = Lists[x].OldClass;
																				}								
																							
																		};
	}
}


function Cities_Select(sender)
{	
	var objZones = (sender.parentNode.id == "CitiesList") ? GeneralZones : InnerZones;	
	if(objZones.IsEmpty())
		SetZonesObj();		
	objZones.txtField.value =  sender.firstChild.innerHTML;		
	objZones.hdnField.value = sender.getAttribute("value");		
	ShowHideCitiesDDL(); 			
}


function SetZoneBox()
{
	if(document.getElementById("ctl00_hdnZone"))
	{
		var hdnzoneVal = document.getElementById("ctl00_hdnZone").value;
		if(hdnzoneVal != null && hdnzoneVal != "" && hdnzoneVal != "0")
		{
			var ZoneList = document.getElementById("CitiesList").getElementsByTagName("li");
			for(var i = 0 ; i < ZoneList.length; i++)
			{
				if(ZoneList[i].getAttribute("value") == hdnzoneVal)	
				{	
					document.getElementById('ctl00_txtZones').value = ZoneList[i].firstChild.innerHTML;	
					break;
				}	
			}
		}
	}
	
}



function MoveToPage(intCurrentPage)
{	
		document.getElementById("ctl00_ContentPlaceHolder1_hdnCurrentPage").value = intCurrentPage;	
		var url = location.href;
		var pageString = "";
		if(location.href.indexOf("Items.aspx") >= 0 )
		 pageString = "&pag=";
		else
		 pageString = "/דף-";
		if(url.indexOf(pageString)> 0)
		{
			var removeStr = url.substring(url.indexOf(pageString) , url.length);
			url = url.replace(removeStr,"");
					
		}	 		
		url +=  pageString;
		
		location.href =   url + intCurrentPage;
}

function Zones()
{
	this.txtField = null;
	this.hdnField = null;	
	this.IsEmpty = function(){if(this.txtField && this.hdnField) return false; else return true;};	
}

function SetZonesObj()
{
	if(GeneralZones.IsEmpty())
	{
		GeneralZones.txtField = document.getElementById("ctl00_kcSearch_txtZones");
		GeneralZones.hdnField = document.getElementById("ctl00_kcSearch_hdnZone");
		if(GeneralZones.IsEmpty())
		{
			GeneralZones.hdnField = document.getElementById("ctl00_hdnZone");	
			GeneralZones.txtField = document.getElementById("ctl00_txtZones");
		}	
	}
	
	if(InnerZones.IsEmpty())
	{		
		InnerZones.txtField = (document.getElementById("ctl00_txtCities"))? (document.getElementById("ctl00_txtCities")) : null;
		InnerZones.hdnField = (document.getElementById("ctl00_hdnCities"))? (document.getElementById("ctl00_hdnCities")) : null;
	}
}

function SetZone()
{
	var CitiesList = document.getElementById("CitiesList");		
	SetZonesObj();	
	if(CitiesList != null)
	{
		if(	GeneralZones.hdnField.getAttribute("value") )
		{
			for(var i=0; i < CitiesList.childNodes.length	; i++)
			{		
				if(CitiesList.childNodes[i].getAttribute("value"))
				{	
					var ElementVal = CitiesList.childNodes[i].getAttribute("value");									
					if(ElementVal.indexOf(GeneralZones.txtField.getAttribute("value")) != -1)	
					{			
						GeneralZones.txtField.value = CitiesList.childNodes[i].firstChild.innerHTML;
						return;
					}					
					 				
				}
			}			
		}	
		else
		{
			if(CitiesList.childNodes[0].childNodes.length > 0)
				GeneralZones.txtField.value =	 CitiesList.childNodes[0].firstChild.innerHTML;
			return;
		}	
		txtZones.value =	 "כל הארץ";
	}
}

function ViewItemImage(imgElementId, imgIconId, divTextId)
{
	if(document.getElementById(imgIconId))
	{
		
		var icon = document.getElementById(imgIconId);
		var preview = document.getElementById(imgElementId);
		var dvText = document.getElementById(divTextId);
		preview.src = icon.src;
		preview.iconId = icon.id;
		preview.alt = icon.alt;
		if(dvText)
			dvText.innerHTML = preview.alt;	
		if(icon.ttl)
		{			
			var prevwTitle = document.getElementById('ctl00_ContentPlaceHolder1_lblPreviewHeader');		
			prevwTitle.innerHTML = icon.ttl;
			preview.onclick = function(){ location.href = "http://www.koogle.co.il/news/NewsItem.aspx?nid=" + icon.hid;};
		}	
	}
}

function StepImage(imgElementId, direction)
{	
	var step = "";
	var preview = document.getElementById(imgElementId);	
	if(preview.iconId)
	{
		var id = preview.iconId;
		var idNum =	id.substring((id.indexOf("Itm") + 3),id.length);
		var idstepNum = Number(idNum) + direction;
		var stepId = id.replace("Itm" + idNum, "Itm" + idstepNum.toString()) ;
		if(document.getElementById(stepId))
		{
			var step = document.getElementById(stepId);
			
			if(
						step.parentNode.className == "second"  
						|| step.parentNode.parentNode.className == "second" 
						||  step.parentNode.parentNode.style.display == "none"
						||  step.parentNode.display == "none"
				)
			{
				
				
				if(!GalleryLength)
				{
					if(document.getElementById("hdnGalLength"))
						GalleryLength = document.getElementById("hdnGalLength").value;
					else
						GalleryLength = document.getElementById("ctl00_ContentPlaceHolder1_hdnGalLength").value;					
				}	
				var tmpIcon = document.getElementById(id.replace("Itm" + idNum, "Itm1"));
				var counter = 1;
				if(document.getElementById(id.replace("Itm" + idNum, "Itm0")))
				{
				 tmpIcon = document.getElementById(id.replace("Itm" + idNum, "Itm0"));
				 counter = 0;
				}
				
				var SectionStart = Math.floor(idstepNum/GalleryLength)*GalleryLength;
				
				while(tmpIcon != null)
				{
					var tempParent = tmpIcon.parentNode;
					if(step.parentNode.parentNode.className == "second" || step.parentNode.parentNode.className == "none" || step.parentNode.parentNode.className == "first" )
						tempParent = tempParent.parentNode;
					if(counter >=  SectionStart && counter < SectionStart + GalleryLength)
						tempParent.style.display = "block";	
					else
						tempParent.style.display = "none";	
									
					tmpIcon = document.getElementById(tmpIcon.id.replace("Itm" + counter, "Itm" + (counter + 1)));
					counter++;
				}			
			}	
		}
				
	}
	else if(direction > 0)
	{		
		
		var itemId= "gal" + imgElementId.substring(imgElementId.indexOf("Image") + 5, imgElementId.length);
		itemId += "ImgItm1"; 		
		step = document.getElementById(itemId);
		if(!step)
		step = document.getElementById("gal0ImgItm1");
	}
	
	if(step)
			return step.id;
			
}



//function GetDate()
//{
//	 var doc = GetXML("http://koogle.co.il/hdate.asmx/DisplayDate");
//	 return doc.getElementsByTagNAme("string").childNodes[0].nodeValue;
//}

function GetXML(path)
{
	try //Internet Explorer
		{
		xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
		}
	catch(e)
		{
		try //Firefox, Mozilla, Opera, etc.
			{
			xmlDoc=document.implementation.createDocument("","",null);
			}
		catch(e)
			{
			alert(e.message);
			return;
			}
		}
	xmlDoc.async=false;
	var xmlhttp = new window.XMLHttpRequest();
	xmlhttp.open("GET", path, false);
	xmlhttp.send(null);
	xmlDoc = xmlhttp.responseXML.documentElement;

	//xmlDoc.load(path);
	return xmlDoc;
}

function GetKosherQuery(lnk)
{
	var qry = "";
	var ddlZone = document.getElementById("ctl00_ContentPlaceHolder1_ddlFoodZone");
	if(ddlZone)
	{
		if(lnk.href.indexOf("&zone") > 0)
			lnk.href = lnk.href.replace(lnk.href.substring(lnk.href.indexOf("&zone"),lnk.href.length),"");	
		qry +=  "&zone=" + ddlZone.options[ddlZone.selectedIndex].value;		
	}
	
	var ddlType = document.getElementById("ctl00_ContentPlaceHolder1_ddlFoodType");
	if(ddlType)
	{
		if(lnk.href.indexOf("&food") > 0)
			lnk.href = lnk.href.replace(lnk.href.substring(lnk.href.indexOf("&food"),lnk.href.length),"");	
		qry +=  "&food=" + ddlType.selectedIndex;
	}	
	
	lnk.href += qry;
}

function MorePopularCategories_Click(lnk)
{
	document.getElementById('ulPopularHdn').style.display = 'block';
  if(lnk.style.backgroundImage.indexOf("Close") > 0)
  {
		lnk.style.backgroundImage = lnk.style.backgroundImage.replace("Close","");
		lnk.innerText = lnk.oldText;
	}
	else
	{
	 lnk.style.backgroundImage = "url(Images/Main/Top/btnAllCategoriesClose.gif)";
	 lnk.oldText = lnk.innerText;
	 lnk.innerText = "חזור למצב סגור";
	}
	
}

function DisplayXML(xmlDoc,xmlPath,TagName,Identifier,Val)
{
	if(xmlDoc == null)
		xmlDoc = GetXML(xmlPath);
	if(xmlDoc.childNodes.length == 0)
		xmlDoc = GetXML("../" + xmlPath);
					
	var nodes = xmlDoc.getElementsByTagName(TagName);
	var catTitle = "";var element = null;
	
	for(i = 0 ; i < nodes.length; i++)
	{
		if(nodes[i].attributes.length > 0 && nodes[i].attributes.getNamedItem(Identifier) != null)
			catTitle = nodes[i].attributes.getNamedItem(Identifier).nodeValue;
		else
			catTitle = nodes[i].getElementsByTagName(Identifier)[0].text;
			
		element = document.getElementById("spn" + catTitle);
		if(element != null)
		{
			var result = "";
			if(Val!=null)
			{
				result = nodes[i].getElementsByTagName(Val)[0].text;
				if(xmlPath.indexOf("currency") >=0)
					result = parseFloat(result).toFixed(4); 				
			}
			else
				result = nodes[i].childNodes[0].nodeValue;
			
			element.innerHTML = result;		
		}			
	}	
}

function DisplayCurrency()
{
	DisplayXML(xmlCurrency,"XML/currency.xml","CURRENCY","CURRENCYCODE","RATE");
}

function PopulateYad2Categories()
{
	DisplayXML(xmlYad2Cat,"XML/yad2Cat.xml","cat","title",null);	
}


function Page_Load()
{	
	IsFireFox = (navigator.userAgent.indexOf('Firefox')!=-1);
	if(!IsFireFox)
		IsChrome = (navigator.userAgent.toLowerCase().indexOf('chrome') != -1);
	if(!txtSearchItem)
	{
		if(document.getElementById("ctl00_txtSearchItem"))
			txtSearchItem = document.getElementById("ctl00_txtSearchItem");
		else if(document.getElementById("ctl00_kcSearch_txtSearchItem"))
			txtSearchItem = document.getElementById("ctl00_kcSearch_txtSearchItem");
	}
	if(txtSearchItem)
		txtSearchItem.blur(); 			
	try
	{
		if(document.getElementById("cboCities"))			
			InitHalachicTimes();			
  }	   
 catch(e){alert(e.message)};	  
  SetZone();   		  
  if(document.getElementById("SearchLnks"))
		InitSearchLinksFunctions(document.getElementById("SearchLnks"));
  if(document.getElementById("WallaShopsProducts"))
		DisplayWalla("",true,0);
	if(document.getElementById("WallaToursProducts"))
		DisplayWalla("1",false,0);
	if(document.getElementById("currency"))
		DisplayCurrency();
		
	SetZoneBox();
	if(document.getElementById("flashmarquee"))
		populateMarquee("flashmarquee");
	if(document.getElementById("Yad2Warper"))
		PopulateYad2Categories();	
	if(location.href.indexOf("&printIt") > 0) 
		printIt();
		
	if(RefreshPage)
		var t = setTimeout("location.href = location.href",300000);			 
}

/////////////////WALLLA///////////////////////////

function WallaPanel(IsShops)
{
	
	if(xmlWallaShops == null && IsShops)
	{	
		xmlWallaShops = GetXML("XML/WallaShops.xml");	
		if((xmlWallaShops == null) || (xmlWallaShops.childNodes.length == 0))
			xmlWallaShops = GetXML("../XML/WallaShops.xml");	
	}
	if(xmlWallaTours == null && !IsShops)
	{
		xmlWallaTours = GetXML("XML/wallatours.xml");
		if(xmlWallaTours == null || xmlWallaTours.childNodes.length == 0)
			xmlWallaTours = GetXML("../XML/wallatours.xml");	
	}
	
	
	this.Class = "WallaProduct";
	this.ClassSelected = "WallaProductsSelected";
	if(IsShops)
	{			
		this.xmlDoc = xmlWallaShops;
		this.Initial = "WS";
		this.CategoryNode = "catName";
		this.Products = xmlWallaShops.getElementsByTagName("product");
		this.Header = "header";
		this.Price="price";
		this.Img="img";
		this.Url= "url";
		
	}
	else
	{
		this.xmlDoc = xmlWallaTours;
		this.Initial = "WT";
		this.CategoryNode = "type";
		this.Products = xmlWallaTours.getElementsByTagName("deal");
		this.Header ="title";
		this.Price="price1";
		this.Img="image";
		this.Url ="url";	
	}
}

function WallaProduct(node,IsShops,obj)
{	
	if(node)
	{		
		this.Header = node.getElementsByTagName(obj.Header)[0].childNodes[0].nodeValue;
		this.Price = node.getElementsByTagName(obj.Price)[0].childNodes[0].nodeValue;		
		this.Image = node.getElementsByTagName(obj.Img)[0].childNodes[0].nodeValue;		
		this.Url = node.getElementsByTagName(obj.Url)[0].childNodes[0].nodeValue;
		
		if(!IsShops)
		{
			this.Price += node.getElementsByTagName("price_currency")[0].childNodes[0].nodeValue;
			if(this.Image.indexOf("http://") < 0)
				this.Image = "http://www.wallatours.co.il/" + this.Image;
			if(this.Url.indexOf("http://") < 0)
				this.Url = "http://koogletours.co.il/" + this.Url;
			
			while	(this.Url.indexOf("#EMP#") > 0)
			{
				this.Url = this.Url.replace("#EMP#", "&");
			}
			this.Url = this.Url.replace("www.koogletours.co.il", "koogletours.co.il");
		}
	}		
}

function WallaTab_hover(tab,IsShops)
{
	var Walla = new WallaPanel(IsShops);
	tabs_Hover(Walla.Class,Walla.ClassSelected,tab,tab.parentNode ,'div');
	
	if(location.href.indexOf("עסקים")< 0 &&location.href.indexOf("חיפוש") < 0)
	{
		tab.onmouseout = "";	
		var DisplayImg = getElementByClassName(tab.parentNode.parentNode.getElementsByTagName("img"),"WallaDisplayedImage");
		if((tab.getElementsByTagName("img").length > 0) && DisplayImg)
		{
			DisplayImg.src = tab.getElementsByTagName("img").item(0).src;
			DisplayImg.parentNode.onclick = function(){location.href = tab.Url};
		}	
		if(document.getElementById("lnk" + Walla.Initial))
			document.getElementById("lnk" + Walla.Initial).href = tab.Url;
	}	
}

function wallaCat_hover(tab,catName,IsShops)
{
	tabs_Hover('Tabs','TabChosen',tab,tab.parentNode ,'div');
	DisplayWalla(catName,IsShops,tab.Index);	
	tab.onmouseout = "";
}

function DisplayWalla(CategoryName, IsShops, tabIndex)
{
	
	var Walla = new WallaPanel(IsShops);
	var products = Walla.Products;
	var divscount = 1;
	var stopIt = false;
	var arrDisplayedProducts = new Array();
	if(CategoryName!="" || tabIndex == null)
		tabIndex = 0;
		
	for(var i = tabIndex*5; divscount < 5 ; i++)
	{		
		if(i < products.length)
		{
			var rand = GetRandom(arrDisplayedProducts,i,products);	
			arrDisplayedProducts[i] = rand;								
			var category = products[i].getElementsByTagName(Walla.CategoryNode)[0];
			if((CategoryName == "")||(category != null && category.childNodes[0].nodeValue == CategoryName))
			{
				var Product = new WallaProduct(products[rand],IsShops,Walla);
				if(divscount == 1 && document.getElementById(Walla.Initial + "Img"))
				{
					document.getElementById(Walla.Initial + "Img").src = Product.Image;
					document.getElementById("lnk" + Walla.Initial).href = Product.Url;	
				}
				var currDiv = document.getElementById(Walla.Initial + divscount);
				if(currDiv != null)
				{
					if(!IsFireFox)
						currDiv.style.display = "block";
					currDiv.innerHTML = "<a rel=\"nofollow\" href='" + Product.Url + "'>" + 
															"<img class=\"WallaProductImage\" src=\""+Product.Image
															+"\" alt=\""+Product.Header+"\"/></a>" +
															"<div class='WallaProductText'><h3><a rel=\"nofollow\" href=\""+ Product.Url+"\">"+ Product.Header+"<a></h3>"+
															" <strong>"+Product.Price+"</strong></div>";
					currDiv.Url = Product.Url;
				}
				//Display 2 products in news
				if(document.getElementById(Walla.Initial + "Img1"))
					stopIt = DoubleProductsDisplay(divscount,Walla.Initial,Product,2);
				
				if(stopIt)
					break;
				else
					divscount++;
				
			}
		}
		else
		{
			if(document.getElementById(Walla.Initial + divscount))
				document.getElementById(Walla.Initial + divscount).style.display = "none";
			divscount++;
		}
	}
}

function GetRandom(arrDisplayedProducts, DisplayedLength, Products)
{
	var iRandom	= Math.floor(Math.random()*(Products.length));
	if(DisplayedLength > 0)
	{
		for(var a = 0; a < DisplayedLength ; a++)
		{			
			if(iRandom == arrDisplayedProducts[a] || Products[iRandom] == null)
			{
				iRandom = GetRandom(arrDisplayedProducts,DisplayedLength,Products);
			}
		}
	}
	return iRandom;
}

function DoubleProductsDisplay(Index, Initial ,p, StopWhen)
{
	document.getElementById(Initial + "Img" + Index).src = p.Image;
	document.getElementById("lnk" + Initial  + Index).href = p.Url;
	document.getElementById("lnk" + Initial  + Index).rel = "nofollow";
	document.getElementById(Initial + "H5" + Index).innerHTML = p.Header;
	document.getElementById(Initial + "span" + Index).innerHTML = p.Price;
	
	if(StopWhen > Index)
		return false;
	else
		return true;		
}

////////////////////////////////////////////////Continuous marquee/////////////////////////////////
/*
Cross browser Marquee II- © Dynamic Drive (www.dynamicdrive.com)
For full source code, 100's more DHTML scripts, and TOS, visit http://www.dynamicdrive.com
Modified by jscheuer1 for continuous content. Credit MUST stay intact for use
*/

//Specify the marquee's width (in pixels)
var marqueewidth="185px";

//Specify the marquee's height
var marqueeheight="180px";
//Specify the marquee's marquee speed (larger is faster 1-10)
var marqueespeed=1;

//Specify initial pause before scrolling in milliseconds
var initPause=1000;
//Specify start with Full(1)or Empty(0) Marquee
var full=1;
//Pause marquee onMousever (0=no. 1=yes)?
var pauseit=1;
//Specify Break characters for IE as the two iterations
//of the marquee, if text, will be too close together in IE
var iebreak='';

var element = false;

//Specify the marquee's content
//Keep all content on ONE line, and backslash any single quotations (ie: that\'s great):

var marqueecontent=false;

var  DefaultTimeout = 20; 


////NO NEED TO EDIT BELOW THIS LINE////////////
var copyspeed=marqueespeed;
var pausespeed=(pauseit==0)? copyspeed: 0;
var Mouseover= "copyspeed=" + pausespeed;
var Mouseout="copyspeed=" + marqueespeed;
var iedom=document.all||document.getElementById;
var actualheight='';
var cross_marquee, cross_marquee2, ns_marquee;

function populateMarquee(id)
{
		
	if(!element)
	{
		element = document.getElementById(id);
		marqueeheight = element.scrollHeight + "px";
		initPause = 0;
		if(IsFireFox)
			DefaultTimeout = 3;
	}
	if(!marqueecontent)
	{
		marqueecontent = element.innerHTML;
		element.innerHTML = '';
		CreateMarquee();
	}
	if (iedom)
	{
		var lb=document.getElementById&&!document.all? '' : iebreak;
		cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee;
		cross_marquee2=document.getElementById? document.getElementById("iemarquee2") : document.all.iemarquee2;
		cross_marquee.style.top=(full==1)? '8px' : parseInt(marqueeheight)+8+"px";
		cross_marquee2.innerHTML=cross_marquee.innerHTML=marqueecontent+lb;
		actualheight=cross_marquee.scrollHeight;
		cross_marquee2.style.top=(parseInt(cross_marquee.style.top)+actualheight+8)+"px"; //indicates following #1
		cross_marquee.onmouseover =cross_marquee2.onmouseover= Mouseover;
		cross_marquee.onmouseout = cross_marquee2.onmouseout= Mouseout;
	}
	else if (document.layers)
	{
		ns_marquee=document.ns_marquee.document.ns_marquee2;
		ns_marquee.top=parseInt(marqueeheight)+8;
		ns_marquee.document.write(marqueecontent);
		ns_marquee.document.close();
		actualheight=ns_marquee.document.height;
	}
	setTimeout('lefttime=setInterval("scrollmarquee()",'+DefaultTimeout +')',initPause);
}


function scrollmarquee()
{

	if (iedom)
	{
		if (parseInt(cross_marquee.style.top)<(actualheight*(-1)+8))
			cross_marquee.style.top=(parseInt(cross_marquee2.style.top)+actualheight+8)+"px";
		if (parseInt(cross_marquee2.style.top)<(actualheight*(-1)+8))
			cross_marquee2.style.top=(parseInt(cross_marquee.style.top)+actualheight+8)+"px";
		cross_marquee2.style.top=parseInt(cross_marquee2.style.top)-copyspeed+"px";
		cross_marquee.style.top=parseInt(cross_marquee.style.top)-copyspeed+"px";
	}

	else if (document.layers)
	{
		if (ns_marquee.top>(actualheight*(-1)+8))
			ns_marquee.top-=copyspeed;
		else
			ns_marquee.top=parseInt(marqueeheight)+8;
	}
}

function CreateMarquee()
{
	if (iedom||document.layers)
	{
		
			if (iedom)
			{
				element.innerHTML +="<div style=\"position:relative;width:"+marqueewidth;
				element.innerHTML +";height:"+marqueeheight+";overflow:hidden\" >";
				//onMouseover=\"copyspeed=pausespeed\" onMouseout=\"copyspeed=marqueespeed\"
				element.innerHTML +="<div id=\"iemarquee\" style=\"position:absolute;left:0px;top:0px;width:100%;height:"+marqueeheight+";background:white;\"></div>";
				element.innerHTML +="<div id=\"iemarquee2\" style=\"position:absolute;height:"+marqueeheight+";left:0px;top:0px;width:100%;z-index:100;background:white;\"></div>";
				element.innerHTML +="</div>";

			}
			else if (document.layers)
			{
				element.innerHTML += "<ilayer width="+marqueewidth+" height="+marqueeheight+" name=\"ns_marquee\">";
				element.innerHTML += "<layer name=\"ns_marquee2\" width="+marqueewidth+" height="+marqueeheight+" left=0 top=0 onMouseover=\"copyspeed=pausespeed\" onMouseout=\"copyspeed=marqueespeed\"></layer>";
				element.innerHTML += "</ilayer>";
			}
		
	}
}


/////////////////
function PrintArticle()
{
	window.open(location.href + "&printIt=1","print_article");		
}

function printIt()
{	
	window.print();
}
function SearchY2()
{
	var url ='http://www.koogle.yad2.co.il/';
	var folder = document.getElementById('ddlCityYad2').options[document.getElementById('ddlCityYad2').selectedIndex].value;
	var query = "";
	if(document.getElementById('txtSearchYad2') != null && document.getElementById('txtSearchYad2').value && document.getElementById('txtSearchYad2').value != "")
		query = '?q=' + document.getElementById('txtSearchYad2').value;	
	location.href = url + folder +  query;
}

function gallery_mouseover(currImage)
{
	var prevwImg = document.getElementById('ctl00_ContentPlaceHolder1_imgPreviewGallery');
	var prevwTitle = document.getElementById('ctl00_ContentPlaceHolder1_lblPreviewHeader');
	var Folder = '';
	prevwImg.src =currImage.src;
	prevwImg.alt = currImage.alt;
	prevwImg.onclick = function(){ location.href = "http://www.koogle.co.il/news/NewsItem.aspx?nid=" + currImage.hid;};
	prevwTitle.innerHTML = currImage.ttl;
}

function RouteStyle()
{		
	if(navigator.userAgent.indexOf("MSIE 6.0")> 0) 
		document.write('<link type="text/css" rel="stylesheet" href="../CSS/ie6.css" />');
	var _eng = "english/";
	var _url = location.href;
	if(_url.toLowerCase().indexOf(_eng) == _url.length - _eng.length || _url.toLowerCase().indexOf(_eng + "default") > 0)
		document.write('<link type="text/css" rel="stylesheet" href="../CSS/English_Directory.css" />');
}

function stripServerId(ServerId)
{
	return ServerId.replace("ContentPlaceHolder1_","").replace("ctl00_","");
}





