﻿
//loading
$(document).ready(function(){

// drop quantidade clientes /////////////////////////////////////////////////////////////////////////////////
    
    //abre o drop
    $(".bt_drop").click(function(){
        $(this).parent().find(".dropList").slideDown();
    });
    
    //fecha o drop
    $(".liDrop").hover(
        function(){
         
        }
        ,
        function(){
            $(this).find(".dropList").slideUp();
        }
    );
    
    // seleciona a quantidade
    $(".dropList a").click(function(){
        var qtd = $(this).html();
        $(this).parent().parent().next().attr("value" , qtd);
        $(this).parent().parent().parent().find(".bg_drop").attr("value" , qtd);        
        $(this).parent().parent().slideUp();
    })
    
// funcao do menu //////////////////////////////////////////////////////////////////////////////////////////    
    $("#nav_content .nav li > a").click(function(){
        var r = $(this).attr('rel');
        if (r != ''){
            $(".nav .ico_seta").fadeOut(380);
            $("#nav_content .nav .sub").slideUp(380);
            
            setTimeout(function() {
                $("#"+r).slideDown(380);
            } , 150);
            
            $(this).parent().find('.ico_seta').fadeIn();
        }    
    });
    
// banner home //////////////////////////////////////////////////////////////////////////////////////////        
    $('.link_carrosel .item_alpha').mouseover(
        function(){
            $('.main_home .link_carrosel').hide();
            $('.carrosel_content .close').fadeIn();
            
            $('.main_home .carrosel_content').animate({
            bottom: "0px"
          }, 500 );
        });       
    $('.carrosel_content .close a').click(         
        function(){
            $('.main_home .link_carrosel').fadeIn();
            $('.carrosel_content .close').fadeOut();
            $('.main_home .carrosel_content').animate({
            bottom: "-140px"
          }, 500 );
        }
    );
    
// sombra do menu comprimento IE6 //////////////////////////////////////////////////////////////////////////////////////////            
    
    if (typeof document.body.style.maxHeight == "undefined") {//if IE 6
        var ab = $('.main').height();
        $('.nav_bg_alpha').css('height' , ab+"px");
    }

    
    
    
    
// fim do loading //////////////////////////////////////////////////////////////////////////////////////////
})


// date picker
$(function()
{
	$('.date-pick').datePicker();
});

function marcaMenu (n,sn)
    {
        
        $(".nav > li:eq(" + n + ")").addClass('nav_atv');
        $(".nav > li:eq(" + n + ") > a").addClass('nav_atv_lk');
        if(sn != '-1'){
            $(".nav > li:eq(" + n + ") .nav_sub li:eq(" + sn + ")").addClass('sub_atv');
        }
        
    }   

function indicaNoticia(){
    document.getElementById("areaIndique").style.display="block";

}    

function popAmigo(url){
    window.open('../pop-up/pop_amigo.aspx?destino='+ url, '_blank', 'width=525,height=450,left=50,top=50,scrollbars=no,resizable=no,menubar=no,toolbar=no');
}

function impressao(){
	popimpressao = window.open('', '_blank', 'width=750,height=500,left=0,top=0,scrollbars=yes,resizable=no,menubar=no,toolbar=no');
	var d, s ;
	d = new Date();
	s =  d.getDate()+ ".";
	s += (d.getMonth() + 1) + ".";
	s += d.getFullYear();


	with (popimpressao.document) {
		write('<html><head><title>Imprime</title></head>');
		//write('<link href="../_css/print.css" rel="stylesheet" type="text/css">');
		write('<style type="text/css">');
		write('p {font-family:Arial; font-size: 12px;}');
		write('h3 {font-size:20px; color:#000; padding-bottom:10px; font-weight:normal; margin-left: -2px;}');
		write('.ocultaImprime{display:none};')
		write('.MT5 {margin-top: 5px;}')
		write('.T18 {font-size: 18px;}');
		write('.MB15 {margin-bottom: 15px;}');
		write('</style>');
		write('<body>');
		write('<div style="width:700px;margin:10px 0 0 20px; font-family:Arial; font-size: 12px;" >');
		//write(document.getElementById("areaTopo").innerHTML.replace("100%","720").replace("50%","350").replace("50%",""));
		//write('<div style="height: 1px; width: 690px; background-color:#CCC; display: block;" class="MT10 MB10"><!-- --></div>');
		write(document.getElementById("areaImprime").innerHTML.replace("bt_hotsite","pix"));
		write('</div>');
		write('<div class="clr MB10"></div><br><br>');		
		write('<table cellpadding="0" cellspacing="0" border="0" width="670" style="margin:0 0 0 10px;border-top:solid 1px #CCC;"><tr><td class="texto_preto T11"><p>&nbsp;&nbsp;&nbsp;&nbsp;<em>Data: ' + s + '<br>&nbsp;&nbsp;&nbsp;&nbsp;http://www.parquebalneario.com.br/</em></p></td></tr></table>');
		write('<br></body></html>');
		close();
		}
        popimpressao.print();
}

    
    
    
 // MASCARAS
