// AUTHOR: Drew Dahlman ( www.drewdahlman.com )
// BACKGROUND.js v2.0

var background = function () {

    // OPTIONS
    var startHeight = 3;
    var startWidth = 4;
	
	var _cIMG;

    return {
      // INIT
      init: function (img) {
		 _cIMG = img+"IMG";
		 $("#background #"+img+"IMG").fadeIn(900);
        // Calculates the ratio
        ratio = startHeight / startWidth;

        // GRAB DIMENSIONS					   
        var browserwidth = $(window).width();
        var browserheight = $(window).height();

        //Resize image to proper ratio
        if ((browserheight / browserwidth) > ratio) {
          $("#background img").height(browserheight);
          $("#background img").width(browserheight / ratio);

        } else {
          $("#background img").width(browserwidth);
          $("#background img").height(browserwidth * ratio);

        }

        
		//window.onresize = function() {this.resize};
      },
      newBG: function (e) {
        $("#background #"+_cIMG).fadeOut(900);
		
        $("#background #"+e).fadeIn(900);
		
		_cIMG = e;
      },
	  kill:function() {
		 $("#background").fadeOut();  
	  }
    }
  }();

background.init();

// RESIZE
      window.onresize = function() {
        // GRAB DIMENSIONS					   
        var browserwidth = $(window).width();
        var browserheight = $(window).height();

        //Resize image to proper ratio
        if ((browserheight / browserwidth) > ratio) {
          $("#background img").height(browserheight);
          $("#background img").width(browserheight / ratio);

        } else {
          $("#background img").width(browserwidth);
          $("#background img").height(browserwidth * ratio);

        }
		if(current == _history){
			var hw = $("#historyHolder").children().length*window.innerWidth;
				$("#hContainer").css({width:window.innerWidth});
				
				$("#historyHolder").css({width:hw});
				$(".itemHolder").css({width:window.innerWidth});
		}
		else {
			
		}
      }
