$(document).ready(function(){

    
    var openDropdown = function() {     
        $(this).css({'background' : '#FBBB6E url(images/topnav_active.png) repeat-x'}); //Add background color and image on hovered list item
        $(this).find("span").show(); //Show the subnav
    };

    var closeDropdown = function() {
        $(this).css({'background' : 'none'}); //Ditch the background
        $(this).find("span").hide(); //Hide the subnav
    };

    var hoverConfig = {
        over: openDropdown,
        interval: 0,
        timeout: 200,
        out: closeDropdown,
    };

    $('#topnav li').hoverIntent(hoverConfig);


    /* Navbar */
    // $("ul#topnav li").hover(function() { //Hover over event on list item
    //        $(this).css({'background' : '#FBBB6E url(images/topnav_active.png) repeat-x'}); //Add background color and image on hovered list item
    //        $(this).find("span").show(); //Show the subnav
    //    } , function() { //on hover out...
    //        $(this).css({'background' : 'none'}); //Ditch the background
    //        $(this).find("span").hide(); //Hide the subnav
    //    });

    /* Corner */
    $(".round, #topnav").corner();
    $(".first").corner("left");
    $(".round_bt").corner("bottom");
    $("ul#topnav li span").corner("bottom");

    /* Jobs */     
    $("ul#jobs-list li a").each(function() {
        var url = this.href;
        var match = url.split("\#");
        var module = "#" + match[1];
        $(module).hide();
        $(this).click(function() {
            var current_state = $(module).attr("rel");
            
            $("div[rel='panel-active']").toggle();
            $("div[rel='panel-active']").removeAttr("rel");

            if (current_state == "panel-active") {
                $(module).removeAttr("rel");
                $(module).hide();
            } else {
                $(module).attr("rel", "panel-active");
                $(module).toggle();
            }
            return false;
        });
    });    
});

