var t;
var defaultLinkIndex = -1;
var auto = 'on';

function timedCount()
{	
	defaultLinkIndex = defaultLinkIndex + 1;	
	if (defaultLinkIndex == $("ul.paging li").length) {
		defaultLinkIndex = 0;
	}
	//$("#hidTest").val(defaultLinkIndex);
	$("ul.paging li").eq(defaultLinkIndex).trigger('click');	
	t = setTimeout("timedCount()", 6000); //8000
}

function stopCount()
{
	clearTimeout(t);
}


jQuery(function($) {	

	$("ul.paging li").bind('click', function() {  
		numberClicked(this);
		return false;
	});
	
	$("ul.numbers li.auto").bind('click', function() {									   
		if (auto == 'on') {		
			stopCount();
			$("a.auto").html('Auto/On');
			auto = 'off';
		} else if (auto == 'off') {
			t = setTimeout("timedCount()", 6000);
			$("a.auto").html('Auto/Off');
			auto = 'on';
		}
		return false;
	});	
	
	timedCount();
	
});


function numberClicked(obj)
{
	var banRel = $("a", $(obj)).attr('rel'); 

	$('ul.photo li').hide();	
	
	$('li.' + banRel).fadeIn('slow'); //7000
	
	$("ul.paging li").removeClass('active');
	
	$(obj).addClass('active');
	
	defaultLinkIndex = $("ul.paging li").index(obj);
}
