var XHR = false ; 

function InitXHR()
{
try { 
   xhr = new ActiveXObject("Msxml2.XMLHTTP"); 
　} catch (e) { 
　　try { 
　　　 xhr = new ActiveXObject("Microsoft.XMLHTTP"); 
　　} catch (E) { 
　　　 xhr = false; 
　　} 
　}
if (! xhr && typeof XMLHttpRequest!='undefined') { 
　　 xhr = new XMLHttpRequest(); 
　} 
return  xhr;
}


function $() {
  var elements = new Array();
  
  for ( var i = 0; i < arguments.length; i++) {
    var element = arguments[i];
    if (typeof element == 'string')
      element = document.getElementById(element);

    if (arguments.length == 1) 
      return element;
      
    elements.push(element);
  }
  
  return elements;
}

function setCity( province , obj ) 
{
    var url = "getcity.php?pid=" + province ;
    var xhrVar = InitXHR();
    xhrVar.onreadystatechange = function()
	{
		if ( xhrVar.readyState == 4 && xhrVar.status == 200 ) 
		{
			fillitem = xhrVar.responseText ;
			fillitems = fillitem.split("|");
			$(obj).length = 0;
			for (var i = 0 ; i < fillitems.length ; i++ )
			{
				aoption = fillitems[i].split("::");
				$(obj).options[i] = new Option(aoption[1],aoption[0]);
			}
		}
	}
    xhrVar.open("GET", url, true); 
   	xhrVar.send(null);
}

function setArea( city ,obj) 
{
    // 1. 取得区县
    var url = "getregion.php?cid=" + city ;
    xhrVar = InitXHR();
	var ii = 0 ;
	$(obj).length = 0;
	$(obj).options[0] = new Option('不限','0');
    xhrVar.onreadystatechange = function()
				{
								if ( xhrVar.readyState == 4 && xhrVar.status == 200 ) {
										fillitem = xhrVar.responseText ;
          // 1::东湖区|2::西湖区|3::青山湖
										fillitems = fillitem.split("|");
										
										
										for (var i = 0 ; i < fillitems.length ; i++ )
										{
										    ii = i+ 1;
              aoption = fillitems[i].split("::");
              $(obj).options[ii] = new Option(aoption[1],aoption[0]);
										}
				　  }
				}
    xhrVar.open("GET", url, false); 
   	xhrVar.send(null);
}