var rs_debug = (document.location.search == '?ryba=true');
rs_debug = false;
function onPageResize()
{
    // CSS could work, but I alas am a programmer
    // Thie makes sure that our map resizes itself like google maps window does
    var loops = 1;
    // HACK - do not "fix"
    // The second iteration resizes content window correctly on webkit browsers
    for (x = 0; x <= loops; x++)
    {
    if (jQuery.browser.msie) {
        //jQuery('#br').css('position','fixed');
        jQuery('#br').css('position','absolute');
    } else {
        jQuery('#br').css('position','absolute');
    }
    jQuery('#br').css('right',0);
    jQuery('#br').css('bottom',0);
    var bro = jQuery('#br').offset();
    var so = jQuery('#sidebar').offset();
    var sw = jQuery('#sidebar').outerWidth();
    var phw = jQuery('#page_header').width();
    var po = jQuery('#page').offset();
    var co = jQuery('#content').offset();
    var brh = jQuery('#br').height();
    var content_height = bro.top - co.top ;
    jQuery('#page').height(bro.top);
    jQuery('#page').css('max-height',bro.top);
//    jQuery('#page').css('overflow','hidden');
//    jQuery('#content').css('overflow','hidden');
//    jQuery('#sidebar').css('overflow','auto');
    // jQuery('#content').css('position','absolute');
    // jQuery('#content').css('top',so.top);
    // jQuery('#content').css('left',sw + po.left);
    if (jQuery('#sidebar').css('display') == 'block')
    {
        jQuery('#content').css('width',phw - sw + 6);
    } else {
        jQuery('#content').css('width',phw - co.left );
    }
    jQuery('#content').css('height',content_height);
    jQuery('#sidebar').css('height',bro.top - so.top);
    //jQuery('#map').css('height',jQuery('#content').css('height'));
    //jQuery('#map').css('width',jQuery('#content').css('width'));
    //jQuery('#map').css('top',so.top);
    //jQuery('#map').css('left',so.top);
   

    }
    if ((jQuery.browser.safari) && (1 == 2)) {
        // content width needs fixin
        if (jQuery('#sidebar').css('display') == 'block')
        {
            jQuery('#content').css('width',phw - sw);
        } else {
            jQuery('#content').css('width',phw - co.left);
        }
    }
    if (D.Map != null)
    {
        D.Map.Resize(jQuery('#content').width(),jQuery('#content').height());
    }
    if (rs_debug)
    {
        jQuery('#debug').append('bottom right top is' + bro.top.toString());
        jQuery('#debug').append('document height is' + jQuery(document).css('top').toString());
        jQuery('#debug').append('page height is ' + jQuery('#page').css('top').toString());
    }

}
jQuery(document).ready(function() {
    jQuery('#hide').toggle(
        function() {           
            jQuery('#sidebar').hide("slow",onPageResize);
            jQuery('#hide').text('SHOW THE SIDEBAR');
        },
        function() {
            jQuery('#content').width(jQuery('#page_header').width() - jQuery('#sidebar').width() );
            jQuery('#sidebar').show("slow",onPageResize);
            jQuery('#hide').text('HIDE THE SIDEBAR');
        }
    );
    jQuery('#lr').toggle(
        function() {
            jQuery('#sidebar').css('float','right');
            jQuery('#lr').text('MOVE THE SIDEBAR LEFT');
        },
        function() {
            jQuery('#sidebar').css('float','left');
            jQuery('#lr').text('MOVE THE SIDEBAR RIGHT');
        }
    );
    onPageResize();
    setTimeout('onPageResize();',200);
});
window.onresize = onPageResize;
