// JavaScript Document

function PowerProvice(){
  // 全局  
  this.Province = new Array;
  this.City = new Array;
  I=0;    
  this.Province[I] = '北京';
  this.City[I] = new Array('北京'); 
  I++;
  this.Province[I] = '上海';
  this.City[I] = new Array('上海');
  I++;
  this.Province[I] = '天津';
  this.City[I] = new Array('天津');
  I++;
  this.Province[I] = '重庆';
  this.City[I] = new Array('重庆');  
  I++;
  this.Province[I] = '河北';
  this.City[I] = new Array("请选择","石家庄","唐山","秦皇岛","邯郸","邢台","保定","张家口","承德","沧州","廊坊","衡水","其他"); 
  I++;
  this.Province[I] = '山西';
  this.City[I] = new Array("请选择","太原","大同","阳泉","长治","晋城","朔州","晋中"	,"运城","忻州","临汾","吕梁");
  I++;
  this.Province[I] = '内蒙古';
 this.City[I] = new Array("请选择","呼和浩特","包头","乌海","赤峰","通辽","鄂尔多斯","呼伦贝尔","乌兰察布盟","锡林郭勒盟","巴彦淖尔盟","阿拉善盟","兴安盟");
  I++;
  this.Province[I] = '辽宁';
  this.City[I] = new Array("请选择","沈阳","大连","鞍山","抚顺","本溪","丹东","锦州","葫芦岛","营口","盘锦","阜新","辽阳","铁岭","朝阳");
  I++;
  this.Province[I] = '吉林';
  this.City[I] = new Array("请选择","长春","吉林市","四平","辽源","通化","白山","松原","白城","延边朝鲜族自治州");
  I++;
  this.Province[I] = '黑龙江';
  this.City[I] = new Array("请选择","哈尔滨","齐齐哈尔","鹤岗","双鸭山","鸡西","大庆","伊春","牡丹江","佳木斯","七台河","黑河","绥化	","大兴安岭");
  I++;
  this.Province[I] = '江苏';
  this.City[I] = new Array("请选择","南京","无锡","徐州","常州","苏州","南通","连云港","淮安","盐城","扬州","镇江","泰州","宿迁"); 
  I++;
  this.Province[I] = '浙江';
  this.City[I] = new Array("请选择","杭州","宁波","温州","嘉兴","湖州","绍兴","金华","衢州舟山","台州","丽水");
  I++;
  this.Province[I] = '安徽';
  this.City[I] = new Array("请选择","合肥","芜湖","蚌埠","淮南","马鞍山","淮北","铜陵","安庆","黄山","滁州","阜阳","宿州","巢湖","六安","亳州","池州","宣城");
  I++;
  this.Province[I] = '福建';
  this.City[I] = new Array("请选择","福州","厦门","莆田","三明","泉州","漳州","南平","龙岩","宁德");
  I++;
  this.Province[I] = '江西';
  this.City[I] = new Array("请选择","南昌","景德镇","萍乡","新余","九江","鹰潭","赣州","吉安","宜春","抚州","上饶");
  I++;
  this.Province[I] = '山东';
  this.City[I] = new Array("请选择","济南","青岛","淄博","枣庄","东营","潍坊","烟台","威海","济宁","泰安","日照","莱芜","德州","临沂","聊城","滨州","菏泽");
  I++;
  this.Province[I] = '河南';
  this.City[I] = new Array("请选择","郑州","开封","洛阳","平顶山","焦作","鹤壁","新乡","安阳","濮阳","许昌","漯河","三门峡","南阳","商丘","信阳","周口","驻马店","济源");  
  I++;
  this.Province[I] = '湖北';
  this.City[I] = new Array("请选择","武汉","黄石","襄樊","十堰","荆州","宜昌","荆门","鄂州","孝感","黄冈","咸宁","随州","仙桃","天门","潜江","神农架","恩施土家族苗族自治州");
  I++;
  this.Province[I] = '湖南';
  this.City[I] = new Array("请选择","长沙","株洲","湘潭","衡阳","邵阳","岳阳","常德","张家界","益阳","郴州","怀化","娄底","湘西土家族苗族自治州");
  I++;
  this.Province[I] = '广东';
  this.City[I] = new Array("请选择","广州","深圳","珠海","汕头","韶关","佛山","江门","湛江","茂名","肇庆","惠州","梅州","汕尾","河源","阳江","清远","东莞","中山","潮州","揭阳","云浮");
  I++;
  this.Province[I] = '广西';
  this.City[I] = new Array("请选择","南宁","柳州","桂林","梧州","北海","防城港","钦州","贵港","玉林","百色","贺州","河池","来宾","崇左");
  I++;
  this.Province[I] = '海南';
  this.City[I] = new Array("请选择","海口","三亚","五指山","琼海","儋州","文昌","万宁","东方","澄迈","定安","屯昌","临高","白沙黎族自治县昌","江黎族自治县","乐东黎族自治县","陵水黎族自治县","保亭黎族苗族自治县","琼中黎族苗族自治县"); 
  I++;
  this.Province[I] = '四川';
  this.City[I] = new Array("请选择","成都","自贡","攀枝花","泸州","德阳","绵阳","广元","遂宁","内江","乐山","南充","宜宾","广安","达州","眉山","雅安","巴中","资阳","阿坝藏族羌族自治州","甘孜藏族自治州","凉山彝族自治州");
  I++;
  this.Province[I] = '贵州';
  this.City[I] = new Array("请选择","贵阳","六盘水","遵义","安顺","铜仁","毕节","黔西南布依族苗族自治州","黔东南苗族侗族自治州","黔南布依族苗族自治州");
  I++;
  this.Province[I] = '云南';
  this.City[I] = new Array("请选择","昆明","曲靖","玉溪","保山","昭通","丽江","思茅","临沧","文山壮族苗族自治州","红河哈尼族彝族自治州","西双版纳傣族自治州","楚雄彝族自治州","大理白族自治州","德宏傣族景颇族自治州 ","怒江傈傈族自治州","迪庆藏族自治州");
  I++;
  this.Province[I] = '西藏';
  this.City[I] = new Array("请选择","拉萨","那曲","昌都","山南","日喀则","阿里","林芝");
 I++;
  this.Province[I] = '陕西';
  this.City[I] = new Array("请选择","西安","铜川","宝鸡","咸阳","渭南","延安","汉中","榆林","安康","商洛");
  I++;
  this.Province[I] = '甘肃';
  this.City[I] = new Array("请选择","兰州","金昌","白银","天水","嘉峪关","武威","张掖","平凉","酒泉","庆阳","定西","陇南","临夏回族自治州","甘南藏族自治州");
  I++;
  this.Province[I] = '青海';
  this.City[I] = new Array("请选择","西宁","海东","海北藏族自治州","黄南藏族自治州","海南藏族自治州","果洛藏族自治州","玉树藏族自治州","海西蒙古族藏族自治州");
  I++;
  this.Province[I] = '宁夏';
  this.City[I] = new Array("请选择","银川","石嘴山","吴忠","固原");
  I++;
  this.Province[I] = '新疆';
   this.City[I] = new Array("请选择","乌鲁木齐","克拉玛依","石河子","阿拉尔","图木舒克","五家渠","吐鲁番","哈密","和田","阿克苏","喀什","克孜勒苏柯尔克孜自治州","巴音郭楞蒙古自治州","昌吉回族自治州","博尔塔拉蒙古自治州","伊犁哈萨克自治州");
   I++;
  this.Province[I] = '香港';
  this.City[I] = new Array("香港");
  I++;
  this.Province[I] = '澳门';
  this.City[I] = new Array("澳门");
  I++;
  this.Province[I] = '台湾';
  this.City[I] = new Array("请选择","台北","高雄","基隆","台中","台南","新竹","嘉义","台北县","宜兰县","新竹县","桃园县","苗栗县","台中县","彰化县","南投县","嘉义县","云林县","台南县","高雄县","屏东县","台东县","花莲县","澎湖县");

  //方法
  this.selBox = PowerSelBox;
  this.selProvice = SelectProvice;
  this.listProvice = ListProvice;
  this.listProvicePower = ListProviceEpower;
}

