$(document).ready(function() {
	var colours = [0, "#639", "#3A3", "#A33", "#33A", "#A30"];
	$(".mainnav a").hover(function(){
		var random = Math.ceil(5*Math.random());
		var randcolour = colours[random];
		$(this).css("color", randcolour);
	}, function(){
		$(this).css("color", "#777");
	});
	$("section p a").hover(function(){
		var random = Math.ceil(5*Math.random());
		var randcolour = colours[random];
		$(this).css("color", randcolour);
	}, function(){
		$(this).css("color", "#666");
	});
	$("h3 a").hover(function(){
		var random = Math.ceil(5*Math.random());
		var randcolour = colours[random];
		$(this).css("color", randcolour);
	}, function(){
		$(this).css("color", "#444");
	});
	$(".mainfooter a").hover(function(){
		var random = Math.ceil(5*Math.random());
		var randcolour = colours[random];
		$(this).css("color", randcolour);
	}, function(){
		$(this).css("color", "#555");
	});
	$("a[href*=#]").click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
		var $target = $(this.hash);
		$target = $target.length && $target || $("[name=" + this.hash.slice(1) +']');
			if ($target.length) {
				var targetOffset = $target.offset().top;
				$("html,body").animate({scrollTop: targetOffset}, 500);
				return false;
			}
		}
	});
});
