jQuery(document).ready(function(){
	
	var FullscreenrOptions = {  width: 1350, height: 898, bgID: '#background-image' };
	jQuery.fn.fullscreenr(FullscreenrOptions);
	
	//////////////////////////////////////////////////////////////////////////	
	// HOME PAGE RANDOM QUOTE
	//////////////////////////////////////////////////////////////////////////

	//hide all quotes
	if (jQuery('[title="quote"]').length){
		jQuery('[title="quote"]').hide();
	}
	
	function getRandomQuote (){
		var rand = Math.ceil(Math.random()*9);
		var newQuote = "#quote" + rand;
		if (currentQuote != newQuote){
			return newQuote;
		} else {
			return getRandomQuote();
		}
	}
	
	var currentQuote = getRandomQuote();
	jQuery(currentQuote).fadeIn(1000)
	setTimeout(swapQuote, 5000)
	
	function swapQuote (){
		jQuery(currentQuote).fadeOut('fast', function() {
			currentQuote = getRandomQuote();
			jQuery(currentQuote).fadeIn(1000);
		});
		setTimeout(swapQuote, 3000)
	}
	
	
	
	
	//////////////////////////////////////////////////////////////////////////	
	// FADE IN SUB NAVIGATION
	//////////////////////////////////////////////////////////////////////////
	
	if (
		jQuery('body[id|="page-about"]').length || 
		jQuery('body[id|="page-bespoke"]').length || 
		jQuery('body[id|="page-ready"]').length || 
		jQuery('body[id|="page-accessories"]').length
	) {
		jQuery('#sub-nav').show().css({ "top" : "-200px" }).
		animate({ "top": "17px" }, {duration: 1000, easing: 'easeOutQuint'});
	}			 
	
	//////////////////////////////////////////////////////////////////////////	
	// POSITION CONTENT
	//////////////////////////////////////////////////////////////////////////
	
	var contentHeight = Number(jQuery('#wrapper').height());
	
	//jQuery('#footer').html(contentHeight);
	//console.log(contentHeight);
	
	jQuery(window).resize(function(){
		
		if (jQuery(window).height() > contentHeight){
			//attached to bottom of screen
			jQuery('#footer').css({'position':'absolute', 'bottom':'0'});
			jQuery('#main').css({'position':'absolute', 'height':'100%'});
			jQuery('#content').css({'position':'absolute','bottom':'0' });
		} else {
			jQuery('#footer').css({'position':'relative','bottom':''});
			jQuery('#main').css({'position':'relative', 'height':''});
			jQuery('#content').css({'position':'relative', 'bottom':'' });
			
			if (jQuery.browser.msie) {
		 		jQuery('#footer').css({'top': '80px'});
				jQuery('#content').css({'top': '80px'});			
			}
		}
		
		if (jQuery(window).width() < 1000){
			jQuery('#wrapper').css({'width':'1000px', 'overflow-x':'scroll'});
		} else {
			jQuery('#wrapper').css({'width':'100%'});
		}
		
	 });
	 
	jQuery(window).resize();
	
	if(navigator.platform == 'iPad' || navigator.platform == 'iPhone' || navigator.platform == 'iPod') {
	     $("#background").css("position", "absolute");
	};
	

});
