function CalculateDateSalida(){
	var noches = jQuery('#noches').val(); 		
	if( !isNaN(noches) && noches!=""){
		var dateEntrada=jQuery('#desde').datepicker('getDate');
	
		var dateSalida=dateEntrada.add({ days: noches });
		jQuery('#hasta').val(dateSalida.toString("dd/MM/yyyy")); 			
	}
}


function CalculateNoches() {	
	var dateEntrada = jQuery('#desde').datepicker('getDate');
	var dateSalida = jQuery('#hasta').datepicker('getDate');
	var diferencia = dateSalida - dateEntrada;	
	noches = Math.floor(diferencia / (1000 * 60 * 60 * 24)); 
	if(noches <1) {
		noches=7;
		jQuery('#noches').val(noches); 	
		CalculateDateSalida();
	} else {
		jQuery('#noches').val(noches); 	
	}
}

function sel_alojamiento(tipo) {	
	if(tipo == 1) {//hotel
		jQuery('#nombre_comercial').val("Hotel AR Galetamar"); 
		jQuery('#codAloja').val("Hotel AR Galetamar;1"); 		
			
	} else if(tipo == 3){ //Bungalow
		jQuery('#nombre_comercial').val("AR Galetamar"); 	
		jQuery('#codAloja').val("AR Galetamar;3"); 		
	}		
}

function crea_edad(ninos) {	
	for (var i=1; i<=ninos; i++){
		jQuery("#edades").append("<input type='hidden' name='edad_nino_1_"+i+"' value='11'/>");		
	}
			
}


function ValidateFormHoteles(form) {
	fechaEntrada = form.fecha_entrada.value;
	fechaSalida = form.fecha_salida.value;
	noches = form.noches.value;
	
	if(fechaEntrada=="" || fechaSalida=="" || noches==""){
		alert("faltan campos por rellenar");
		
	}
	else {		
		form.submit();
		
		jQuery('#iframe').show();		
		jQuery('.superfoto').css('height', '251px');
		jQuery('.superfoto img').attr("src", "fileadmin/microsites/template/img/foto_int.jpg");
		jQuery('.superfoto img').attr("height", "251");
		jQuery('.centro').hide();
		jQuery('.centro_int').hide();
		jQuery('.derecha').hide();
		jQuery('.derecha_int').hide();
	}
	
	return false;
	
}