function PowerSelBox(obj,selectobj){
	// 初始化省份信息
   
   for(I=0;I<obj.length;I++)
   {	  
	  if(obj[I]==selectobj){		
		  document.write("<option value="+obj[I]+" selected>");
	  }else{		  
		 document.write("<option value="+obj[I]+">");
	  }
	  document.write(obj[I]+"</option>");
   }
}

function SelectProvice(Provice,city){
  // 选择省份信息,Provice为选中的省份,city为要改变城市的下拉菜单名称
  var sels = document.getElementsByTagName("SELECT");
  for(var i=0;i<sels.length;i++){
	  if(sels[i].name==city){
		  // 得到城市下拉菜单对象
		  var obj = sels[i]
	  }
  }	
  
  if(Provice!=""){
	  // 清空城市下拉菜单
	  clear(obj);
	  m=sel(Provice,this.Province);
	  for (var i=0;i<this.City[m].length;i++){
		  fullup(obj,this.City[m][i]);
	  }
  }else{
	  // 清空城市
	  clear(city);
  }  
}

function clear(obj1){
  var count = obj1.length
  for(j=count-1;j>=0;j--){
	obj1.options[j] = null;
  }
}

function sel(val,obj1){
  // 确定所选省分在数组中的位置
  for(var i=0;i<obj1.length;i++){
	if(obj1[i]==val){
		return i;
	}
  }
}

function fullup(obj1,val){
  // 增加下拉选
  var vn = new Option(val,val); 
  //循环增加所有选择城市
  obj1.add(vn);
}
function ListProvice(page){
  var j=0
  //document.write("<center>");
  document.write("<a href='co.asp'>[全国]</a> ");
  for(var c=0;c<this.Province.length/12;c++){
	  for(var i=0;i<12&&j<this.Province.length;i++){
		document.write("<a href="+page+"?province="+this.Province[j]+">["+this.Province[j]+"]</a> ");
		j++
	  }	  
	  document.write("</br>");
  }
 // document.write("</center>");
}
function ListProviceEpower(page,num){
  var j=0
  //document.write("<center>");
  for(var c=0;c<this.Province.length/num;c++){
	  for(var i=0;i<num&&j<this.Province.length;i++){
		document.write("[<a href="+page+"?province="+encodeURI(this.Province[j])+">"+this.Province[j].substr(0,2)+"</a>] ");
		j++
	  }	  
	  document.write("</br>");
  }
 // document.write("</center>");
}
