﻿$(document).ready(function(){
	$("#featurenav").show();
	featLinks("#featurenav li a");
	featHighlight();
});


// 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 clickFire(h) 
{
var addr = (h.href + " #mainfeature");
$("#featurelist").removeClass("first second third fourth");
$("#mainfeature").wrapInner("<span id='featInner'></span>");
$("#featInner").fadeOut('200', function() {
		$("#featurewrap").load(addr, function() {
				$("#featInner").hide();
				$("#featInner").fadeIn('200');    	
				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);
	});


// image preloader
function preload(images) {
    if (document.images) {
        var i = 0;
        var imageArray = new Array();
        imageArray = images.split(',');
        var imageObj = new Image();
        for(i=0; i<=imageArray.length-1; i++) {
            //document.write('<img src="' + imageArray[i] + '" />');// Write to page (uncomment to check images)
            imageObj.src=images[i];
        }
    }
}

