function isNum(event){
  var Key = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
  if(Key==8 || Key==13 || Key==127 || (Key >= 48 && Key <=57)) return true;
  else return false;
}


function checkMail(mail){
    var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
    if(typeof(mail) == "string") {
        if(er.test(mail)) { return true; }
	}
	else if(typeof(mail) == "object") {
		if(er.test(mail.value)) { return true; }
	}
    else {
        return false;
    }
}


function validar_login() {
	if(document.getElementById('t_login').value=='') {
		alert('O campo e-mail é obrigatório!');
		document.getElementById("t_login").focus();
		return false;
	}
	if(!checkMail(document.getElementById('t_login').value)) {
		alert('O seu e-mail é inválido. Tente novamente!');
		document.getElementById("t_login").focus();	
		return false;
	}
	/*if(document.getElementById('rb_primeira').checked==false && document.getElementById('rb_cadastrado').checked==false){
	    alert('Escolha uma das duas opções!');
	    return false;
	}*/
	if(document.getElementById('t_senha_cadastrado').value=='') {
		alert('O campo senha é obrigatório!');
		document.getElementById("t_senha_cadastrado").focus();
		return false;
	}
//    if (document.getElementById("t_senha_cadastrado").value.length < 5) {
//		alert('A sua senha é inválida. Tente novamente!');
//		document.getElementById("t_senha").focus();
//		return false;
//	}															
	return true;				
}

function validar_lembrar_senha() {
	if(document.getElementById('t_email').value=='') {
		alert('O campo e-mail é obrigatório!');
		document.getElementById("t_email").focus();
		return false;
	}	
	if(!checkMail(document.getElementById('t_email').value)) {
		alert('O e-mail é inválido. Tente novamente!');
		document.getElementById("t_email").focus();	
		return false;
	}														
	return true;				
}


function validar_cadastro_03() {
    if (document.getElementById('t_email').value == '') {
 //       alert('O campo e-mail é obrigatório!');
        document.getElementById("t_email").focus();
        return false;

    }
    else if (!checkMail(document.getElementById('t_email').value)) {
   //     alert('O e-mail informado é inválido. Tente novamente!');
        document.getElementById("t_email").focus();
        return false;

    } else {
    return true;
    }
}


function validar_cadastro_01() {

    if (document.getElementById('t_nome').value == '' || document.getElementById('t_nome').value == 'Nome') {
        alert('O campo nome é obrigatório!');
        document.getElementById("t_nome").focus();
        return false;
    }
    if (document.getElementById('t_senha').value == '' || document.getElementById('t_senha').value == 'senha') {
		alert('O campo senha é obrigatório!');
		document.getElementById("t_senha").focus();
		return false;
	}
	if(document.getElementById("t_senha").value.length<6) {
		alert('A sua senha deve possuir no mínimo 6 dígitos!');
		document.getElementById("t_senha").focus();
		return false;
	}
	if(document.getElementById("t_senha_confirmacao").value != document.getElementById("t_senha").value) {
		alert('A cofirmação da sua senha está incorreta!');
		document.getElementById("t_senha_confirmacao").focus();
		return false;
	}
    if (document.getElementById('t_data_nascimento').value == '' || document.getElementById('t_data_nascimento').value == 'data de nascimento') {
		alert('O campo data de nascimento é obrigatório!');
		document.getElementById("t_data_nascimento").focus();
		return false;
	}
    if (document.getElementById('t_telefone').value == '' || document.getElementById('t_telefone').value == 'telefone') {
		alert('O campo telefone é obrigatório!');
		document.getElementById("t_telefone").focus();
		return false;
    }

    if (document.getElementById('t_estado').value == '' || document.getElementById('t_estado').value == '0') {
            alert('Selecione seu estado!');
            document.getElementById("t_estado").focus();
            return false;
    }
    	
	return true;
}

function validar_cadastro_02() {
    if(document.getElementById('t_nome').value=='') {
		alert('O campo nome é obrigatório!');
		document.getElementById("t_nome").focus();
		return false;
	}
	if(document.getElementById('t_nascimento').value=='') {
		alert('O campo data de nascimento é obrigatório!');
		document.getElementById("t_nascimento").focus();
		return false;
	}	
	if(document.getElementById('t_telefone').value=='') {
		alert('O campo telefone é obrigatório!');
		document.getElementById("t_telefone").focus();
		return false;
	}															
	return true;				
}

function validar_senha() {
	if(document.getElementById('t_senha_atual').value=='') {
		alert('O campo senha atual é obrigatório!');
		document.getElementById("t_senha_atual").focus();
		return false;
	}
	if(document.getElementById('t_senha_nova').value=='') {
		alert('O campo senha nova é obrigatório!');
		document.getElementById("t_senha_nova").focus();
		return false;
	}	
	if(document.getElementById("t_senha_nova").value.length<6) {
		alert('A sua senha nova deve possuir no mínimo 6 dígitos!');
		document.getElementById("t_senha_nova").focus();
		return false;
	}
	if(document.getElementById("t_senha_confirmacao").value != document.getElementById("t_senha_nova").value) {
		alert('A cofirmação da sua senha está incorreta!');
		document.getElementById("t_senha_confirmacao").focus();
		return false;
	}	
	return true;
}

