
	
	var AjaxServerPageName;
	AjaxServerPageName = "FillDropDown.aspx";
	
//Global XMLHTTP Request object
var XmlHttp;

//Creating and setting the instance of appropriate XMLHTTP Request object to a “XmlHttp” variable  
function CreateXmlHttp()
{
	//Creating object of XMLHTTP in IE
	try
	{
		XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			XmlHttp = null;
		}
	}
	//Creating object of XMLHTTP in Mozilla and Safari 
	if(!XmlHttp && typeof XMLHttpRequest != "undefined") 
	{
		XmlHttp = new XMLHttpRequest();
	}
}



//Gets called when state combo box selection changes
function LoadCity()
{
	var stateList = document.getElementById("DropDownList1");

	//Getting the selected state from state combo box.
	var selectedState = stateList.options[stateList.selectedIndex].value;
	
	
	
	
	
	var re = /\$|,|@|#|~|`|\%|\*|\^|\&|\(|\)|\+|\=|\[|\-|\_|\]|\[|\}|\{|\;|\:|\'|\"|\<|\>|\?|\||\\|\!|\$|\./g;
   // URL to get category for a given state
	var requestUrl = AjaxServerPageName + "?type=State&selectedState=" + escape(selectedState.replace(re," "));
	CreateXmlHttp();
	
	// If browser supports XMLHTTPRequest object
	if(XmlHttp)
	{
		//Setting the event handler for the response
		XmlHttp.onreadystatechange = HandleResponseState;
		
		//Initializes the request object with GET (METHOD of posting), 
		//Request URL and sets the request as asynchronous.
		XmlHttp.open("GET", requestUrl,  true);
		
		//Sends the request to server
		XmlHttp.send(null);		
	}
}

function LoadCityContact()
{
	var stateList = document.getElementById("DropDownList1");

	//Getting the selected state from state combo box.
	var selectedState = stateList.options[stateList.selectedIndex].value;
	var re = /\$|,|@|#|~|`|\%|\*|\^|\&|\(|\)|\+|\=|\[|\-|\_|\]|\[|\}|\{|\;|\:|\'|\"|\<|\>|\?|\||\\|\!|\$|\./g;
	// URL to get category for a given state
	var requestUrl = AjaxServerPageName + "?type=Contact&selectedState=" + escape(selectedState.replace(re," "));
	CreateXmlHttp();
	
	// If browser supports XMLHTTPRequest object
	if(XmlHttp)
	{
		//Setting the event handler for the response
		XmlHttp.onreadystatechange = HandleResponseState;
		
		//Initializes the request object with GET (METHOD of posting), 
		//Request URL and sets the request as asynchronous.
		XmlHttp.open("GET", requestUrl,  true);
		
		//Sends the request to server
		XmlHttp.send(null);		
	}
}

//Called when response comes back from server
function HandleResponseState()
{
	// To make sure receiving response data from server is completed
	if(XmlHttp.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttp.status == 200)
		{	
			var responseStr = XmlHttp.responseText;
			ClearAndSetDropdown("DropDownList2",responseStr);
		}
		else
		{
			alert("problem" );
		}
	}
}


function ClearAndSetDropdown(drdName,values)
{
	var Counter=0;
	var ElementNo;
	var cmbValues = new String();
	cmbValues = values.split("|");
	    	
	try
		{
					
		var drdList = document.getElementById(drdName);
		//Clears the combo box contents.
		for (var count = drdList.options.length-1; count >-1; count--)
		{
			drdList.options[count] = null;
		}
		ElementNo=cmbValues.length-1 ;
		for (Counter=1;Counter<ElementNo;Counter++)// adding the elements
			{
			var oOption = document.createElement("OPTION");				
			var ControlValues = new String();
			ControlValues= cmbValues[Counter].split(",");
			if(drdList != null)
				drdList.options.add(oOption);
			oOption.innerHTML =ControlValues[1];
			oOption.value = ControlValues[0];
			}
		}
	catch(e)
	{
		alert(e);
	}
		
}
function City_Click()
	{	
		var stateList = document.getElementById("DropDownList1");
		var selectedState = stateList.options[stateList.selectedIndex].value;
		var cityList = document.getElementById("DropDownList2");
		var selectedCity = cityList.options[cityList.selectedIndex].value;
		document.getElementById("hState").value = selectedState;
		document.getElementById("hCity").value = selectedCity;
		
	}
	
function Refill()
		{
			
			if(document.getElementById("hCityValues").value!="")	
				{
				ClearAndSetDropdown("DropDownList2",document.getElementById("hCityValues").value);
				document.getElementById("DropDownList2").value=document.getElementById("hCity").value;
				}
			
							
		}


function btUpdate_Click()
	{	
		alert(document.getElementById("hCat").value + "#" + document.getElementById("hSubcat").value);
		document.getElementById("hCat").value=document.getElementById("hCat").value;
	}