/* Author: 

*/

var hideFooter;

$(document).ready(function() {

	//Auto BG resize
	stretch_bg_img();
	$(window).resize( stretch_bg_img );

	//Cufon
	Cufon.replace('.cufon-futura', { fontFamily: 'Futura' });
	Cufon.replace('#main-nav a', {
		fontFamily: 'Futura',
		letterSpacing: '1px',
		textShadow: '1px 1px 1px #FFF'
	});
	Cufon.replace('.cufon-snell', { fontFamily: 'Snell Roundhand' });

	/*$('#footer').mouseover(function(){
		$(this).animate({ bottom: 0});
	});
	$('#footer').mouseout(function(){
		$(this).animate({ bottom: -45});
	});*/
	
	footerAnimate(false);

/*	var mouseY = 0;
	var pageHeight = 100;
	$().mousemove( function(e) {
		mouseY = e.pageY;
		pageHeight = $(window).height();
		
	});*/

	$('#footer-sensor,#footer').mouseenter(function(){
		footerAnimate(true);
	}).mouseleave(function(){
		footerAnimate(false);
	});


	$('.menu-handler,.menu-close').click(function(){
		if(!$('.menu-close').is(':visible')) {
			$('#menus').animate({right: 0},200);
			$('.menu-close').fadeIn('slow');
		} else {
			$('.menu-close').fadeOut('fast');
			$('#menus').animate({right: -212},150);
		}
		return false;
	});


	// Background images...
	$('#bg-image img:eq(0)').show();
	$('#bg-image img:gt(0)').hide();
	setInterval(function(){
		$('#bg-image img:eq(0)')
			.fadeOut(2000)
			.next('img').fadeIn(2000)
			.end()
			.appendTo('#bg-image');}
		,6000
	);

	/*$('#main-nav a').click(function(){
		$('#main-nav li.active').removeClass('active');
		$(this).parents('li').addClass('active');
		return false;
	});*/

});



function footerAnimate(show){
	var target = $('#footer');
	if(show == undefined) show = true;
	if(show){
		clearTimeout(hideFooter);
		$(target).stop().animate({ bottom: 0},200);
	} else {
		hideFooter = setTimeout(function(){
			$(target).stop().animate({ bottom: -45},400);
		},1200);
	}
}



function stretch_bg_img() {
	if ($(window).height() > $('body').innerHeight()) {
		$('#bg').height( $(document).height() );
	}
}
