$(document).ready(function () {
var colors = new Array();
colors[0] = "#3A8E35";
colors[1] = "#72A9B8";
colors[2] = "#975C2B";
colors[3] = "#C39E00";
colors[4] = "#4B6E29";
colors[5] = "#992A2C";
colors[6] = "#253764";


$('#mainNavigation').supersleight();

// loop through main nav and apply bg colours from array above
$("#mainNavigation li").each(function(index) {
	var $this = $(this);
	var $thisLink = $(this).find("a");
	$this.css("background-color",colors[index]);
	$thisLink.wrap("<div class='MainNavigationOption'></div>")
});

// add class and change pointer for main navigation
$("#mainNavigation li").hover(function() {
	$(this).addClass("hover").css("cursor","pointer");								   
}, function() {
	$(this).removeClass("hover").css("cursor","default");	
});

// add click event to li
$("#mainNavigation li").click(function() {
	var thisLink = $(this).find("a").attr("href");
	if($("#imageAnimation").length > 0) {
		var thisLink = "";
	}
	window.location = thisLink;
});

// Add the classes to the .jumpbox on the homepage
$('.jumptobox').each(function() {
	var $this = $(this);
	$this.find('p:eq(0)').addClass("image");
	$this.find('p:eq(1)').addClass("title");
	$this.find('p:eq(2)').addClass("cost");
	$this.find('p:eq(3)').addClass("description");
	$this.find('p:gt(3)').css("display","none"); // :gt indexing starts at 0. Hide any paragraphs after the 4th one.
});

// Because this script appears on all pages and not all pages will have a div#imageAnimation so check for its existance
if($("#imageAnimation").length > 0) {						   
	var leftPos = 0;
	var imgCount = $("#imageAnimation img").length;
	var nextImg = imgCount;
	var e = 1;
	var i = 1;
	var j = 6000;
	
	$("#imageAnimation").addClass("prep");
	
	$("#imageAnimation img").each(function() {
		$(this).addClass("id"+e);
		e++;
	});
	
	function animateImages() {
		$(".id"+i).animate({left:leftPos},j);	
		leftPos += 160;
		i++;
		j -= 1000;
		nextImg -= 1;
		if(nextImg<0) {
			return;
		}
		animateImages();
		
	}
	animateImages();
	
}


$(".noticeBox").wrap("<div class='wrap'></div>");



// close document ready
});