/*
	
	Fosse Way School
	
	Designed & Developed by Systemagic
	www.systemagic.co.uk
	
*/

$(document).bind("ready", function(){
				   
	$('body').addClass("javascript");	
	
	$('.clickable').css("cursor", "pointer");
	$('.clickable').bind("click", function(){
		window.location = $(this).find("a:first").attr("href");
	});
	
	$('a[rel=lightbox]').lightBox();
	
	jQuery.fn.extend({
		getCurrentAndNext: function(filter){
			current = $(this).find(filter + "[current]");
			
			len  = $(this).find(filter + "[current]").next().length;
			if(len >= 1){
				next = $(this).find(filter + "[current]").next();
			}else{
				next = $(this).find(filter + ":first");
			}
			
			$(current).removeAttr("current");
			$(next).attr("current", "true");
			
			return [current, next];
		}
	});
	
	if($('div.images div').length){

		$('div.images div:not(:first)').fadeOut(0);
		$('div.images div:first').attr("current", "true");
		
		updateBanner = function(){
			nextCurrent = $('div.images').getCurrentAndNext("div");
			
			current = nextCurrent[0];
			next	= nextCurrent[1];
			
			$(current).fadeOut(400);
			$(next).fadeIn(400);
		}
		
		setInterval(updateBanner, 5000);
	}
	
	$('div.home-ribbon').find("img").fadeTo(0, 0.8);
	
	$('div.home-ribbon').find("a").hover(function(){
		$(this).find("img").stop().fadeTo(400, 1);
	}, function(){
		$(this).find("img").stop().fadeTo(100, 0.8);
	});
	
});
