<!-- FUNCOES PARA CONTROLAR OS DESTAQUES DA HOME - index.php -->

function sw_abrir(elem)

{

	document.getElementById(elem).style.display = '';

}

function sw_fechar(prefixo, qtde)

{

	for(i=0;i<qtde;i++)

	{

	  var elem = prefixo.concat(i);

	  document.getElementById(elem).style.display = 'none';

	}

}



<!--FUNCOES PARA CONTROLAR AS ABAS - EM DETALHES DE HOTEIS hotel_detalhe.php -->

function sw_abrirGuia(elem1, elem2)

{

	document.getElementById(elem1).style.display = '';

	document.getElementById(elem2).className = 'menuDetailActive';

}

function sw_fecharGuia(prefixo1, qtde1, prefixo2, qtde2)

{

	for(i=0;i<qtde1;i++)

	{

	  var elem = prefixo1.concat(i);

	  document.getElementById(elem).style.display = 'none';

	}

	

	for(i=0;i<qtde2;i++)

	{

	  var elem2 = prefixo2.concat(i);

	  document.getElementById(elem2).className = 'menuDetail';

	}

}



<!--funcao para a parte de compra de produto-->

function abre_combo_quartos(elem)

{

	var prefixo = "q";

	for(i=1;i<=4;i++)

	{

		var elem2 = prefixo.concat(i);

		if(i <= elem) document.getElementById(elem2).style.display = 'block';

		else document.getElementById(elem2).style.display = 'none';

		

	}

	return true;

}



function openPopUp(URL, NAME, OPTIONS) {

  window.open(URL, NAME, OPTIONS)

}



//FUNCOES PRA FORMATAR DADOS

function txtBoxFormat(objeto, sMask, evtKeyPress) {

    var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;

    if(document.all) { // Internet Explorer

      nTecla = evtKeyPress.keyCode;

    } else if(document.layers) { // Nestcape

      nTecla = evtKeyPress.which;

    } else {

      nTecla = evtKeyPress.which;

      if (nTecla == 8) {

          return true;

      }

    }



    sValue = objeto.value;



    // Limpa todos os caracteres de formatação que

    // já estiverem no campo.

    sValue = sValue.toString().replace( "-", "" );

    sValue = sValue.toString().replace( "-", "" );

    sValue = sValue.toString().replace( ".", "" );

    sValue = sValue.toString().replace( ".", "" );

    sValue = sValue.toString().replace( "/", "" );

    sValue = sValue.toString().replace( "/", "" );

    sValue = sValue.toString().replace( ":", "" );

    sValue = sValue.toString().replace( ":", "" );

    sValue = sValue.toString().replace( "(", "" );

    sValue = sValue.toString().replace( "(", "" );

    sValue = sValue.toString().replace( ")", "" );

    sValue = sValue.toString().replace( ")", "" );

    sValue = sValue.toString().replace( " ", "" );

    sValue = sValue.toString().replace( " ", "" );

    fldLen = sValue.length;

    mskLen = sMask.length;



    i = 0;

    nCount = 0;

    sCod = "";

    mskLen = fldLen;



    while (i <= mskLen) {

      bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/") || (sMask.charAt(i) == ":"))

      bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " "))



      if (bolMask) {

        sCod += sMask.charAt(i);

        mskLen++; }

      else {

        sCod += sValue.charAt(nCount);

        nCount++;

      }



      i++;

    }



    objeto.value = sCod;



    if (nTecla != 8) { // backspace

      if (sMask.charAt(i-1) == "9") { // apenas números...

        return ((nTecla > 47) && (nTecla < 58)); } 

      else { // qualquer caracter...

        return true;

      } 

    }

    else {

      return true;

    }

}



//Funcao pra checar formularios

function ValidaEmail(sEmail) {

  var regex=/^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;

  return regex.test(sEmail);

}



function ValidaPedido(theForm){

  if (theForm.pnome.value=="") {

    alert("Informe seu nome.");

    theForm.pnome.focus();

    return(false);

  }

  if (theForm.pcpf.value==""){

    alert("Informe seu CPF.");

    theForm.pcpf.focus();

    return(false);

  }

  if (theForm.pemail.value==""){

    alert("Informe seu e-mail.");

    theForm.pemail.focus();

    return(false);

  }

  if (theForm.ptelefone.value==""){

    alert("Informe seu telefone.");

    theForm.ptelefone.focus();

    return(false);

  }

  if (!ValidaEmail(theForm.pemail.value)){

    alert("E-mail digitado inválido.");

    theForm.pemail.focus();

    return(false);

  }

  theForm.submit();

}

//funcao exclusiva dos pacotes

