var xmlHttp;
//-----------------------------------------------------------------------------------
function updateCatName(id)
{
	document.m_form.act.value = 'catname';
	document.m_form.action = "main.asp?page=categories&id="+id;
	//alert(document.m_form.action);
	//document.m_form.submit();
	window.location = "main.asp?page=categories&act=catname&id="+id+"&va="+document.getElementById('cat'+id).value;
}
//-----------------------------------------------------------------------------------
function showProduct(id)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  } 
	var url="ajax_oper/ajx_opr.asp";
	var params = "acKey=showproduct&id="+id+"&st="+document.getElementById('show_home'+id).checked;
	xmlHttp.open("POST", url, true);
	//Send the proper header information along with the request
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.onreadystatechange = stateChanged;
	xmlHttp.send(params);
}
//-----------------------------------------------------------------------------------
function saleProduct(id)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  } 
	var url="ajax_oper/ajx_opr.asp";
	var params = "acKey=saleProduct&id="+id+"&st="+document.getElementById('saleProduct'+id).checked;
	xmlHttp.open("POST", url, true);
	//Send the proper header information along with the request
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.onreadystatechange = stateChanged;
	xmlHttp.send(params);
}
//-----------------------------------------------------------------------------------
function newProduct(id)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  } 
	var url="ajax_oper/ajx_opr.asp";
	var params = "acKey=newProduct&id="+id+"&st="+document.getElementById('newProduct'+id).checked;
	xmlHttp.open("POST", url, true);
	//Send the proper header information along with the request
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.onreadystatechange = stateChanged;
	xmlHttp.send(params);
}
//-----------------------------------------------------------------------------------
function vahadProduct(id)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  } 
	var url="ajax_oper/ajx_opr.asp";
	var params = "acKey=vahadProduct&id="+id+"&st="+document.getElementById('vahadProduct'+id).checked;
	xmlHttp.open("POST", url, true);
	//Send the proper header information along with the request
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.onreadystatechange = stateChanged;
	xmlHttp.send(params);
}
//-----------------------------------------------------------------------------------
function DelCat(id)
{
	document.m_form.act.value = 'delCat';
	document.m_form.action = "main.asp?page=categories&id="+id;
	//alert(document.m_form.action);
	//document.m_form.submit();
	window.location = "main.asp?page=categories&act=delCat&id="+id;
}
//----------------------------------------------------------------------------------

function ajaxPost(id)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  } 
	var url="ajax_oper/ajx_opr.asp";
	var params = "acKey=CatName&id="+id+"&na="+document.getElementById('cat'+id).value;
	xmlHttp.open("POST", url, true);

	//Send the proper header information along with the request
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.onreadystatechange = stateChanged;
	xmlHttp.send(params);
}
//----------------------------------------------------------------------------------
function stateChanged() 
{ 
if (xmlHttp.readyState==4)
	{ 
		//alert(xmlHttp.responseText);
		alert('הנתון עודכן בשרת');
	}
}
//----------------------------------------------------------------------------------
function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

//----------------------------------------------------------------------------------


