﻿$(document).ready(function () {
    //hide all splash subpanels
    $("div.subPanel").css("display", "block").hide();
    //apply corners
    $("div#splash > ul a, div#splash > div#display").corner("4px");
    //add the dots into the markup
    $("div#splash > ul li").prepend("<div class='dot'><img src='Images/splash_nav_dec.png' alt='' /></div>");
    //set the height of the columns
    //attach the function to switch visual states for the splash nav
    $("div#splash > ul li a").hover(
        function () {
            //add class to change background
            $(this).addClass("active");
            //change the dot
            img = $(this).parent().find("div.dot img");
            oldfilename = img.attr("src");
            insertIndex = oldfilename.lastIndexOf(".png");
            img.attr("src", oldfilename.substring(0, insertIndex) + "_active.png");
            //change text image
            var img = $(this).find("img");
            var oldfilename = img.attr("src");
            var insertIndex = oldfilename.lastIndexOf(".png");
            img.attr("src", oldfilename.substring(0, insertIndex) + "_active.png");
            //toggle visible panel
            $("div#display_inner > div").hide();
            panelid = $(this).attr("id").substring(0, $(this).attr("id").lastIndexOf("_lnk"));
            $("div#" + panelid).show();
        },
        function () {
            //remove class to change background
            $(this).removeClass("active");
            //change the dot
            var img = $(this).parent().find("div.dot img");
            var oldfilename = img.attr("src");
            var removeIndex = oldfilename.lastIndexOf("_active.png");
            img.attr("src", oldfilename.substring(0, removeIndex) + ".png");
            //change text image
            var img = $(this).find("img");
            var oldfilename = img.attr("src");
            var removeIndex = oldfilename.lastIndexOf("_active.png");
            img.attr("src", oldfilename.substring(0, removeIndex) + ".png");
            //toggle visible panel
            $("div#display_inner > div").hide();
            $("div#panel_0").show();
        }
    );
    $("div#splash > ul li a").click(function () {
        return false;
    });
});
