// JScript 文件

		
    var HishopPlaceAjaxUrlBase;
	
	var _defaultHishopPlace;//HishopPlaceDefault对象，记录默认选中的国家等信息
	function HishopPlaceDefault(_country,_province,_region,_area)
	{
		this.Country=_country;
		this.Province=_province;
		this.Region =_region;
		this.Area=_area;					
	}
    function CountryInit(_countryId,_provinceId,_regionId,_areaId)
    {
        //创建国家的列表        
        GetValue2(HishopPlaceAjaxUrlBase,CountryCreate,_countryId,_provinceId,_regionId,_areaId,null,null,null,null,null);
    }
    //国家的列表返回
    function CountryCreate(_backText,_countryId,_provinceId,_regionId,_areaId)
    {
        var CountryList=_backText.split('|');
        var dropCountry=document.getElementById(_countryId);
        dropCountry.length=0;
        for(var i=0;i<CountryList.length;i++)
        {
            dropCountry.options.add(new Option(CountryList[i].split('@')[0] ,CountryList[i].split('@')[0]));
        }
		if (_defaultHishopPlace) {
			for (var i = 0; i < dropCountry.options.length; i++) {
				if (_defaultHishopPlace.Country == dropCountry.options[i].value)
				{
					dropCountry.selectedIndex=i;					
				}
			}
		}
		else 
			dropCountry.selectedIndex = 0;//默认选择第一个
        //创建省
        ProvinceInit(dropCountry,_countryId,_provinceId,_regionId,_areaId)
    }
    
    //根据传入的国家列表控件显示省
    function ProvinceInit(_countryControl,_countryId,_provinceId,_regionId,_areaId)
    {
        var selectValue=escape(_countryControl.options[_countryControl.selectedIndex].value);
        var theUrl= HishopPlaceAjaxUrlBase + "?Country="+selectValue;        
        GetValue2(theUrl,ProvinceCreate,_countryId,_provinceId,_regionId,_areaId,null,null,null,null,null);
    }
    //省份的返回
    function ProvinceCreate(_backText,_countryId,_provinceId,_regionId,_areaId)
    {        
        var ProvinceList=_backText.split('|');
        var dropProvince=document.getElementById(_provinceId);
        dropProvince.length=0;
        for(var i=0;i<ProvinceList.length;i++)
        {
            dropProvince.options.add(new Option(ProvinceList[i].split('@')[0] ,ProvinceList[i].split('@')[0]));
        }
		if (_defaultHishopPlace) {
			for (var i = 0; i < dropProvince.options.length; i++) {
				if (_defaultHishopPlace.Province == dropProvince.options[i].value)
				{
					dropProvince.selectedIndex=i;					
				}
			}
		}
		else
        	dropProvince.selectedIndex=0;//默认选择第一个
        //创建市
        RegionInit(dropProvince,_countryId,_provinceId,_regionId,_areaId);
    }
   
   //根据传入的省显示市
   function RegionInit(_province,_countryId,_provinceId,_regionId,_areaId)
   {
        //获得当前选择的国家
        var dropCountry=document.getElementById(_countryId);           
        var selectCountryValue=escape(dropCountry.options[dropCountry.selectedIndex].value);       
        var selectValue=escape(_province.options[_province.selectedIndex].value); 
        var theUrl= HishopPlaceAjaxUrlBase + "?Country="+selectCountryValue+"&Province="+selectValue;  

        GetValue2(theUrl,RegionCreate,_countryId,_provinceId,_regionId,_areaId,null,null,null,null,null);
   }
   function RegionCreate(_backText,_countryId,_provinceId,_regionId,_areaId)
   {
        var RegionList=_backText.split('|');
        var dropRegion=document.getElementById(_regionId);
        dropRegion.length=0;
        for(var i=0;i<RegionList.length;i++)
        {
            dropRegion.options.add(new Option(RegionList[i].split('@')[0] ,RegionList[i].split('@')[0]));
        }
		if (_defaultHishopPlace) {
			for (var i = 0; i < dropRegion.options.length; i++) {
				if (_defaultHishopPlace.Region == dropRegion.options[i].value)
				{
					dropRegion.selectedIndex=i;					
				}
			}
		}
		else
        	dropRegion.selectedIndex=0;//默认选择第一个
        //创建县
        AreaInit(dropRegion,_countryId,_provinceId,_regionId,_areaId);
   }
   
   //根据传入市显示县
   function AreaInit(_region,_countryId,_provinceId,_regionId,_areaId)
   {
            //获得当前选择的国家
        var dropCountry=document.getElementById(_countryId); 
        var dropProvince=document.getElementById(_provinceId);
         
        var selectCountryValue=escape(dropCountry.options[dropCountry.selectedIndex].value);
        var selectProvince=escape(dropProvince.options[dropProvince.selectedIndex].value);
        var selectValue=escape(_region.options[_region.selectedIndex].value);
        
        var theUrl= HishopPlaceAjaxUrlBase + "?Country="+selectCountryValue+"&Province="+selectProvince+"&Region="+selectValue;  
  
        
        GetValue2(theUrl,AreaCreate,_countryId,_provinceId,_regionId,_areaId,null,null,null,null,null);
   }
   
   function AreaCreate(_backText,_countryId,_provinceId,_regionId,_areaId)
   {
        var AreaList=_backText.split('|');
        var dropArea=document.getElementById(_areaId);
        dropArea.length=0;
        for(var i=0;i<AreaList.length;i++)
        {
            dropArea.options.add(new Option(AreaList[i].split('@')[0] ,AreaList[i].split('@')[0]));
        }
		if (_defaultHishopPlace) {
			for (var i = 0; i < dropArea.options.length; i++) {
				if (_defaultHishopPlace.Area == dropArea.options[i].value)
				{
					dropArea.selectedIndex=i;					
				}
			}
		}

}


    