﻿$(document).ready(function() {

    // ################ Rotatives Setup's - Begin ################

    $('.cm-slideshow .rotative').cycle({
        fx: 'fade',
        timeout: 10000,
        prev: '.leftNav',
        next: '.rightNav'
    });

    $('.optDesc .left, #boxes').cycle({
        fx: 'fade',
        timeout: 5000,
        speed: 1000,
        startingSlide: 3
    });

    $('.optDesc .right div').cycle({
        fx: 'fade',
        timeout: 5000
    });

    $('.wrapper .content .bannerWrap .packs .options').cycle({
        fx: 'fade',
        timeout: 5000,
        speed: 1000,
        pager: '.wrapper .content .bannerWrap .packs .controls div',
        prev: '.wrapper .content .bannerWrap .packs .controls img.left',
        next: '.wrapper .content .bannerWrap .packs .controls img.right'
    });

    $('.wrapper .content .intro .right div').cycle({
        fx: 'fade',
        timeout: 5000,
        speed: 1000
    });

    // ################ Rotatives Setup's - End ################
    // ################ Rotatives Handlers & Events - Begin ################

    $('#sOpt_1, #sOpt_2, #sOpt_3, #sOpt_4').mouseover(cycleOverHandler);
    $('#mPack_1, #mPack_2, #mPack_3, #mPack_4').mouseover(cycleOverHandler);

    // ################ Rotatives Handlers & Events - End ################
    // ################ PROMOS - Handlers - Begin ################

    $("#infoPromos .infoPromoBG, #infoPromos .infoPromoWrap .btnClose").click(function() {
        $("#infoPromos").fadeOut("fast");
    });

    $(".promo.special .btnLink").click(function() {
        $("#infoPromos").fadeIn("fast");
        //alert("Hola");
        return false;
    });

    // ################ PROMOS - Handlers End ################
    // ################ GALLERIES Handlers - Begin ################

    //$(".cancunGallery, .ixtapaGallery, .pVallartaGallery, .cdJuarezGallery").click(handlerGalleries);
    $(".gallery a").click(handlerGalleries);
    
    // ################ GALLERIES Handlers - End ################

});

// ################ Rotatives Handlers & Events ##################
function cycleOverHandler() {
    var splitOptions = $(this).attr("id").split("_");
    var idContainer;

    switch (splitOptions[0]) {
        case "sOpt":
            idContainer = ".optDesc .left";
            break;

        case "mPack":
            idContainer = "#boxes";
            break;
    }

    $(idContainer).cycle(parseInt(splitOptions[1]) - 1);
    return false;
}

function handlerGalleries() {
    var windowFeatures;
    var hrefLink = $(this).attr("href");
    var ruteTotal = "http://" + location.host;
    
    ruteTotal += hrefLink;
    windowFeatures = "toolbar=no,";
    windowFeatures += "location=no,";
    windowFeatures += "directories=no,"
    windowFeatures += "status=no,";
    windowFeatures += "menubar=no,";
    windowFeatures += "scrollbars=no,";
    windowFeatures += "resizable=no,";
    //windowFeatures += ($(this).attr("id") == "bookLink") ? "width=718, height:682," : "height=1000, height=570,";
    //windowFeatures += "width=718,";
    //windowFeatures += "height=682,";
    windowFeatures += "width=820,";
    windowFeatures += "height=600,";
    windowFeatures += "left=200,";
    windowFeatures += "top=100";

    window.open(ruteTotal, "Galerias-Krystal", windowFeatures);
    //alert(ruteTotal);
    return false;
}
