/*
 * --------------------------------------------------------------------
 * Simple Scroller
 * by Siddharth S, www.ssiddharth.com, hello@ssiddharth.com
 * Version: 1.0, 05.10.2009 	
 * --------------------------------------------------------------------
 */
jQuery.noConflict();
jQuery(document).ready(function() 
{	 
	var index = 0;
	var images = jQuery("#gallery img");
	var thumbs = jQuery("#thumbs img");
	var imgHeight = $(thumbs).attr("height");
	jQuery(thumbs).slice(0,4).clone().appendTo("#thumbs");
	for (i=0; i<thumbs.length; i++)
	{
		jQuery(thumbs[i]).addClass("thumb-"+i);
		jQuery(images[i]).addClass("image-"+i);
	}
	
	jQuery("#next").click(sift);
<!--	show(index);-->
	setInterval(sift, 5000);
	
	
	function sift()
	{
		if (index<(thumbs.length-1)){index+=1 ; }
		else {index=0}
		show (index);
	}
	
	function show(num)
	{
		jQuery(images).fadeOut(400);
		jQuery(".image-"+num).stop().fadeIn(1000);
		var scrollPos = (num+1)*100;  <!--need to change the "81" value if thumbnail height changes!-->
		jQuery("#thumbs").stop().animate({scrollTop: scrollPos}, 400);		
		console.log(scrollPos, "img.image-"+num);
	}
});
