		$(document).ready(function() {

			/*
			
			IMAGE FADER
			
			*/
							
			$('#feature').innerfade({
				speed: 1000,
				timeout: 4000,
				type: 'sequence',
				containerheight: '350px'
			});
		
			// some pages have both scroll-nav-uber and scroll0nav
			//var inLikables = $("#likables")[0];
			var inCollection = $("#collection")[0];			
			var hasScrollUber = false;
			//if (inLikables) {
			//	hasScrollUber = true
			//}
			if (inCollection) {
				hasScrollUber = true
			}
			
			// store the scroll-nav-uber and scroll-nav anchors
			var scrollNavUberAnchors = $("#scroll-nav-uber > li a");
			var scrollNavAnchors = $("#scroll-nav > ul a");
			
			// when page loads, turn on first scroll-nav-uber and scroll-nav anchor
			$(scrollNavUberAnchors[0]).addClass("on");
			$(scrollNavAnchors[0]).addClass("selected");
		
		
			if (hasScrollUber) {
				// maintain scroll-nav-uber state
				scrollNavUberAnchors.click(function() {
					scrollNavUberAnchors.removeClass("on");
					$(this).addClass("on");
					// make sure sroll-nav links maintain state as sroll-nav-uber is clicked
					scrollNavAnchors.removeClass("selected");
					scrollNavAnchors[getAryIndex(scrollNavUberAnchors,this)].className = "selected";
				})			
			}
		
			// maintain scroll-nav state
			scrollNavAnchors.click(function() {
				scrollNavAnchors.removeClass("selected");
				$(this).addClass("selected");
				if (hasScrollUber) {
					// make sure sroll-nav-uber links maintain state as sroll-nav is clicked
					scrollNavUberAnchors.removeClass("on");
					scrollNavUberAnchors[getAryIndex(scrollNavAnchors,this)].className = "on";
				}
			});
			
			
			// check for contact form and maintain the contact address nav state, also write the href into a hidden field
			var contactAddress = $("#contact-address")[0];
			if(contactAddress) {
			     var contactAddressLinks = $("#contact-address > li a");
				contactAddressLinks.click(function() {
					// maintain nav state
					contactAddressLinks.removeClass("on");
					contactAddressLinks.addClass("off");
					$(this).addClass("on");
					
					// open up the contact form
					var contactForm = $("#contact-form")[0];
					$(contactForm).addClass("show-form");
					
					// write href (minus the "mailto:") to hidden field so when form posts, we can use that email address
					var contactAddress = $("#contactAddress")[0];
					var emailAddress = this.href.split(":")[1];
					contactAddress.value = emailAddress;
					
					// don't follow the href
					return false;
				});
			     
			}
			
			// on the collection page there are three bag views: front, inside, side
			if (inCollection) {
				var bagNavAnchors = $(".bag-nav a");
				bagNavAnchors.click(function() {
					
					// find the associated image
					var theBag =  $(this).parents("li")[1];
					var theBagImg = theBag.getElementsByTagName("IMG")[0];
					theBagImg.src = this.href;
				
					// maintain nav state for the set we are on
					var currentBagNav = $(this).parents("ul")[0];
					var aryLinks = currentBagNav.getElementsByTagName("A");
					for( var i=0; i < aryLinks.length; i++ ){
						aryLinks[i].className = "";
					}
					
					// turn on the anchor just clicked
					$(this).addClass("on");
					
					// don't follow the link
					return false;
				});
				
				// on collecion page, user could click the first image to advance to the first bag, 
				// so we need to trigger nav state on scroll-nav-uber and scroll-nav
				var collectionStart = $("#start > a")[0];
				/*
				collectionStart.click(function() {
					
					alert(collectionStart.href);
					
					// don't follow the link
					return false;
				});
				*/
			}
			
			
			
		});
		
		
		// helper function which loops through an array and returns the index of the element that matches
		// the anchor trigger passed in (pEl). This is used so the scroll nav and scroll nav uber can stay in sync
		function getAryIndex(pAry,pEl) {
			var retIndex = 0;
			for( var i=0; i < pAry.length; i++ ){
				if (pAry[i] == pEl) {
					retIndex = i;
				}
			}
			//alert(retIndex);
			return retIndex;
		}