                
/* load images from array */
$.preloadImages = function(){
    for(var i = 0; i<arguments.length; i++){
        $("<img />").attr("src", arguments[i]);
    }
}
/* array of images to load */
$.preloadImages("/images/tab_top_dark.gif",
                "/images/tab_top_light.gif",
                "/images/tab_bottom_dark.gif",
                "/images/tab_bottom_light.gif");

$(document).ready(function() {
        
    $("a[rel=external]").attr('target', '_blank');

    /* image swap for the main menu */
    $(function() {
        $("#primeNav img").hover(function() {
            if(!$(this).hasClass("active")){
                $(this).attr("src", $(this).attr("src").split(".").join("-hover."));
            }
        }, function() {
            if(!$(this).hasClass("active")){
                $(this).attr("src", $(this).attr("src").split("-hover.").join("."));
            }
        });
    });
    
    /* image swap for the next button */
    $(function() {
        $("#nextButton").hover(function() {
                $(this).attr("src", $(this).attr("src").split(".").join("-hover."));
        }, function() {
                $(this).attr("src", $(this).attr("src").split("-hover.").join("."));
        });
    });
    
    /* image swap for the more button */
    $(function() {
        $("#moreButtonLight").hover(function() {
                $(this).attr("src", $(this).attr("src").split(".").join("-hover."));
        }, function() {
                $(this).attr("src", $(this).attr("src").split("-hover.").join("."));
        });
        $("#moreButtonDark").hover(function() {
                $(this).attr("src", $(this).attr("src").split(".").join("-hover."));
        }, function() {
                $(this).attr("src", $(this).attr("src").split("-hover.").join("."));
        });
    });
    
    /* add arrows for the sub-menu */
    $(function() {
        $("#nav_sub li").hover(function() {
            if(!$(this).hasClass("here")){
                $('a', this).css("text-decoration","underline");
                $(this).append('<span style="font-weight:bold;"> &gt; </span>');
            }
        }, function() {
            if(!$(this).hasClass("here")){
                $('a', this).css("text-decoration","none");
                $(this).find('span').remove();
            }
        });
    });

    /* image swap for the main menu */
    $(function() {
        $("#iTabPro").click(function() {
            $('#indexProfessionals').show();
            $('#indexPractices').hide();
            $('#indexTab').attr('src','/images/tab_top_light.gif');
            $('#indexTabBottom').attr('src','/images/tab_bottom_light.gif');
        });
    });
    
    /* image swap for the main menu */
    $(function() {
        $("#iTabPrac").click(function() {
            $('#indexProfessionals').hide();
            $('#indexPractices').show();
            $('#indexTab').attr('src','/images/tab_top_dark.gif');
            $('#indexTabBottom').attr('src','/images/tab_bottom_dark.gif');
        });
    });
    
    /* set active page image in primeNav */
    if($('body').attr('id') != "index"){
        var menuItem = "#nav_" +$('body').attr('id');
        $(menuItem).attr("src", $(menuItem).attr("src").split(".").join("-active."));
        $(menuItem).addClass("active");
    }
    $(".here a").append("<span> &gt; </span>");

});