$(document).ready(function(){
	$("#featurenav").show();
	featLinks("#featurenav li a");
	featHighlight();


	$("#firstvid").click(function() {
		clearthumbs();
		$(this).addClass("selected");
		$("#videoswitch").load("/ssi/video/one.html");
		return false;

	});

	$("#secondvid").click(function() {
		clearthumbs();
		$(this).addClass("selected");
		$("#videoswitch").load("/ssi/video/two.html");
		return false;

	});

	$("#thirdvid").click(function() {
		clearthumbs();
		$(this).addClass("selected");
		$("#videoswitch").load("/ssi/video/three.html");
		return false;
	});

	$("#fourthvid").click(function() {
		clearthumbs();
		$(this).addClass("selected");
		$("#videoswitch").load("/ssi/video/four.html");
		return false;

	});

	$("#fifthvid").click(function() {
		clearthumbs();
		$(this).addClass("selected");
		$("#videoswitch").load("/ssi/video/five.html");
		return false;
	});

});

// Swaps the features in and out. Adapted from Paul Boag/Headscape http://www.boagworld.com/technology/question_headscape_tabs/
function featLinks(linkLoc) {
$(linkLoc).click(function(){
clickFire(this);
return false;
});
};

function clearthumbs() {
  	$("#firstvid").removeClass("selected");
  	$("#secondvid").removeClass("selected");
  	$("#thirdvid").removeClass("selected");
  	$("#fourthvid").removeClass("selected");
  	$("#fifthvid").removeClass("selected");
 };

function clickFire(h)
{
var addr = (h.href);
$("#featurelist").removeClass("first second third fourth");
$("#mainfeature").wrapInner("<span id='featInner'></span>");
$("#featInner").fadeOut(300, function() {
		$("#featurewrap").load(addr, function() {
				$("#featInner").hide();
				$("#featInner").fadeIn(300);
				if(typeof(supersleight) == 'object')
			    	supersleight.run();
			  		featHighlight();
				});
		});
}


// Feature highlight function: get the class from the mainfeature and apply it to the feature navigation list so that the css can highlight the correct feature

var featHighlight = (function() {
  var featNumber = $("#mainfeature").attr("class");
  $("#featurelist").addClass(featNumber);
  $("body").removeClass("blue green red orange");
  if(featNumber=="first") {
  	$("body").addClass("orange");
	$.cookie('sitecolor','orange');
  }
  if(featNumber=="second") {
  	$("body").addClass("blue");
	$.cookie('sitecolor','blue');
  }
  if(featNumber=="third") {
  	$("body").addClass("red");
	$.cookie('sitecolor','red');
  }
  if(featNumber=="fourth") {
  	$("body").addClass("green");
	$.cookie('sitecolor','green');
  }
});





