// JavaScript Document

//Code writenby Robert Hanwell robert@mailsent.co.uk works with the footer php
jQuery(document).ready(function($){
	$('#news .newsItem li:not(:first)').hide();
	$('.prev').bind("click", function() {
		prev();
		return false;
	});
	$('.next').bind("click", function() {
		next();
		return false;
	});
	$('.small-images a').bind("click", function() {
		display($(this).parent().attr('value'));
		return false;
	});
	
	
	function prev() {
		var total = $("#news .newsItem li").length;
		var current = $("#news .newsItem li:visible").attr('value');
		if(current > 1) {
			display(parseInt(current)-1);
		} else {
			display(total);
		}
	}
	function next() {
		var total = $("#news .newsItem li").length;
		var current = $("#news .newsItem li:visible").attr('value');
		if(current < total) {
			display(parseInt(current)+1);
		} else {
			display(1);
		}
	}
	function display(num) {
		$("#news .newsItem li").slideUp("slow");
		$("#news .newsItem li[value='"+num+"']").slideDown("slow");
		$('.small-images a').removeClass('active');
		$(".small-images li[value='"+num+"'] a").addClass('active');
	}
	setInterval(function(){$(next)},5000);
});
