/* Author:JM@AOUTCH.COM */
if (screen.width <= 1025) {
	location.replace("http://mobile.aoutch.com/");
}
var FullscreenrOptions1 = { width: 2560, height: 1440, bgID: '#bg-global' };
var Fullscreenr2Options2 = { width: 2560, height: 1440, bgID: '#bg-about' };
var Fullscreenr2Options3 = { width: 2560, height: 1440, bgID: '#bg-refs' };
var Fullscreenr2Options4 = { width: 2560, height: 1440, bgID: '#bg-home' };
var Fullscreenr3Options1 = { width: 2560, height: 1440, bgID: '#bg-hook' };
var Fullscreenr3Options2 = { width: 2560, height: 1440, bgID: '#bg-potatoes' };
var Fullscreenr3Options3 = { width: 2560, height: 1440, bgID: '#bg-jerry' };
var Fullscreenr3Options4 = { width: 2560, height: 1440, bgID: '#bg-plouk' };
var Fullscreenr3Options5 = { width: 2560, height: 1440, bgID: '#bg-romeo' };
var Fullscreenr3Options6 = { width: 2560, height: 1440, bgID: '#bg-nunettes' };
jQuery.fn.fullscreenr(FullscreenrOptions1);
jQuery.fn.fullscreenr2(Fullscreenr2Options2);
jQuery.fn.fullscreenr2(Fullscreenr2Options3);
jQuery.fn.fullscreenr2(Fullscreenr2Options4);
jQuery.fn.fullscreenr3(Fullscreenr3Options1);
jQuery.fn.fullscreenr3(Fullscreenr3Options2);
jQuery.fn.fullscreenr3(Fullscreenr3Options3);
jQuery.fn.fullscreenr3(Fullscreenr3Options4);
jQuery.fn.fullscreenr3(Fullscreenr3Options5);
jQuery.fn.fullscreenr3(Fullscreenr3Options6);

function locationHashChanged() {  
	if (location.hash === ""){openHome();}
	if (location.hash === "#!/home"){openHome();}
	if (location.hash === "#!/about"){openAbout();}
	if (location.hash === "#!/refs"){openRefs();}    
}        
window.onhashchange = locationHashChanged;  
function hash() {
    var hash = window.location.hash.replace('#!/','');
	if (hash == ""){openHome();}
	if (hash == "home"){openHome();}
	if (hash == "about"){openAbout();}
	if (hash == "refs"){openRefs();} 
    $(window).trigger( 'hashchange' );
}
hash();

function openHome() {  
	//close about
	$("#about, #refs").animate({opacity: 0}, 250);
	setTimeout(function() { $("#about, #refs").hide() }, 250);
	//open refs
	setTimeout(function() { $("#home").show().animate({opacity: 1}, 250) }, 250);
	setTimeout(function() { $("#block-home").show().animate({opacity: 1}, 250) }, 550);
	//fix topbar
	setTimeout(function() { $("#topbar").animate({top: '-20px'}, 250) }, 250);
	setTimeout(function() { $("#topbar").find("h1, .navigation").animate({marginTop:'20px'}, 250) }, 250); 
	
	openHomeBtState();
}
function openHomeBtState() {  
	// active class
	$(".li-home a").removeClass("unselected");
	$(".li-refs a, .li-about a").addClass("unselected").animate({color: '#FFFFFF'}, 250);
} 

function openRefs() {  
	//close about
	$("#about, #home").animate({opacity: 0}, 250);
	setTimeout(function() { $("#about, #home").hide() }, 250);
	//open refs
	setTimeout(function() { $("#refs").show().animate({opacity: 1}, 250) }, 250);
	setTimeout(function() { $("#block-refs").show().animate({opacity: 1}, 250) }, 550);
	//fix topbar
	setTimeout(function() { $("#topbar").animate({top: '-20px'}, 250) }, 250);
	setTimeout(function() { $("#topbar").find("h1, .navigation").animate({marginTop:'20px'}, 250) }, 250); 
	
	openRefsBtState();
}
function openRefsBtState() {  
	// active class
	$(".li-refs a").removeClass("unselected");
	$(".li-about a, .li-home a").addClass("unselected").animate({color: '#FFFFFF'}, 250);
} 

