(function($wnd){
    
    
  $wnd.bind('load resize', onload);
  $(onload);
  
  if ($.browser.msie && $.browser.version >= 6 & $.browser.version < 7) {
    $(function() {
      var footer = $('#footer').css({
        position: 'absolute',
        bottom: 'auto'
      });
      
      var h = footer.outerHeight();
      
      $wnd.bind('resize scroll', function() {
        footer.hide().css({
          width: $(document).width(),
          top: $(window).height() + $(window).scrollTop() - h - 1
        }).show();
      }).trigger('resize');
    });
  }
  
  var $doc = $(document),
      body,
      main,
      pseudo,
      footer;
  
  if ($.browser.msie && $.browser.version == 6) {
    //setTimeout(onload, 1000);
  }
  
  //setTimeout(onload, 2000);
  
  function onloadold() {
    var wnd_width = $('body').width(),
        wnd_height = $('body').height();
    
    body = body || $('body');
    pseudo = pseudo || $('#pseudo-body');
    footer = footer || $('#footer');
    
    body.css({
      height: $wnd.height() - 128,
      paddingBottom: 128
    });
    
    
    var bg = $('#background').find('img');
    var ratio = 12/8;
    bg.attr({
      width: wnd_width,
      height: wnd_width / ratio
    });

    if (bg.height() < wnd_height) {
      bg.attr({
        width: wnd_height * ratio,
        height: wnd_height
      });
    }
    
    
    main = main || $('#main-wrapper');
    
    var width = main.outerWidth(),
        height = main.outerHeight();
        
    main.css({
      left: Math.max(0, (wnd_width - width)/2),
      top: (Math.max(0, (wnd_height - height)/2)-30),
      //top: (Math.max(0, (wnd_height - height)/2)),
      position: 'absolute'
    });
    
  }
  
  
  function onload() {
    var wnd_width = $('body').width(),
        wnd_height = $('body').height();
    /*
    body = body || $('body');
    pseudo = pseudo || $('#pseudo-body');
    footer = footer || $('#footer');
    */
    //alert(11);
    body = $('body');
    //alert(12);
    pseudo = $('#pseudo-body');
    //alert(13);
    //footer = $('#footer');
    //alert(footer);
    wnd = $('window');
    //alert(2);
    /*body.css({
      height: wnd.height() - 128,
      paddingBottom: 128
    });*/
    var bg = $('#background').find('img');
    var ratio = 12/8;
    bg.attr({
      width: wnd_width,
      height: wnd_width / ratio
    });
    if (bg.height() < wnd_height) {
      bg.attr({
        width: wnd_height * ratio,
        height: wnd_height
      });
    }
    //main = main || $('#main-wrapper');
    main = $('#main-wrapper');
    var width = main.outerWidth(),
        height = main.outerHeight();
    main.css({
      left: Math.max(0, (wnd_width - width)/2),
      top: (Math.max(0, (wnd_height - height)/2)-30),
      //top: (Math.max(0, (wnd_height - height)/2)),
      position: 'absolute'
    });
  }  
  
  
  
})($(window));
