$(document).ready(function() {
    
    // nav mouseover
    $("#nav > li, #faq span.question").hover(function() {
        $(this).addClass("hover");
    }, function() {
        $(this).removeClass("hover");
    });
    
    // faq entry expansion
    $("#faq span.question").toggle(function() {
        $(this).addClass("opened").next().slideDown();
    }, function() {
        $(this).removeClass("opened").next().slideUp();
    });
    
    // print now
    if(window.location.search.indexOf("Print=true") != -1)
    {
        $("head link").each(function(){
            if( ($(this).attr("id")).indexOf("PrintCSS") != -1 )
                $(this).attr("rel", "stylesheet");
        });
        window.print();
    }
    
    // print
    $(".toolbar .print a").attr("href","#").click(function(){
    
        var end = (window.location.href.indexOf("#") <= 0) ? window.location.href.length : window.location.href.indexOf("#");

        var link = window.location.href.substring(0, end);

        link += (window.location.search.indexOf("?") == -1) ? "?Print=true" : "&Print=true";

        if(window.location.hash.indexOf("#") == -1)
            link += "#";

        link += window.location.hash;

        window.open(link, window.name, "menubar=1,resizable=1,width=740&height=480,scrollbars=1");

        return false;
        
    });
    
});