$(document).ready(function(){

    var helpPage = "/help/viewhelp.action";

    $("a.getHelp").click(function(e){
        if (requestURI == null || requestURI == ""){
            $("#help").load(helpPage,{helpItemUrl:"home"},function(){
                $("#fogger").css({"opacity": "0.7"}).fadeIn("fast");
                $("#help").fadeIn("fast");
                $("#helpButtons").fadeIn("fast");
                return false;
            });
        }
        else{
            $("#help").load(helpPage,{helpItemUrl:requestURI},function(){
                $("#fogger").css({"opacity": "0.7"}).fadeIn("fast");
                $("#help").fadeIn("fast");
                $("#helpButtons").fadeIn("fast");
                return false;
            });
        }
        
        
        $("#fogger").css({"opacity": "0.7"}).fadeIn("fast");
        $("#help").html("Can't find help, sorry!").fadeIn("fast");
        $("#helpButtons").fadeIn("fast");
        return false;
    });

    $("#fogger").click(function(){
        $("#fogger").fadeOut("fast");
        $("#help").fadeOut("fast");
        $("#helpButtons").fadeOut("fast");
        return false;
    })
    
    $("#help").click(function(e){
        if ($(e.target).attr("id") == "help"){
            $("#fogger").fadeOut("fast");
            $("#help").fadeOut("fast");
            $("#helpButtons").fadeOut("fast");
            return false;
        }
    })
    
    $("#helpButtons").click(function(){
        $("#fogger").fadeOut("fast");
        $("#help").fadeOut("fast");
        $("#helpButtons").fadeOut("fast");
        return false;
    });
});

