// color animation plugin
(function(d){d.each(["backgroundColor","borderBottomColor","borderLeftColor","borderRightColor","borderTopColor","color","outlineColor"],function(f,e){d.fx.step[e]=function(g){if(!g.colorInit){g.start=c(g.elem,e);g.end=b(g.end);g.colorInit=true}g.elem.style[e]="rgb("+[Math.max(Math.min(parseInt((g.pos*(g.end[0]-g.start[0]))+g.start[0]),255),0),Math.max(Math.min(parseInt((g.pos*(g.end[1]-g.start[1]))+g.start[1]),255),0),Math.max(Math.min(parseInt((g.pos*(g.end[2]-g.start[2]))+g.start[2]),255),0)].join(",")+")"}});function b(f){var e;if(f&&f.constructor==Array&&f.length==3){return f}if(e=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(f)){return[parseInt(e[1]),parseInt(e[2]),parseInt(e[3])]}if(e=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(f)){return[parseFloat(e[1])*2.55,parseFloat(e[2])*2.55,parseFloat(e[3])*2.55]}if(e=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(f)){return[parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16)]}if(e=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(f)){return[parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16)]}if(e=/rgba\(0, 0, 0, 0\)/.exec(f)){return a.transparent}return a[d.trim(f).toLowerCase()]}function c(g,e){var f;do{f=d.curCSS(g,e);if(f!=""&&f!="transparent"||d.nodeName(g,"body")){break}e="backgroundColor"}while(g=g.parentNode);return b(f)}var a={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0],transparent:[255,255,255]}})(jQuery);

// "go to top" plugin
jQuery.fn.topLink = function(settings) {
		settings = jQuery.extend({
			min: 1,
			fadeSpeed: 200,
			
			ieOffset: 50
		}, settings);
		return this.each(function() {
			//listen for scroll
			var el = $(this);
			el.css('display','none'); //in case the user forgot
			$("#content").scroll(function() {
				if(!jQuery.support.hrefNormalized) {
					el.css({
						'position': 'absolute',
						'top': $("#content").scrollTop() + $("#content").height() - settings.ieOffset
					});
				}
				if($("#content").scrollTop() >= settings.min)
				{
					el.fadeIn(settings.fadeSpeed);
				}
				else
				{
					el.fadeOut(settings.fadeSpeed);
				}
			});
		});
	};

// set custom fonts in headers to have class=header
// cufon fallback for FireFox and Safari (versions before font embedding)
/*   if ($.browser.mozilla) {
	   if (jQuery.browser.version.substr(0, 5) == "1.9.1") {
	   //do nothing //
		} else {
				if (jQuery.browser.version.substr(0, 5) == "1.9.2") {
				// do nothing
				} else {
					if (jQuery.browser.version.substr(0, 1) >= "2") { 
					//do nothing
					}
					else {
						Cufon.replace('.header');
					}
				}
		}
   } 
   if ($.browser.safari) {
   	var browserVersion2 = jQuery.browser.version.substr(0, 3);
	var browserVersion = parseInt(browserVersion2);
   	if (browserVersion < 525 ){
		Cufon.replace('.header');
	}
   }
*/

analytics = "on";
// analytics = "off";


// +++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
// +++++++++++++++++++++++ ON LOAD +++++++++++++++++++++++ //
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++ //

