<%@ Control Language="c#" AutoEventWireup="false"%>
<%@ Import namespace="System.Data" %>
<%
	Response.Write("<script language=javascript>");
	
		Response.Write("var aryCountry = new Array(");
		DataBase db = new DataBase();
		string strSql = "select cId,ctId,(ctCNName + '(' + ctENName + ')') as ctName from tbDictCountry where ctState = 1  order by ctOrder";
		DataSet ds = new DataSet();
		ds = db.GetDataSet(strSql,ds);
		int itbRowCount = ds.Tables[0].Rows.Count;
		int i = 0;
		foreach(DataRow row in ds.Tables[0].Rows)
		{
			Response.Write("new Array('" + row[0].ToString() + "','" + row[1].ToString() + "','" + row[2].ToString() + "'),");
		}
		Response.Write("new Array('x','x','x')");
		ds.Dispose();
		ds = null;
		Response.Write(");");
		
		
		Response.Write("var aryProvince = new Array(");
		strSql = "select ctId,pId,(pCNName + '(' + pENName + ')') as pName from tbDictProvince where pState = 1  order by pOrder";
		ds = new DataSet();
		ds = db.GetDataSet(strSql,ds);
		itbRowCount = ds.Tables[0].Rows.Count;
		i = 0;
		foreach(DataRow row in ds.Tables[0].Rows)
		{
			Response.Write("new Array('" + row[0].ToString() + "','" + row[1].ToString() + "','" + row[2].ToString() + "'),");
		}
		Response.Write("new Array('x','x','x')");
		ds.Dispose();
		ds = null;
		Response.Write(");");
		
		
		
		Response.Write("var aryCity = new Array(");
		strSql = "select pId,cyId,(cyCNName + '(' + cyENName + ')') as cyName from tbDictCity where cyState = 1  order by cyOrder";
		ds = new DataSet();
		ds = db.GetDataSet(strSql,ds);
		itbRowCount = ds.Tables[0].Rows.Count;
		i = 0;
		foreach(DataRow row in ds.Tables[0].Rows)
		{
			Response.Write("new Array('" + row[0].ToString() + "','" + row[1].ToString() + "','" + row[2].ToString() + "'),");
		}
		Response.Write("new Array('x','x','x')");
		ds.Dispose();
		ds = null;
		db = null;
		Response.Write(");");
	Response.Write("</script>");
%>
<script language="javascript">
	function Contonchange(cId,objCountry,objProvince,objCity)
	{
		if (cId!="")
		{
			var strCountry="";j=0,p=0;
			for (i=0;i<aryCountry.length;i++)
			{
				if (aryCountry[i][0] == cId)
				{
					j=j+1;
					strCountry = strCountry + aryCountry[i][1] +"," +aryCountry[i][2]+",";
				}
			}
			objCountry.length=j+1;
			aryCountry1 = strCountry.split(",");
			objCountry.options[0].value = "0";
			objCountry.options[0].text = "请选择国家";
			for (i=1;i<=j;i++)
			{
				if(aryCountry1[p] != null && aryCountry1[p] != "")
				{
					objCountry.options[i].value = aryCountry1[p];
					objCountry.options[i].text = aryCountry1[p+1];
				}
				p=p+2;
			}
			Countryonchange(objCountry.options[objCountry.options.selectedIndex].value,objProvince,objCity)
		}
	}
	
	function Countryonchange(ctId,objProvince,objCity)
	{
		if (ctId!="")
		{
			var strProvince="";j=0,p=0;
			for (i=0;i<aryProvince.length;i++)
			{
				if (aryProvince[i][0] == ctId)
				{
					j=j+1;
					strProvince = strProvince + aryProvince[i][1] +"," +aryProvince[i][2]+",";
				}
			}
			objProvince.length=j+1;
			aryProvince1 = strProvince.split(",");
			objProvince.options[0].value = "0";
			objProvince.options[0].text = "不指定省份/州";
			for (i=1;i<=j;i++)
			{
				if(aryProvince1[p] != null && aryProvince1[p] != "")
				{
					objProvince.options[i].value = aryProvince1[p];
					objProvince.options[i].text = aryProvince1[p+1];
				}
				p=p+2;
			}
			Provinceonchange(objProvince.options[objProvince.options.selectedIndex].value,objCity);
		}
	}
	
	function Provinceonchange(pId,objCity)
	{
		if (pId!="")
		{
			var strCity="";j=0,p=0;
			for (i=0;i<aryCity.length;i++)
			{
				if (aryCity[i][0] == pId)
				{
					j=j+1;
					strCity = strCity + aryCity[i][1] +"," +aryCity[i][2]+",";
				}
			}
			objCity.length=j+1;
			aryCity1 = strCity.split(",");
			objCity.options[0].value = "0";
			objCity.options[0].text = "不指定城市";
			for (i=1;i<=j;i++)
			{
				if(aryCity1[p] != null && aryCity1[p] != "")
				{
					objCity.options[i].value = aryCity1[p];
					objCity.options[i].text = aryCity1[p+1];
				}
				p=p+2;
			}
		}
	}
</script>



