function diasEnMes(m, y){
	if (m==4 || m==6 || m==9 || m==11) {return 30;}
	else if (m!=2) return 31;
	else return diasEnFebrero(y);
}

function diasEnFebrero(y){
	return (((y % 4 == 0) && ( (!(y % 100 == 0)) || (y % 400 == 0))) ? 29 : 28 );
}

function comprobarFecha(d, m, y){
	if (m>0&&m<13)
		return ((d>0) && (d<=diasEnMes(m, y)))
	else
		return false;
}

function comprobarFechaInicio(){
	return comprobarFecha(document.getElementById("gg").value, document.getElementById("mm").value, document.getElementById("aa").value)
}

function comprobarFechaSalida(){
	return comprobarFecha(document.getElementById("ggf").value, document.getElementById("mmf").value, document.getElementById("aaf").value)
}
function siguienteDia(){
	 var fecha;
	 var milisegundos; 
	 milisegundos = parseInt(1*24*60*60*1000);
	 
	 fecha = new Date(document.getElementById("aa").value, parseFloat(document.getElementById("mm").value)-1, document.getElementById("gg").value);
	 dia = fecha.getDate();
	 mes = fecha.getMonth()+1;
	 anio = fecha.getYear();

	 tiempo = fecha.getTime();
	 total = fecha.setTime(parseInt(tiempo+milisegundos));
	 dia = fecha.getDate();
	 mes = fecha.getMonth()+1;
	 anio = fecha.getYear();

	 str = "00" + mes
	 var iLen = String(str).length;
	 mes = String(str).substring(iLen, iLen - 2);

	 str = "00" + dia
	 var iLen = String(str).length;
	 dia = String(str).substring(iLen, iLen - 2);
	 
	 
	 document.getElementById("ggf").value = dia
	 document.getElementById("mmf").value = mes
	 document.getElementById("aaf").value = anio
	
	 //alert(dia+"/"+mes+"/"+anio);
	 
 }	
 
function chkCana(formu){
	if (formu.residente ){	
		if(formu.residente.checked){
			formu.codice_cli.value="";
			formu.codice_cli.disabled="disabled";
		} else {
			formu.codice_cli.disabled=false;
			formu.codice_cli.value="";
		}
	}
}
 
