function Dsy()
{
    this.Items = {};
}
Dsy.prototype.add = function(id,iArray)
{
    this.Items[id] = iArray;
}
Dsy.prototype.Exists = function(id)
{
    if(typeof(this.Items[id]) == "undefined") return false;
    return true;
}

function change(v,Flag)
{
   if(Flag==1)
   {  
     str0 = "ctl00$ContInfo$";
     str1 = "ctl00_ContInfo_";
   }
   else
   {  
      str0 = "";
      str1 = "";
   } 
   var str="中国";
   var ss=document.getElementById(str0+s[v]);
   with(ss)
   {
      length = 0;
      for(i=0;i<v;i++){ str += "-"+document.getElementById(str0+s[i]).options[document.getElementById(str0+s[i]).selectedIndex].value;};
      options[0]=new Option(opt0[v],opt0[v]);    
      if(dsy.Exists(str))
      {
         ar = dsy.Items[str];
         for(i=0;i<ar.length;i++)options[length]=new Option(ar[i],ar[i]);
         options[1].selected = true;
      }
   }
	  if(++v<s.length){change(v,Flag);}
}


var dsy = new Dsy();

dsy.add("中国",["北京","天津","上海","广东","湖南","辽宁","湖北","重庆","河北","河南","澳门","香港","新疆","宁夏","青海","甘肃","陕西","西安","贵州","台湾","四川","海南","广州","黑龙江","内蒙","山西","福建","安徽","浙江","吉林","山东","江苏","云南","江西" ]);
 
var s=["province","city","county"];
var opt0 = ["省份","地级市","市、县级市、县"];
function setupArea(Flag)
{
   if(Flag==1)
     str0 = "ctl00$ContInfo$";
   else
      str0 = "";
   for(i=0;i<s.length-1;i++)
   document.getElementById(str0+s[i]).onchange=new Function("change("+(i+1)+","+Flag+")");
   change(0,Flag);
}

function initializeArea(Flag)
{
   if(Flag==1)
   {  
     str0 = "ctl00$ContInfo$";
     str1 = "ctl00_ContInfo_";
   }
   else
   {  
      str0 = "";
      str1 = "";
   } 
   for(i=0;i<s.length-1;i++)document.getElementById(str0+s[i]).onchange=new Function("change("+(i+1)+","+Flag+")");
   s1=document.getElementById(str1+s[0]);
   s2=document.getElementById(str1+s[1]);
   s3=document.getElementById(str1+s[2]);
   ProvinceID = document.getElementById(str1 + "txtProvince").value;
   CityID = document.getElementById(str1 + "txtcity").value;
   CountyID = document.getElementById(str1 + "txtcounty").value;
   var length = 0;
   var str = "中国";
   with(s1)
   {
      if(dsy.Exists(str))
      {
         arr = dsy.Items[str];
         options[0]=new Option(opt0[0],"");
         for(i=0;i<arr.length;i++)
         {
            options[length]=new Option(arr[i],arr[i]);
            if(options[i].value==ProvinceID)options[i].selected = true;
         } 
      }
   };
   str += "-"+ProvinceID;
   with(s2)
   {
      if(dsy.Exists(str))
      {
         arr = dsy.Items[str];
         options[0]=new Option(opt0[0],"");
         for(i=0;i<arr.length;i++)
         {
            options[length]=new Option(arr[i],arr[i]);
            if(options[i].value==CityID)options[i].selected = true;
         } 
      }
   };
   str += "-"+CityID;
   with(s3)
   {
      if(dsy.Exists(str))
      {
         arr = dsy.Items[str];
         options[0]=new Option(opt0[0],"");
         for(i=0;i<arr.length;i++)
         {
            options[length]=new Option(arr[i],arr[i]);
            if(options[i].value==CountyID)options[i].selected = true;
         } 
      }
   };
};

