/* ================ */
/* = HTML5 Shiv   = */
/* ================ */
/*@cc_on'abbr article aside audio canvas details figcaption figure footer header hgroup mark menu meter nav output progress section summary time video'.replace(/\w+/g,function(n){document.createElement(n)})@*/


/* ==================== */
/* = Google Analytics = */
/* ==================== */
/* http://www.shamasis.net/projects/ga/
 * Revision: 13
 */


$(function(){
	/* ================ */
	/* = Navigation   = */
	/* ================ */
	
	var $selected = $("#nav ul .selected");
	var $magicLine = $("<li id='magic-line'></li>").css({ left: $selected.position().left, width: $selected.width() });
	$("#nav ul li").hover(
		function() { $magicLine.stop().animate({ left: $(this).position().left, width: $(this).width() },500,'swing'); },
		function() { $magicLine.stop().animate({ left: $selected.position().left, width: $selected.width() },500,'swing'); }
	).slice(-1).after($magicLine);
	
	
	$("#pages-nav").tabs("#pages > .page").history();
	
	$('.photos').wrapInner("<div class='scrollable'><div class='items'></div></div>").append('<div class="arrows"><a class="prev arrow-left">Prev</a><a class="next arrow-right">Next</a></div><div class="navi"></div>');
	var horizontal = $(".scrollable").scrollable({size: 1, speed: 1000, loop: true}).navigator(".navi").autoscroll(6000).eq(0).scrollable().focus();
	
	// Load Google Analytics
	$.ga={};$.ga.load=function(uid,callback){$.ajax({type:'GET',url:(document.location.protocol=="https:"?"https://ssl":"http://www")+'.google-analytics.com/ga.js',cache:true,success:function(){if(typeof _gat==undefined){throw"_gat has not been defined";}t=_gat._getTracker(uid);bind();if($.isFunction(callback)){callback(t);}t._trackPageview();},dataType:'script',data:null});};var t;var bind=function(){if(noT()){throw"pageTracker has not been defined";}for(var $1 in t){if($1.charAt(0)!='_'){continue;}$.ga[$1.substr(1)]=t[$1];}};var noT=function(){return t==undefined;};

	$.ga.load("UA-15353274-1");
	
	/* =========================== */
	/* = Second Level Navigation = */
	/* =========================== */
	$('#pages-nav a').click(function() {
		// Register the click in Google Analytics
		$.ga.trackPageview(this.href);
		
		// focus on the horzontal scrollable
		setTimeout( function(){ $(".scrollable:visible").eq(0).scrollable().focus(); }, 100 );
		
		var targetOffset = $('#bar').offset().top;
		$('html,body').css({scrollTop: targetOffset});
		
		return false;
	});
	

});