function ValidaFormPacotes(theFormPacotes){
	
//validacao de radio buttons sem saber quantos sao
	marcado = -1
	for (i=0; i<theFormPacotes.cdinvest.length; i++) {
		if (theFormPacotes.cdinvest[i].checked) {
			marcado = i
			resposta = theFormPacotes.cdinvest[i].value
		}
	}
	if (marcado == -1) {
    alert("Escolha a cidade da Lookal mais próxima de você.\nSão Paulo ou Belo Horizonte");
		return false;
	} 
if (theFormPacotes.nome.value=="") {

    alert("Informe seu nome.");

    theFormPacotes.nome.focus();

    return(false);

  }

  if (theFormPacotes.email.value==""){

    alert("Informe seu e-mail.");

    theFormPacotes.email.focus();

    return(false);

  }

  if (!ValidaEmail(theFormPacotes.email.value)){

    alert("E-mail digitado inválido.");

    theFormPacotes.email.focus();

    return(false);

  }

  if (theFormPacotes.telefone.value==""){

    alert("Informe seu telefone.");

    theFormPacotes.telefone.focus();

    return(false);

  }

  if (theFormPacotes.cidade.value==""){

    alert("Informe sua cidade.");

    theFormPacotes.cidade.focus();

    return(false);

  }

  if (theFormPacotes.estado.value==""){

    alert("Informe seu estado.");

    //theFormPacotes.estado.focus();

    return(false);

  }

  if (theFormPacotes.nascimento.value!=""){

    var resposta = VerificaData(theFormPacotes.nascimento.value, "", "nascimento");

    if(resposta == false) { theFormPacotes.nascimento.focus(); return(false); }

  }

  return true;

}

function ValidaFaleConosco(theForm){

  if (theForm.remetente.value=="") {

    alert("Informe seu nome.");

    theForm.remetente.focus();

    return(false);

  }

  if (theForm.email_remetente.value==""){

    alert("Informe seu e-mail.");

    theForm.email_remetente.focus();

    return(false);

  }

  if (theForm.assunto.value==""){

    alert("Informe um assunto.");

    theForm.assunto.focus();

    return(false);

  }

  if (theForm.mensagem.value==""){

    alert("Digite sua mensagem.");

    theForm.mensagem.focus();

    return(false);

  }

  if (!ValidaEmail(theForm.email_remetente.value)){

    alert("E-mail inválido.");

    theForm.email_remetente.focus();

    return(false);

  }

  return true;

}



function ValidaThisForm(theForm){

  if (theForm.nome.value=="") {

    alert("Informe seu nome.");

    theForm.nome.focus();

    return(false);

  }

  if (theForm.email.value==""){

    alert("Informe seu e-mail.");

    theForm.email.focus();

    return(false);

  }

  if (!ValidaEmail(theForm.email.value)){

    alert("E-mail digitado inválido.");

    theForm.email.focus();

    return(false);

  }

  if (theForm.telefone.value==""){

    alert("Informe seu telefone.");

    theForm.telefone.focus();

    return(false);

  }

  if (theForm.cidade.value==""){

    alert("Informe sua cidade.");

    theForm.cidade.focus();

    return(false);

  }

  if (theForm.estado.value==""){

    alert("Informe seu estado.");

    //theForm.estado.focus();

    return(false);

  }

  if (theForm.nascimento.value!=""){

    var resposta = VerificaData(theForm.nascimento.value, "", "nascimento");

    if(resposta == false) { theForm.nascimento.focus(); return(false); }

  }

  return true;

}



function LimitaTexto(CampoTexto,MaxChars,iIdioma){

//Limita a quantidade de caracteres de CampoTexto a MaxChars

  if(CampoTexto.value.length>MaxChars){

    CampoTexto.value=CampoTexto.value.substring(0,MaxChars);

    if(iIdioma==0)alert('Este campo pode conter até '+MaxChars+' caracteres.');

    else if(iIdioma==1)alert('Maximum capacity is '+MaxChars+' characters.');

    else if(iIdioma==2)alert('Este campo puede contener hasta '+MaxChars+' caracteres.');

    else if(iIdioma==3)alert('Este campo pode conter até '+MaxChars+' caracteres.');

    CampoTexto.focus();

    }

}



function VerificaData(digData, idform, idcampo) 

{

    var bissexto = 0;

    var data = digData; 

    var tam = data.length;

    if (tam == 10) 

    {

        var dia = data.substr(0,2)

        var mes = data.substr(3,2)

        var ano = data.substr(6,4)

        if ((ano > 1900)||(ano < 2100))

        {

            switch (mes) 

            {

                case '01':

                case '03':

                case '05':

                case '07':

                case '08':

                case '10':

                case '12':

                    if  (dia <= 31) 

                    {

                        return true;

                    }

                    break

                

                case '04':        

                case '06':

                case '09':

                case '11':

                    if  (dia <= 30) 

                    {

                        return true;

                    }

                    break

                case '02':

                    /* Validando ano Bissexto / fevereiro / dia */ 

                    if ((ano % 4 == 0) || (ano % 100 == 0) || (ano % 400 == 0)) 

                    { 

                        bissexto = 1; 

                    } 

                    if ((bissexto == 1) && (dia <= 29)) 

                    { 

                        return true;                 

                    } 

                    if ((bissexto != 1) && (dia <= 28)) 

                    { 

                        return true; 

                    }            

                    break                        

            }

        }

    }

    else if(tam == 0) return true; 

    alert("A Data "+data+" é inválida!");

    document.getElementById(idcampo).value = "";

    return false;

}


