function fill(combo, name, src)
{
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4)
		{
			if (xmlhttp.status != 200)
			{
				alert("שגיאה!");
				return;
			}
			var doc = new ActiveXObject("Microsoft.XMLDOM");
			doc.async = false;
			doc.loadXML(xmlhttp.responseText);
			var nodes = doc.selectNodes("xml/rs:data/z:row");
			combo.length = 1;
			for (i=0; i < nodes.length; i++)
			{
				var opt = document.createElement("OPTION");
				opt.value = nodes[i].getAttribute("ID");
				opt.text = nodes[i].getAttribute("Name");
				combo.add(opt);
			}
			xmlhttp = null;
			doc = null;
		}
	}
	xmlhttp.open("GET", "getxml.asp?" + name + "=" + src.value, true);
//	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlhttp.send();
}

function GetComboData( ComboID, Name, Table, Src, SrcValue ){ 
 var combo = document.getElementById(ComboID);
 var retArr = new Array();
 var myAjax = new Ajax.Request(
   'getdata.asp?Name='+Name+'&Table='+Table+'&Src='+Src+'&SrcValue='+SrcValue,
   {
    method: 'get', 
    onComplete: function(response) { 
	 retArr=response.responseText.split(';');
     combo.options.length=1;
     for(i=0; i< (retArr.length/2)-1; i++){
      combo.options[i+1] = new Option(retArr[2*i], retArr[2*i+1]);
     }
     combo.selectedIndex=0;
     
    }
    
   }
   );
}

function GetComboAdData( ComboID, Name, Src ){ 
 var combo = document.getElementById(ComboID);
 var retArr = new Array();
 var myAjax = new Ajax.Request(
   'getaddata.asp?'+Name+'='+Src,
   {
	method: 'get', 
	onComplete: function(response) { 
	 //alert(response.responseText);
	 retArr=response.responseText.split(';');
	 combo.options.length=1;
	 for(i=0; i< (retArr.length/2)-1; i++){
	  combo.options[i+1] = new Option(retArr[2*i], retArr[2*i+1]);
	 }
	 combo.selectedIndex=0;
	}
   }
);
}

function showGalleries( id )
{
	var myAjax = new Ajax.Request(
   'getGalleries.asp?CategoryID='+id,
   {
	method: 'get', 
	onComplete: function(response)
	{ 
	 //alert(response.responseText);
	 document.getElementById('TextBox').innerHTML = response.responseText;
	}
   }
  );
}

function showGallery( id )
{
	var myAjax = new Ajax.Request(
   'getGallery.asp?GalleryID='+id,
   {
	method: 'get', 
	onComplete: function(response)
	{ 
	 //alert(response.responseText);
	 document.getElementById('PageBox').innerHTML = '';
	 document.getElementById('GalleryBox').innerHTML = response.responseText;
	}
   }
  );
}

function showPage( id )
{
	var myAjax = new Ajax.Request(
   'getPage.asp?PageID='+id,
   {
	method: 'get', 
	onComplete: function(response)
	{ 
	 //alert(response.responseText);
	 document.getElementById('PageBox').innerHTML = response.responseText;
	}
   }
  );
}

function changePhoto( obj, src )
{
	document.getElementById('img0').src = src;	
}
function filterData(strURL)
{
	var oSelect = window.event.srcElement;
	var strName = oSelect.name;
	var strValue = oSelect.options[oSelect.selectedIndex].value;
	strURL += "&" + strName + "=" + strValue;
	window.location.replace(strURL);
}

function setVacancy( BusinessID, RoomID, dDate ){ 

	var myAjax = new Ajax.Request(
   'setBusinessDate.asp?BusinessID='+BusinessID+'&RoomID='+RoomID+'&Date='+dDate,
   {
    method: 'get', 
    onComplete: function(response) { 
     msg=response.responseText;
     alert(msg);
    }
    
   }
   );
}

