var xmlHttp
var strprod
// Get the States' dropdown #########################################################
function getstate(str)
{ 
	var val;
	if(document.getElementById("ordno").value=="")
				{ 
				   alert("Please Enter Order Number!!");
				   document.getElementById("ordno").focus();
				   val = false;
				}
	if(val!=false)
	{
		
		var url="modules/gethint2.php?sid=" + Math.random() + "&ordid=" + str
		xmlHttp=GetXmlHttpObject(setstate)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
	}
	else
	{
		return val;	
	}
	}
 



function setstate() 
{
	if (xmlHttp.readyState==3 || xmlHttp.readyState==2 || xmlHttp.readyState==1)
	{ 
		document.getElementById("txtstate").innerHTML="Loading Order Status..."
	}
 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("txtstate").innerHTML=xmlHttp.responseText
	} 
} 
//###########################################################################################


//###########################################################################################
// Get the category's dropdown #########################################################
function getcategory(country,str)
{ 
	var val;
	if(document.form1.p_year.value=="")
	{
		alert("please select country first")
		document.form1.p_year.focus();
		val=false;
	}
	
	if(document.form1.state.value=="")
	{
		alert("please select state first")
		document.form1.state.focus();
		val=false;
	}
	if(val!=false)
	{
		var url="gethint.php?sid=" + Math.random() + "&country="+ country +"&sub_id=" + str
		
		xmlHttp=GetXmlHttpObject(setcategory)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
	}
	else
	{
		return val;	
	}
	
	
} 



function setcategory() 
{
	if (xmlHttp.readyState==3 || xmlHttp.readyState==2 || xmlHttp.readyState==1)
	{ 
		document.getElementById("txtcategory").innerHTML="Loading Categories..."
	}
 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("txtcategory").innerHTML=xmlHttp.responseText
	} 
} 
//###########################################################################################

// Get the subcategory's dropdown #########################################################
function getsubcategory(country,state,str)
{ 
	var val;
	if(document.form1.country.value=="")
	{
		alert("please select country first")
		document.form1.country.focus();
		val=false;
	}
	
	if(document.form1.state.value=="")
	{
		alert("please select state first")
		document.form1.state.focus();
		val=false;
	}
	
	if(document.form1.category.value=="")
	{
		alert("please select category first")
		document.form1.category.focus();
		val=false;
	}
	if(val!=false)
	{
	var url="gethint.php?sid=" + Math.random() + "&country=" + country + "&state=" + state + "&cat_id=" + str
	
	xmlHttp=GetXmlHttpObject(setsubcategory)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
	}
	else
	{
		return val;	
	}
	
} 



function setsubcategory() 
{
	if (xmlHttp.readyState==3 || xmlHttp.readyState==2 || xmlHttp.readyState==1)
	{ 
		document.getElementById("txtsubcategory").innerHTML="Loading subcategories..."
	}
 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("txtsubcategory").innerHTML=xmlHttp.responseText
	} 
} 
//###########################################################################################

// Get the company's dropdown #########################################################
function getcompany(country,state,category,str)
{ 
	var val;
	if(document.form1.country.value=="")
	{
		alert("please select country first")
		document.form1.country.focus();
		val=false;
	}
	
	if(document.form1.state.value=="")
	{
		alert("please select state first")
		document.form1.state.focus();
		val=false;
	}
	
	if(document.form1.category.value=="")
	{
		alert("please select category first")
		document.form1.category.focus();
		val=false;
	}
	
	if(document.form1.subcategory.value=="")
	{
		alert("please select subcategory first")
		document.form1.subcategory.focus();
		val=false;
	}
	if(val!=false)
	{
		var url="gethint.php?sid=" + Math.random() + "&country=" + country + "&state=" + state + "&category=" + category + "&subcat_id=" + str;
		
		xmlHttp=GetXmlHttpObject(setcompany)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
	}
	else
	{
		return val;	
	}
} 



function setcompany() 
{
	if (xmlHttp.readyState==3 || xmlHttp.readyState==2 || xmlHttp.readyState==1)
	{ 
		document.getElementById("txtcompany").innerHTML="Loading companies..."
	}
 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("txtcompany").innerHTML=xmlHttp.responseText
	} 
} 
//###########################################################################################

// Get the company's details #########################################################
function getcompanydetail(str)
{ 
	var url="gethint.php?sid=" + Math.random() + "&company_id=" + str
	xmlHttp=GetXmlHttpObject(setcompanydetail)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
	
} 



function setcompanydetail() 
{
	if (xmlHttp.readyState==3 || xmlHttp.readyState==2 || xmlHttp.readyState==1)
	{ 
		document.getElementById("txtcompanydetails").innerHTML="Loading company's Details..."
	}
 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("txtcompanydetails").innerHTML=xmlHttp.responseText
	} 
} 
//###########################################################################################




function GetXmlHttpObject(handler)
{ 
var objXmlHttp=null

if (navigator.userAgent.indexOf("Opera")>=0)
{
alert("This example doesn't work in Opera") 
return 
}
if (navigator.userAgent.indexOf("MSIE")>=0)
{ 
var strName="Msxml2.XMLHTTP"
if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
{
strName="Microsoft.XMLHTTP"
} 
try
{ 
objXmlHttp=new ActiveXObject(strName)
objXmlHttp.onreadystatechange=handler 
return objXmlHttp
} 
catch(e)
{ 
alert("Error. Scripting for ActiveX might be disabled") 
return 
} 
} 
if (navigator.userAgent.indexOf("Mozilla")>=0)
{
objXmlHttp=new XMLHttpRequest()
objXmlHttp.onload=handler
objXmlHttp.onerror=handler 
return objXmlHttp
}
}