function validar_contato() {
    if(document.getElementById('t_nome').value=='Nome') {
		alert('O campo nome é obrigatório!');
		document.getElementById("t_nome").focus();
		return false;
	}
	if(document.getElementById('t_email').value=='E-mail') {
		alert('O campo e-mail é obrigatório!');
		document.getElementById("t_email").focus();
		return false;
	}
	if(!checkMail(document.getElementById('t_email').value)) {
		alert('E-mail inválido. Tente novamente!');
		document.getElementById("t_email").focus();	
		return false;
	}
	if(document.getElementById('t_mensagem').value=='Mensagem') {
		alert('O campo mensagem é obrigatório!');
		document.getElementById("t_mensagem").focus();
		return false;
	}
	return true;
}


function validar_termo_compromisso() {
    if(!document.getElementById("t_termo_compromisso").checked) {
		alert('Confirme da leitura do termo de compromisso!');
		return false;
	}
	return true;				
}

function validar_forma_pagamento() {
    var pagamento_selecionado = false;
    if(document.getElementById("t_opcao_pagamento_boleto") != null) {
        if(document.getElementById("t_opcao_pagamento_boleto").checked) {
		    pagamento_selecionado = true;
		}
	}
    if(document.getElementById("t_opcao_pagamento_deposito") != null) {
        if(document.getElementById("t_opcao_pagamento_deposito").checked) {
		    pagamento_selecionado = true;
		}
	}
    if(document.getElementById("t_opcao_pagamento_visa") != null) {
        if(document.getElementById("t_opcao_pagamento_visa").checked) {
		    pagamento_selecionado = true;
		}
    }
    if (document.getElementById("t_opcao_pagamento_cielo") != null) {
        if (document.getElementById("t_opcao_pagamento_cielo").checked) {
            pagamento_selecionado = true;
        }
    }
    if(document.getElementById("t_opcao_pagamento_mastercard") != null) {
        if(document.getElementById("t_opcao_pagamento_mastercard").checked) {
		    pagamento_selecionado = true;
		}
	}			
    if(document.getElementById("t_opcao_pagamento_amex") != null) {
        if(document.getElementById("t_opcao_pagamento_amex").checked) {
		    pagamento_selecionado = true;
		}
	}
	if(pagamento_selecionado == false) {
		alert('Selecione uma forma de pagamento!');
        return false;	
	}
	return true;				
}

function launch_cardapio() {
    unique = dounique();
    eval("page" + unique + " = window.open('cardapio.aspx', '" + unique + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=770,height=600');");
}

function launch_faq() {
    unique = dounique();
    newwin = window.open("faq.aspx",unique,"toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=770,height=500");
    newwin.focus();
}

function launch_support() {
    unique = dounique();
    newwin = window.open("http://www.vipsmotel.com.br/chat/request.php?l=tracocerto&x=1&deptid=1", unique, "scrollbars=no,menubar=no,resizable=0,location=no,screenX=50,screenY=100,width=450,height=360");
    newwin.focus();
}

function launch_360(suite,unidade) {
    unique = dounique();
    newwin = window.open("unidade_360.aspx?sid=" + suite + "&uid=" + unidade,unique,"toolbar=0,scrollbars=no,statusbar=0,menubar=no,resizable=0,location=no,screenX=50,screenY=100,width=720,height=564");
    newwin.focus();    
}

function launch_suite_millenium(link) {
    unique = dounique();
    newwin = window.open(link,unique,"toolbar=0,scrollbars=no,statusbar=0,menubar=no,resizable=1,location=no,screenX=0,screenY=0,width=800,height=600");
    newwin.focus();    
}

function launch_voucher(reserva) {
    unique = dounique();
    newwin = window.open("imprimir_voucher.aspx?rid=" + reserva,unique,"toolbar=0,scrollbars=no,statusbar=0,menubar=no,resizable=0,location=no,screenX=50,screenY=100,width=720,height=480");
    newwin.focus();    
}

function launch_recibo(reserva) {
    unique = dounique();
    newwin = window.open("imprimir_recibo.aspx?rid=" + reserva,unique,"toolbar=0,scrollbars=yes,statusbar=0,menubar=no,resizable=0,location=no,screenX=50,screenY=100,width=720,height=480");
    newwin.focus();    
}

function launch_boleto(url_boleto) {
    unique = dounique();
    newwin = window.open(url_boleto,unique,"menubar,scrollbars,resizable,screenX=50,screenY=100,width=680,height=400");
    newwin.focus();
}

function launch_termo_compromisso() {
    unique = dounique();
    newwin = window.open("termo_compromisso.aspx",unique,"toolbar=0,statusbar=0,menubar=0,scrollbars=1,resizable=0,location=0,screenX=50,screenY=100,width=600,height=600");
    newwin.focus();
}

function dounique() { var date = new Date(); return date.getTime(); }

function unidBloqueada(){
    alert("Unidade temporariamente indisponivel para reserva. Tente outra unidade!");
    return false;
}

function fechar_banner() {
    var div_banner_noiva = document.getElementById("div_banner_noiva");
    div_banner_noiva.style.display = 'none';
}
