$(document).ready(function() {
    setupTemplate();
    $(window).bind("resize", setupTemplate);

    $(".hoverTab").bind("mouseover", function(evt) {
        var imgSrc = $("img", $(evt.currentTarget)).attr("src");
        if (imgSrc.indexOf("hover") == -1) {
            $("img", $(evt.currentTarget)).attr("src", imgSrc.replace(".png", "_hover.png"));
        }
    });
    $(".hoverTab").bind("mouseout", function(evt) {
        var imgSrc = $("img", $(evt.currentTarget)).attr("src");
        if (imgSrc.indexOf("hover") != -1) {
            $("img", $(evt.currentTarget)).attr("src", imgSrc.replace("_hover.png", ".png"));
        }
    });
});

function setupTemplate() {
    var targetHeight = $(window).height() - 254;
    var contentHeight = $("#main_left").height();
    
    if (targetHeight >= contentHeight ) {
	$("#main_full_width").height(targetHeight);
        $("#main").height(targetHeight);
        $("#main_left").height(targetHeight);
    }
    else {
	$("#main_full_width").height(contentHeight);
        $("#main").height(contentHeight);
        $("#main_left").height(contentHeight);
        $("html").css("overflow", "auto");
    }
}
