function validar(fechav){
	fecha1=fechav
	var fec=new Date();
	var d=fec.getDate();
	var dia = (d < 10) ? '0' + d : d;
	var m = fec.getMonth() + 1;
	var mes = (m < 10) ? '0' + m : m;
	var ano=fec.getFullYear();
	fecha2=dia+"/" + mes+ "/"+ ano
	if (compare_dates(fecha1, fecha2)==false){  
		alert(msfecha);
  		return(false);  
	}
	valor=document.getElementById("noches").value
	if ( valor == null || valor.length == 0 || /^\s+$/.test(valor) || valor < 2 || valor > 365) {
		alert(msnoches)
		document.getElementById("noches").focus(); 
		document.getElementById("noches").select(); 
 		return(false);  
	}
	var ocupa = document.getElementById("ocupantes").value;
	if ( ocupa == null || ocupa.length == 0 || /^\s+$/.test(ocupa) || ocupa < 1 || ocupa > capacidadmax) {
		alert(mscapacidad)
		document.getElementById("ocupantes").focus(); 
		document.getElementById("ocupantes").select(); 
 		return(false);  
	}
	document.getElementById("areaEspera").style.visibility="visible";
	document.getElementsByTagName("html")[0].style.overflow = "hidden";
}

function compare_dates(fec1, fec2) { 
		var xMonth=parseInt(fec1.substring(3, 5),10);  
		var xDay=parseInt(fec1.substring(0, 2),10);  
		var xYear=parseInt(fec1.substring(6,10));  
		var yMonth=parseInt(fec2.substring(3, 5),10);  
		var yDay=parseInt(fec2.substring(0, 2),10);  
		var yYear=parseInt(fec2.substring(6,10));  
		if (xYear > yYear) { 
			//return(true)
			if ((xYear-yYear)>1) {
				return(false)
			}else {
				if (xMonth > yMonth) {
					return(false)
				}else {
					if (xDay >= yDay) {
						return(false)
					}else return(true)
				}
			}
		}  
		else  
		{  
		  if (xYear == yYear)  
		  {   
			if (xMonth > yMonth)  
			{  
				return(true)  
			}  
			else  
			{   
			  if (xMonth == yMonth)  
			  {  
				if (xDay > yDay)  
				  return(true);  
				else  
				  return(false);  
			  }  
			  else  
				return(false);  
			}  
		  }  
		  else  
			return(false);  
		}  
}  


