﻿$(document).ready(function () {

    // MASCARA INPUTS
    var txt = null;
    var txt2 = null;
    $(".mascara").focus(function () {
        txt = $(this).attr("value");
        txt2 = $(this).attr("title"); // Title no componente .net é o paramento ToolTip
        if (txt == txt2) {
            $(this).attr("value", "");
        }
    });
    // lista comparacao tamanho 
    var tul = 0
    $('.listItem > li , .listItemBigContent > li, .promocoesContent > ul > li').each(function () {
        var tv = $(this).height();

        if (tul <= tv) {
            tul = tv;
        }
    });
    $('.listItem > li, .listItemBigContent > li , .promocoesContent > ul > li').css('height', tul);

    var tul = 0
    $('.listItem2 > li').each(function () {
        var tv = $(this).height();

        if (tul <= tv) {
            tul = tv;
        }
    });
    $('.listItem2 > li').css('height', tul);


    $('.subNav').hover(
        function () {
            $('.subNavItem').animate({ opacity: ['toggle', 'swing'], "top": "-=30px" }, 300);
        },
        function () {
            $('.subNavItem').animate({ opacity: ['toggle', 'swing'], "top": "+=30px" }, 300);
        }
    );

    $('.linguagens .dropFlag ').hover(
        function () {
            $('.linguagens .dropFlag ul').animate({height: 'show'});
        },
        function () {
            $('.linguagens .dropFlag ul').animate({ height: 'hide' });
        }
    );


    // lista comparacao tamanho 

    // ABRE MAPA
    $('.ver_mapa').click(function () {

        $(this).parent().parent().parent().find(".mapa").slideToggle();
    });

    // LINK CARROSEL 
    $('.jcarousel-skin a').click(function () {
        var vlr = '' + $(this).attr('rel'); +'" alt="" />';
        $('.areaMultimidia .area img').attr('src', vlr);
    });


    $("#btnAssinarNewsletter").click(function () {
        $("#news").slideToggle("medium");
        $("#redes_sociais").slideUp("medium")

        return false;
    });


    $("#btnCompartilhar").click(function () {
        $("#redes_sociais").slideToggle("medium");
        $("#news").slideUp("medium")

        return false;
    });

    $("#btnFoto").click(function () {
        $("#areaFoto").slideDown("medium");
        $("#btnFoto").hide("fast")

        return false;
    });

    //MODAL
    $(document).ready(function () {

        $('a[name=modal]').click(function (e) {
            e.preventDefault();

            var id = $(this).attr('href');

            var maskHeight = $(document).height();
            var maskWidth = $(window).width();

            $('#mask').css({ 'width': maskWidth, 'height': maskHeight });

            $('#mask').fadeIn(200);
            $('#mask').fadeTo("fast", 0.5);

            //Get the window height and width
            var winH = $(window).height();
            var winW = $(window).width();

            $(id).css('top', winH / 2 - $(id).height() / 2);
            $(id).css('left', winW / 2 - $(id).width() / 2);

            $(id).fadeIn(500);




        });

        $('.modal .close').click(function (e) {
            e.preventDefault();

            $('#mask').hide();
            $('.modal').hide();
        });

        $('#mask').click(function () {
            $(this).hide();
            $('.modal').hide();
        });
    });



    // fim do loading
});

// ABRE O 1 ITEM DO CARROSEL
function abre1 (){
    var vlr = $('#carrousel li:first a').attr('rel');
    $('.areaMultimidia .area img').attr('src', vlr );
}
// marca nav
function nav(obj){
    $('.navTop li:eq('+obj+')').addClass('atv');
}

// marca sub nav
function subnav(obj){
    $('.nav li:eq('+obj+')').addClass('atv');
}


function popUp(URL) {
    window.open(URL, 'janela', 'width=600, height=500, top=200, left=200, scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');
    //return false;
}
function popUpVideo(URL) {
    window.open(URL, 'janela', 'width=380, height=450, top=200, left=200, scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');
    //return false;
}

function valorCombo(campo, valor){
    document.getElementById(campo).value = valor;
}

function slideDown(obj){
    $('#' + obj).slideDown("medium");
}

function slideUp(obj){
    $('#' + obj).slideUp("medium");
}

function limpaCampo(obj){
    document.getElementById(obj).value = "";
}

function preencheCampo(obj){
    document.getElementById(obj).value = "&nbsp;";
}

function mesPromo(mes, nome){
    document.location.href = "default.aspx?mes="+ mes+"&nomeMes="+ nome;
}

function hotelPromo(hotel, nome) {
    document.location.href = "default.aspx?NumHotel=" + hotel + "&nome=" + nome;
}



function buscaEvento(){   
    var caminho = document.getElementById("hddCaminhoHotel").value;
    var numHotel = document.getElementById("hddNumDestinoBusca").value;
    var tipo = document.getElementById("hddNumTipoEvento").value;
    if(numHotel!=""){
        document.location.href = "http://www.hoteismabu.com.br/br/" + caminho + "/" + numHotel + "/eventos.aspx?tipo=" + tipo
    }else{
        alert('Selecione um destino!')
    }
}

function buscaCM(){
    //alert('A');
    //alert(document.getElementById("busca_reserva_hddBook").value)
    var URL = "";
	try
	{
	    URL = document.getElementById("boxBusca_hddBook").value;
		URL = URL + "?start-date="+ document.getElementById("boxBusca_date1").value;
        URL = URL + "&end-date="+ document.getElementById("boxBusca_date2").value;
	}
	catch(err)
	 {
	    URL = document.getElementById("ctl00_box_busca_hddBook").value;
        URL = URL + "?start-date="+ document.getElementById("ctl00_box_busca_date1").value;
        URL = URL + "&end-date="+ document.getElementById("ctl00_box_busca_date2").value;
	 }
	         
    URL = URL + "&adultos="+ document.getElementById("hddAdultos").value;
    URL = URL + "&criancas="+ document.getElementById("hddCriancas").value;
    //URL = URL + "&CodHotel="+ document.getElementById("hddNumHotelBusca").value;
    URL = URL + "&codCidade="+ document.getElementById("codCidade").value;
    //alert(URL);
    
    document.location.href = URL;
    
    //window.open(URL);
}

		function fecha(){
			document.getElementById('floatingBanner').style.display = 'none';
			
	
		}

$('#LangItens li').mouseover(function(){
   $(this).parent().find('li').addClass('hover');   
});
$('#LangItens li').mouseout(function(){
   $(this).parent().find('li').removeClass('hover');

});


/* 2011 */
function showHide (){

    $('.btFotos').click(function () {

        var _t = $(this), _e = _t.parents('.boxInfo').next(), _g = _e.find('.jcarousel-skin');
        _e.animate({ height: 'toggle' })
        //alert(_g.attr('class'))
        if(!_e.hasClass('fA')){
            _e.addClass('fA');
           _g.jcarousel({
            scroll: 1
            });
        }
    })

}