function menuclick(id)
{
	var div = document.getElementById("div" + id);
	if (div.style.display == "none")
		div.style.display = "block";
	else
		div.style.display = "none";
}

function changeamount(id, change)
{
	obj = document.getElementById("prod" + id);
	if (obj.value > 0)
		obj.value = parseFloat(obj.value) + change;
	else if (change == 1)
		obj.value = 1;
	else if (change == 0.5)
		obj.value = 0.5;
}

function addtocart(bid,id)
{
	amount = document.getElementById("prod" + id).value;
	if (amount == "")
		alert("נא לבחור כמות להזמנה ממוצר זה. השתמש ב(+) ו(-) לשינוי הכמות.");
	else
		location.href = "addtocart.asp?BusinessID=" + bid + "&ProductID=" + id + "&Amount=" + amount + "&BackURL=" + location.href.replace("&", "%26");
}

function checkCatalog(oForm)
{
	if (oForm.Products.checked)
		return true;
	for(i = 0; i < oForm.Products.length; i++)
		if (oForm.Products[i].checked)
			return true;
	alert("יש לסמן לפחות מוצר אחד");
	return false;
}

function submitSearch(obj)
{
	if (obj.Search.value == "" && obj.CategoryID.selectedIndex == 0)
	{
		alert("יש לבחור קטגוריה");
		return false;
	}
	if (obj.Search.value == "" && obj.AreaID.selectedIndex == 0)
	{
		alert("יש לבחור אזור");
		return false;
	}
	return true;
}

function redirectSearch(obj)
{
	oForm = obj.form;
	if (oForm.query.value == "")
	{
		alert("יש לרשום מילת חיפוש");
		return false;
	}
	for (i=0; i<oForm.rdSearchSite.length; i++)
		if (oForm.rdSearchSite[i].checked)
		{
			location.href = oForm.rdSearchSite[i].value + oForm.query.value;
			return true;
		}
	alert("יש לבחור מנוע חיפוש");
	return false;
}


/*function window.onscroll()
{
	obj = document.getElementById("sidebanner");
	if (!obj) return;
	obj.style.top = document.body.scrollTop;
}*/

function printPage()
{
	args = "top=100, left=100, height=500, width=700, status=no, toolbar=no, menubar=no, scrollbars=yes, location=no";
	window.open("print.asp", "Print", args);
}

function showHide(id)
{
	oDiv = document.getElementById(id);
	if (oDiv)
	{
		if (oDiv.style.display == "none")
		{
			oDiv.style.display = "inline";
		}
		else
		{
			oDiv.style.display = "none";
		}
	}
}

function overData()
{
	var obj = window.event.srcElement;
	if (obj.tagName == "TD")
	{
		if (obj.parentElement.className.indexOf("click") < 0)
			obj.parentElement.className += " over";
	}
	else if (obj.tagName == "TH")
	{
		obj.className = "over";
	}
}

function outData()
{
	var obj = window.event.srcElement;
	if (obj.tagName == "TD")
	{
		if (obj.parentElement.className.indexOf("over") > 0)
			obj.parentElement.className = obj.parentElement.className.replace(" over", "");
	}
	else if (obj.tagName == "TH")
	{
		obj.className = "";
	}
}

function sortData(strURL, strSort)
{
	var obj = window.event.srcElement;
	if (obj.tagName == "TH")
	{
		var ID = obj.id;
		if (ID)
		{
			strURL += "&Sort=" + ID;
			if (strSort == ID)
			{
				strURL += " DESC"
			}
			window.location.replace(strURL);
		}
	}
}

function showHotAd(ID,Type)
{
	args = "top=0, left=0, height=500, width=700, status=no, toolbar=no, menubar=no, scrollbars=yes, location=no";
	window.open("showhotad.asp?AdvertiseID=" + ID + "&Type=" + Type, "Advertise"+ID, args);
}

function showAdPic(ID,Type)
{
	args = "top=0, left=0, height=500, width=700, status=no, toolbar=no, menubar=no, scrollbars=yes, location=no";
	window.open("showPhotos.asp?AdvertiseID=" + ID + "&Type=" + Type, "Advertise"+ID, args);
}

