	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;
					$('.subnav', this).localScroll( {
						target: $('.content', this), 
						duration: 1500,
						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: $('.content', this), 
						axis: 'xy',
						queue: true,
						hash: false,
						duration: 1500
					} );					
				} );				
				$('ul.photography,ul.identity').hide();
				$('a.web').click(function() {
					if ($("ul.photography").is(":visible")) 
						$("ul.photography").slideUp();
					if ($("ul.identity").is(":visible")) 
						$("ul.identity").slideUp();
					if ($("ul.web").is(":hidden"))
						$("ul.web").slideDown();
				} );
				$('a.photography').click(function() {
					if ($("ul.web").is(":visible")) 
						$("ul.web").slideUp();
					if ($("ul.identity").is(":visible")) 
						$("ul.identity").slideUp();
					if ($("ul.photography").is(":hidden"))
						$("ul.photography").slideDown();
				} );
				$('a.identity').click(function() {
					if ($("ul.photography").is(":visible")) 
						$("ul.photography").slideUp();
					if ($("ul.web").is(":visible")) 
						$("ul.web").slideUp();
					if ($("ul.identity").is(":hidden"))
						$("ul.identity").slideDown();
				} );				
				setupZoom();				
				$('#foliothumbs').cycle();		
			} );	