var xmlhttp_request="";
var id;
var msg;
function select_loc(did,regionid)
{
	id = did;
 	//alert(did+"\n"+regionid);
 
	if(regionid == "")
	{
		alert("Please Select Region");
		return false;
	}
	if(regionid == 1)
	{
		document.getElementById('state_hide_data2').style.visibility= "hidden";
		document.getElementById('state_hide_data2').style.display = "none";
		
		document.getElementById('state_hide_data').style.visibility= "visible";
		document.getElementById('state_hide_data').style.display = "block";
	}
	else if(regionid == 2)
	{
		document.getElementById('state_hide_data').style.visibility= "hidden";
		document.getElementById('state_hide_data').style.display = "none";
		
		document.getElementById('state_hide_data2').style.visibility= "visible";
		document.getElementById('state_hide_data2').style.display = "block";
	}
	else
	{
		
		document.getElementById('state_hide_data').style.visibility= "hidden";
		document.getElementById('state_hide_data').style.display = "none";
		
		document.getElementById('state_hide_data2').style.visibility= "hidden";
		document.getElementById('state_hide_data2').style.display = "none";
	}
	var regionid = regionid;
 
	msg="<span class='darkbluebigfont'>Please wait ... <b>loading ...</b></span>"
	xmlhttp_request = getRequestObject();
	
	if(xmlhttp_request == null)
	{
		alert("XMLHTTP does not supported to your broswer");
		return;
	}

	var url = "ajax_select_loc.php";
	 
	var parameter = "regionid="+regionid;
	//alert(url);return false;
	xmlhttp_request.onreadystatechange = readystatechange;

	xmlhttp_request.open("POST",url,true);

	xmlhttp_request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmlhttp_request.setRequestHeader("Content-Length",parameter.length);
	xmlhttp_request.setRequestHeader("Connection","Close");
	
	xmlhttp_request.send(parameter);
}

function select_prod(did,loc_id,regionid)
{
	id = did;
	var loc_id = loc_id;
	var regionid = regionid;
/*	document.getElementById('state_hide_data').style.visibility= "hidden";
	document.getElementById('state_hide_data').style.display = "none";
	document.getElementById('state_hide_data2').style.visibility= "hidden";
	document.getElementById('state_hide_data2').style.display = "none";
	*/
	if(document.getElementById('star'))
	{
	document.getElementById('star').style.visibility= "hidden";
	document.getElementById('star').style.display = "none";
	}
	
	if(loc_id == "")
	{
		alert("Please Select Location");
		return false;
	}
	
	 //style="visibility:hidden; display:none;"
	//alert(did+"\n"+loc_id+"\n"+regionid);
	msg="<span class='darkbluebigfont'>Please wait ... <b>loading ...</b></span>"
	xmlhttp_request = getRequestObject();
	
	if(xmlhttp_request == null)
	{
		alert("XMLHTTP does not supported to your broswere");
		return;
	}

	var url = "ajax_select_prod.php";
	
	var parameter = "loc_id="+loc_id+"&regionid="+regionid;
	//alert(parameter);return false;
	xmlhttp_request.onreadystatechange = readystatechange;

	xmlhttp_request.open("POST",url,true);

	xmlhttp_request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmlhttp_request.setRequestHeader("Content-Length",parameter.length);
	xmlhttp_request.setRequestHeader("Connection","Close");
	
	xmlhttp_request.send(parameter);
}

function select_contact(did,pid,lid,rid)
{
	id = did;
	if(pid == "")
	{
		alert("Please Select Product Category");
		return false;
	}
	var pid = pid;
	var lid = lid;
	var rid = rid;
	//alert("pid="+pid+"lid="+lid+"rid="+rid);
	msg="<span class='darkbluebigfont'>Please wait ... <b>loading ...</b></span>"
	xmlhttp_request = getRequestObject();
	
	if(xmlhttp_request == null)
	{
		alert("XMLHTTP does not supported to your broswere");
		return;
	}

	var url = "ajax_select_contact.php";
	
	var parameter = "pid="+pid+"&lid="+lid+"&rid="+rid;

	xmlhttp_request.onreadystatechange = readystatechange;

	xmlhttp_request.open("POST",url,true);

	xmlhttp_request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmlhttp_request.setRequestHeader("Content-Length",parameter.length);
	xmlhttp_request.setRequestHeader("Connection","Close");
	
	xmlhttp_request.send(parameter);
}
function select_contact_new(did,pid,lid,rid)
{
	id = did;
	if(pid == "")
	{
		alert("Please Select Product Category");
		return false;
	}
	var pid = pid;
	var lid = lid;
	var rid = rid;
	//alert("pid="+pid+"lid="+lid+"rid="+rid);
	msg="<span class='darkbluebigfont'>Please wait ... <b>loading ...</b></span>"
	xmlhttp_request = getRequestObject();
	
	if(xmlhttp_request == null)
	{
		alert("XMLHTTP does not supported to your broswere");
		return;
	}

	var url = "ajax_select_contact_detail.php";
	
	var parameter = "pid="+pid+"&lid="+lid+"&rid="+rid;

	xmlhttp_request.onreadystatechange = readystatechange;

	xmlhttp_request.open("POST",url,true);

	xmlhttp_request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmlhttp_request.setRequestHeader("Content-Length",parameter.length);
	xmlhttp_request.setRequestHeader("Connection","Close");
	
	xmlhttp_request.send(parameter);
}
function select_contact_detail(did,cid,pid,lid,rid)
{
	id = did;
	if(pid == "")
	{
		alert("Please Select Product Category");
		return false;
	}
	var pid = pid;
	var lid = lid;
	var rid = rid;
	//alert("cid="+cid+"pid="+pid+"lid="+lid+"rid="+rid);
	msg="<span class='darkbluebigfont'>Please wait ... <b>loading ...</b></span>"
	xmlhttp_request = getRequestObject();
	
	if(xmlhttp_request == null)
	{
		alert("XMLHTTP does not supported to your broswere");
		return;
	}

	var url = "ajax_select_contact_detail.php";
	
	var parameter = "cid="+cid+"&pid="+pid+"&lid="+lid+"&rid="+rid;

	xmlhttp_request.onreadystatechange = readystatechange;

	xmlhttp_request.open("POST",url,true);

	xmlhttp_request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmlhttp_request.setRequestHeader("Content-Length",parameter.length);
	xmlhttp_request.setRequestHeader("Connection","Close");
	
	xmlhttp_request.send(parameter);
}
function getRequestObject()
{
	if(window.XMLHttpRequest)
	{
		// IE 7 , mozila , opera , safari
		return new XMLHttpRequest();
	}
	
	if(window.ActiveXObject)
	{
		//IE 5 , IE 6
		return new ActiveXObject("Microsoft.XMLHTTP");
	}

	return null;
}

function readystatechange()
{
	if(xmlhttp_request.readyState==1) 
		{
		document.getElementById(id).innerHTML=msg;
		}
	if(xmlhttp_request.readyState == 4)
	{
		document.getElementById(id).innerHTML = xmlhttp_request.responseText;
		
	}
}
