//replace this with the number of the default active tab

var defaultactivetab = 1;

//find the full URL of the page we're on
var loc = window.location.href;
//split out the URL into usable pieces
var locarr = loc.split('/');
//locate the last piece of the URL - the page we're actually on
var loclen = locarr.length-1;
//clean it up (removing query string)
var localmost = locarr[loclen].split("?");
//clean it up (removing hashes)
var shortloc = localmost[0].replace(/[^a-zA-Z 0-9 \. \_ \-]+/g,'');
//give me something to test against later to see if an active tab has been set
var active = "";
//initialize an empty array to drop tab URLs into
var url=[];

$(document).ready(function(){

	var i=1;
	$("#nav ul li").each(function(){
	
	    this.id = i;
	    i++;
	
	});

	var u = 1;

	$("#nav ul li a").each(function(){
	
		url[u] = $(this).attr("href").replace(/[^a-zA-Z 0-9 \. \_ \-]+/g,'');
		u++;
	
	});

	for(var j=1; j<url.length; j++){
	
		if(url[j] == shortloc.toString()){
	         $("#"+j).addClass("active");
	         active = "found";
	    }
	    
	}
	
	if(active == ""){
	
		$("#"+defaultactivetab).addClass("active");
	
	}

	$("li.selected").show();

});
