
	function validaForm(){
		//validar nome
		d = document.reservas;
		if (d.quarto_tipo.value == "" || d.entrada.value =="" || d.saida.value =="" || d.num_criancas.value =="" || d.num_adultos.value =="")
		{
			alert("Todos os campos são obrigatórios.");
			
			return false;
		}
		
	}
	
	//calendarios..........................................................................
	//$('quarto_tipo').observe('click', respondToClick);

	function SetDataEntrada(valor) { 
		document.reservas.saida.value = "";
	    document.reservas.entrada.value=valor;
		//document.getElementById('PopCalendarEntrada').style.visibility = 'hidden';
		abreDivsaida("PopCalendarSaida");
	}
	
	
	function SetDataSaida(valor) { 
	    document.reservas.saida.value=valor; 
		fechaDiv("PopCalendarSaida");
	}

	function fechaDiv(Thisdiv)
    {
        divstyle = document.getElementById(Thisdiv).style.visibility;
        document.getElementById(Thisdiv).style.visibility = "hidden";
    }
	
	function abreDiv(Thisdiv)
    {
        divstyle = document.getElementById(Thisdiv).style.visibility;
        document.getElementById(Thisdiv).style.visibility = "visible";
    }
	
	function highlightCalendarCell(element) {
		$(element).style.border = '1px solid #999999';
	}

	function resetCalendarCell(element, color) {
		$(element).style.border = '1px solid #000000';
	}
	
//valmir
 
function Div_load(thisDiv){
	//alterar propiedade de load pra todos
	//carregando = '<div id="fechar"><img onclick="fechaDiv("'+thisDiv+')" src="img/fechar-calendario_pt.gif"></div><br><br>Aguarde... <img src="../img/ajax-loader-calendario.gif" title="aguarde">';	
	
		carregando = '<div id="fechar"><a href="#" title="Fechar" onclick="fechaDiv("'+thisDiv+')">Fechar</a></div><br><br>Carregando...';	
		divcalen = document.getElementById(thisDiv);
		divcalen.innerHTML = carregando;
}
 
 	
//	abreDivsaida	
	function abreDivsaida(Thisdiv)
    {
		data = document.reservas.saida.value;

		if(data == ""){
			data = document.reservas.entrada.value;
		}else{
			document.reservas.saida.value= "";
			divstyle = document.getElementById(Thisdiv).style.visibility;
        	document.getElementById(Thisdiv).style.visibility = "visible";
			document.getElementById('PopCalendarEntrada').style.visibility = 'hidden';
			return;
		
		}
		
		if(data == ""){
			month_s = 0;
			year_s = 0;
			dia_s = 0;
		}else{
			month_s = (data.substring(3,5));
			year_s = (data.substring(6,10));
			dia_s = (data.substring(0,2));
		}
		
		
			Div_load('calendarSaida');
			
			divstyle = document.getElementById(Thisdiv).style.visibility;
        	document.getElementById(Thisdiv).style.visibility = "visible";
			document.getElementById('PopCalendarEntrada').style.visibility = 'hidden';
			
			new Ajax.Updater('calendarSaida', 'calendario_disp_saida.php', {method: 'post', postBody: 'action=startCalendarSaida&dia='+dia_s+'&month_s='+month_s+'&year_s='+year_s+'&id='+document.getElementById("quarto_tipo").value+''});
		      
		
    }


//abreDiventrada 
	function abreDiventrada(Thisdiv)
    {
		dataent = document.reservas.entrada.value;

		if(dataent != ""){
//			document.reservas.entrada.value = "";
			divstyle = document.getElementById(Thisdiv).style.visibility;
        	document.getElementById(Thisdiv).style.visibility = "visible";
			document.getElementById('PopCalendarSaida').style.visibility = 'hidden';
			return;
		}
		
		Div_load('calendarEntrada');
		divstyle = document.getElementById(Thisdiv).style.visibility;
		document.getElementById(Thisdiv).style.visibility = "visible";
		document.getElementById('PopCalendarSaida').style.visibility = 'hidden';
		
		if(dataent == ""){
			month = 0;
			year = 0;
		}else{
			month = (dataent.substring(3,5));
			year = (dataent.substring(6,10));
		}
	
		startCalendar(month, year);
		
    }


	function startCalendar(month, year) {
		//var quartoid = $(quarto_tipo).getValue();
		//document.getElementById("quarto_tipo").value;
		Div_load('calendarEntrada');	
		new Ajax.Updater('calendarEntrada', 'calendario_disp_entrada.php', {method: 'post', postBody: 'action=startCalendar&month='+month+'&year='+year+'&id='+document.getElementById("quarto_tipo").value+''});
	}
	
	function startCalendarSaida(month_s, year_s) {
		Div_load('calendarSaida');
//		new Ajax.Updater('calendarSaida', 'calendario_disp_saida-valmir.php', {method: 'post', postBody: 'action=startCalendarSaida&month_s='+month_s+'&year_s='+year_s+'&id='+document.getElementById("quarto_tipo").value+''});
			new Ajax.Updater('calendarSaida', 'calendario_disp_saida.php', {method: 'post', postBody: 'action=startCalendarSaida&dia='+dia_s+'&month_s='+month_s+'&year_s='+year_s+'&id='+document.getElementById("quarto_tipo").value+''});
	}

	
	

