
$(document).bind("ready", function(){
	
	if(jQuery.fn.lightBox) $('a[rel=lightbox]').lightBox();
	
	jQuery.fn.extend({
		getCurrentAndNext: function(filter){
			current = $(this).find(filter + "[current]");
			
			len  = $(this).find(filter + "[current]").next(filter).length;
			if(len >= 1){
				next = $(this).find(filter + "[current]").next(filter);
			}else{
				next = $(this).find(filter + ":first");
			}
			
			$(current).removeAttr("current");
			$(next).attr("current", "true");
			
			return [current, next];
		}
	});
	
	$('.header img:not(:first)').css("display", "none");
	$('.header img:first').attr("current", "true");
	
	updateBanner = function(){
		nextCurrent = $('.header').getCurrentAndNext("img");
		
		current = nextCurrent[0];
		next	= nextCurrent[1];
		
		$(current).fadeOut(400);
		$(next).fadeIn(400);
	}
	
	setInterval(updateBanner, 5000);
		
});