function az_change_insertcategory(level) {
	window.location='?page=categories&level='+level.options[level.selectedIndex].value;
}
function validatespec(id) {
    var status=true;
	var msg="";
	if (document.getElementById('ni_variable').value.length<1) {
	  msg=msg+"שם מאפיין הפרמטר אינו יכול להיות ריק\n"
	  status=false;
	}
	if (document.getElementById('ni_value').value.length<1) {
	  msg=msg+"ערך הפרמטר אינו יכול להיות ריק\n"
	  status=false;
	}
	if (status==false) {
	  alert(msg);
	} else {
	  window.location='main.asp?page=catalog&command=InsertSpec&a='+document.getElementById('ni_variable').value+'&b='+document.getElementById('ni_value').value+'&id='+id;
	}
  }
  function RemoveSpec(id,productid) {
    var temp;
	temp=confirm("? האם הינך בטוח שברצונך להסיר את המאפיין וערכו");
	if (temp==true) {
	  window.location='main.asp?page=catalog&command=RemoveProductSpec&item='+id+'&id='+productid;
	}
  }
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function confirmcategoryremoval(categorylevelid,level) {
	var confirmremove=confirm('נא לאשר את מחיקת הקטגוריה');
	if (confirmremove==true) {
		if (level==1) {
		  window.location='main.asp?page=categories&command=RemoveCategoryLevel01&categorylevel01id='+categorylevelid;
		}
		if (level==2) {
		  window.location='main.asp?page=categories&command=RemoveCategoryLevel02&categorylevel02id='+categorylevelid;
		}
		if (level==3) {
		  window.location='main.asp?page=categories&command=RemoveCategoryLevel03&categorylevel03id='+categorylevelid;
		}
		if (level==4) {
		  window.location='main.asp?page=categories&command=RemoveCategoryLevel04&categorylevel04id='+categorylevelid;
		}
	}
}
function confirmcatalogremoval(id,t,Pagenum) {
	var confirmremove=confirm('נא לאשר את מחיקת המוצר');
	if (confirmremove==true) {
		window.location='main.asp?page=catalog&command=removeproduct&id='+id+'&Pagenum='+Pagenum;
	}
}
function confirmcolourremoval(id) {
	var confirmremove=confirm('נא לאשר את מחיקת הצבע');
	if (confirmremove==true) {
		window.location='main.asp?page=others&command=removecolour&id='+id;
	}
}
function confirmsizeremoval(id) {
	var confirmremove=confirm('נא לאשר את מחיקת המידה');
	if (confirmremove==true) {
		window.location='main.asp?page=others&command=removesize&id='+id;
	}
}
function confirmgalleryremoval(id,galleryid) {
	var confirmremove=confirm('נא לאשר את מחיקת התמונה');
	if (confirmremove==true) {
		window.location='main.asp?page=others&command=removegallery&id='+id+'&galleryid='+galleryid;
	}
}
function confirmgallerycategoryremoval(id) {
	var confirmremove=confirm('נא לאשר את מחיקת הגלריה');
	if (confirmremove==true) {
		window.location='main.asp?page=others&command=removegallerycategory&id='+id;
	}
}
function confirmmanremoval(id) {
	var confirmremove=confirm('נא לאשר את מחיקת היצרן');
	if (confirmremove==true) {
		window.location='main.asp?page=others&command=removeman&id='+id;
	}
}
function confirmmotorbikeremoval(id) {
	var confirmremove=confirm('נא לאשר את מחיקת סוג האופנוע');
	if (confirmremove==true) {
		window.location='main.asp?page=others&command=removemotorbike&id='+id;
	}
}
function setnewcatbg(box,categorylevel) {
	switch(box.options[box.selectedIndex].value) {
		case '2': document.getElementById('setnewcat'+categorylevel).style.backgroundColor='#99ff9e';
				break;
		case '3': document.getElementById('setnewcat'+categorylevel).style.backgroundColor='#ffd599';
				break;
		case '4': document.getElementById('setnewcat'+categorylevel).style.backgroundColor='#e199ff';
				break;
	}
}
function openclosewindow(categorylevel,level) {
  /*
  if (level==1) {
	document.getElementById('L'+categorylevel+'8').style.display='';
	//document.getElementById('sign'+categorylevel).src='images/minus.gif';
  } else {
	var display=document.getElementById('CategoryLevel02ID'+categorylevel).style.display;
	if (display=='') {
		document.getElementById('CategoryLevel02ID'+categorylevel).style.display='none';
		document.getElementById('sign'+categorylevel).src='images/plus.gif';
	} else {
		document.getElementById('CategoryLevel02ID'+categorylevel).style.display='';
		document.getElementById('sign'+categorylevel).src='images/minus.gif';
	}
  }
  */
}

function validLength (txtbox,num,error)
	{
		if (txtbox.value == "" | txtbox.value.length < num )
	 	{
	    	alert(error);
	    	txtbox.focus();
			txtbox.select();
	    	return false;
	 	}else{
			return true;
		}
	}
	
function validChr (txtbox,error){
	var pos=txtbox.value.indexOf('"')
	var pos1=txtbox.value.indexOf("%")
	var pos2=txtbox.value.indexOf("'")
	if (pos>=0 || pos1>=0 || pos2>=0)
  	{
	    alert(error);
	    txtbox.focus();
		txtbox.select();
	    return false;
	}else{
		return true;
	}
}

function validEmail (txtbox,error)
	{
		S=txtbox.value.indexOf("@")
		D=txtbox.value.indexOf(".")
		if (txtbox.value == "" | txtbox.value.length < 6 | S<1)// | D<=S+1)
	 	{
	    	alert(error);
	    	txtbox.focus();
			txtbox.select();
	    	return false;
	 	}else{
			return true;
		}
	}
	
function validSpace (txtbox,error){
	if (txtbox.value.indexOf(" ")>=0)
  	{
	    alert(error);
	    txtbox.focus();
		txtbox.select();
	    return false;
	}else{
		return true;
	}
}
