/* JS Document bgAdapter.js */

window.addEvent('resize', function(){
    setBackground();
});

window.addEvent('domready', function(){
    setInterval('setBackground()',2500);
});

  function setBackground () {
    x = document.body.offsetWidth;
    y = document.body.offsetHeight;
    my_ratio = x/y;
    if (my_ratio>1.6)
    {
      document.getElementById('scaled_bg').style.height=y/1.6*my_ratio+'px';
      document.getElementById('scaled_bg').style.marginTop=(y - y/1.6*my_ratio)/2+'px';
    }
    if (my_ratio<1.6)
    {
      document.getElementById('scaled_bg').style.width=x/my_ratio*1.6+'px';
      document.getElementById('scaled_bg').style.marginLeft=(x/1.6*my_ratio - x)/2+'px';
    }
  }