/*
    onkeypress="mascara(this,soNumeros)"
    onkeypress="mascara(this,telefone)" maxlength="14"
    onkeypress="mascara(this,cpf)" maxlength="14"
    onkeypress="mascara(this,cep)" maxlength="9" 
*/

function mascara(o,f)
{
    v_obj=o
    v_fun=f
    setTimeout("execmascara()",1)
}

function execmascara()
{
    v_obj.value=v_fun(v_obj.value)
}

function soNumeros(v){
    v = v.replace(/\D/g,"")
    return v;
}
    
    
        // máscara de campos
    // uso: onkeypress="return formata(this, '###.###.###-##', event)"
    function FormataCampo(campo,evt,mask){
		 if(document.all) { // Internet Explorer
			key = evt.keyCode; }
			else{ // Nestcape
			   key = evt.which;
			 }

		if (key == 8) {
		return true;
		}

		 string = campo.value;  
		 i = string.length;

		 if (i < mask.length) {
		  if (mask.charAt(i) == '#') {
			   return (key > 47 && key < 58);
			  } else {
			   if (mask.charAt(i) == '!') {  return true;  }
		   for (c = i; c < mask.length; c++) {
				 if (mask.charAt(c) != '#' && mask.charAt(c) != '!')
				 campo.value = campo.value + mask.charAt(c);
			  else if (mask.charAt(c) == '!'){
						return true;
			   } else {
				 return (key > 47 && key < 58);
				  }
			   }
			}
		  } else return false;
    }


    //Adiciona todos os caracteres que podem ser usados como máscara
    function OrganizaCasa(Campo,arrpos,teclapres_key,strtext){
    if (((arrpos == "/") || (arrpos == ".") || (arrpos == ",") || (arrpos == ":") || (arrpos == " ") || (arrpos == "-")) && !(teclapres_key == 9)){
     separador = arrpos
     masktext = strtext + separador
     Campo.value = masktext
    }
    }
    function DetonaEvent(Campo,strtext){
    event.returnValue = false
    if (strtext != "") {
     Campo.value = strtext
    }
    }

	function limpaCampo(fild, limpa){
		DateValue = fild.value;
		if(DateValue==limpa){
			fild.value = "";
			DateValue = "";

		}
	}

    function check_date(field){
        var checkstr = "0123456789";
        var DateField = field;
        var Datevalue = "";
        var DateTemp = "";
        var seperator = "/";
        var day;
        var month;
        var year;
        var leap = 0;
        var err = 0;
        var i;
		var strDataMsg = "";

        err = 0;
        DateValue = DateField.value;
		
		
		//DateValue = DateValue.replace('dd/mm/aaaa','');

		//alert(DateValue.charAt(2));

		if (DateValue.charAt(2) != "/" || DateValue.charAt(5) != "/")
		{
			 err = 18;
			 strDataMsg = "Verifique o formato da data.";	
		}
		
		if(DateValue.length < 10){
			 err = 40;
			 strDataMsg = "A data informada é inválida.";	
		}

       /* Delete all chars except 0..9 */
       for (i = 0; i < DateValue.length; i++) {
          if (checkstr.indexOf(DateValue.substr(i,1)) >= 0) {
             DateTemp = DateTemp + DateValue.substr(i,1);
          }
       }
       DateValue = DateTemp;
       /* Always change date to 8 digits - string*/
       /* if year is entered as 2-digit / always assume 20xx */
       if (DateValue.length == 6) {
          DateValue = DateValue.substr(0,4) + '20' + DateValue.substr(4,2); }
       if (DateValue.length != 8) {
          err = 19;
		  strDataMsg = "A data informada é inválida.";		  
		}

       /* Validation of day*/
       day = DateValue.substr(0,2);
	   //alert(day);
       if ((day < 1) || (day > 31)) {
         err = 22;
		 strDataMsg = "o dia informado é inválido.";
       }		

		/* Validation of month*/
       month = DateValue.substr(2,2);
       if ((month < 1) || (month > 12)) {
          err = 21;
		  strDataMsg = "O mês informado é inválido.";
       }

       /* year is wrong if year = 0000 */
       year = DateValue.substr(4,4);
       if (year == 0) {
          err = 20;
		  strDataMsg = "O ano informado é inválido.";
       }

       /* Validation leap-year / february / day */
       if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0)) {
          leap = 1;
       }
       if ((month == 2) && (leap == 1) && (day > 29)) {
          err = 23;
		  strDataMsg = "O mês informado possui no máximo 29 dias.";
       }
       if ((month == 2) && (leap != 1) && (day > 28)) {
          err = 24;
		  strDataMsg = "O mês informado possui no máximo 28 dias.";
       }
       /* Validation of other months */
       if ((day > 31) && ((month == "01") || (month == "03") || (month == "05") || (month == "07") || (month == "08") || (month == "10") || (month == "12"))) {
          err = 25;
		  strDataMsg = "O mês informado possui no máximo 31 dias.";
       }
       if ((day > 30) && ((month == "04") || (month == "06") || (month == "09") || (month == "11"))) {
          err = 26;
		  strDataMsg = "O mês informado possui no máximo 30 dias.";
       }
       /* if 00 ist entered, no error, deleting the entry */
       if ((day == 0) && (month == 0) && (year == 00)) {
          err = 0; day = ""; month = ""; year = ""; seperator = "";
       }
       /* if no error, write the completed date to Input-Field (e.g. 13.12.2001) */
       if (err == 0) {
          //DateField.value = day + seperator + month + seperator + year;
          return true;
       }
       else {
          alert(strDataMsg);
		  DateField.value="";
          DateField.select();
          DateField.focus();
          return false;
       }
    }


	function Organiza_Casa(Campo,arrpos,teclapres_key,strtext){
        if (((arrpos == "/") || (arrpos == ".") || (arrpos == ",") || (arrpos == ":") || (arrpos == " ") || (arrpos == "-")) && !(teclapres_key == 9)){
            separador = arrpos
            masktext = strtext + separador
            Campo.value = masktext
        }
    }
    