function openAbout() {  
	//close refs
	$("#refs, #home").animate({opacity: 0}, 250);	
	setTimeout(function() { $("#refs, #home").hide() }, 250);
	//$("#block-refs").animate({opacity: 0}, 250);	
	//setTimeout(function() { $("#block-refs").hide() }, 250);			
	//open about
	setTimeout(function() { $("#about").show().animate({opacity: 1}, 250) }, 250);
	//fix topbar  
	setTimeout(function() { $("#topbar").animate({top: '-20px'}, 250) }, 250); 
	setTimeout(function() { $("#topbar").find("h1, .navigation").animate({marginTop:'20px'}, 250) }, 250); 
	
	openAboutBtState();  
}
function openAboutBtState() {  
	// active class
	$(".li-about a").removeClass("unselected");
	$(".li-refs a, .li-home a").addClass("unselected").animate({color: '#FFFFFF'}, 250);
}

$(function(){
	$('.navigation > li').hover(function() { 
		$(this).find('.unselected, .link').stop().animate({color: '#999999'}, 250);
		} , function() { 
		$(this).find('.unselected, .link').stop().animate({color: '#FFFFFF'}, 250);			
	});
	
	$('#home-bt').click(function(){
		openHome();
	});	
	
	$('#about-bt').click(function(){
		openAbout();
	});	
	
	$('#refs-bt').click(function(){
		openRefs();
	});
	
	$('.launch-alternate-hook').click(function() { 
		var containerWidth = $('body').width();
		$("#global").animate({left: -(containerWidth)}, 450);
		$("#bg-global").animate({left: -(containerWidth)}, 450);
		$("#bg-global").animate({opacity:0}, 0);
		$("#alternate-hook").animate({left:0,opacity:1}, 450);
		$(".close-alternate").animate({opacity: 1}, 250);
		setTimeout(function() { $("#topbar").animate({top: '-75px'}, 250) }, 250); 
		setTimeout(function() { $("#global, #bg-global").animate({opacity:0}, 50) }, 500); 
	});
	
	$('.launch-alternate-potatoes').click(function() { 
		var containerWidth = $('body').width();
		$("#global").animate({left: -(containerWidth)}, 450);
		$("#bg-global").animate({left: -(containerWidth)}, 450);
		$("#bg-global").animate({opacity:0}, 0);
		$("#alternate-potatoes").animate({left:0,opacity:1}, 450);
		$(".close-alternate").animate({opacity: 1}, 250);
		setTimeout(function() { $("#topbar").animate({top: '-75px'}, 250) }, 250); 
		setTimeout(function() { $("#global, #bg-global").animate({opacity:0}, 50) }, 500); 
	});
	
	$('.launch-alternate-jerry').click(function() { 
		var containerWidth = $('body').width();
		$("#global").animate({left: -(containerWidth)}, 450);
		$("#bg-global").animate({left: -(containerWidth)}, 450);
		$("#bg-global").animate({opacity:0}, 0);
		$("#alternate-jerry").animate({left:0,opacity:1}, 450);
		$(".close-alternate").animate({opacity: 1}, 250);
		setTimeout(function() { $("#topbar").animate({top: '-75px'}, 250) }, 250); 
		setTimeout(function() { $("#global, #bg-global").animate({opacity:0}, 50) }, 500); 
	});
	
	$('.launch-alternate-plouk').click(function() { 
		var containerWidth = $('body').width();
		$("#global").animate({left: -(containerWidth)}, 450);
		$("#bg-global").animate({left: -(containerWidth)}, 450);
		$("#bg-global").animate({opacity:0}, 0);
		$("#alternate-plouk").animate({left:0,opacity:1}, 450);
		$(".close-alternate").animate({opacity: 1}, 250);
		setTimeout(function() { $("#topbar").animate({top: '-75px'}, 250) }, 250); 
		setTimeout(function() { $("#global, #bg-global").animate({opacity:0}, 50) }, 500); 
	});
	
	$('.launch-alternate-romeo').click(function() { 
		var containerWidth = $('body').width();
		$("#global").animate({left: -(containerWidth)}, 450);
		$("#bg-global").animate({left: -(containerWidth)}, 450);
		$("#bg-global").animate({opacity:0}, 0);
		$("#alternate-romeo").animate({left:0,opacity:1}, 450);
		$(".close-alternate").animate({opacity: 1}, 250);
		setTimeout(function() { $("#topbar").animate({top: '-75px'}, 250) }, 250); 
		setTimeout(function() { $("#global, #bg-global").animate({opacity:0}, 50) }, 500); 
	});
	
	$('.launch-alternate-nunettes').click(function() { 
		var containerWidth = $('body').width();
		$("#global").animate({left: -(containerWidth)}, 450);
		$("#bg-global").animate({left: -(containerWidth)}, 450);
		$("#bg-global").animate({opacity:0}, 0);
		$("#alternate-nunettes").animate({left:0,opacity:1}, 450);
		$(".close-alternate").animate({opacity: 1}, 250);
		setTimeout(function() { $("#topbar").animate({top: '-75px'}, 250) }, 250); 
		setTimeout(function() { $("#global, #bg-global").animate({opacity:0}, 50) }, 500); 
	});
		
  	$('.close-alternate').click(function() { 
  		$(this).animate({opacity: 0}, 250);
		var containerWidth = $('body').width();
		$("#global").animate({left:0,opacity:1}, 450);
		$(".closable").animate({left:containerWidth}, 450);
		setTimeout(function() {  $(".closable").animate({opacity: 1}, 250) }, 450);
		$('#footer').animate({bottom:-50}, 750);
		var browserwidth = $(window).width();
		var browserheight = $(window).height();
		$("#bg-global").css('left', (browserwidth - $("#bg-global").width())/2);
		$("#bg-global").css('top', (browserheight - $("#bg-global").height())/2);
		setTimeout(function() {  $("#bg-global").animate({opacity: 1}, 250) }, 450);
		setTimeout(function() {  $(".closable").animate({opacity: 0}, 250) }, 450);
		setTimeout(function() { $("#topbar").animate({top: 0}, 250) }, 250); 
	});	
	
	$('#yoolk, #mstar').hover(function() { 
		$(this).stop().animate({bottom: 0}, 450);
		$(this).find(".logo").rotateAnimation(360);
		} , function() { 
		$(this).stop().animate({bottom: -370}, 450);
		$(this).find(".logo").rotateAnimation(-360);
	});
	
	$('.social-link, .close-alternate, .faded').hover(function() { 
		$(this).animate({opacity: 0.5}, 250);
		} , function() { 
		$(this).animate({opacity: 1}, 250);
	});
	
	$('#topbar').hover(function() { 
		$(this).animate({top:0}, 250);
		$(this).find("h1, .navigation").animate({marginTop:'10px'}, 250);
		} , function() { 
		$(this).animate({top:'-20px'}, 250);
		$(this).find("h1, .navigation").animate({marginTop:'20px'}, 250);
	});
	
});
$(window).load(function(){
	$("#loading").animate({opacity:0}, 250);
	$("#global").animate({opacity:1}, 250);
	$("#topbar").animate({opacity:1}, 250);
	var globalWidth = $('#global').width();
	$("#alternate-hook, #alternate-potatoes, #alternate-jerry, #alternate-plouk, #alternate-romeo, #alternate-nunettes").animate({left:globalWidth,opacity:0}, 0);
});
