	function calcParallax(tileheight, speedratio, scrollposition) {
			  return ((tileheight) - (Math.floor(scrollposition / speedratio) % (tileheight+1)));
			}
			$(function() {				
				window.onscroll = function() {
					var posX = (document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : window.pageXOffset;
					var posY = (document.documentElement.scrollTop) ? document.documentElement.scrollTop : window.pageYOffset;				
					var clouds = document.getElementById('clouds');
					var cloudsparallax = calcParallax(500, .4, posY);
					clouds.style.backgroundPosition = "0 " + cloudsparallax + "px"; 
				}
				
				$('.nav, .folio, .welcome, #baselinks').localScroll( {
					duration: 2000,					
					onBefore: function(e, anchor, $target) {
					    $('.outer').removeClass('important');
					},
					onAfter: function(e, anchor, $target) {
					    $(e).addClass('important');
					}
				} );	
				
				$('.outer').each(function() {
					var wrapper = this.id;
					$('.bandeaumenu', this).localScroll( {
						target: $('.masque', this), 
						duration: 2000,
						hash: false,
						axis: 'xy',
						queue: true,
						onBefore: function(e, anchor, $target, $wrapper){ 
							$('.' + wrapper + 'scrolling').removeClass(wrapper + 'scrolling');
							$(this).addClass(wrapper + 'scrolling');
							this.blur();
						}
					} );
					
					$('.portfoliosection').each(function() {
					var wrapper = this.id;
					$('.submenu', this).localScroll( {
						target: $('.portfoliomasque', this), 
						duration: 2000,
						hash: false,
						axis: 'xy',
						queue: true,
						onBefore: function(e, anchor, $target, $wrapper){ 
							$('.' + wrapper + 'scrolling').removeClass(wrapper + 'scrolling');
							$(this).addClass(wrapper + 'scrolling');
							this.blur();
						}
					} );

					
					$('li.sub p, li.sub li', this).localScroll( {
						target: $('.masque', this), 
						axis:'xy',
						queue: true,
						hash: false,
						duration: 1500
					} );
					
						$('div.subtexte a, div.subtexte', this).localScroll( {
						target: $('.portfoliomasque', this), 
						axis:'xy',
						queue: true,
						hash: false,
						duration: 1500
					} );					

				} );
			} );	
} );
