//本页代码需要和国家、省份、城市数据合用。用于生成动态显示地区。
function InitRegionSelect(list_FirstType,list_SecondType,dumy, FirstID, SecondID)
{

	list_FirstType.options.length=FirstType.length;
	for (loop=0; loop < FirstType.length; loop++) {
		list_FirstType.options[loop].text=FirstType[loop][0];
		list_FirstType.options[loop].value=FirstType[loop][1];
	}

	list_FirstType.selectedIndex = 0; //FirstID;
	OnSelectFirstType(list_FirstType,list_SecondType);
	list_SecondType.selectedIndex = SecondID;
}


function setRegionOptionText(list_new,the_array, selectedIndex)
{
	list_new.options.length=the_array.length;
	list_new.options[0].text=the_array[the_array.length-1][0];
	list_new.options[0].value=the_array[the_array.length-1][1];
	for (loop=0; loop < the_array.length-1; loop++) {
		list_new.options[loop+1].text=the_array[loop][0];
		list_new.options[loop+1].value=the_array[loop][1];
	}
	if ( typeof selectedIndex != "undefined") list_new.selectedIndex = selectedIndex;
	else list_new.selectedIndex = 0;
}


function OnSelectFirstType(list_FirstType,list_SecondType,txtFirstType, txtSecondType)
{
	sel = list_FirstType.selectedIndex;
	//reset SecondType list
	the_array = eval("SecondType_"+sel);
	setRegionOptionText(list_SecondType,the_array);

	//clear text 
	if ( typeof txtFirstType != "undefined") txtFirstType.value=list_FirstType.options[sel].text;
	if ( typeof txtSecondType != "undefined") txtSecondType.value="";
}


function OnSelectSecondType(list_FirstType, list_SecondType,txtSecondType)
{
	selFirstType = list_FirstType.selectedIndex;
	selSecondType = list_SecondType.selectedIndex-1;

	//clear text 
	if ( typeof txtFirstType != "undefined") txtFirstType.value=list_FirstType.options[sel].text;
	if ( typeof txtSecondType != "undefined") txtSecondType.value=list_SecondType.options[selSecondType].text;
}



function OnSelectThirdType(list_ThirdType, txtThirdType)
{
	sel=list_ThirdType.selectedIndex;
	if ( typeof txtThirdType != "undefined") txtThirdType.value=list_ThirdType.options[sel].text;
}


//Add on function
function SetRegion(FirstID, SecondID, ThirdID, list_FirstType,list_SecondType,list_ThirdType )
{
	
	if ( FirstID == 0 ) return ;
	list_FirstType.selectedIndex = FirstID;

	if ( SecondID != 0 ) { 
		list_SecondType.selectedIndex = SecondID;
		SecondID--;
		list_ThirdType.selectedIndex = ThirdID;
	}
}




