var startX = -10;

$(document).ready(function() {
	
	var sploc = location.pathname.split('/'); // turn it into an array
	if (sploc.length > 2)
	{
		var loc = '/'+sploc[1]+'/';
	}
	else
	{
		loc = '/';
	}

	var startNav = $('div#nav a[href='+loc+']');
	
	
	
	if (startNav.length > 0) // not home
	{
		var sX = $(startNav).position().left;
		var sW = $(startNav).width();
		startX = Math.round(sX + (sW/2)) - 5;
	}
	$('div#triangle').css('left', startX);

	$('div#triangle').show();
	$('div#nav a').mouseover(function(e) {
		var w = $(this).width();
		var new_x = $(this).position().left;
		var newpos = parseInt(new_x) + (w/2) - 5;
		
		//var pos = $('div#triangle').position().left;
		$('div#triangle').stop().animate({
			left: newpos
		}, 500);
	});

	$('div#content, div#container h1').mouseover(function(e) {
		$('div#triangle').stop().animate({
			left: startX
		}, 500);
		
	});
	

	
});