// JavaScript Document
var initialPrint = 0;
var initialInteractive = 0;

//Activate Immediately
$(document).ready(function(){
						   
	//Show Web
		$('#work_web').serialScroll({
		items:'#web li', // Selector to the items ( relative to the matched elements, '#sections' in this case )
		prev:'#arrow_left',// Selector to the 'prev' button (absolute!, meaning it's relative to the document)
		next:'#arrow_right',// Selector to the 'next' button (absolute too)
		axis:'x',// The default is 'y' scroll on both ways
		duration:700,// Length of the animation (if you scroll 2 axes and use queue, then each axis take half this time)
		force:true, // Force a scroll to the element specified by 'start' (some browsers don't reset on refreshes)
		lock:false, // Ignore events if already animating (true by default)		
		start:window.startpoint, // On which element (index) to begin ( 0 is the default, redundant in this case )		
		constant:false, // constant speed
		
		onBefore:function( e, elem, $pane, $items, pos ){
			e.preventDefault();
			if( this.blur )
				this.blur();
		},
		onAfter:function( elem ){

		}
	});
	//Show Arrows	
	$("#arrow_left").show();
	$("#arrow_right").show();
	$("#arrow_left").hover(function() {$(this).css( {backgroundPosition:"0px -77px"});},function () {$(this).css( {backgroundPosition:"0px 0px"});});
	$("#arrow_right").hover(function() {$(this).css( {backgroundPosition:"0px -77px"});},function () {$(this).css( {backgroundPosition:"0px 0px"});});
						   
	//Allows Non-Javascript Users to Scroll through choices					   
	$("#work_web").css( {overflow:"hidden"});
	$("#work_print").css( {overflow:"hidden"});
	$("#work_interactive").css( {overflow:"hidden"});
	
	//Randomly picks starting image (favoring those listed first)				
	window.startpoint = Math.floor(Math.random()*8);
	if(startpoint > 2){window.startpoint = Math.floor(Math.random()*8);};
	if(startpoint > 4){window.startpoint = Math.floor(Math.random()*8);};
	
	menuRollovers();
	$("#menu_web").hover(function() {$(this).css( {backgroundPosition:"0px -66px"});},function () {$(this).css( {backgroundPosition:"0px -66px"});});

});

//Work Menu Rollovers
function menuRollovers(){
	$("#menu_web").hover(function() {$(this).css( {backgroundPosition:"0px -33px"});},function () {$(this).css( {backgroundPosition:"0px 0px"});});
	$("#menu_print").hover(function() {$(this).css( {backgroundPosition:"-76px -33px"});},function () {$(this).css( {backgroundPosition:"-76px 0px"});});
	$("#menu_interactive").hover(function() {$(this).css( {backgroundPosition:"-156px -33px"});},function () {$(this).css( {backgroundPosition:"-156px 0px"});});
}

//Work Menu Highlights
function menuHighlight(){
	$("#menu_web").css( {backgroundPosition:"0px 0px"});
	$("#menu_print").css( {backgroundPosition:"-76px 0px"});
	$("#menu_interactive").css( {backgroundPosition:"-156px 0px"});
}

//Reveals Web Work
function showWeb(){
	$("#interactive").hide();
	$("#print").hide();
	$("#web").show();
	$("#work_web").trigger( 'goto', [ 0 ] );
	$("#work_interactive").css("z-index", "40");
	$("#work_print").css("z-index", "40");
	$("#work_web").css("z-index", "50");
	menuHighlight();
	$("#menu_web").css( {backgroundPosition:"0px -66px"});
	menuRollovers();
	$("#menu_web").hover(function() {$(this).css( {backgroundPosition:"0px -66px"});},function () {$(this).css( {backgroundPosition:"0px -66px"});});
}
//Reveals Print Work
function showPrint(){
	if(initialPrint == 0){
		$('#work_print').serialScroll({
		items:'#print li', // Selector to the items ( relative to the matched elements, '#sections' in this case )
		prev:'#arrow_left',// Selector to the 'prev' button (absolute!, meaning it's relative to the document)
		next:'#arrow_right',// Selector to the 'next' button (absolute too)
		axis:'x',// The default is 'y' scroll on both ways
		duration:700,// Length of the animation (if you scroll 2 axes and use queue, then each axis take half this time)
		force:true, // Force a scroll to the element specified by 'start' (some browsers don't reset on refreshes)
		lock:false, // Ignore events if already animating (true by default)		
		start:0, // On which element (index) to begin ( 0 is the default, redundant in this case )		
		constant:false, // constant speed
		
		onBefore:function( e, elem, $pane, $items, pos ){
			e.preventDefault();
			if( this.blur )
				this.blur();
		},
		onAfter:function( elem ){

		}
	});
	};
	initialPrint = 1;
	$("#interactive").hide();
	$("#web").hide();
	$("#print").show();
	$("#work_print").trigger( 'goto', [ 0 ] );
	$("#work_interactive").css("z-index", "40");
	$("#work_print").css("z-index", "50");
	$("#work_web").css("z-index", "40");
	menuHighlight();
	$("#menu_print").css( {backgroundPosition:"-76px -66px"});
	menuRollovers();
	$("#menu_print").hover(function() {$(this).css( {backgroundPosition:"-76px -66px"});},function () {$(this).css( {backgroundPosition:"-76px -66px"});});
}
//Reveals Interactive Work
function showInteractive(){
	if(initialInteractive == 0){$("#interactive").load("interactive.htm");};
	initialInteractive = 1;
	$("#print").hide();
	$("#web").hide();
	$("#interactive").show();
	$("#work_interactive").trigger( 'goto', [ 0 ] );
	$("#work_interactive").css("z-index", "50");
	$("#work_print").css("z-index", "40");
	$("#work_web").css("z-index", "40");
	menuHighlight();
	$("#menu_interactive").css( {backgroundPosition:"-156px -66px"});
	menuRollovers();
	$("#menu_interactive").hover(function() {$(this).css( {backgroundPosition:"-156px -66px"});},function () {$(this).css( {backgroundPosition:"-156px -66px"});});
}

//Show Work Menu
function showMenu(){
	document.write('<ul id="work_menu"><li id="menu_web" onclick="showWeb();"><span class="green">PLANNING</span> </li><li id="menu_print" onclick="showPrint();"><span class="green"><?=PLAN_AND_CARRY?></span></li></ul>');
}
	
