function relate(frm,elementNum,j) {

	var sel_countries = "";
	var count = 0;
  for(i=0; i < frm.Country.length; i++){
    if(frm.Country.options[i].selected) {
      count++;
    }
	}

  for(i=frm.province.options.length-1; i >= 0; i--)	frm.province.options[i] = null; //empty out list

	if (count == 1){			    
	  $.getJSON("/exe/get_provincesJSON.asp", {country: frm.Country.value}, function(data) {
	  	var provinces = data.provinces;

	    for(i=0; i < provinces.length; i++) {
	    	if (provinces[i][1]) {
		      frm.province.options[i] = new Option(provinces[i][1],provinces[i][0]); 
		    }
	    }
			if (frm.province.options[0]) frm.province.options[0].selected = true;
	  });
	}
	
}

function getCities(frm,label,caption){
	
	var isCities = $("select[name='Country']").val();
	var isProvince = $("select[name='province']").val();
	if(isProvince.length == 1){
	var html = caption+'<br /><select multiple size="6" name="resCity" style="width:138px;" ><option value="" selected>'+label+'</option></select>';
		if(isCities == 'US' || isCities == 'CA'){//show cities
			$("select[name='province']").width("138px");
			$("#resCity").html(html);
			
			$.getJSON("/exe/get_cityJSON.asp", {country: isCities, province:isProvince}, function(data) {
				var cities = data.cities;
				for(i=0; i < cities.length; i++) {
					if (cities[i][1]) {
					  frm.resCity.options[i] = new Option(cities[i][1],cities[i][0]); 
					}
				}
				if (frm.resCity.options[0]) frm.resCity.options[0].selected = true;
				
			});
		
		}else{
			
			$("#resCity").html("");
			$("select[name='province']").width("250px");
		}
	}else{
		$("#resCity").html("");
		$("select[name='province']").width("250px");
	}
	//alert($("select[name='province']").val()+' --- '+$("select[name='Country']").val());
}




