     var temp = "";
     
     function getData(ddl,ddlRegionClientId,ddlMapTypeClientId,ddlMapSubTypeClientId) 
     {
		var selectedmaptype="";
		var url="";
		var maptype=document.getElementById(ddlMapTypeClientId);
			if (ddl == "ddlRegion")
			{

				var Region = document.getElementById(ddlRegionClientId);
				var selectedRegion = Region.options[Region.selectedIndex].value;
				url = "controls/dropdowns.aspx?";
				url += "&region="+selectedRegion;
				GetResponse(url,ddl,ddlRegionClientId,ddlMapTypeClientId,ddlMapSubTypeClientId);

//                //alert(maptype.options[0].value);
//                var ddlmaptype = document.getElementById(ddlMapTypeClientId);
//                //alert(ddlmaptype.options[0].value);

//			    url = "controls/dropdowns.aspx?";
//			    url += "&maptype="+ddlmaptype.options[0].value;

//			    //GetResponse fires off the server request and waits for the response
//			    GetResponse(url,"ddlMapType",ddlRegionClientId,ddlMapTypeClientId,ddlMapSubTypeClientId);
//                
//			    var mapsubtype=document.getElementById(ddlMapSubTypeClientId);
//			    setSessionVariables(ddlRegionClientId,ddlMapTypeClientId,ddlMapSubTypeClientId,mapsubtype.options[0].value,ddlmaptype.options[0].value);
			}
		else
			{
				selectedmaptype = maptype.options[maptype.selectedIndex].value;
			    url = "controls/dropdowns.aspx?";
			    url += "&maptype="+selectedmaptype;

			    //GetResponse fires off the server request and waits for the response
			    GetResponse(url,"ddlMapType",ddlRegionClientId,ddlMapTypeClientId,ddlMapSubTypeClientId);

			    var mapsubtype=document.getElementById(ddlMapSubTypeClientId);
			    selectedmapsubtype = mapsubtype.options[0].value;
			    setSessionVariables(ddlRegionClientId,ddlMapTypeClientId,ddlMapSubTypeClientId,selectedmapsubtype,selectedmaptype);
			}

	}
	
	function setSessionVariables(ddlRegionClientId,ddlMapTypeClientId,ddlMapSubTypeClientId,selectedmapsubtype,selectedmaptype)
	{
		var Region = document.getElementById(ddlRegionClientId);
		var selectedRegion = Region.options[Region.selectedIndex].value;
		if (selectedmapsubtype == "" && selectedmaptype == "")
		{
			var maptype=document.getElementById(ddlMapTypeClientId);
			selectedmaptype = maptype.options[maptype.selectedIndex].value;
			var mapsubtype=document.getElementById(ddlMapSubTypeClientId);
			selectedmapsubtype = mapsubtype.options[mapsubtype.selectedIndex].value;
		}
		
	
		var url = "controls/dropdowns.aspx?";
			url += "&maptype="+selectedmaptype;
			url += "&region="+selectedRegion;
			url += "&mapsubtype="+selectedmapsubtype;
			
	
		//Start by getting the appropriate xmlhttp object for this browser.
		//this is the workhorse that will make the asynch call. 
		var xmlhttp = GetXmlHttp();
		
		//If we got a valid xmlhttp object, were good to go 
		if(xmlhttp) {
			xmlhttp.open("GET", url, true);
			
			xmlhttp.onreadystatechange=function() 
			{
				if(xmlhttp.readyState==4) 
				{
					var strResult = xmlhttp.responseText;
          		}
			}
			
			//Finally fire off the request.
			xmlhttp.send(null);
		}
	}
		
	function GetResponse(url,dropdown,ddlRegionClientId,ddlMapTypeClientId,ddlMapSubTypeClientId) 
	{
		//Start by getting the appropriate xmlhttp object for this browser.
		//this is the workhorse that will make the asynch call. 
		var xmlhttp = GetXmlHttp();
		
		//If we got a valid xmlhttp object, were good to go 
		if(xmlhttp) {
			xmlhttp.open("GET", url, true);
			
			//set the callback. this function is called when the send() 
			//method below completes. 
			xmlhttp.onreadystatechange=function() 
			{
				//Server responded. how did things go? for status, check
				//the readyState. 4 is success. FOr more details on other readyStates
				//http://www.quirksmode.org/blog/archives/2005/09/xmlhttp_notes_r_2.html
				if(xmlhttp.readyState==4) 
				{
					//Round Trip to server and back is complete! lets do something with the result.
					//our server script responds with a string of formatted javascript.
					//eval() will simply execute the returned code. in our case, we
					//are just going to update a Div's HTML by calling Displayphoto()
					//See the Server component of the tutorial for details.
					var strResult = xmlhttp.responseText;
					LoadData(xmlhttp.responseXML.documentElement,dropdown,ddlRegionClientId,ddlMapTypeClientId,ddlMapSubTypeClientId);
          		}
			}
			
			//Finally fire off the request.
			xmlhttp.send(null);
		}
	}

	//This function returns the appropriate xmlhttp object for the browser. 		
	function GetXmlHttp()
	{
		var x = null;
		try { x = new ActiveXObject("Msxml2.XMLHTTP") }
		catch(e) { try { x = new ActiveXObject("Microsoft.XMLHTTP") }
		catch(e) { x = null } }
		if(!x && typeof XMLHttpRequest != "undefined") { x = new XMLHttpRequest() }
		return x;
	}
		
		//Callback function that is called after Server code completes.
		function LoadData(htmlResult,dropdown,ddlRegionClientId,ddlMapTypeClientId,ddlMapSubTypeClientId) 
		{
			if (dropdown == "ddlRegion")
			{
				var types = htmlResult.getElementsByTagName('Map_Name'); 
				var ddlMapType = document.getElementById(ddlMapTypeClientId);
				var textValueName; 
				var optionItemName;

				//Clears the ddlMapType dropdown list                   
				for (var count = ddlMapType.options.length-1; count >-1; count--)
				{
					ddlMapType.options[count] = null;            
				}    
			
				//populate the ddlMapType
				for (var count = 0; count < types.length; count++)
					{
					//alert(GetInnerText(types[count]));
						textValueName = GetInnerText(types[count]);  
						//alert(textValueName);
						optionItemName = new Option( textValueName, 
							textValueName,  false, false);
						ddlMapType.options[ddlMapType.length] = optionItemName;  
					}   
				ddlMapType.selectedIndex = 0;  

			    var url = "controls/dropdowns.aspx?";
			    url += "maptype="+ddlMapType.options[0].value;

                //alert(url);
			    //GetResponse fires off the server request and waits for the response
			    GetResponse(url,"ddlMapType",ddlRegionClientId,ddlMapTypeClientId,ddlMapSubTypeClientId);
                
			    var mapsubtype=document.getElementById(ddlMapSubTypeClientId);
			    setSessionVariables(ddlRegionClientId,ddlMapTypeClientId,ddlMapSubTypeClientId,mapsubtype.options[0].value,ddlMapType.options[0].value);
 			}
			if (dropdown == "ddlMapType")
			{
				var subtypes = htmlResult.getElementsByTagName('Map_SubType'); 
				var ddlSubMapType = document.getElementById(ddlMapSubTypeClientId);
				var textValueName; 
				var optionItemName;

				//Clears the ddlMapType dropdown list                   
				for (var count = ddlSubMapType.options.length-1; count >-1; count--)
				{
					ddlSubMapType.options[count] = null;            
				}    
			
				//populate the ddlMapType
				for (var count = 0; count < subtypes.length; count++)
					{
					//alert(GetInnerText(subtypes[count]));
						textValueName = GetInnerText(subtypes[count]);  
						optionItemName = new Option( textValueName, 
							textValueName,  false, false);
						ddlSubMapType.options[ddlSubMapType.length] = optionItemName;  
					} 
				ddlSubMapType.selectedIndex = 0;  
			}
		}
			
		function GetInnerText (node)
		{
			return (node.textContent || node.innerText || node.text) ;
		}