$("html").removeClass("ohfouc");
	
		var Errand = (function(foolio) {
			
			var the_window,
				primary,
				chapters,
				menu,
				sections,
				feedback,
				current;
			
	
			var nope = function nope(event) { event.preventDefault(); };

			
			var patches = {
			
				continuedText: function(selector) {
					$(selector).each(function(eq) {
						var p = $(this);
						if(eq == 0) {
							p.append($(' <a href="#more" class="more">Read on&hellip;<\/a>').click(function(e){
								e.preventDefault();
								p.hide().next().fadeIn();
							}));
						} else {
							p.prepend($('<a href="#less" class="more">(continued)<\/a> &hellip;').click(function(e){
								e.preventDefault();
								p.hide().prev().fadeIn();						
							})).hide();
						}				
					});				
				}, 
				
				positionsections: function() {				
					$('#case').css('width', (sections.length*100) + "%");
					sections.each(function(eq) {
						var foolio = $(this);
						var w = 100/sections.length;
						foolio.data('index', eq)
							.css({ 'left': (eq * w) + "%",
								   'width': w + "%",
								   'visibility': 'visible'})
							.data('translate', "translate(-" + (eq * w) + "%),0");
	
					
					})
				},
				
				shuttles: function(sel) {
					$(sel).each(function(eq) {
						var target = $(this);
						var children = target.children();
						$('<ul class="shuttle"><li class="next"><a class="next">Next<\/a><\/li><li class="previous"><a class="previous">Previous<\/a><\/li><li class="status">1/' + children.length + '<\/li><\/ul>')
							.insertBefore(target)
							.data('target', target)
							.delegate("a.next, a.previous", "click", navigation.shuttle);
						children.not(':first').hide();
					});				
				},
					buildControls: function() {
					$('<li class="next"><a class="next">Next<\/a><\/li><li class="previous"><a class="previous">Previous<\/a><\/li>')
						.appendTo('#primary>ul')
						.delegate("a.next, a.previous", "click", navigation.shuttleProduct);
					
					
					menu.parent().hover(function(e) {
						menu.addClass('shown');
					}, function(e) {
						menu.removeClass('shown');					
					});
				}
			};
			
			
			
			
			var navigation = {				
				scrollElement: $("html"),
				primary: function(event) {
					$.address.value($(event.target).attr('href').replace(/#/,''));
					event.preventDefault();
					return false;
				},

				menuClick: function(event) {
					var target = $.data(this, 'address');
					if(target && target.length) {
						
					}
				},

				smoothScroll: function(event) {
					event.preventDefault();
					event.stopPropagation();
					$.address.value($(this).attr('href').replace(/#/,''));
					return false;
				},

			};

			$.address.change(function(event) {
				var target = $("#" + event.pathNames[0]);
					
				if(!target.length) {
					//------ Try again, assuming this is some kind of primary navigation link.
					target = primary.find('[href=' + event.path.replace(/^\//,'') + ']');
					if(target.length) {
						navigation.showChapter(target);
					}
				} else if(target.hasClass('product')) {
					navigation.scrollElement.stop().animate({ scrollTop: 0 }, 600);
					var pan = $('#case');								
					var i = target.data('index');								
					if($.support.transition) {
						pan.css( "-webkit-transform", "translate(-" + (20 * i) + "%,0)");
					} else {
						pan.stop().animate({ left: (-100 * i) + '%'}, 400);
					}
					if(event.pathNames[0] == 'cabernetsauvignon' && target.hasClass("lazy")) {
						patches.continuedText('#cabernetsauvignon .overview p');
						target.removeClass('lazy');
					}					
				} else {				
					if(event.pathNames[0] == "updates") {
						navigation.scrollElement.stop().animate({ scrollTop: chapters.offset().top }, 600);
						$('.chapter').hide();
						target.show();
						return;
					}
					
					
				}
			});
			
				
							
			$(document).ready(function() {
			
				the_window = $(window);
				sections = $('#sections').find('.product');
				primary = $('#primary');
				chapters = $('#chapters');
				menu = $('#releases ul').delegate("li", "click", navigation.menuClick).detach();
												
				patches.positionsections();
				patches.buildControls();
				patches.shuttles('#updates .gallery');

				navigation.scrollElement = (function(){
					var detected = "body";
					$('html, body').each(function(eq, elem) {
						var initScrollTop = elem.scrollTop;
						elem.scrollTop = initScrollTop + 1;
						if(elem.scrollTop == initScrollTop + 1) {
							detected = elem.nodeName.toLowerCase();
							elem.scrollTop = initScrollTop;
							return false;
						}
					});			
					return $(detected);
				})();
			
			
				primary.delegate("a[rel=chapter], a[href$=updates]", "click", navigation.primary)
					   .bind('onselectstart', nope);
					   
				$('a[href^=#]').live('click', navigation.smoothScroll);				   

		
				if($.support.transition) $('body').addClass('unboring');
			});			

				})("#taureau");
		
