jQuery(function( $ ){
	/**
	 * 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 = 'y';
	
	// Scroll initially if there's a hash (#something) in the url 
	$.localScroll.hash({
		target: '#truth', // Could be a selector or a jQuery object too.
		queue:true,
		duration:0,
		onBefore:function(){
			fadeTop();
		},
		onAfter:function(){
			goBottom();
		}
	});
	
	/**
	 * 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({
		target: '#truth', // could be a selector or a jQuery object too.
		queue:true,
		duration:1500,
		hash:true,
		onBefore:function(){
			fadeTop();
		},
		onAfter:function(){
			goBottom();
		}
	});
});

function fadeTop(){
	var what = self.document.location.hash.substring(1)
	$("#curtain").fadeIn(300);
	$("#hardest").fadeOut(500);
	$("#flashVents").fadeOut(500);
	$("#topLearn").fadeOut(500);
	$("#topContact").fadeOut(500);
	$("#topConnect").fadeOut(500);
	$("#topCoach").fadeOut(500);
	$("#topBench").fadeOut(500);
	$("#corpComm").fadeOut(500);
	$("#topPlanning").fadeOut(500);
	$("#topTools").fadeOut(500);
	$("#pushTab").fadeOut(0);
	$("#learnBR").hide();
	$("#contactBR").hide();
	$("#coachBR").hide();
	$("#planBR").hide();
	$("#teamBR").hide();
	$("#commBR").hide();
	$("#toolBR").hide();
	$("#connectBR").hide();
	$("#content2").css("height","380px");
	$("#bn1int").css("margin-left","0px");
	$("#bn2int").css("margin-left","0px");
	$("#bn3int").css("margin-left","0px");
	$("#bn4int").css("margin-left","0px");
	$("#bn5int").css("margin-left","0px");
	if (what != 'home') {
		$("#story").hide();
		$("#cForm").hide();
		$("#connection").hide();
		$("#exeCoach").hide();
		$("#stratPlan").hide();
		$("#teamDev").hide();
		$("#commUnity").hide();
		$("#toolSet").hide();
		$("#homeBR").hide();
	}
}

function goBottom(){
		var what = self.document.location.hash.substring(1)
		$("#curtain").fadeOut(250);
			if (what != 'Home') {
				$("#conference").animate({
					marginLeft:"-575px"
				},2000);
				$("pullTab").fadeIn(250);
				if (what == 'Learn'){
					$("#quote0").hide();
					$("#quote1").hide();
					$("#quote2").hide();
					$("#quote3").hide();
					$("#quote4").hide();
					$("#quote5").hide();
					$("#quote6").hide();
					$("#quote7").hide();
					$("#quote8").hide();
					//Generate Random Number between 0 and 9 for quotes
					var rand_no = (Math.floor(Math.random()*4));
					//This line turns on the correct quote
					$("#quote"+rand_no).show();
					$("#bottomNav").animate({
						marginLeft:"-575px"
					},2000);
					$("#whereArrow").fadeIn(500);
					$("#whereArrow").animate({
						marginLeft:"177px"
					},500);
					$("#conference").animate({
						marginLeft:"-575px"
					},2000);
					$("#story").show();
					$("#cForm").hide();
					$("#connection").hide();
					$("#exeCoach").hide();
					$("#corpComm").hide();
					$("#topLearn").fadeIn(500);
					$("#learnBR").show();
				}
				else if (what == 'Contact'){
					$("#bottomNav").animate({
						marginLeft:"-575px"
					},2000);
					$("#whereArrow").fadeIn(500);
					$("#whereArrow").animate({
						marginLeft:"237px"
					},500);
					$("#story").hide();
					$("#cForm").show();
					$("#connection").hide();
					$("#exeCoach").hide();
					$("#corpComm").hide();
					$("#topContact").fadeIn(500);
					$("#contactBR").show();
				}
				else if (what == 'Connect'){
					$("#content2").css("height","auto");
					$("#bottomNav").animate({
						marginLeft:"-575px"
					},2000);
					$("#whereArrow").fadeIn(500);
					$("#whereArrow").animate({
						marginLeft:"304px"
					},500);
					$("#story").hide();
					$("#cForm").hide();
					$("#connection").show();
					$("#exeCoach").hide();
					$("#topConnect").fadeIn(500);
					$("#connectBR").show();
				}
				else if (what == 'Coaching'){
					$("#content2").css("height","auto");
					$("#whereArrow").fadeOut(500);
					$("#pushTab").fadeOut(500);
					$("#story").hide();
					$("#cForm").hide();
					$("#connection").hide();
					$("#corpComm").hide();
					$("#exeCoach").show();
					$("#topCoach").fadeIn(500);
					$("#coachBR").show();
					$("#bn1int").css("margin-left","-105px");
					$("#content2").css("height","auto");
				}
				else if (what == 'Planning'){
					$("#content2").css("height","auto");
					$("#whereArrow").fadeOut(500);
					$("#pushTab").fadeOut(500);
					$("#story").hide();
					$("#cForm").hide();
					$("#connection").hide();
					$("#corpComm").hide();
					$("#stratPlan").show();
					$("#topPlanning").fadeIn(500);
					$("#planBR").show();
					$("#bn2int").css("margin-left","-94px");
				}
				else if (what == 'Development'){
					$("#content2").css("height","auto");
					$("#whereArrow").fadeOut(500);
					$("#bn3int").css("margin-left","-134px");
					$("#pushTab").fadeOut(500);
					$("#story").hide();
					$("#cForm").hide();
					$("#connection").hide();
					$("#corpComm").hide();
					$("#teamDev").show();
					$("#teamBR").show();
					$("#topBench").fadeIn(500);
				}
				else if (what == 'Corporate'){
					$("#content2").css("height","auto");
					$("#whereArrow").fadeOut(500);
					$("#bn4int").css("margin-left","-100px");
					$("#pushTab").fadeOut(500);
					$("#story").hide();
					$("#cForm").hide();
					$("#connection").hide();
					$("#corpComm").fadeIn(500);
					$("#commUnity").show();
					$("#commBR").show();
				}
				else if (what == 'Toolset'){
					$("#content2").css("height","auto");
					$("#whereArrow").fadeOut(500);
					$("#bn5int").css("margin-left","-92px");
					$("#pushTab").fadeOut(500);
					$("#story").hide();
					$("#cForm").hide();
					$("#connection").hide();
					$("#corpComm").hide();
					$("#toolSet").show();
					$("#topTools").fadeIn(500);
					$("#toolBR").show();
				}
			}
			else {
				$("#bottomNav").animate({
					marginLeft:"0px"
				},2000);
				$("#conference").animate({
					marginLeft:"0px"
				},2000);
				$("#whereArrow").fadeIn(500);
				$("#whereArrow").animate({
					marginLeft:"130px"
				},500);
				$("#hardest").fadeIn(500);
				$("#flashVents").fadeIn(500);
				$("#pushTab").fadeOut(500);
				$("#homeBR").show();
			}
}

function pushBottom(){
	$("#bottomNav").animate({
		marginLeft:"-575px"
	},2000);
	$("#conference").animate({
		marginLeft:"-575px"
	},2000);
}

function pullBottom(){
	$("#bottomNav").animate({
		marginLeft:"0px"
	},1500);
	$("#conference").animate({
		marginLeft:"0px"
	},1500);
	$("#pushTab").fadeIn(0);
}

$(document).ready(function() {
	$("#curtain").fadeOut(250);
    $("#pushTab").fadeOut(0);
	$("#learnBR").hide();
	$("#contactBR").hide();
	$("#coachBR").hide();
	$("#planBR").hide();
	$("#teamBR").hide();
	$("#commBR").hide();
	$("#toolBR").hide();
	$("#connectBR").hide();
});

function toggleMenu(){
	if (toggleVar=="up"){
		$("#mobileMenu").animate({
			"margin-top": "-10px",
			"z-index": "1"
		}, 1000);
		$("#mobileWindow").animate({
			"height": "273"
		}, 0);
		toggleVar="down";
	}
	else if (toggleVar=="down"){
		$("#mobileMenu").animate({
			"margin-top": "-250px"
		}, 1000)
		$("#mobileWindow").animate({
			"height": "50"
		}, 2000);
		toggleVar="up";
	}
}
