﻿$(function(){
    Layout();
    setTimeout("LateBound();",200);
    $(window).resize(function(){Layout();});
    $(document).bind('AjaxLoaded',function(){Layout();});
});

function LateBound()
{
    Layout();
    $('.ui-accordion').bind('accordionchange', function(){Layout();});
}


function Layout()
{
    jQuery.each(jQuery.browser, function(i) 
    {
        if ($.browser.msie && parseFloat($.browser.version) < 8.0) 
        {
        }
        else
        {
            $('div#content_wrapper, div#sidemenu, div#content').height('inherit');
        } 
    });
    
    var smh = $('div#sidemenu').height();
    var ch = $('div#content').height();
    var ph = $(window).height() - (90+21+10+10+21);
    var wh = Math.max(smh,ch,ph);


    jQuery.each(jQuery.browser, function (i) {
        if ($.browser.msie && parseFloat($.browser.version) < 8.0) {
            wh = wh + 20;

            $('div#sidemenu, div#content').height((wh - 8) + 'px');
            $('div#content_wrapper').height(wh + 'px').css('position', 'absolute').css('top', '121px');
            $('div#content_wrapper div').css('position', 'relative').css('top', '0px');

            $('div#topmenu').css('margin-top', '90px').css('position', 'absolute').css('top', '0px');
            $('div#footer').css('margin-top', (wh + 141) + 'px');
        }
        else {
            $('div#sidemenu, div#content').height((wh - 8) + 'px');
            $('div#content_wrapper').height(wh + 'px');
        }
    });
}
