/**
 * Funci�n que comprueba si el c�digo postal introducido corresponde con el de la provincia. Para ello se usa un array 
 * auxiliar en la que se establecen los dos primeros caracteres del c�digo postal de la provincial. 
 * Comentamos de momento el c�digo postal correspondiente a Canarias, Ceuta y Melilla pues no se hacen env�os a dichas
 * provincias.
 * @params integer i_postalCode. C�digo postal.
 * @returns integer 		0 si no se encontr� el c�digo postal (0)
 *							1 si el c�digo postal es de una provincia a la que no se env�a
 *
 */
function getProvinceFromPostalCode(i_postalCode)
{
	
	if (i_postalCode.length != 5) return 0; 
	else if (!isUnsignedInteger(i_postalCode)) return 0; // Comprobamos que son enteros sin signo.
	
	i_postalCodeTwoDigits = i_postalCode.substring(0, 2);
			
	var st_postalCodeInit = new Array();
	var st_specialPostalCode = new Array();
	var st_postalCodeNoShipments = new Array();
	
	
	// js for italian zipcodes: use Regione, not Provincia
	
	st_specialPostalCode['00120'] = 'Città del Vaticano';
	st_specialPostalCode['47890'] = 'Repubblica di San Marino';
	st_specialPostalCode['47891'] = 'Repubblica di San Marino';
	st_specialPostalCode['47892'] = 'Repubblica di San Marino';
	st_specialPostalCode['47893'] = 'Repubblica di San Marino';
	st_specialPostalCode['47894'] = 'Repubblica di San Marino';
	st_specialPostalCode['47895'] = 'Repubblica di San Marino';
	st_specialPostalCode['47896'] = 'Repubblica di San Marino';
	st_specialPostalCode['47897'] = 'Repubblica di San Marino';
	st_specialPostalCode['47898'] = 'Repubblica di San Marino';
	st_specialPostalCode['47899'] = 'Repubblica di San Marino';
	
	
	st_postalCodeInit['00'] = 'Lazio';
	st_postalCodeInit['01'] = 'Lazio';
	st_postalCodeInit['02'] = 'Lazio';
	st_postalCodeInit['03'] = 'Lazio';
	st_postalCodeInit['04'] = 'Lazio';
	st_postalCodeInit['05'] = 'Umbria';
	st_postalCodeInit['06'] = 'Umbria';
	st_postalCodeInit['07'] = 'Sardegna';
	st_postalCodeInit['07'] = 'Sardegna';
	st_postalCodeInit['08'] = 'Sardegna';
	st_postalCodeInit['08'] = 'Sardegna';
	st_postalCodeInit['09'] = 'Sardegna';
	st_postalCodeInit['09'] = 'Sardegna';
	st_postalCodeInit['09'] = 'Sardegna';
	st_postalCodeInit['09'] = 'Sardegna';
	st_postalCodeInit['10'] = 'Piemonte';
	st_postalCodeInit['11'] = 'Valle d\'Aosta';
	st_postalCodeInit['12'] = 'Piemonte';
	st_postalCodeInit['13'] = 'Piemonte';
	st_postalCodeInit['14'] = 'Piemonte';
	st_postalCodeInit['15'] = 'Piemonte';
	st_postalCodeInit['16'] = 'Liguria';
	st_postalCodeInit['17'] = 'Liguria';
	st_postalCodeInit['18'] = 'Liguria';
	st_postalCodeInit['19'] = 'Liguria';
	st_postalCodeInit['20'] = 'Lombardia';
	st_postalCodeInit['21'] = 'Lombardia';
	st_postalCodeInit['22'] = 'Lombardia';
	st_postalCodeInit['23'] = 'Lombardia';
	st_postalCodeInit['24'] = 'Lombardia';
	st_postalCodeInit['25'] = 'Lombardia';
	st_postalCodeInit['26'] = 'Lombardia';
	st_postalCodeInit['27'] = 'Lombardia';
	st_postalCodeInit['28'] = 'Piemonte';
	st_postalCodeInit['29'] = 'Emilia-Romagna';
	st_postalCodeInit['30'] = 'Veneto';
	st_postalCodeInit['31'] = 'Veneto';
	st_postalCodeInit['32'] = 'Veneto';
	st_postalCodeInit['33'] = 'Friuli-Venezia Giulia';
	st_postalCodeInit['34'] = 'Friuli-Venezia Giulia';
	st_postalCodeInit['35'] = 'Veneto';
	st_postalCodeInit['36'] = 'Veneto';
	st_postalCodeInit['37'] = 'Veneto';
	st_postalCodeInit['38'] = 'Trentino-Alto Adige / S�dtirol';
	st_postalCodeInit['39'] = 'Trentino-Alto Adige / S�dtirol';
	st_postalCodeInit['40'] = 'Emilia-Romagna';
	st_postalCodeInit['41'] = 'Emilia-Romagna';
	st_postalCodeInit['42'] = 'Emilia-Romagna';
	st_postalCodeInit['43'] = 'Emilia-Romagna';
	st_postalCodeInit['44'] = 'Emilia-Romagna';
	st_postalCodeInit['45'] = 'Veneto';
	st_postalCodeInit['46'] = 'Lombardia';
	st_postalCodeInit['47'] = 'Emilia-Romagna';
	st_postalCodeInit['48'] = 'Emilia-Romagna';
	st_postalCodeInit['50'] = 'Toscana';
	st_postalCodeInit['51'] = 'Toscana';
	st_postalCodeInit['52'] = 'Toscana';
	st_postalCodeInit['53'] = 'Toscana';
	st_postalCodeInit['54'] = 'Toscana';
	st_postalCodeInit['55'] = 'Toscana';
	st_postalCodeInit['56'] = 'Toscana';
	st_postalCodeInit['57'] = 'Toscana';
	st_postalCodeInit['58'] = 'Toscana';
	st_postalCodeInit['59'] = 'Toscana';
	st_postalCodeInit['60'] = 'Marche';
	st_postalCodeInit['61'] = 'Marche';
	st_postalCodeInit['62'] = 'Marche';
	st_postalCodeInit['63'] = 'Marche';
	st_postalCodeInit['64'] = 'Abruzzo';
	st_postalCodeInit['65'] = 'Abruzzo';
	st_postalCodeInit['66'] = 'Abruzzo';
	st_postalCodeInit['67'] = 'Abruzzo';
	st_postalCodeInit['70'] = 'Puglia';
	st_postalCodeInit['71'] = 'Puglia';
	st_postalCodeInit['72'] = 'Puglia';
	st_postalCodeInit['73'] = 'Puglia';
	st_postalCodeInit['74'] = 'Puglia';
	st_postalCodeInit['75'] = 'Basilicata';
	st_postalCodeInit['80'] = 'Campania';
	st_postalCodeInit['81'] = 'Campania';
	st_postalCodeInit['82'] = 'Campania';
	st_postalCodeInit['83'] = 'Campania';
	st_postalCodeInit['84'] = 'Campania';
	st_postalCodeInit['85'] = 'Basilicata';
	st_postalCodeInit['86'] = 'Molise';
	st_postalCodeInit['87'] = 'Calabria';
	st_postalCodeInit['88'] = 'Calabria';
	st_postalCodeInit['89'] = 'Calabria';
	st_postalCodeInit['90'] = 'Sicilia';
	st_postalCodeInit['91'] = 'Sicilia';
	st_postalCodeInit['92'] = 'Sicilia';
	st_postalCodeInit['93'] = 'Sicilia';
	st_postalCodeInit['94'] = 'Sicilia';
	st_postalCodeInit['95'] = 'Sicilia';
	st_postalCodeInit['96'] = 'Sicilia';
	st_postalCodeInit['97'] = 'Sicilia';
	st_postalCodeInit['98'] = 'Sicilia';
	

	// try specialPostalCode first, then postalCodeInit, then postalCodeNoShipments (empty for now)
	if(typeof(st_specialPostalCode[i_postalCode]) == 'string') {
		return st_specialPostalCode[i_postalCode];
	} else if(typeof(st_postalCodeInit[i_postalCodeTwoDigits]) == 'string') {
		return st_postalCodeInit[i_postalCodeTwoDigits];
	} else if (typeof(st_postalCodeNoShipments[i_postalCodeTwoDigits]) == 'string') {
		return 1;
	} else {
		return 0;
	}

}

