/*
	author: Cristiano Aicardi
	copyright: Net Source (http://www.netsource.it/)
	version: 1.0
	ref: jQuery
	ajaxCall: getCities.xml.php / getCountries.xml.php
*/

/* Select City Name */
$(document).ready(function(){ 
	$("#countryCode").change(function() {

		if ($("#countryCode").val()!="") {

			/* Carica nella select tutte le cittą */
			$.get("ajaxCall/getCityParam.xml.php?countrycode="+$("#countryCode").val(), function(xml) {
				$('#cityNumber').html('');
   				$(xml).find('item').each(function(){
				var item_text = $(this).text();
        			$('#cityNumber').append(item_text);
				});
			});

		} else {
			$('#cityNumber').html('<option value="">city name</option>');
		}

	});
});

/* Select City Name al reload */
$(document).ready(function(){ 
	if ($("#countryCode").val()!="") {

		/* Carica nella select tutte le cittą */
		$.get("ajaxCall/getCityParam.xml.php?countrycode="+$("#countryCode").val(), function(xml) {
			$('#cityNumber').html('');
   			$(xml).find('item').each(function(){
			var item_text = $(this).text();
        		$('#cityNumber').append(item_text);
			});
			if ($("#cn_reload").val()!="") {
				$('#cityNumber').val($("#cn_reload").val());
			}
		});

	} else {
		$('#cityNumber').html('<option value="">city name</option>');
	}

});
