var t;
var defaultLinkIndex = -1;

function timedCount()
{	
	defaultLinkIndex = defaultLinkIndex + 1;	
	if (defaultLinkIndex == $("#thumb_gallery_images li").length) {
		defaultLinkIndex = 0;
	}
	

	$("#thumb_gallery_images li").eq(defaultLinkIndex).trigger('click');	
	t = setTimeout("timedCount()", 3000);
}

function stopCount()
{
	clearTimeout(t);
}

jQuery(function($) {
	
	var imgURL = "includes/images/";
	
	$("#thumb_gallery_images li").bind("click", function() {	
		$("#thumb_gallery_images a").removeClass('current');		
		
		var curRel = $("a", $(this)).attr('rel'); // Getting a's rel
		
		var curTitle = $("a", $(this)).attr('title'); // Getting a's alt
		
		var ind = curRel.split('_');
		var def = parseInt(ind[1]) - 1;
		
		$(".img_class").hide();
		$(".text_section").hide();
		
		$("#" + curRel).fadeIn('slow');
		$("#" + curTitle).fadeIn('slow');
		 
		$("a", $(this)).addClass('current'); // making tab - active	
		
		defaultLinkIndex = def;
		
		$.sifr({path:'includes/sifr'});
	$('h3.link1').sifr({font:'cowboy'});
	$('h3.link2').sifr({font:'cowboy'});
	$('h3.link3').sifr({font:'cowboy'});
	$('h3.link4').sifr({font:'cowboy'});
	});
	timedCount();
});