function fadeHome(){
	var atual = document.getElementById("hddFotoAtual").value;
	var fecha = "";
	var abre = "";

	if(atual=="1"){
		$("#fotoHome1").fadeOut(1000);
		document.getElementById("fotoHome1").style.display = "none";
		$("#fotoHome2").fadeIn(1000);
		document.getElementById("hddFotoAtual").value = "2";

		setTimeout("fadeHome()",8000)
	}

	if(atual=="2"){
		$("#fotoHome2").fadeOut(1000);
		document.getElementById("fotoHome2").style.display = "none";
		$("#fotoHome3").fadeIn(1000);
		document.getElementById("hddFotoAtual").value = "3";

		setTimeout("fadeHome()",8000)
	}

	if(atual=="3"){
		$("#fotoHome3").fadeOut(1000);
		document.getElementById("fotoHome3").style.display = "none";
		$("#fotoHome1").fadeIn(1000);
		document.getElementById("hddFotoAtual").value = "1";

		setTimeout("fadeHome()",8000)
	}
}

function fadeLazer(){
	var atual = document.getElementById("hddFotoAtual").value;
	var fecha = "";
	var abre = "";

	if(atual=="1"){
		$("#fotoHome1").fadeOut(1000);
		document.getElementById("fotoHome1").style.display = "none";
		$("#fotoHome2").fadeIn(1000);
		document.getElementById("hddFotoAtual").value = "2";

		setTimeout("fadeLazer()",8000)
	}

	if(atual=="2"){
		$("#fotoHome2").fadeOut(1000);
		document.getElementById("fotoHome2").style.display = "none";
		$("#fotoHome1").fadeIn(1000);
		document.getElementById("hddFotoAtual").value = "1";

		setTimeout("fadeLazer()",8000)
	}
}



function reserva(){
	var url = "https://booking.ihotelier.com/istay/istay.jsp?hotelid=72868&languageid=4&locale=PT";
	var data = document.getElementById("date1").value;
	var noites = document.getElementById("noites").value;
	var adultos = document.getElementById("hddAdultos").value;
	var criancas = document.getElementById("hddCriancas").value;

	if(noites==""){
		noites = "1";
	}

	if(criancas==""){
		criancas = "0";
	}

	if(adultos==""){
		adultos = "1";
	}


	//var date = '26/02/2009';
	if(data !=""){
		var elem = data.split('/');

		day = elem[0];
		month = elem[1];
		year = elem[2];
		data = month + "/" + day + "/"+year;
	}
	url = url + "&DateIn="+data+"&Adults="+adultos+"&Length="+noites+"&Children="+criancas;
	window.open(url);
	//https://booking.ihotelier.com/istay/istay.jsp?hotelid=72868&languageid=4&locale=PT&DateIn=10/24/2009&Adults=2&Length=5


}


function reservaLink(){
	var url = "https://booking.ihotelier.com/istay/istay.jsp?hotelid=72868&languageid=4&locale=PT";
	window.open(url);

}

function menuGastronomia(atual){
    document.getElementById("areaGastro1").style.display = "none";
    document.getElementById("areaGastro2").style.display = "none";
    document.getElementById("areaGastro3").style.display = "none";
    document.getElementById("areaGastro4").style.display = "none";
    
    document.getElementById("link_bar1").src = "../_img/link_bar1.gif";
    document.getElementById("link_bar2").src = "../_img/link_bar2.gif";
    document.getElementById("link_bar3").src = "../_img/link_bar3.gif";
    document.getElementById("link_bar4").src = "../_img/link_bar4.gif";
    
    document.getElementById("areaGastro"+ atual).style.display = "block";
    document.getElementById("link_bar"+ atual).src = "../_img/link_bar"+atual+"A.gif";
    
    
}