	function checkCf(codice, formId, scriptPath){
		var cf = codice.value;
		
		var codiceComune = cf.substring(11,15);
		loadAndExecuteScript(scriptPath + "/" + codiceComune .substring(0,1).toLowerCase() + '.js', cf, formId);
	}	
	
	function loadAndExecuteScript(sScriptSrc, cf, formId) {
		var callback = function (){
			//alert('callback');
			var theForm = getFormByID(formId);
 
			var codiceAnnoNascita = cf.substring(6,8);
			var codiceMeseNascita = cf.substring(8,9);
			var codiceGiornoNascita = cf.substring(9,11);
			var data = getGiorno(codiceGiornoNascita) + "/" + getMese(codiceMeseNascita) + "/" + getAnno(codiceAnnoNascita);
			theForm.dataNascita.value = data;
			var codiceComune = cf.substring(11,15);
			var comune = comuni[codiceComune.toUpperCase()];
			theForm.luogoNascita.value = comune;		
		}

		var oHead = document.getElementsByTagName('head')[0];
		var oScript = document.createElement('script');
		oScript.type = 'text/javascript';
		oScript.src = sScriptSrc;
		oScript.onload= callback;
		//alert('pre load');
		oHead.appendChild(oScript);
	}
	
	function getMese (mese){
		var found='';
		mese = mese.toUpperCase();
		switch (mese){
			case 'A' :
				found='01';
				break;
			case 'B' :
				found='02';
				break;
			case 'C' :
				found='03';
				break;
			case 'D' :
				found='04';
				break;
			case 'E' :
				found='05';
				break;
			case 'H' :
				found='06';
				break;
			case 'L' :
				found='07';
				break;
			case 'M' :
				found='08';
				break;
			case 'P' :
				found='09';
				break;
			case 'R' :
				found='10';
				break;
			case 'S' :
				found='11';
				break;
			case 'T' :
				found='12';
				break;
		}
		return found;
	}
	
	function getAnno (anno){
		if (anno > 10 )
			return '19' + anno;
		else
			return '20' + anno;	
	}

	function getGiorno (giorno){
		if (giorno > 31)
			return giorno - 40;
		else 
			return giorno;	
	}

