  // sticky footer plugin
  
  (function($){
	var footer;
  
	$.fn.extend({
	  stickyFooter: function(options) {
		footer = this;
		
		$(window).load(positionFooter);
  //$("#sticky-footer-push").css("height","10px");
		$(window)
		  .scroll(positionFooter)
		  .resize(positionFooter);
  
		function positionFooter() {
		  var docHeight = $(document.body).height() - $("#sticky-footer-push").height();
		  if(docHeight < $(window).height()){
			var diff = $(window).height() - docHeight;
			if (!$("#sticky-footer-push").length > 0) {
			  $(footer).before('<div id="sticky-footer-push"></div>');
			}
			$("#sticky-footer-push").height(diff);
			
		  }
		}
	  }
	});
  })(jQuery);


$(function() {   
		
			var theWindow        = $(window),
			    $bg              = $("#bg"),
				$bottom          = $("#bottom"),
				$collection      = $("#products"),
				$mainWindow		 = $("#content"),
			    //aspectRatio      = ($bg.width() / $bg.height());
			    aspectRatio      =  1.826955074875208;
				$bottom.addClass('nonSticky');
					//console.log(theWindow.height());
//console.log( $("body").height());


 

			function resizeBg() {
				//console.log(theWindow.width() / theWindow.height());
				//console.log(aspectRatio);
				
				if ( (theWindow.width() / theWindow.height()) < aspectRatio ) {
				    $bg
				    	.removeClass()
				    	.addClass('bgheight');
				} else {
				    $bg
				    	.removeClass()
				    	.addClass('bgwidth');
						
				}
							
			}
			                   			
			theWindow.resize(function() {
				resizeBg();
				
					/*$bgwidth = $(window) - 588;
					$bgwidth = $bgwidth + "px";
					$collection.css("width",$bgwidth);

					$bgwidth = $(window) - 222;
					$bgwidth = $bgwidth + "px";

					$mainWindow.css("width",$bgwidth);*/
				//					if(theWindow.height()<=$("body").height()) {


				/*var docHeight = $(document).height();
				  var scroll    = $(window).height() + $(window).scrollTop();
				  var trulyH = ((docHeight == scroll));*/
				  
				  //console.log(trulyH);
					//if(theWindow.height()<=830) {
					//if(trulyH==false) {
						/*console.log(theWindow.height());
						//console.log($("#top").height()+$("#content").height());
						if(theWindow.height()<=$("#top").height()+$("#content").height()) {
						$bottom	
							.removeClass()
							.addClass('nonSticky');*/
						/*$("#backgroundD").css("position","relative");
						$("#backgroundD").css("top","-110px");*/
						
							//alert("!asdf");
					/*} else {
						$bottom
							.removeClass()
							.addClass('sticky');*/
						/*$("#backgroundD").css("position","relative");
						$("#backgroundD").css("top","-30px");*/
					//}

			}).trigger("resize");
		
		
		
		
		
		
		});
