/*****************************************************************
*                                                                *
*   Branch list functions                                        *
*                                                                *
*****************************************************************/

//create arrays for ab, bc, nt and yt	
city = new Array()
city[0] = new Array()
city[1] = new Array()
city[2] = new Array()
city[3] = new Array()

function buildArrays(){
  //build arrays from anchors
  var strProvince
  var intProvinceIdx = -1
  var intCityIdx

  for(i=0;i<document.anchors.length;i++){
    if(document.anchors[i].name!=''){
      strNextProvince = document.anchors[i].name.split('|')[0]
      if(strProvince != strNextProvince){
        intProvinceIdx++;
        strProvince = strNextProvince;
        intCityIdx = 0;
      }
      city[intProvinceIdx][intCityIdx] = document.anchors[i].name;
      intCityIdx++;
    }
  }
}

//update city list
function showCities(form){
  buildArrays();

	//deterine which province radio was clicked
	var i = 0
	while (!form.province[i].checked){i++}

	//populate list from array
	//remove current cities
	for(j=form.citylist.options.length;j>=0;j--){
	    form.citylist.options[j] = null;
	}

	//init new cities
	for(j=0;j<city[i].length+1;j++){
	    form.citylist.options[j] = new Option();
	}
    
	//fill list with array values
	for(t=0;t<city[i].length;t++){
	    form.citylist.options[t].value = city[i][t];
	    form.citylist.options[t].text = city[i][t].split('|')[1].replace('_',' ');
		    
	}
	form.citylist.options[t].text = '                                ';
}
	
//jump to specified city
function jumpTo(form) {
	location='#' + form.citylist.options[form.citylist.selectedIndex].value;
}



