
$(document).ready(function() {


/* NAV LINKS FADE IN 


$(document).ready(function(){ // This sets the opacity of the thumbs to fade down to 60% when the page loads
	$("").fadeTo("slow", 0.6);
	
	$(".thumbs img").hover(function(){
	$(".thumbs img").fadeTo("slow", 1.0); // This sets the opacity to 100% on hover
	},function(){
	$(".thumbs img").fadeTo("slow", 0.6); // This sets the opacity back to 60% on mouseout
	});
});



*/





		/*  ------------------------------
		
					ROW 1 
				
		------------------------------  */
		
		
		
		$(document).ready(function(){
  			
			
			$(".reel").mouseenter(function(){
			  $("#hiddenReel").animate({ "opacity": 0.8, "marginTop": "-=50px", },  
			  
			  {
				duration: 300, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });
			
			});
			
			
			
			$(".reel").mouseleave(function(){
			  $("#hiddenReel").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				  
				  
			
			});
			
			
			    $(".reel").click(function () { 
									   
				$("#hiddenReel").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				   
				 
    			});

			
			
			
			
 		});
		
	
		$(document).ready(function(){
  			
			$(".tiod").mouseenter(function(){
			  $("#hiddenTiod").animate({ "opacity": 0.8, "marginTop": "-=50px", },  
			  
			  {
				duration: 300, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });
			
			
			});
			
			$(".tiod").mouseleave(function(){
			  $("#hiddenTiod").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				  
						  
									  
			});
			
			
			
		$(".tiod").click(function () { 
									   
				$("#hiddenTiod").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				   
				 
    			});

			
 		});
		
		
		$(document).ready(function(){
  			
			$(".zbx").mouseenter(function(){
			  $("#hiddenZbx").animate({ "opacity": 0.8, "marginTop": "-=50px", },  
			  
			  {
				duration: 300, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });
			
			
			});
			
			$(".zbx").mouseleave(function(){
			  $("#hiddenZbx").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				  
						  
									  
			});
			
		 $(".zbx").click(function () { 
									   
				$("#hiddenZbx").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				   
				 
    			});

			
 		});
		
		
		
		/*  ------------------------------
		
					ROW 2 
				
		------------------------------  */
		
		
		$(document).ready(function(){
  			
			$(".mj").mouseenter(function(){
			  $("#hiddenMj").animate({ "opacity": 0.8, "marginTop": "-=50px", },  
			  
			  {
				duration: 300, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });
			
			
			});
			
			$(".mj").mouseleave(function(){
			  $("#hiddenMj").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				  
						  
									  
			});
			
		  $(".mj").click(function () { 
									   
				$("#hiddenMj").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				   
				 
    	});

			
 		});
		
	
		$(document).ready(function(){
  			
			$(".bm").mouseenter(function(){
			  $("#hiddenBm").animate({ "opacity": 0.8, "marginTop": "-=50px", },  
			  
			  {
				duration: 300, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });
			
			
			});
			
			$(".bm").mouseleave(function(){
			  $("#hiddenBm").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				  
						  
									  
			});
			
			  $(".bm").click(function () { 
									   
				$("#hiddenBm").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				   
				 
    			});

			
 		});
		
		
		$(document).ready(function(){
  			
			$(".rooney").mouseenter(function(){
			  $("#hiddenRooney").animate({ "opacity": 0.8, "marginTop": "-=50px", },  
			  
			  {
				duration: 300, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });
			
			
			});
			
			$(".rooney").mouseleave(function(){
			  $("#hiddenRooney").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				  
						  
									  
			});
			
		    $(".rooney").click(function () { 
									   
				$("#hiddenRooney").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				   
				 
    			});

			
 		});
		
		
		/*  ------------------------------
		
					ROW 3 
				
		------------------------------  */
		
		
		$(document).ready(function(){
  			
			$(".um").mouseenter(function(){
			  $("#hiddenUm").animate({ "opacity": 0.8, "marginTop": "-=50px", },  
			  
			  {
				duration: 300, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });
			
			
			});
			
			$(".um").mouseleave(function(){
			  $("#hiddenUm").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				  
						  
									  
			});
			
		 $(".um").click(function () { 
									   
				$("#hiddenUm").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				   
				 
    			});

			
 		});
		
		
		 
		$(document).ready(function(){
  			
			$(".lf").mouseenter(function(){
			  $("#hiddenLf").animate({ "opacity": 0.8, "marginTop": "-=50px", },  
			  
			  {
				duration: 300, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });
			
			
			});
			
			$(".lf").mouseleave(function(){
			  $("#hiddenLf").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				  
						  
									  
			});
			
	 $(".lf").click(function () { 
									   
				$("#hiddenLf").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				   
				 
    			});

			
 		});
		
		
		
		
		$(document).ready(function(){
  			
			$(".ms").mouseenter(function(){
			  $("#hiddenMs").animate({ "opacity": 0.8, "marginTop": "-=50px", },  
			  
			  {
				duration: 300, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });
			
			
			});
			
			$(".ms").mouseleave(function(){
			  $("#hiddenMs").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				  
						  
									  
			});
			
		 $(".ms").click(function () { 
									   
				$("#hiddenMs").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				   
				 
    			});

			
 		});
		
		
		
		
		
	    /*  ------------------------------
		
					ROW 4 
				
		------------------------------  */
		
		
		$(document).ready(function(){
  			
			$(".umcur").mouseenter(function(){
			  $("#hiddenUmcur").animate({ "opacity": 0.8, "marginTop": "-=50px", },  
			  
			  {
				duration: 300, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });
			
			
			});
			
			$(".umcur").mouseleave(function(){
			  $("#hiddenUmcur").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				  
						  
									  
			});
			
		 $(".umcur").click(function () { 
									   
				$("#hiddenUmcur").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				   
				 
    			});

			
 		});
		
		
		 
		$(document).ready(function(){
  			
			$(".nike").mouseenter(function(){
			  $("#hiddenNike").animate({ "opacity": 0.8, "marginTop": "-=50px", },  
			  
			  {
				duration: 300, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });
			
			
			});
			
			$(".nike").mouseleave(function(){
			  $("#hiddenNike").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				  
						  
									  
			});
			
	        $(".nike").click(function () { 
									   
				$("#hiddenNike").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				   
				 
    			});

			
 		});
		
		
		
		
		$(document).ready(function(){
								   $("img.a").hover(
function() {
$(this).stop().animate({"opacity": "0"}, "fast");
},
function() {
$(this).stop().animate({"opacity": "1"}, "slow");
});

  			
			$(".fadehover").mouseenter(function(){
			  $("#hiddenCm").animate({ "opacity": 0.8, "marginTop": "-=50px", },  
			  
			  {
				duration: 300, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });
			
			
			});
			
			$(".fadehover").mouseleave(function(){
			  $("#hiddenCm").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				  
						  
									  
			});
			
			 $(".fadehover").click(function () { 
									   
				$("#hiddenCm").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				   
				 
    			});

			
 		});
		
		
			    /*  ------------------------------
		
					ROW 5 
				
		------------------------------  */
		
		
		$(document).ready(function(){
  			
			$(".mt").mouseenter(function(){
			  $("#hiddenMt").animate({ "opacity": 0.8, "marginTop": "-=50px", },  
			  
			  {
				duration: 300, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });
			
			
			});
			
			$(".mt").mouseleave(function(){
			  $("#hiddenMt").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				  
								
						
			});
			
			   $(".mt").click(function () { 
									   
				$("#hiddenMt").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				   
				 
    			});

			
 		});
		
		
		 
		$(document).ready(function(){
  			
			$(".gal").mouseenter(function(){
			  $("#hiddenGal").animate({ "opacity": 0.8, "marginTop": "-=50px", },  
			  
			  {
				duration: 300, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });
			
			
			});
			
			$(".gal").mouseleave(function(){
			  $("#hiddenGal").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				  
						  
									  
			});
			
				$(".gal").click(function () { 
									   
				$("#hiddenGal").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				   
				 
    			});

			
 		});
		
		
		
		
		$(document).ready(function(){
  			
			$(".umints").mouseenter(function(){
			  $("#hiddenUmints").animate({ "opacity": 0.8, "marginTop": "-=50px", },  
			  
			  {
				duration: 300, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });
			
			
			});
			
			$(".umints").mouseleave(function(){
			  $("#hiddenUmints").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				  
						  
									  
			});
			
			 $(".umints").click(function () { 
									   
				$("#hiddenUmints").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				   
				 
    			});

			
 		});

		
			
			    /*  ------------------------------
		
					ROW 6 
				
		------------------------------  */
		
		
		$(document).ready(function(){
  			
			$(".xg").mouseenter(function(){
			  $("#hiddenXg").animate({ "opacity": 0.8, "marginTop": "-=50px", },  
			  
			  {
				duration: 300, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });
			
			
			});
			
			$(".xg").mouseleave(function(){
			  $("#hiddenXg").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				  
						  
									  
			});
			
		$(".xg").click(function () { 
									   
				$("#hiddenXg").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				   
				 
    			});

			
 		});
		
		
		 
		$(document).ready(function(){
  			
			$(".sjs").mouseenter(function(){
			  $("#hiddenSjs").animate({ "opacity": 0.8, "marginTop": "-=50px", },  
			  
			  {
				duration: 300, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });
			
			
			});
			
			$(".sjs").mouseleave(function(){
			  $("#hiddenSjs").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				  
						  
									  
			});
			
			 $(".sjs").click(function () { 
									   
				$("#hiddenSjs").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				   
				 
    			});

			
 		});
		
		
		
		
		$(document).ready(function(){
  			
			$(".dx").mouseenter(function(){
			  $("#hiddenDx").animate({ "opacity": 0.8, "marginTop": "-=50px", },  
			  
			  {
				duration: 300, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });
			
			
			});
			
			$(".dx").mouseleave(function(){
			  $("#hiddenDx").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				  
						  
									  
			});
			
			$(".dx").click(function () { 
									   
				$("#hiddenDx").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				   
				 
    			});

			
 		});
	
		
					    /*  ------------------------------
		
					ROW 7 
				
		------------------------------  */
		
		
		$(document).ready(function(){
  			
			$(".hw").mouseenter(function(){
			  $("#hiddenHw").animate({ "opacity": 0.8, "marginTop": "-=50px", },  
			  
			  {
				duration: 300, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });
			
			
			});
			
			$(".hw").mouseleave(function(){
			  $("#hiddenHw").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				  
						  
									  
			});
			
			 $(".hw").click(function () { 
									   
				$("#hiddenHw").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				   
				 
    			});

			
 		});
		
		
		 
		$(document).ready(function(){
  			
			$(".cs").mouseenter(function(){
			  $("#hiddenCs").animate({ "opacity": 0.8, "marginTop": "-=50px", },  
			  
			  {
				duration: 300, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });
			
			
			});
			
			$(".cs").mouseleave(function(){
			  $("#hiddenCs").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				  
						  
									  
			});
			
			 $(".cs").click(function () { 
									   
				$("#hiddenCs").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				   
				 
    			});

			
 		});
		
		
		
		
		$(document).ready(function(){
  			
			$(".sk").mouseenter(function(){
			  $("#hiddenSk").animate({ "opacity": 0.8, "marginTop": "-=50px", },  
			  
			  {
				duration: 300, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });
			
			
			});
			
			$(".sk").mouseleave(function(){
			  $("#hiddenSk").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				  
						  
									  
			});
			
		 $(".sk").click(function () { 
									   
				$("#hiddenSk").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				   
				 
    			});

			
 		});
		
		
	   /*  ------------------------------
		
					ROW 8 
				
		------------------------------  */
		
		
		$(document).ready(function(){
  			
			$(".dpt").mouseenter(function(){
			  $("#hiddenDpt").animate({ "opacity": 0.8, "marginTop": "-=50px", },  
			  
			  {
				duration: 300, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });
			
			
			});
			
			$(".dpt").mouseleave(function(){
			  $("#hiddenDpt").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				  
						  
									  
			});
			
		$(".dpt").click(function () { 
									   
				$("#hiddenDpt").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				   
				 
    			});

			
 		});
		
		
		 
		$(document).ready(function(){
  			
			$(".mz").mouseenter(function(){
			  $("#hiddenMz").animate({ "opacity": 0.8, "marginTop": "-=50px", },  
			  
			  {
				duration: 300, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });
			
			
			});
			
			$(".mz").mouseleave(function(){
			  $("#hiddenMz").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				  
						  
									  
			});
			
			 $(".mz").click(function () { 
									   
				$("#hiddenMz").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				   
				 
    			});

			
 		});
		
		
		
		
		$(document).ready(function(){
  			
			$(".vl").mouseenter(function(){
			  $("#hiddenVl").animate({ "opacity": 0.8, "marginTop": "-=50px", },  
			  
			  {
				duration: 300, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });
			
			
			});
			
			$(".vl").mouseleave(function(){
			  $("#hiddenVl").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				  
						  
									  
			});
			
			$(".vl").click(function () { 
									   
				$("#hiddenVl").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				   
				 
    			});

			
 		});
		
	
		
		   /*  ------------------------------
		
					ROW 9 
				
		------------------------------  */
		
		
		$(document).ready(function(){
  			
			$(".om").mouseenter(function(){
			  $("#hiddenOm").animate({ "opacity": 0.8, "marginTop": "-=50px", },  
			  
			  {
				duration: 300, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });
			
			
			});
			
			$(".om").mouseleave(function(){
			  $("#hiddenOm").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				  
						  
									  
			});
			
		  $(".om").click(function () { 
									   
				$("#hiddenOm").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				   
				 
    			});

			
 		});
		
		
		 
		$(document).ready(function(){
  			
			$(".three").mouseenter(function(){
			  $("#hiddenThree").animate({ "opacity": 0.8, "marginTop": "-=50px", },  
			  
			  {
				duration: 300, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });
			
			
			});
			
			$(".three").mouseleave(function(){
			  $("#hiddenThree").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				  
						  
									  
			});
			
		  $(".three").click(function () { 
									   
				$("#hiddenThree").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				   
				 
    			});

			
 		});
		
		
		
		
		$(document).ready(function(){
  			
			$(".moz").mouseenter(function(){
			  $("#hiddenMoz").animate({ "opacity": 0.8, "marginTop": "-=50px", },  
			  
			  {
				duration: 300, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });
			
			
			});
			
			$(".moz").mouseleave(function(){
			  $("#hiddenMoz").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				  
						  
									  
			});
			
			 $(".moz").click(function () { 
									   
				$("#hiddenMoz").animate({   "marginTop": "+=50px",}, 
									  
			  {
				duration: 200, // how fast we are animating
               	easing: 'swing', // the type of easing
			  });				   
				 
    			});

			
 		});
	















});






