﻿var noFlash = false;

// Load widgets after flash has been loaded. This function must be triggered through Flash.
function loadWidgets() {
    $("div.widgets").css("display", "block");
//    $("div.widgets").load("widgets.jsp");
}

function resizeWindow() {

    var browserWidth = $(window).width();
    var browserHeight = $(window).height();

    // Hide third column on small screens
    if (browserWidth <= 1338) {
        $("div.widgets").addClass("twoColumns")
        $("div.widgets").removeClass("threeColumns");
    }
    else {
        $("div.widgets").addClass("threeColumns")
        $("div.widgets").removeClass("twoColumns")
    }

    // Set flash height
    $("div.flash").attr("class", "flash");
    if (browserHeight <= 500) {
        // -50 added to show a portion of the widget bar
        $("div.flash").css("height", 450 + "px");
    } else if (browserHeight <= 870){
        $("div.flash").css("height", browserHeight - 50 + "px");
    } else {
        $("div.flash").css("height", browserHeight - 233 + "px");
    }
    return false;
}

$(document).ready(function() {
    resizeWindow();
})

function addBindings() {
    
    resizeWindow();

    // Hide all but the first panel
    $("div.widgets div.information ul.menuBar li:first").addClass("selected");
    $("div.widgets div.information > div").each(function(divCount) {
        if (divCount > 0) {
            $(this).addClass("hidden");
        }
    })

    // Bind menuBar click event
    $("div.widgets div.information ul.menuBar li a").each(function(aCount) {
        $(this).click(function() {
            showInformationPanel(aCount);
            return false;
        })
    })

    // Show the indicated panel and hide the others
    function showInformationPanel(panel) {
        $("div.widgets div.information ul.menuBar li").each(function(liCount) {
            if (liCount == panel) {
                $(this).addClass("selected");
            }
            else {
                $(this).removeClass("selected");
            }
        })
        $("div.widgets div.information > div").each(function(divCount) {
            if (divCount == panel) {
                $(this).removeClass("hidden");
            }
            else {
                $(this).addClass("hidden");
            }
        })
        return false;
    }

}

    $(window).bind("resize", function() {
        resizeWindow();
        return false;
    })