var ratio = 12/8;

    
function fullBgResize(){
     var bg = $('img.bg');
     var bg2 = $('img.bg2');

     var toW = $(window).width();
     var toH = $(window).height();
     
     var minH = $('div.wrapper').height();
     var minW = $('div.wrapper').width();
     
    if( (toW<minW) || (toH<minH) ){
        toH = minH;
        toW = minW;
        }
     
     bg.width( toW );
     bg.height( toW / ratio );
     
     bg2.width( toW );
     bg2.height( toW / ratio );

     if ( bg.height() < toH ){
        bg.height( toH );
        bg.width( toH * ratio);
        }
     if ( bg2.height() < toH ){
     bg2.height( toH );
     bg2.width( toH * ratio);
     }
}
     
     
 
 
$(window).resize(function(){
  fullBgResize();
  }
);

$(window).load(function(){
  fullBgResize();
  }
);

$('div.fullBg div img').resize(function(){
  fullBgResize();
  }
);




