function updateHidden(txt, li)
{
    hiddenName = txt.name.replace("_","");
    id = li.id;
    txt.form[hiddenName].value = id;
    
    button = "boton_" + hiddenName;
    txt.form[button].disabled=false;
}

function fillDays(monthsId, daysId, yearId){
	var DaysMonth = new Array();
	var Days = document.getElementById(daysId);
	var Months = document.getElementById(monthsId);
	var Years = document.getElementById(yearId);
	var Year = Years.options[Years.options.selectedIndex].value;
	if(Year==0) Years.options[1].selected=true;
	var month = Months.options[Months.options.selectedIndex].value;
	var Leap=0;
	if((Year%4==0) && ((Year%4!=100) || (Year%400==0)))
		Leap=1;
	DaysMonth[1] = 31; DaysMonth[3] = 31; DaysMonth[5] = 31; DaysMonth[7] = 31; 
	DaysMonth[8] = 31; DaysMonth[10] = 31; DaysMonth[12] = 31;
	DaysMonth[2] = (Leap==1)?29:28;
	DaysMonth[4] = 30; DaysMonth[6] = 30; DaysMonth[9] = 30; DaysMonth[11] = 30; 
	Days.length = 0;
	for(d=1; d<=DaysMonth[month]; d++){
		Days.options[d-1] = new Option(d,d);
	}	
}

function setMonths(mesIda,diaVuelta,mesVuelta,anoVuelta){
	
	var aMesIda = document.getElementById(mesIda);
	var aMesVuelta = document.getElementById(mesVuelta);
	var aAnoVuelta = document.getElementById(anoVuelta);
	
	aMesVuelta.options[aMesIda.options.selectedIndex].selected = true;
	fillDays(mesVuelta, diaVuelta, anoVuelta);
	
}

function validateForm(){
	var form = document.getElementById("searchForm");
	var mErrors = "Ocurrieron los siguientes errores:\n\n";
	var sErr = 0;
	if(form.cCode.options.selectedIndex==0){
		sErr = 1;
		mErrors += "- Debe seleccionar un Pais\n";
	}
	if(form.fechaIda.value==""){
		sErr = 1;
		mErrors += "- Debe seleccionar la Fecha de Entrada\n";
	}
	else if(compareDates(form.fechaIda.value,'dd/MM/yyyy',form.tDate.value,'dd/MM/yyyy')==0){
		sErr = 1;
		mErrors += "- La Fecha de Entrada es erronea\n";		
	}
	if(form.fechaVuelta.value==""){
		sErr = 1;
		mErrors += "- Debe seleccionar la Fecha de Salida\n";
	}
	else if(compareDates(form.fechaIda.value,'dd/MM/yyyy',form.fechaVuelta.value,'dd/MM/yyyy')==1){
		sErr = 1;
		mErrors += "- La Fecha de Salida es erronea\n";
	}
	
	if(sErr == 1){
		alert(mErrors);
		return false;	
	}
	else form.submit();	
}