function showAgent(id)
{		
	args = "top=0, left=0, height=500, width=700, status=no, toolbar=no, menubar=no, scrollbars=yes, location=no";
	window.open("agentAds.asp?ClientID=" + ID, "Agent"+ID, args);
}

function showInfo(ID)
{
	args = "top=0, left=0, height=500, width=700, status=no, toolbar=no, menubar=no, scrollbars=yes, location=no";
	window.open("showInfo.asp?LinkID=" + ID, "Info"+ID, args);
}

function openPage(url)
{
	args = "top=0, left=0, height=500, width=700, status=no, toolbar=no, menubar=no, scrollbars=yes, location=no";
	window.open(url, "popupPage", args);
}

function img_onmouseover(source_pic){
	var imgSrc = new Image();
	imgSrc.src=source_pic;
	img_0.src=imgSrc.src;
}

function mov_onmouseover(source_mov){
	obj = document.getElementById("mov_0");
	obj.fileName = source_mov;
}

function showHide(id)
{
	var obj = window.event.srcElement;
	oDiv = document.getElementById(id);
	if (oDiv)
	{
		if (oDiv.style.display == "none")
		{
			oDiv.style.display = "";
		}
		else
		{
			oDiv.style.display = "none";
		}
	}
}

function showAd(url,id)
{		
	var obj = document.getElementById('AdTitle_'+id);
	URL = url + "_result_box.asp?AdvertiseID="+id;
	if(!insideHTML('AdDetails_' + id))
	{
		makeRemark('AdDetails_' + id,'<iframe src="' + URL + '" style="width:100%; height:480px;" frameborder="0" scrolling="no"></iframe>');
		obj.className += " click";
	 }
	else
	 {
		makeRemark('AdDetails_' + id,'');
		obj.className = obj.className.replace(" click", "");
	 }
}

function showMail(url,id)
{		
	var obj = document.getElementById('MailTitle_'+id);
	URL = url + ".asp?MessageID="+id;
	if(!insideHTML('MailDetails_' + id))
	{
  		makeRemark('MailDetails_' + id,'<iframe src="' + URL + '" style="width:100%; height:220px;" frameborder="0" scrolling="auto"></iframe>');
	 }
	else
	 {
		makeRemark('MailDetails_' + id,'');
	 }	
}

function loadPage(url,val)
{
	//var obj = window.event.srcElement;
	window.location.replace(url + val);
}

function popUpWindow(URLStr)
{
  //popUpWin = window.open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbar=yes,scroll=yes,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
  var w = 700;
  var h = 600;
  var winl = (screen.width - w) / 2;
  var wint = (screen.height - h) / 2;
  winprops = "top=" + wint + ",left=" + winl + ",status=no, toolbar=no, menubar=no, scrollbars=yes, location=no" + ",width="+ w + ",height="+ h;
  popUpWin = window.open(URLStr, "popUpWin", winprops)
  if (parseInt(navigator.appVersion) >= 4) { popUpWin.window.focus(); }  
}

function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);}

//Miscellaneous JavaScript Functions Written by Shawn Olson
//Copyright 2005 by Shawn Olson
//Permission to use these scripts provided credit is provided to Shawn Olson
//Find more JavaScript resources at http://www.shawnolson.net/topics/JavaScript/ 


function insideHTML(cell){
eval('theCell = document.getElementById("'+cell+'").innerHTML');
return theCell;
}


function checkValueAgainst(objId,val1){
if(insideHTML(objId)==val1){verify=true;} else {verify=false;}
return verify;
}

function makeRemark(target,statement){
string = 'theTarget = document.getElementById("'+target+'");';
eval(string);
if(theTarget != null){
 theTarget.innerHTML = statement;
}

}

/***********************************************
* Bookmark site script-  Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

/* Modified to support Opera */
function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}
