jQuery.noConflict();
(function($){
    //Setup content-wrapper shadow
    $('#content-wrapper').append('<div id="shadow"></div>');

    //Setup integrated search
    if ( $('#search').css('display') != 'none' ) {
        $('#search').hide();
        $('#toolbar > ul:first').append('<li id="search-link"><a href="' + base_url + '" title="Search">Search</a></li>');
        $('#search-link a').click(function() {
            $('#search').slideToggle('fast',function() {
                if ( $('#search').css('display') == 'block' ) {
                    $('#search input.text:first').focus();
                }
            });
            return false;
        });
    }

    //Enable prettyPhoto
    $('a[rel~="prettyPhoto"]').prettyPhoto();

    //Cleanup logo
    if ( $('#logo a:first').html() == '' ) {
        $('#logo').remove();
    }

    //Cleanup page header
    if ( $('#breadcrumbs').size() == 0 && $('#page-title').css('display') == 'none' ) {
        $('#content-header').css('margin','0px');
    }

    //Setup sidebar
    var sidebarHeight = $('#sidebar').height();
    var contentHeight = $('#content').height();
    if( contentHeight < sidebarHeight ) {
        if ( $.browser.msie && parseFloat($.browser.version) < 7.0 ) {
            $('#content').height(sidebarHeight-60);
        } else {
            $('#content').css('minHeight',(sidebarHeight - 60)+'px'); //Subtract top 10px border and 50px top/bott padding
        }
    }

    //Setup dropdowns
    $('#toolbar ul ul li:has(ul) > a').addClass('parent');

    //IE6 menu
    if ( $.browser.msie && parseFloat($.browser.version) < 7.0 ) {
        $('#toolbar ul li').hover(
            function(){
                $('ul:first',this).show();
            },
            function(){
                $('ul:first',this).hide();
            }
        );
    }
})(jQuery);
