﻿

$(document).ready(function(){
    $("#BodyContent IMG[align='right']").addClass("right_aligned");
    
    
    //generic rollover
    $(".img_over").hover(
        function()
        {
            var ext = getExtension($(this).attr("src"));
            $(this).attr("src", "/userfiles/image/" + $(this).attr("id") + "_over." + ext);
        },
        function()
        {
            var ext = getExtension($(this).attr("src"));
            $(this).attr("src", "/userfiles/image/" + $(this).attr("id") + "_off." + ext);
        }
    );



});

var counterArray = new Array();
var timerArray = new Array();

function getExtension(in_path)
{
    return in_path.substring(in_path.lastIndexOf(".") + 1, in_path.length);
}


function initArrays(in_item)
{
    if(counterArray[in_item] == null)
    {
        counterArray[in_item] = 0;
        timerArray[in_item] = "";
    }
}

function showSubNav(img_item, in_sub)
{
    initArrays(img_item);
    counterArray[img_item] -= -1;
    clearTimeout(timerArray[img_item]);
    if($(in_sub).is(":hidden"))
    {
        var ext = getExtension($(img_item).attr("src"));
        $(img_item).attr("src", "/userfiles/image/" + $(img_item).attr("id") + "_over." + ext);
        $(in_sub).animate({height: "toggle", opacity: ".93"}, 400);
    }
}

function hideSubNav(img_item, in_sub)
{
    initArrays(img_item);
    counterArray[img_item] -= 1;
    if(counterArray[img_item] == 0)
    {
        timerArray[img_item] = setTimeout("finalizeHide('" + img_item + "', '" + in_sub + "')", 200);
    }
}

function finalizeHide(img_item, in_sub)
{

    if($(in_sub).is(":visible") && counterArray[img_item] == 0)
    {
        var ext = getExtension($(img_item).attr("src"));
        $(img_item).attr("src", "/userfiles/image/" + $(img_item).attr("id") + "_off." + ext);
        $(in_sub).animate({height: "toggle", opacity: "0"}, 400);
    }
}