jQuery(function( $ ){
// ++++++++++++++++++++++++++++++++++++ //
// ++++++++++ SITE SPECIFICS ++++++++++ //
// ++++++++++++++++++++++++++++++++++++ //
	$('#zach').hide();
	$('#chad').hide();
	$('#dave').hide();
	
	$('#zach2').hover(
	  function () {
	    $('#zach').show();
	  },
	  function () {
	    $('#zach').hide();
	  }
	);
	$('#chad2').hover(
	  function () {
	    $('#chad').show();
	  },
	  function () {
	    $('#chad').hide();
	  }
	);
	$('#dave2').hover(
	  function () {
	    $('#dave').show();
	  },
	  function () {
	    $('#dave').hide();
	  }
	);


$.ajax({
  url: "http://www.simplymichele.com/browse.php?video",
  cache: false,
  success: function(html){
    $('#videos').html(html);
  }
});

$.ajax({
  url: "http://www.simplymichele.com/browse.php?project",
  cache: false,
  success: function(html){
    $('#projects').html(html);
  }
});

$.ajax({
  url: "http://www.simplymichele.com/press.php",
  cache: false,
  success: function(html){
    $('#press').html(html);
  }
});

$(".ajaxarea a").live('click',function(e){
  e.preventDefault(); //*
  var URL = $(this).attr('href');
  var parentFrame = $(this).closest(".ajaxarea"); //**
  $.ajax({
    url: URL,
    cache: false,
	beforeSend: function(html){
		parentFrame.children(".loadingoverlay").show();
		
    },
    success: function(html){
      parentFrame.html(html); //***
	  parentFrame.children(".loadingoverlay").hide();
    }
  });
});

$("#cboxLoadedContent a").live('click',function(e){
  e.preventDefault(); //*
  URL2 = $(this).attr('href');
  parentFrame2 = $(this).closest("#cboxLoadedContent"); //**
  $.ajax({
    url: URL2,
    cache: false,
	beforeSend: function(html){
	//	parentFrame.children(".loadingoverlay").show();
    },
    success: function(html){
      parentFrame2.html(html); //***
	//  parentFrame.children(".loadingoverlay").hide();
//	container = $('#cboxLoadedContent').height();
//	projectContent = $('#projectContent').height();
//	  if(container >  projectContent){
//	  	$('#projectContent').height(container);
//	  };
    } 
/* ,	complete: function(){
	projectContent2 = $('#projectContent2').height();
	nintypercentage = $(window).height() * .9;
	if (projectContent2 < nintypercentage) {
		$('#projectContent').height(projectContent2);
		$('#cboxLoadedContent').height(projectContent2);
		$('#cboxContent').height(projectContent2);
		$('#cboxWrapper').height(projectContent2);
	}
	else {
		// set window to 90%
		$('#cboxLoadedContent').height(nintypercentage);
		$('#cboxContent').height(nintypercentage);
		$('#cboxWrapper').height(nintypercentage);
	}
}
*/

  });
});


//cboxLoadedContent
$("a[rel='example1']").live('click',function(e){
	e.preventDefault;
	theURL = $(this).attr('href');
	$.colorbox({
		href:theURL,
		slideshow: true,
		arrowKey: true,
		photo: true,
		rel:'example1'
	});
	return false;
});
	

$(".videobox").live('click',function(){
	theID = $(this).attr('id');
	TheURLLink = "http://www.simplymichele.com/video.php?video_id=" + theID;
	$.colorbox({href:TheURLLink , maxHeight:maxHeightOfBox, scrolling:true});
});
$(".projectbox").live('click',function(){
	theID = $(this).attr('id');
	TheURLLink = "http://www.simplymichele.com/project.php?project=" + theID;
	$.colorbox({href:TheURLLink , 
	//maxHeight:maxHeightOfBox,
	height: "90%" ,
	 scrolling:true});
});

$("#gotoproject").live('click',function(e){
	e.preventDefault;
	$.colorbox.close();
});
// ++++++++++++++++++++++++++++++++++++ //
// ++++++++++ BUILD FUNCTIONS +++++++++ //
// ++++++++++++++++++++++++++++++++++++ //

	// needed variables
	navHeight = $("#theNavigation").height();
	tipVar = 1;

	
	function slideRight(){
		var test = window.location.href.indexOf("#"); //1234
		var pageNum2 = window.location.hash.slice(1);
		var pageNum = parseInt(pageNum2);
		if (test > 0){
			var numOfPages = $(".section").length;
			if(pageNum == numOfPages){
				var next2 = "#nav1";
			} else {
				if (pageNum == 1){
					var next = pageNum + 1;
					var next2 = "#nav" + next;	
				} else {
					var next = pageNum + 1;
					var next2 = "#nav" + next;	
				}
			}
		} else {
			var next2 = "#nav2";	
		}
		$(next2).click();
	}
	
	function slideLeft(){
		var test = window.location.href.indexOf("#"); //1234
		var pageNum2 = window.location.hash.slice(1);
		var pageNum = parseInt(pageNum2);
		if (test > 0){
			var numOfPages = $(".section").length;
			if(pageNum == numOfPages){
				var back = pageNum - 1;
				var back2 = "#nav" + back;
			} else {
				if (pageNum == 1){
					var back = $(".section").length;
					var back2 = "#nav" + back;	
				} else {
					var back = pageNum - 1;
					var back2 = "#nav" + back;	
				}
			}
		} else {
			var back2 = "#nav" + $(".section").length;
		}
		$(back2).click();
	}

	// initializes section height
	function init_SectionHeight(){
		var test = window.location.href.indexOf("#"); //1234
		
		if (test > 0) {
			var pageNum2 = window.location.hash.slice(1);
			str = pageNum2.split('/');
			pageNum2 = pageNum2[0];
			var pageNum = parseInt(pageNum2);
			var hash = "#" + pageNum;
			var newHeight = $(hash).children().height();
			var testHeight = $(window).height() - navHeight -1;
			if (newHeight < testHeight){
					newHeight3 = testHeight;
				} else {
					newHeight3 = newHeight;
				}
		} else {
			var hash = "#1";
			var newHeight = $(hash).children().height();
			var testHeight = $(window).height() - navHeight -1;
			if (newHeight < testHeight){
					newHeight3 = testHeight;
				} else {
					newHeight3 = newHeight;
				}
		}
		$('#insidecontent').height(newHeight3);
		$('.section ul').children().height(newHeight3);
	}
	
	// initializes content height
	function init_ContentHeight(){
		if ($.browser.mozilla) {
			initSectionHeight = $(window).height() - navHeight + 14;
			initSectionHeight1 = initSectionHeight + "px";
		}
		else {
			winHeight = window.innerHeight ? window.innerHeight : $(window).height()
			initSectionHeight = winHeight - navHeight;
			initSectionHeight1 = initSectionHeight + "px";
		}
		$('#content').css("height", initSectionHeight1);
	}


	// center home page images
	function centerImages(){
		if (initSectionHeight > 460) { // change to window - nav
			// center michele
			contentHeight = $("#content").height();
			michelePhotoHeight = $("#michelephoto2").height();
			subtracted = contentHeight - michelePhotoHeight;
			micheleHeight = subtracted / 2;
			micheleHeight2 = micheleHeight + "px";
			$("#michelephoto").css("margin-top", micheleHeight2);
			mediakitPhotoHeight = $("#mediakit2").height();
			subtracted2 = contentHeight - mediakitPhotoHeight;
			mediakitHeight = subtracted2 / 2;
			mediakitHeight2 = mediakitHeight + "px";
			$("#mediakit").css("margin-top", mediakitHeight);
		}
		
		if (initSectionHeight > 230) { // change to window - nav
			contentHeight = $("#content").height();
			mediakitPhotoHeight = $("#mediakit2").height();
			subtracted2 = contentHeight - mediakitPhotoHeight;
			mediakitHeight = subtracted2 / 2;
			mediakitHeight2 = mediakitHeight + "px";
			$("#mediakit").css("margin-top", mediakitHeight);
		}
	}
	
	// set section width
	function sectionWidth(){
		$('div .section').css("width", $(window).width());
	}
	
	//set/change position of the sliding nav pointer
	function setPointer(){
		var test = window.location.href.indexOf("#"); //1234
		if (test > 0) {
			var pageNum2 = window.location.hash.slice(1);
			str = pageNum2.split('/');
			pageNum2 = pageNum2[0];
			navPos = "#nav" + pageNum2;
		} else {
			navPos = "#nav1";
		}
		moveTo2 = $(navPos).position().left + ($(navPos).width()/2);
		moveTo3 = $(navPos).position().top + $(navPos).height() + 0; // change "35" depending on your situation
		$("#theMover").css("left", moveTo2);
		//$("#theMover").css("top", moveTo3);
	}

// ++++++++++++++++++++++++++++++++++++ //
// ++++++++++++++++ Tip +++++++++++++++ //
// ++++++++++++++++++++++++++++++++++++ //
    $("#tip").hide();

// ++++++++++++++++++++++++++++++++++++ //
// +++++++ SWIPE FUNCTIONALITY	+++++++ //
// ++++++++++++++++++++++++++++++++++++ //
	var mdPoint; // must be defined
swipe = "1"; // change to "0" to turn off swiping
if (swipe == "1") {
	
	$(".sub").mousedown(function(e) {
	    e.stopPropagation();
	});
	
	$(".sub").mouseup(function(e) {
		if (mdPoint == "0") {
			e.stopPropagation();
		}
	});

	$(".sub").mouseover(function(e) {
			$("#tip").hide();
			$(".sub").css("border", "none");
			$("#color").stop().animate({
				backgroundColor: '#ffffff'
			}, 150);
			$("#insidecontent").removeClass('grab grabbing').addClass('nograb');
		if (mdPoint == "1") {
			// do nothing
		} else {
			$(window).unbind("mousemove");
			$("#content").unbind("mousemove");
			e.stopPropagation();
		}
	});


	$(".section, #rightarrow, #leftarrow").mouseover(function(e) {
		if (tipVar <= "2") {
			$("#tip").show();
			$(".section").mousemove(function(e){
				$("#tip").css({
					top: (e.pageY + 13) + "px",
					left: (e.pageX + -13) + "px"
				});
			});
		}
		$(".sub").css("background-color","#ffffff");
		$(".sub").css("border-right","solid");
		$(".sub").css("border-left","solid");
		$(".sub").css("border-width","2px");
		$(".sub").css("border-color","#A2DAA9");
		$("#color").stop().animate({backgroundColor:'#D5EED8'}, 150);
		$("#insidecontent").removeClass('nograb').addClass('grab');
		$(".section, #rightarrow, #leftarrow").mousedown(function(e) {
			$("#insidecontent").removeClass('grab').addClass('grabbing');
		});
		$(".section, #rightarrow, #leftarrow").mouseup(function(e) {
			$("#insidecontent").removeClass('grabbing').addClass('grab');
		});
	});
	
	$(".section").mouseleave(function(e) {
		$("#color").stop().animate({backgroundColor:'#ffffff'}, 150);
		$(".sub").css("border","none");
		$("#insidecontent").removeClass('grab grabbing').addClass('nograb');
		$("#tip").hide();
	});
	
	$("#insidecontent").mousedown(function(e){
			// Reference to the drag pad
			var inner = $(this);
			// Position where mouse was pressed
			lastPageX = e.pageX;
			
			
			start_Y = e.pageY;
			down_x = e.pageX;
			innit_x = $("#content").scrollLeft();
			mdPoint = "1";

			dontDoIt = "3";
			// Attach mouse move listener
			$(window).mousemove(function(e){
				dontDoIt = "1";
				up_x = e.pageX;
				var diffX = lastPageX - e.pageX;
				// Scroll based on the new curson position
				$("#content").scrollLeft($("#content").scrollLeft() + diffX);
				lastPageX = e.pageX;
				
				//////////
				
				if (mdPoint == "1") {
						
				if ((down_x - up_x) > 100) {
					slideRight();
					mdPoint = "0";
					$(window).unbind("mousemove");
					$("#content").unbind("mousemove");
					dontDoIt = "2";
					tipVar++;

				}
				if ((up_x - down_x) > 100) {
					slideLeft();
					mdPoint = "0";
					$(window).unbind("mousemove");
					$("#content").unbind("mousemove");
					dontDoIt = "2";
					tipVar++;
				}
				}

				
				/////////
			});
			// Remove mouse move listener
			$(window).mouseup(function(){
					$(window).unbind("mousemove");
					$("#content").unbind("mousemove");
					
			});
			e.preventDefault();
			

	});
	
	$(".sub, #theNavigation").mousedown(function(){
		 mdPoint = "0";
	});

	$(window).mouseup(function(e){
		if (mdPoint == "1") {
			up_x = e.pageX;
			do_work();
			mdPoint = "0";
		}
	});

//	$("#content").mousedown(function(e){
//		$("#content").mouseleave(function(e){
//			up_x = e.pageX;
//			do_work();
//		});
//	});
	
	
	$("#content").bind('touchstart', function(e){
		down_x = e.originalEvent.touches[0].pageX;
		innit_x = $("#content").scrollLeft();
		///////
		lastPageX = e.originalEvent.touches[0].pageX;
		lastPageY = e.originalEvent.touches[0].pageY;
	});
	$("#content").bind('touchmove', function(e){
		e.preventDefault();
		up_x = e.originalEvent.touches[0].pageX;
		/////////
		var diffX = lastPageX - e.originalEvent.touches[0].pageX;
		var diffY = lastPageY - e.originalEvent.touches[0].pageY;
		// Scroll based on the new curson position
		if (Math.abs(diffX) > Math.abs(diffY)) {
			$("#content").scrollLeft($("#content").scrollLeft() + diffX);
			
		}
		else {
			$("#content").scrollTop($("#content").scrollTop() + diffY);
			
		}
		lastPageX = e.originalEvent.touches[0].pageX;
		lastPageY = e.originalEvent.touches[0].pageY;
		
	});
	$("#content").bind('touchend', function(e){
		do_work();
		//	$("#content").unbind("touchmove");
	
	});
	function do_work(){
		if (dontDoIt == "1") {
			if ((down_x - up_x) > 50) {
				slideRight();
			}
			if ((up_x - down_x) > 50) {
				slideLeft();
				
			}
			
			else {
				if ((down_x - up_x) > 50) {
				// nothing
				}
				else {
					$("#content").animate({
						scrollLeft: innit_x
					}, 100);
				}
			}
		}
	}
	function do_work2(){
		if ((down_x - up_x) > 50) {
			slideRight();
		}
		if ((up_x - down_x) > 50) {
			slideLeft();
			
		}
	}

}	// end swipe functionality

// ++++++++++++++++++++++++++++++++++++ //
// ++++++ KEYBOARD FUNCTIONALITY ++++++ //
// ++++++++++++++++++++++++++++++++++++ //
	// build key arrow (down)
	$(window).keydown(function(e) {
		if (e.keyCode == '40') {
			var hashLength = window.location.hash.length;
			if (hashLength < 3){
				// select first link 
				var hashLink = window.location.hash + " > .insection"; 
				$(hashLink).find('a.verticalNav[href*="#"]:first').click();
			} else {
				// select link after current link
				var hashLink = window.location.hash;
				var search = "a[href*=\"" + hashLink + "\"]";
				$(search).nextAll('a[href*="#"]:first').click();
			}
			e.preventDefault();
		}
	});

	// build key arrow (up)
	$(window).keydown(function(e) {
		if (e.keyCode == '38') {
			var hashLength = window.location.hash.length;
			if (hashLength < 3){
				// already at top 
			} else {
				// select link before current link
				var hashLink = window.location.hash;
				var search = "a[href*=\"" + hashLink + "\"]";
				if ( $(search).prevAll('a[href*="#"]:first').length ){
					$(search).prevAll('a[href*="#"]:first').click();
				} else {
					$('.top-link').click();
				}
			}
			e.preventDefault();
		}
	});

	// build arrow (left) nav
	$(window).keydown(function(e) {
		if (e.keyCode == '37') {
			slideLeft();
		}
	});

	// build arrow (right) nav
	$(window).keydown(function(e) {
		if (e.keyCode == '39') {
			slideRight();
		}
	});

// ++++++++++++++++++++++++++++++++++++ //
// ++++++++ ARROW FUNCTIONALITY +++++++ //
// ++++++++++++++++++++++++++++++++++++ //

	// initialize left arrow buttons
	$("#leftarrow, #leftbutton").click(function(e){
			slideLeft();
			e.preventDefault();
	});

	// initialize right arrow buttons
	$("#rightarrow, #rightbutton").click(function(e){
			slideRight();
			e.preventDefault();
	});
// ++++++++++++++++++++++++++++++++++++ //
// +++++++ OTHER FUNCTIONALITY ++++++++ //
// ++++++++++++++++++++++++++++++++++++ //
	
		$('.top-link').topLink({
			min: 200,
			fadeSpeed: 500
		});
	
// ++++++++++++++++++++++++++++++++++++ //
// ++++++++++ INITIALIZE PAGE +++++++++ //
// ++++++++++++++++++++++++++++++++++++ //
	
	// initialize #insidesection width
	var numberOfSections = $('div .section .sub').length;
//	$('#insidecontent').css("width", (numberOfSections*100) + "%"); // currently turned off because this makes it (100% * number of pages * 100% of $('#color').width() ) = 1,000% * number of pages
	$('#color').css("width", (numberOfSections*101) + "%"); // needs to be slightly larger than %100, probably due to padding

	// initializes section width
	sectionWidth();
	
	// set page to float (if javascript is turned off everything will be vertical)
	$('div .section').css("float", "left");

	// reset theNavigation to absolute position
	$("#theNavigation").css("position", "absolute");
	// reset arrows to visible (this disables them if you dont have javascript on)
	$("#rightarrow, #leftarrow, #leftbutton, #rightbutton").css("display", "block"); // offender
	
	init_ContentHeight();	
	init_SectionHeight();

	// display moving pointer (turns it off if you dont have javascripted turned on)
	$("#theMover").css("display", "block");

	setPointer();	
// ++++++++++++++++++++++++++++++++++++ //
// ++++++++++ WINDOW RESIZE +++++++++++ //
// ++++++++++++++++++++++++++++++++++++ //
	// on window resize:
	$(window).resize(function() {
		
		// scroll page left/right to keep current page in center
		var test = window.location.href.indexOf("#"); // 1234
		var pageNum2 = window.location.hash.slice(1);
		str = pageNum2.split('/');
		pageNum2 = pageNum2[0];
		var pageNum = parseInt(pageNum2);
		if (test > 0) {
			if ($(window).width() < 900){
				moveWidth = 900;
			} else {
				moveWidth = $(window).width();
			}
			move = (pageNum - 1) * moveWidth;
			$("#content").scrollLeft(move);
		} else{
			// do nothing
		}

		setPointer();
		sectionWidth();
		init_ContentHeight();
		centerImages();		
		init_SectionHeight();

/// site specific
maxHeightOfBox = $('#content').height() + 30;
/// end of site specific

	}); // end of window resize
	
// ++++++++++++++++++++++++++++++++++++ //
// ++++++++ SCROLL TO SETTINGS ++++++++ //
// ++++++++++++++++++++++++++++++++++++ //

	///////////////////////
	///////////////////////
		var theOffset = 0;
		// sets and resets the offset for localScroll
		var myOffset = {top: 0, left: theOffset};
		function calcOffset() {
		  var windowWidth = $(window).width();
		  if (windowWidth < 900) {
		    myOffset.left = 0;
		  } else {
		    myOffset.left = (windowWidth - 900) / -2;
		  }
		}
		calcOffset();
		// note leaving off the () will pass the function as a parameter instead of calling it
		$(window).resize(calcOffset);
		// end of offset setting
	///////////////////////
	///////////////////////

	// scroll vertical then horizontal
	$.localScroll.defaults.axis = 'yx';
	
	// Scroll initially if there's a hash (#something) in the url 
	$.localScroll.hash({
		target: '#content', // Could be a selector or a jQuery object too.
		queue:true,
		offset: myOffset,
		duration:1500
	});

	$.localScroll({
		target: '#content', // could be a selector or a jQuery object too.
		queue:true,
		duration:1500,
		hash:true,
		stop:true,
		onBefore:function( e, anchor, $target ){
			$('#insidecontent').stop(); // not entirely needed, or maybe at all. Suposed to eliminate pause between scrolling.
			//move position of the sliding nav pointer
			if (anchor.id.length < 4) { // this suports up to 999 pages but is not fail safe to vertical scrolling. Just Make sure those are 4 or more characters long.
				hashNumba = anchor.id;
				goToHash = "#nav" + hashNumba;
				theMoverPos = $("#theMover").position().left;
				goToPos = $(goToHash).position().left + ($(goToHash).width() / 2);
				moveto = goToPos - theMoverPos;
				moveTo2 = "+=" + moveto;
				$("#theMover").stop().animate({
					left: moveTo2
				}, 500);
			}
		},
		offset: myOffset,
		onAfter:function( anchor, settings ){
			if (analytics == "on"){
			    var trackhash = location.hash.replace('#','/') || '';
			    var query_string = location.search || '';
			    _gaq.push(['_trackPageview',location.pathname + query_string  + trackhash]);
			}

			var pageNum2 = window.location.hash.slice(1);
			var pageNum = parseInt(pageNum2);
		// change go to top link location
			var hash = "#" + pageNum;
			$('.top-link').attr("href", hash);
		// change height of content to match current hash
			var newHeight = $(hash).children().height();
			var testHeight = $(window).height() - navHeight -1;
			if (newHeight < testHeight){
				newHeight3 = testHeight;
			} else {
				newHeight3 = newHeight;
			}
		$('#insidecontent').stop().animate({height: newHeight3}, 200);
		$('.section ul').children().stop().animate({height: newHeight3}, 200);

		}
	});
	
/// site specific
maxHeightOfBox = $('#content').height() + 30;
/// end of site specific
	
});
