$(function(){
    $("#accordion").show().accordion({
        header: "h3",
        autoHeight: false,
        active: false
    });

    $("#accordion > h3 > span").click(function(){
        return false;
    });

    $("#accordion > div > ul > li > a").each(function(){
        if (endsWith(location.href, $(this).attr('href'))){
            $(this).parentsUntil('.level-3').prev().click();
        }
    });

    $('.notused').unbind('click');

    $(".headerhref").unbind('click').click(function(){
        location.href = $(this).attr('href');
        return false;
    });

    //hover states on the static widgets
    $('#dialog_link, ul#icons li').hover(
        function() {
            $(this).addClass('ui-state-hover');
        },
        function() {
            $(this).removeClass('ui-state-hover');
        });
});

function endsWith(testString, endingString){
    if(endingString.length > testString.length) return false;
    return testString.indexOf(endingString)==(testString.length-endingString.length);
}
