﻿//xmlhttp start
function gethttp()
{
	return zXmlHttp.createRequest();
}

//xmlhttp end

//*****************************************************************************************************************

function subcats(value)
{
	if(value==0)
	{   
		return;
	} 
	var http=gethttp();
	http.onreadystatechange=function()
	{
		if (http.readyState==4 && http.status==200)
		{
			document.getElementById("sub").innerHTML=http.responseText;
		}
	}
	http.open("GET","show_subcats.php?code="+value,true);
	http.send(null);
}
//********************************************************************************************************************
function result(value)
{
	if(value==0)
	{   
		return;
	} 
	var http=gethttp();
	http.onreadystatechange=function()
	{
		if (http.readyState==4 && http.status==200)
		{
			document.getElementById("result").innerHTML=http.responseText;
		}
	}

	http.open("GET","advenced_s.php?code="+value,true);
	http.send(null);
}
//********************************************************************************************************************
function result1(value)
{
	if(value==0)
	{   
		return;
	} 
	var http=gethttp();
	http.onreadystatechange=function()
	{
		if (http.readyState==4 && http.status==200)
		{
			document.getElementById("result1").innerHTML=http.responseText;
		}
	}
	http.open("GET","advenced_s.php?code="+value,true);
	http.send(null);
}
//********************************************************************************************************************
function sub_subcats(value)
{
	if(value==0)
	{   
		return;
	} 
	var http=gethttp();
	http.onreadystatechange=function()
	{
		if (http.readyState==4 && http.status==200)
		{
			document.getElementById("arm").innerHTML=http.responseText;
		}
	}
	http.open("GET","show_subsubcats.php?code="+value,true);
	http.send(null);
}
//************************************    چک کردن پر بودن فیلد ها   *****************************************
function errorentery(inbox)
{
	if(inbox.value=='')
	{
		window.document.getElementById(inbox.name).style.border="#FF0000 1px solid";
	}
	else
	{
		window.document.getElementById(inbox.name).style.border="#7F9DB9 1px solid";
	}


	
}
//**************************         ************************************************************
function c(inbox)
{
	var http=gethttp();
	var charpos = inbox.value.search("[^0-9]"); 
	if(charpos >= 0)
	{
		//alert("لطفا فقط عدد را وارد کنید");
		window.document.getElementById(inbox.name).style.border="#FF0000 1px solid";
		inbox.value="";
		document.getElementById('phoneNumberStatus').innerHTML ='لطفا فقط عدد را وارد کنید';
	}
	else
	{
		window.document.getElementById(inbox.name).style.border="#7F9DB9 1px solid";
		document.getElementById('phoneNumberStatus').innerHTML = '';
	}
	
}
//**********************************    **************************************************
function showmoreinfo(e,code)
{
	window.document.getElementById('moreinfo').style.display="block";
	window.document.getElementById('moreinfomainloading').style.display="block";
	window.document.getElementById('moreinfomaintext').style.display="none";
	var http=gethttp();
	var pageurl="moreinfo.php?code="+code;
	http.open("GET",pageurl,true);
	http.onreadystatechange=
	function ()
	{
		if(http.readyState==4 && http.status == 200)
		{	
			result=(http.responseText);
			window.document.getElementById('moreinfomainloading').style.display="none";
			window.document.getElementById('moreinfomaintext').innerHTML=result;
			window.document.getElementById('moreinfomaintext').style.display="block";
								

		}
	};
	http.send(null);
	moreinfopos(e);
}

function hidemoreinfo()
{
	window.document.getElementById('moreinfo').style.display="none";
}

function moreinfopos (e)
{
	var x = e.pageX-200;
	window.document.getElementById('footermoreinfo').className="footermoreinfo";
	var y = e.pageY;
	window.document.getElementById('moreinfo').style.left = x + "px";
   	window.document.getElementById('moreinfo').style.top = y +"px";
}
/*tree menu scripts*/
function SwitchViews(id)
{
id = document.getElementById(id);
id.style.display = (id.style.display == 'none') ? 'block' : 'none';
return;
}
//************************************************************
function admin_subcats(value)
{

	if(value==0)
	{   
		return;
	} 
	var http=gethttp();
	http.onreadystatechange=function()
	{
		if (http.readyState==4 && http.status==200)
		{
			document.getElementById("result2").innerHTML=http.responseText;
		}
	}
	http.open("GET","show_subcats.php?code="+value,true);
	http.send(null);
}
