$(document).ready(function() {
		
		var windowWidth = $('#wrapper').width(); 
		var titles = new Array("","Accueil","Notre Salon","La Morphopsychologie","Nos marques : sebastian professional","Nos marques : wella","Contact","Presse people","Les bons plans de steph");

		function newPos(pos, inertia){
			return (50 + ((-pos*inertia*100)/windowWidth))  + "% 0px";
		}

		function Move(){ 
		
			var offset = $('#box1').offset();
			var pos = offset.left; 
			
			$("#box1 .content").css({'backgroundPosition': newPos(pos, -0.5)});
			$("#box1 .inner").css({'backgroundPosition': newPos(pos, -0.8)});
			$("#box1 .inner1").css({'backgroundPosition': newPos(pos, 0.2)});
			$("#box1 .inner2").css({'backgroundPosition': newPos(pos, 0.8)});
			
			var offset2 = $('#box2').offset();
			var pos2 = offset2.left;
			
			$("#box2 .content").css({'backgroundPosition': newPos(pos2, -5)});
			$("#box2 .inner").css({'backgroundPosition': newPos(pos2, 2)});
			
			var offset3 = $('#box3').offset();
			var pos3 = offset3.left;
			
			$("#box3 .content").css({'backgroundPosition': newPos(pos3, 0.5)});
			
			var offset4 = $('#box4').offset();
			var pos4 = offset4.left;
			
			$("#box4 .content").css({'backgroundPosition': newPos(pos4, 1.5)});
			$("#box4 .inner").css({'backgroundPosition': newPos(pos4, 0.5)});
			$("#box4 .inner1").css({'backgroundPosition': newPos(pos4, 0.5)});
			$("#box4 .inner2").css({'backgroundPosition': newPos(pos4, 0.5)});
			$("#box4 .inner3").css({'backgroundPosition': newPos(pos4, -1)});
			
			var offset5 = $('#box5').offset();
			var pos5 = offset5.left;
			
			$("#box5 .content").css({'backgroundPosition': newPos(pos5, 0.5)});
			$("#box5 .inner").css({'backgroundPosition': newPos(pos5, -2)});
			$("#box5 .inner1").css({'backgroundPosition': newPos(pos5, -0.8)});
			$("#box5 .inner2").css({'backgroundPosition': newPos(pos5, 0.9)});
			$("#box5 .inner3").css({'backgroundPosition': newPos(pos5, -0.3)});
			
			var offset6 = $('#box6').offset();
			var pos6 = offset6.left;
									
			$("#box6 .content").css({'backgroundPosition': newPos(pos6, -0.5)});
			
			var offset7 = $('#box7').offset();
			var pos7 = offset7.left;
			
			$("#box7 .content").css({'backgroundPosition': newPos(pos7, 0)});
		}	
		
		$('#wrapper').bind('scroll', function(){ 
			Move(); 
		});
		
		
		$('a.link').click(function () {			
			if ($(this).attr('href').substr(3, 2) != $('#header').attr('class'))
			{
				$('#header').switchClass( $('#header').attr('class'), $(this).attr('href').substr(3, 2), 0 );
			}
			document.getElementById("title").innerHTML = titles[$(this).attr('href').substr(4, 1)];
			
			$('#wrapper').scrollTo($(this).attr('href'), {duration: 2000,easing:'swing',queue:false});
			$('a.link').removeClass('selected');
			$(this).addClass('selected');
			return false;						
		});
	});
	
