/*function click() {
if (event.button==2||event.button==3) {
 oncontextmenu='return false';
  }
}
document.onmousedown=click
document.oncontextmenu = new Function("return false;")
*/

function sair() {
	if(confirm('Deseja Sair da Sua Área-Reservada?')){ return true; }
	return false;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' terá que ser válido.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+': formato errado.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' é necessário.\n'; }
  } if (errors) alert('ERRO:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function BloqueiaLetras(evento)
{
var tecla;

if(window.event) { // Internet Explorer
  tecla = event.keyCode;
}
else { // Firefox
  tecla = evento.which;
} 

    if(tecla >= 48 && tecla <= 57 || tecla == 8) return true;
   return false;
}


// função datahora
function takeYear(theDate)
{
	x = theDate.getYear();
	var y = x % 100;
	y += (y < 38) ? 2000 : 1900;
	return y;
}
function dataExtenso() {
now = new Date()
dia = now.getDate()
mes = now.getMonth() + 1
ano = now.getYear()
if (dia < 10)
dia = "0" + dia
if (mes < 10)
mes = "0" + mes
if (ano < 2000)
ano = "19" + ano
document.write(dia+"-" +mes+ "-" +ano)
}
function diaExtenso(d){
	var dia=new Array();
	dia[0]="Domingo";dia[1]="Segunda-feira";dia[2]="Terça-feira";
	dia[3]="Quarta-feira";dia[4]="Quinta-feira";dia[5]="Sexta-feira";
	dia[6]="Sábado";
	return dia[d];
}
function mesExtenso(m){
	var mes=new Array();
	mes[0]="Jan";mes[1]="Fev";mes[2]="Mar";mes[3]="Abr";
	mes[4]="Mai";mes[5]="Jun";mes[6]="Jul";mes[7]="Ago";
	mes[8]="Set";mes[9]="Out";mes[10]="Nov";mes[11]="Dez";
	return mes[m];
}
function ShowDataHora(){
	var Digital=new Date()
	var horas=Digital.getHours();
	var minutos=Digital.getMinutes();
	var segundos=Digital.getSeconds();
	var diaSemana=Digital.getDay();
	var dia=Digital.getDate();
	var mes=Digital.getMonth();
	var ano = takeYear(Digital);
	if (dia<=9) dia="0"+dia;
	if (minutos<=9) minutos="0"+minutos;
	if (segundos<=9) segundos="0"+segundos;
	relogio=diaExtenso(diaSemana)+", "
	relogio=relogio + dia + mesExtenso(mes) + ano
	//relogio=relogio + horas +":" + minutos + ":" + segundos
	if (document.layers) {
		document.layers.datahora.document.write(relogio)
		document.layers.datahora.document.close()
	}
	else 
		if (document.all||document.getElementById)
			document.getElementById("datahora").innerHTML=relogio; //funciona para ie6,NS6 e ie5+
	setTimeout("ShowDataHora()",1000)
}

// fim funcao datahora

function SetCookie(cookieName,cookieValue,nDays) {
 var today = new Date();
 var expire = new Date();
// if (nDays==null || nDays==0) nDays=1;
 expire.setTime(today.getTime() + 3600000*24*nDays);
 document.cookie = cookieName+"="+escape(cookieValue)
                 + ";expires="+expire.toGMTString();
}

function ReadCookie(cookieName) {
 var theCookie=""+document.cookie;
 var ind=theCookie.indexOf(cookieName);
 if (ind==-1 || cookieName=="") return ""; 
 var ind1=theCookie.indexOf(';',ind);
 if (ind1==-1) ind1=theCookie.length; 
 return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
}

//jquery
/*
$(function(){
      $("#carrega").hide();
      
         $("ul#ulM a").click(function(){
            pagina = $(this).attr('href');			            
			
            $("#carrega").ajaxStart(function(){
               $(this).show()			   
               })
            $("#carrega").ajaxStop(function(){
               $(this).hide();
               
            })
            
            $("#mostraConteudo").load(pagina);			
            return false;
         })
		 
		 $("form#formReservas").click(function(){
            pagina = $(this).attr('action');			            
			
            $("#carrega").ajaxStart(function(){
               $(this).show()			   
               })
            $("#carrega").ajaxStop(function(){
               $(this).hide();			   
			
			//$.post("reservas.php", $("#formReservas").serialize());

			$.post("reservas.php",{diaIni:diaIni, mesIni:mesIni, diaFim:diaFim, mesFim:mesFim, pessoas:pessoas, quartos:quartos},
				function(retorno){
				  $('.loading').fadeOut();
				  $('#resposta').html(retorno).fadeIn();
				  $('#form-contato').fadeTo("slow", 1);  
				  $('#resposta').fadeOut(3000);
			  })					
			
               
            })
            $.post("reservas.php", $("#formReservas").serialize());
            $("#mostraConteudo").load(pagina);			
            return false;
         })
})*/

function abrirPag(url){

req = null;

	if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		
		if (req) {
		req.onreadystatechange = processReqChange;
		req.open("GET",url,true);
		req.send();
		}
	}
	
	else if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = processReqChange;
		req.open("GET",url,true);
		req.send(null);	
	} 
}

function processReqChange()
{
	if (req.readyState == 1) {
		document.getElementById('mostraConteudo').innerHTML = "<img src='images/loaderMeio.gif'>";
	}


	else if (req.readyState == 4) {

		if (req.status==200) {
			document.getElementById('mostraConteudo').innerHTML = req.responseText;
		} else {
			alert("Houve um problema ao obter os dados:n" + req.statusText);
		}
	}
}
