/* 
 * resizeChecker.js
 * 
 * Copyright (c) 2011 Pink Donut <joaolopes at pinkdonut.net>. 
 * 
 * This file is part of CoreOnFire.
 * 
 * CoreOnFire is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * CoreOnFire is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with CoreOnFire.  If not, see <http ://www.gnu.org/licenses/>.
 */
$(window).bind("resize",function(){
   resizeThatFrame();
   resizeWindow();
});

function resizeThatFrame(){
    var $loadWrap = $(".contents_load_wrapper");
   if($loadWrap.length > 0){
       var minheight = $loadWrap.css("min-height").replace("px", "");
       if($(window).height() > minheight){
           $loadWrap.height("100%");
       }else{
           $loadWrap.height(minheight);
       }
   }
}

function resizeWindow(){
   var backImg = $("#background").find("img");
   backImg.each(function(){
       var theBack = $(this);
       if(theBack.attr("height") !== undefined && theBack.attr("width") !== undefined){
           theBack.removeAttr("height");
       }
       if(theBack.height() < $(window).height()){
           theBack.removeAttr("width");
           theBack.attr("height", "100%");
       }
       if(theBack.width() < $(window).width()){
           theBack.removeAttr("height");
           theBack.attr("width", "100%");
       }
   });
}


resizeThatFrame();

resizeWindow();


