﻿$(document).ready(function() {
    $('.rotative').cycle({
        fx: 'fade',
        timeout: 5000,
        next: '.next',
        prev: '.prev'
    });

    // HANDLER -> Options -> Little Extras
    $(".wrapper .mainCont .contenedor .info .exposedOptions a").click(handlerOpt);

    // HANDLER -> Tour Virtual
    $(".wrapper .mainCont .mainImg .header .topmenu .subMenu.gallery p a").click(newWindow);

    // HANDLER -> Gallery -> Paraiso de la Bonita
    $('.rotative.gallery').cycle({
        fx: 'fade',
        timeout: 5000
    });

    $(".wrapper .mainCont .contenedor .dockImg .pieces img").mouseover(function() { $(this).addClass("active"); });
    $(".wrapper .mainCont .contenedor .dockImg .pieces img").mouseout(function() { $(this).removeClass("active"); });
    $(".wrapper .mainCont .contenedor .dockImg .pieces img").click(handlerImgSelected);
    $(".wrapper .mainCont .contenedor .dockImg .pieces").cycle({
        fx: 'scrollRight',
        timeout: 0,
        next: '.wrapper .mainCont .contenedor .dockImg .leftNav',
        prev: '.wrapper .mainCont .contenedor .dockImg .rightNav'
    });

    // HANDLER -> Paquete de Bodas.
    $(".weddingPacks .tabs a").click(weddingPackOpt);

    // HANDLER -> Usuario de agencia.
    $(".wrapper .mainCont .agency #firstWellcome .top .caption img").click(show2Wellcome);
    $(".wrapper .mainCont .agency #secondWellcome img.moreBtn").click(show1Wellcome);
});

/* HANDLER -> Options -> Little Extras */            
function handlerOpt() {
    var idName = $(this).attr("id").split("_")[0];
    
    if ($(".wrapper .mainCont .contenedor .info .option").hasClass("exposed")) {
        $(".wrapper .mainCont .contenedor .info .option").removeClass("exposed");
    }

    $(".wrapper .mainCont .contenedor .info ." + idName).addClass("exposed");
    
    return false;
}

/* HANDLER -> Gallery -> Paraiso de la Bonita */
function handlerImgSelected() {
    var indexImg = parseInt($(this).attr("id").substring(2) - 1);
    //alert(indexImg);
    $('.rotative.gallery').cycle(indexImg);
    //return false;            
}

//HANDLER -> Nuevas Ventanas.
function newWindow() {
    var features = "toolbar=no,";
    features += "location=no,";
    features += "directories=no,"
    features += "status=no,";
    features += "menubar=no,";
    features += "scrollbars=no,";
    features += "resizable=no,";
    features += "width=700,";
    features += "height=450,";
    features += "left=200,";
    features += "top=100";
    
    window.open($(this).attr("href"), "", features);
    //alert("Hola");
    return false;
}

// HANDLER -> Paquete de Bodas.
function weddingPackOpt() {
    var idSelected = $(this).attr("id").split("_")[0] + "_pack";

    $(".weddingPacks .tabs a").removeClass("active");
    $(this).addClass("active");
    $(".weddingPacks .content > div").hide();
    $(".weddingPacks .content #" + idSelected).show();
}

// HANDLER -> Usuario de agencia.
function show2Wellcome() {
    $(".wrapper .mainCont .agency #firstWellcome").slideUp("fast");
    $(".wrapper .mainCont .agency #secondWellcome").slideDown("slow");
}

function show1Wellcome() {
    $(".wrapper .mainCont .agency #secondWellcome").slideUp("fast");
    $(".wrapper .mainCont .agency #firstWellcome").slideDown("slow");
}
