﻿var selectedButtton;
$(document).ready(function() {
    //activate selected
    if (selectedButton == undefined || selectedButton == null) {
        selectedButton = "home";
    }
    $('#menu a').mouseenter(function() {
        //reset any events
        resetAll();
        //activate selection
        $(this).parent().css('background', 'url(/includes/images/btn-mid.png) repeat-x');
        $(this).parent().prev().append('<img src="/includes/images/btn-start.jpg" />');
        $(this).parent().next().append('<img src="/includes/images/btn-end.png" />');
        //show sub menu
        $('#sm-' + getKey(this)).css('display', 'block');
    });
    $('#navigation').mouseleave(function() {
        //reset all
        resetAll();
        //show active item
        $('#tm-' + selectedButton).trigger('mouseenter');
    });
    $('#tm-' + selectedButton).trigger('mouseenter');
});
function resetAll() {
    $('#menu td img').remove();
    $('#menu td').each(function() {
        $(this).css({ 'background-image': 'none' });
    });
    //hide all sub menus
    $('#sub-menu ul').each(function() {
        $(this).css('display', 'none');
    });
}
function getKey(item) {
    return $(item).attr('id').substring(3);
}