jQuery(function( $ ) {
	$("#logo IMG").css('display', 'inline').removeClass('active').css('opacity', 0);
	$("#portfolio-frame-logo").addClass('active').css('opacity', 1);
	
	if (navigator.userAgent.match(/MSIE 6/i)) {
		$("#header").css('margin-left', '125px');
	}

	$("#slider").easySlider({
		auto:false,
		continuous:true
	});
	
	/**
	 * Most jQuery.localScroll's settings, actually belong to jQuery.ScrollTo, check it's demo for an example of each option.
	 * @see http://flesler.demos.com/jquery/scrollTo/
	 * You can use EVERY single setting of jQuery.ScrollTo, in the settings hash you send to jQuery.LocalScroll.
	 */
	
	// The default axis is 'y', but in this demo, I want to scroll both
	// You can modify any default like this
	$.localScroll.defaults.axis = 'x';
	
	// Scroll initially if there's a hash (#something) in the url 
	$.localScroll.hash({
		queue:true,
		duration:1500
	});
	
	/**
	 * NOTE: I use $.localScroll instead of $('#navigation').localScroll() so I
	 * also affect the >> and << links. I want every link in the page to scroll.
	 */
	$.localScroll({
		queue:true,
		duration:1000,
		hash:true,
		onBefore:function( e, anchor, $target ){
			// The 'this' is the settings object, can be modified
		},
		onAfter:function( anchor, settings ){
			// The 'this' contains the scrolled element (#content)
			
			var anchorID = $(anchor).attr("id");

			var $activeLogo = $('#logo IMG.active');

			$activeLogo.removeClass('active').animate({opacity: 0}, 1000);
			$('#' + anchorID + '-logo').addClass('active').animate({opacity: 1.0}, 1000);
			
			$("a[rel='gallery']").click(function() { return false; });
			
			if ( (navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) ) {
				switch (anchorID) {
					case 'portfolio-frame':
						$('#header').animate({left: '125px'}, 500);
						break;

					case 'about-frame':
						$('#header').animate({left: '1650px'}, 500);
						break;

					case 'services-frame':
						$('#header').animate({left: '3175px'}, 500);
						break;

					case 'contact-frame':
						$('#header').animate({left: '4700px'}, 500);
						break;
				}
			} else if (navigator.userAgent.match(/MSIE 6/i)) {
				switch (anchorID) {
					case 'portfolio-frame':
						$('#header').animate({marginLeft: '125px'}, 500);
						break;

					case 'about-frame':
						$('#header').animate({marginLeft: '1650px'}, 500);
						break;

					case 'services-frame':
						$('#header').animate({marginLeft: '3175px'}, 500);
						break;

					case 'contact-frame':
						$('#header').animate({marginLeft: '4700px'}, 500);
						break;
				}
			}
		}
	});
	
	$.fn.HoverImageText.defaults.AnimShow = {height: "show"};
	$.fn.HoverImageText.defaults.AnimHide = {height: "hide"};
	$('#slider li').HoverImageText();
	
	// Don't call for iPhone
	if ( !(navigator.userAgent.match(/iPhone/i)) && !(navigator.userAgent.match(/iPod/i)) ) { 
		$("a[rel='gallery']").colorbox({transition:"fade"});
	} else {
		$("#i-phone-about-nav").css('visibility', 'visible');
		$("#i-phone-services-nav").css('visibility', 'visible');
		
		$("a[rel='gallery']").each(function(){
			var $t = jQuery(this);
			$t.click(function(e) { e.preventDefault(); });
		});
	}
});
