initStunts = function(){
	window.currentLocation = "";
	
	if(document.location.hash == "#adjhome" || document.location.hash == "" || document.location.hash == "#"){
		document.location = "#adjhome";
		toggleLink('home',1);
		loadSection('home');
	}
	else{
		loadSection(breakdownHash(document.location.hash)); 
	}
	
	$('#header a').click(function(){
		
		blur();
		navClick(this);
		
	});
	
	$( window.location ).bind("change",function(e,d){
		$("#header a").each(function(){toggleLink(this.id,0);});
		toggleLink(breakdownHash(d.currentHash), 1);
		loadSection(breakdownHash(d.currentHash)); 
	});
	
	//Load the outlaw
	var params = {};var attributes = {};var flashvars = {};
	params.menu = "false";
	params.scale = "exactfit";
	params.wmode = "transparent";
	swfobject.embedSWF("./sw/flying.swf", "theoutlaw", "100%", "100%", "9.0.0", "./js/so/expressInstall.swf", flashvars, params, {});
	
}

breakdownHash = function(h){
		return h.substr(h.indexOf("#")+4,20);;
}

flyingDone = function(){
	//console.log("Flying Done");

	var nparams = {};
	nparams.menu = "false";
	nparams.scale = "noscale";
	nparams.wmode = "transparent";
	swfobject.embedSWF("./sw/hanging.swf", "theoutlaw", "250", "450", "9.0.0", "./js/so/expressInstall.swf", {},nparams, {});
	
}

toggleLink = function(id,offon){
	var ns = $('#'+id+' img')[0].src;
	ns = './gfx/n/' + ns.substr(ns.lastIndexOf('/')+1,(ns.lastIndexOf('.') - ns.lastIndexOf('/') - 2) ) + offon + ".png";
	
	$('#'+id+' img')[0].src = ns;
	
}

navClick = function(link){
	//console.log(link);
	$("#header a").each(function(){toggleLink(this.id,0);});
	//document.location = "#" + link.id;
	toggleLink(link.id,1);
	loadSection(link.id);

}

loadSection = function(loc){
	if(window.currentLocation == loc) return; //Don't load anything if already there
	//otherwise, make this the new location
	window.currentLocation = loc;
	
	$('#content').fadeOut(200,function(){
		//document.location = '#' + loc;
		document.title = "Stunt Adjustment: " + loc.substr(0,1).toUpperCase() + loc.substr(1,20);
		thisLoc = loc;
		$.scrollTo('0',{duration:600,easing:'swing'});
		$.get("./pg/"+ loc + '.htm?r=' + Math.random(),function(data){
			$('#content').html(data);
			sectionCaps(); 
			$('#content').fadeIn(200);
		});	
	});
	
}

//section specific
sectionCaps = function(){
	//$('.section').prepend("<span class='relativeWrap'><span class='stop'></span></span>").append("<span class='relativeWrap'><span class='sbot'></span></span>");
}

//gallery
makeGallery = function(){
	//console.log("Building gallery");
	
	window.gal = new Object();
	gal.id = $('#galleryBox');
	gal.currentLoc = 0;
	
	gal.imgList = Array({i:"t2-1.jpg",t:"Terminator 2",d:"About this photo"},
						{i:"t2-2.jpg",t:"Terminator 2",d:"About this photo"},
						{i:"carib.jpg",t:"Pirates of the Caribbean",d:"About this photo"});
	gal.imgPath = "./gfx/gp/";
	
	$(gal.id).wrap("<div class='relativeWrap'></div>").append("<div id='gal-frame'></div><div id='gal-link-left' class='galleryNavLink'><img src='./gfx/gallery/navleft.png'></div><div id='gal-link-right' class='galleryNavLink'><img src='./gfx/gallery/navright.png'></div><div id='gallery-imageHolder'><img src='./gfx/gallery/blank.png' class='gallery-image'><img src='./gfx/gallery/blank.png' class='gallery-load'></div></div><div id='gallery-shadow'></div>");
	//console.log($(gal.id + " img").each(function(){console.log(this)}));
	
	$(".galleryNavLink img").hide();
	$(".galleryNavLink").hover(function(){$(this).children().fadeIn(200);},function(){$(this).children().fadeOut(500);});
	$(".galleryNavLink").click(function(){
		//console.log('clicky');
		gal.direction =	( (this.id == "gal-link-left") ? -1 : 1);
		
		gal.rightLoc = ( ((gal.currentLoc + 1) < gal.imgList.length) ? gal.currentLoc + 1 : 0 );
		gal.leftLoc = ( ((gal.currentLoc - 1) < 0) ? gal.imgList.length-1 : gal.currentLoc - 1 );
		
		if(gal.direction == -1){
			$(".gallery-load")[0].src = gal.imgPath + gal.imgList[gal.leftLoc].i;
		}
		
		$(".gallery-image").fadeOut(500,function(){
			
			this.src = $(".gallery-load")[0].src;
			$(this).show();
			
			
			$(".gallery-load")[0].src = gal.imgPath + gal.imgList[gal.rightLoc].i;
			
			gal.currentLoc = ( (gal.direction == 1) ? gal.rightLoc : gal.leftLoc );
			
			//console.log("Went: " + (gal.direction==1? "right":"left") + " Postion: " + gal.currentLoc + " Right: " + gal.rightLoc);
			
			//$(".gallery-load")[0].src = gal.imgPath + gal.imgList[gal.loadPhoto].i;
			
			//console.log("Image is: " + $(".gallery-image")[0].src);
			//console.log("Load is: " + $(".gallery-load")[0].src);
			
		});
		
		
	});
	$(".gallery-image")[0].src = gal.imgPath + gal.imgList[gal.currentLoc].i;
	$(".gallery-load")[0].src = gal.imgPath + gal.imgList[(gal.currentLoc + 1)].i;
}
