function fill(combo, name, src)
{
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4)
		{
			if (xmlhttp.status != 200)
			{
				alert(xmlhttp.responseText);
				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 fill2(combo, name, src)
{
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4)
		{
			if (xmlhttp.status != 200)
			{
				alert(xmlhttp.responseText);
				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", "getxml2.asp?" + name + "=" + src.value, true);
//	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlhttp.send();
}

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 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 = "block";
		}
		else
		{
			oDiv.style.display = "none";
		}
	}
}

function openproduct(id,bid)
{
	var args = "left=300, top=200, width=450, height=450, status=no, toolbar=no, menubar=no, scrollbars=yes, location=no";
	window.open("showproduct.asp?ProductID=" + id + "&BusinessID=" + bid, "", args);
}

function openproduct2(num,bid)
{
	var args = "left=300, top=200, width=450, height=450, status=no, toolbar=no, menubar=no, scrollbars=yes, location=no";
	window.open("showproduct2.asp?PhotoNum=" + num + "&BusinessID=" + bid, "", args);
}

function openPhoto(src,name)
{
	var args = "left=300, top=200, width=450, height=450, status=no, toolbar=no, menubar=no, scrollbars=yes, location=no";
	window.open("showPhoto.asp?Photo=" + src + "&Name=" + name, "PopUpPhoto", args);
}

function upload(path, key)
{
	args = "top=200, left=300, height=150, width=400, status=no, toolbar=no, menubar=no, scrollbars=no, location=no";
	window.open("upload.asp?path=" + path + "&key=" + key, "Upload", args);
}

function update(fileName, key)
{
	var pic = document.getElementById(key);
	pic.value = fileName;
}