﻿$(document).ready(function() {
    $(".slideshow").cycle({ 
        fx:    'fade', 
        speed:  4500,
        containerResize: 1,
        height: 136,
        width: 311,
        fit: 1
    });
    
    $(".business_slideshow").cycle({ 
        fx:    'fade', 
        speed:  2000,
        containerResize: 1,
        height: 246,
        width: 328,
        fit: 1
    });


    $(".imageSwitch").click(function() {
        $("#dynamicImage").attr({ src: this.id });
    });
    $(".imageSwitch").click(showCaption);
    $(".topicLink").click(showTopic);
    $("a.remote_get").click(showRemote); 
    hideAllTopics();
});

function hideAllTopics() {
    $(".topic").hide();
    $(".caption").hide();
}

function showCaption(event) {
    $(".defaultTopic").hide();
    hideAllTopics();
    var id = "#" + $(this).attr("title");
    $(id).show();
    event.preventDefault();
}

function showTopic(event) {
   $(".defaultTopic").hide();
   hideAllTopics();
   var id = "#" + $(this).attr("name");
   $(id).show();
   event.preventDefault();
}

var remote_visible = false;
function showRemote(event){
    if (!remote_visible){
        var page = $(this).attr("href");
        $(this).addClass("current");
        $.get(page, function(data){
            var html = $("#page_right", data).html();
            $("#page_right").children().hide();
            $("#page_right").append('<div id="remote">' + html + '</div>');

            var calendar = $("#remote .calendar");
            if (calendar != null){
                $(calendar).append('<p style="text-align: center; font-weight: bold;">Click on any Month to expand the list of events.</p>');
                var uls = $("#remote h3.month_name").next();
                $(uls).hide();
                $("#remote h3.month_name").toggle(function(){
                    $(this).next().slideDown();
                }, function(){
                    $(this).next().slideUp();
                });

                $("#remote h3.month_name").hover(function(){
                    $(this).css('cursor', 'pointer');
                });
            }
        });

        remote_visible = true;
    }else{
        $("#remote").remove();
        $("#page_right").children().show();
        $(".current").removeClass("current");
        remote_visible = false;
    }
    event.preventDefault();
}

function hideRight() {
   $("#page_left").css({"width": "570px", "padding-left": "82px", "padding-right" : "0"});
   $("#page_right").css({"display": "none", "width" : "0", "padding-right" : "0"});
}

