//jQuery
(function($){
    $(document).ready( function(){
        var extend = function() {
            if( $('#content').height() > $('#menuleft').height() ){
                var bigHeight = $('#content').height();
            }
            else{
                var bigHeight = $('#menuleft').height(); 
            }
            $('#footer').css('top', bigHeight + $('#animatie').height() +50).css('visibility', 'visible');
            $('#contentwrap .height').css('height', bigHeight + $('#animatie').height() + 100);
            //$('#menuleft').children().filter(':gt(1)').hide(); //hides all elements in the menu which are lower then the login (which is 1 since the menu is 0)
        }        
        extend();
        //We redo this function after a short interval because $('#content').height() is not always correct on intital readystate
        setTimeout(extend, 1000);
        /*--------------------------------------- uncomment this when you want to give the AJAX submenus another chance
        //We add click handlers to the menu to load the submenu (this is potentially very slow)
        $('.menu li:not(".menu li ul li")').click( function(e){
            $this = $(this);
            $('.submenu, #current li').remove(); //remove old submenus
            $('#current').attr('id', '');//remove element with old current ID
            $this
                .addClass('active') //add the stuff that Joomla normally adds to active lis
                .attr('id', 'current');
            var pageUrl = $this.children('a').attr('href');
            var containerDiv = $('<div />').addClass('submenu');
            //preform AJAX request;
            if(!$this.data('submenu')){
                $.ajax({
                    type: 'GET',
                    url: pageUrl,
                    succes: function(html){
                        var insertHTML = $(html).find('#current ul');
                        containerDiv.html(insertHTML);
                        $this.data('submenu', insertHTML);
                    }
                });
            }
            else{
                containerDiv.html( $this.data('submenu') );
            }
            $this.append(containerDiv);
            return false;
        });----------------------------------------------------*/
    });
})(jQuery);