var flexiBackground = function(){
	
	/**
		CONFIGURATION:
		Define the size of our background image
	*/
	var bgImageSize = {
		width : 128,
		height : 96,
	};
	
	/**
		Declare and define variables
	*/ 
	var $window,
		$body,
		imageID = "expando",
		tallClass = 'tall',
		wideClass = 'wide',
		$bgImage, $wrapper, img, url, imgAR;
		
	/**
		Are we dealing with ie6?
	*/
	var ie6 = ($.browser.msie && parseInt($.browser.version, 10) <= 6);
	
	/**
		Set up the action that happens on resize
	*/
	var resizeAction = function() {
		var win = {
			height : $window.height(),
			width : $window.width()
		};

		// The current aspect ratio of the window
		var winAR = win.width / win.height;

		// Determine if we need to show the image and whether it needs to stretch tall or wide
		if (win.width < bgImageSize.width && win.height < bgImageSize.height) {
			$body
				.removeClass(wideClass)
				.removeClass(tallClass);
		} else if ((win.w < bgImageSize.width && win.height >= bgImageSize.height) || (winAR < imgAR)) {
			$body
				.removeClass(wideClass)
				.addClass(tallClass);
			// Center the image
			$bgImage.css('left', Math.min(((win.width - bgImageSize.width) / 2), 0));
		} else if (win.width >= bgImageSize.width) {
			$body
				.addClass(wideClass)
				.removeClass(tallClass);
			$bgImage.css('left', 0);
		}
		
		// Need to fix the height of the wrapper for IE6
		if (ie6) {
			$wrapper.css('height', win.height);
		}
	};
	
	return {
		
		/*
			Sets up the basic functionality
		*/
		initialize : function() {
			
			// No need for any of this if the screen isn't bigger than the background image
			if (screen.availWidth <= bgImageSize.width || screen.availHeight <= bgImageSize.height) {
				return;
			}
			
			// Grab elements we'll reference throughout
			$window = $(window);
			$body = $('body');
			
			// Parse out the URL of the background image and drop out if we don't have one
			url = $body.css('background-image').replace(/^url\(("|')?|("|')?\);?$/g, '') || false;	
			if (!url || url === "none" || url === "") {
				return;
			}
			
			// Get the aspect ratio of the image
			imgAR = bgImageSize.width / bgImageSize.height;

			// Create a new image element
			$bgImage = $('<img />')
						.attr('src', url)
						.attr('id', imageID);
						
			// Create a wrapper and append the image to it.
			// The wrapper ensures we don't get scrollbars.
			$wrapper = $('<div></div>')
							.css({
								'overflow' : 'hidden',
								'width' : '100%',
								'height' : '100%',
								'z-index' : '-1'
							})
							.append($bgImage)
							.appendTo($body);
							
			// IE6 Doesn't do position: fixed, so let's fake it out.
			// We'll apply a class which gets used in the CSS to emulate position: fixed
			// Otherwise, we'll simply used position: fixed.
			if (ie6) {
				$wrapper.addClass('ie6fixed');
			} else {
				$wrapper.css({
					'position' : 'fixed',
					'top' : 0,
					'left' : 0
				});
			}
			
			// Set up a resize listener to add/remove classes from the body 
			$window.bind('resize', resizeAction);

			// Set it up by triggering a resize
			$window.trigger('resize');
		}
	};
}();





$(document).ready(flexiBackground.initialize);
