var http = getXMLHTTPRequest();

function getXMLHTTPRequest() 
{
	try 
	{
		req = new XMLHttpRequest();
	} 
	catch (ex) 
	{
		try 
		{
			req = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (ex) 
		{
			try 
			{
				req = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (ex) 
			{
				req = false;
			}
		}
	}
	
	return req;
}

function GetDataCallBack(objId) 
{
	if (http.readyState == 4) 
	{ 
		if(http.status == 200) 
		{	
			var obj = document.getElementById(objId);
			
			if (obj != null)
			{
				while(obj.options.length)
				{
					obj.options[0] = null;
				}
				
				if (objId == "city")
				{
					tmp = document.getElementById("metro");
					
					if (tmp != null)
					{
						while(tmp.options.length)
						{
							tmp.options[0] = null;
						}
					}
				}

				var retVal = http.responseXML.getElementsByTagName("RetVal");
				
				for ( i = 0; i < retVal.length; i++ )
				{	
					obj.options.add(new Option(retVal[i].getElementsByTagName("v")[0].firstChild.nodeValue, retVal[i].getElementsByTagName("k")[0].firstChild.nodeValue, false, false)); 
				}
			}
		}
	}
}

function GetData(val, obj, p) 
{
	var reqUrl = "/beta/helper/" + p + ".php";
	
	var modurl = reqUrl + "?v=" + val + "&o=" + obj;

	http.open("GET", modurl, false);
		
	http.onreadystatechange = function() { GetDataCallBack(obj) };
	
	http.send(null);
}