 /* Initialization **********************************************************************************/
$(document).ready(function(){
	
//	iewarning.init();
	home.init();
	scroll.init();
	tabledrag.init();
//	lazyload.init();

});


/* IE WARNING BOX **********************************************************************************/
var iewarning = {
	init: function(){	
	    $('#warning').load('http://www.ngall.fr/beta/public_html/front/js/ie.html');
	}
};


/* HOME ANIMATION **********************************************************************************/
var home = {
	init: function(){
		$('#home a.nav img').hover(function()	{
			$('#home img.go').stop().animate({left:"836px"}, 600, 'easeOutBounce');
		}, function()	{
			$('#home img.go').stop().animate({left:"800px"}, 1200, 'easeInOutCubic');
		});
	}
};


/* SCROLL NAVIGATION **********************************************************************************/
var scroll = {
	
	init: function(){
		
		//event on menu click
		$('.nav a, a.menu, #home a.nav').click(function () {
			var speed = 2500;
			
			// Content scrolling
			if ($(this).attr('href') == '#home')	{
				$('#content').animate(		{scrollLeft: '0px'}, {duration: speed, easing: 'easeInOutCubic'});
				$('#background').animate(	{backgroundPosition: '0px 0px'}, {duration: speed, easing: 'easeInOutCubic'});
				$('#layer').animate(		{backgroundPosition: '0px 0px'}, {duration: speed, easing: 'easeInOutCubic'});
				$('#clouds').animate(		{backgroundPosition: '0px 0px'}, {duration: speed, easing: 'easeInOutCubic'});
			} else if ($(this).attr('href') == '#about')	{
				$('#content').animate(		{scrollLeft: '4000px'}, {duration: speed, easing: 'easeInOutCubic'});
				$('#background').animate(	{backgroundPosition: '-200px 0px'}, {duration: speed, easing: 'easeInOutCubic'});
				$('#layer').animate(		{backgroundPosition: '-300px 0px'}, {duration: speed, easing: 'easeInOutCubic'});
				$('#clouds').animate(		{backgroundPosition: '-1000px 0px'}, {duration: speed, easing: 'easeInOutCubic'});
			} else if ($(this).attr('href') == '#skills')	{
				$('#content').animate(		{scrollLeft: '8000px'}, {duration: speed, easing: 'easeInOutCubic'});
				$('#background').animate(	{backgroundPosition: '-400px 0px'}, {duration: speed, easing: 'easeInOutCubic'});
				$('#layer').animate(		{backgroundPosition: '-600px 0px'}, {duration: speed, easing: 'easeInOutCubic'});
				$('#clouds').animate(		{backgroundPosition: '-2000px 0px'}, {duration: speed, easing: 'easeInOutCubic'});
			} else if ($(this).attr('href') == '#works')	{
				$('#content').animate(		{scrollLeft: '12000px'}, {duration: speed, easing: 'easeInOutCubic'});
				$('#background').animate(	{backgroundPosition: '-600px 0px'}, {duration: speed, easing: 'easeInOutCubic'});
				$('#layer').animate(		{backgroundPosition: '-900px 0px'}, {duration: speed, easing: 'easeInOutCubic'});
				$('#clouds').animate(		{backgroundPosition: '-3000px 0px'}, {duration: speed, easing: 'easeInOutCubic'});
			} else if ($(this).attr('href') == '#contact')	{
				$('#content').animate(		{scrollLeft: '16000px'}, {duration: speed, easing: 'easeInOutCubic'});
				$('#background').animate(	{backgroundPosition: '-800px 0px'}, {duration: speed, easing: 'easeInOutCubic'});
				$('#layer').animate(		{backgroundPosition: '-1200px 0px'}, {duration: speed, easing: 'easeInOutCubic'});
				$('#clouds').animate(		{backgroundPosition: '-4000px 0px'}, {duration: speed, easing: 'easeInOutCubic'});
			} else {
				$('#content').animate(		{scrollLeft: '0px 0px'}, {duration: speed, easing: 'easeInOutCubic'});
				$('#background').animate(	{backgroundPosition: '0px 0px'}, {duration: speed, easing: 'easeInOutCubic'});
				$('#layer').animate(		{backgroundPosition: '0px 0px'}, {duration: speed, easing: 'easeInOutCubic'});
				$('#clouds').animate(		{backgroundPosition: '0px 0px'}, {duration: speed, easing: 'easeInOutCubic'});
			}
	
    	    //to hide the anchor in url, return false
			return false;
		});  
		
	}
};

/* PROJECT TABLE DRAG **********************************************************************************/
var tabledrag = {
	init: function(){	
	    $('#viewport').dragscrollable();
	}
};


/* LAZY LOAD IMAGES **********************************************************************************/
var lazyload = {
	init: function(){	
		$('img.lazy').lazyload({
    		effect: "fadeIn"
        });
	}
};
