$(function () {
    $("a.new-window").click(function () {
        var width = 900;
        var height = 700;
        if (window.screen) {
            width = screen.availWidth;
            height = screen.availHeight;
        }

        window.open($(this).attr("href"), "popup", "width=" + width + ",height=" + height + ",modal=yes,alwaysRaised=yes");
        return false;
    });

    function open_accordion_item(accordion_link) {
        var child = accordion_link.parent().find(".accordion_child");

        if (accordion_link.hasClass("accordion_open")) {
            child.slideUp("slow", function () {
                accordion_link.removeClass("accordion_open");
            });
        } else {
            child.slideDown("slow", function () {
                accordion_link.addClass("accordion_open");
            });
        }
    }

    $("a.month-title").live("click", function () {   
        open_accordion_item($(this));
        
        return false;
    });

    $('#toggle-slideshow').click(function() {
        galleries[0].slideshow.toggle();
        return false;
    });

    var first_accordion_link = $("a.month-title:first");
    open_accordion_item(first_accordion_link);

     $("#clickEvent").bind('search', function () {
        var tabs = $(".has-results").find("a.month-title");
        $.each(tabs, function(i, tab) {
            open_accordion_item($(tab));
        });
    });

    $('.slideshow p').cycle({
        fx: 'fade'
    });

    var galleries = $('.ad-gallery').adGallery();
    $('#switch-effect').change(
      function() {
        galleries[0].settings.effect = $(this).val();
        return false;
      }
    );
    $('#toggle-slideshow').click(
      function() {
        galleries[0].slideshow.toggle();
        return false;
      }
    );
       
    $("#interactive-map").fancybox({
        'width': 990,
        'height': 700,
        'autoScale': false,
        'transitionIn': 'none',
        'transitionOut': 'none',
        'type': 'iframe'
    });

//    $("#hospitality-video").fancybox({
//        'width': 370,
//        'height': 255,
//        'autoScale': false,
//        'transitionIn': 'none',
//        'transitionOut': 'none',
//        'type': 'iframe'
//    });


    $("#hospitality-video").click(function () {
        $.fancybox({
            'padding': 0,
            'autoScale': false,
            'transitionIn': 'none',
            'transitionOut': 'none',
            'title': this.title,
            'width': 680,
            'height': 495,
            'href': this.href.replace(new RegExp("watch\\?v=", "i"), 'v/') + '&autoplay=1',
            'type': 'swf',
            'swf': {
                'wmode': 'transparent',
                'allowfullscreen': 'true'
            }
        });

        return false;
    });

});
