/*
 * --------------------------------------------------------------------
 * Simple Scroller
 * by Siddharth S, www.ssiddharth.com, hello@ssiddharth.com
 * Version: 1.0, 05.10.2009 	
 * --------------------------------------------------------------------
 */

$(document).ready(function()  
{  
    var index = 0;  
    var images = $("#galeriaRotativo img");  
    var thumbs = $("#iconosRotativo img");  
    var imgHeight = thumbs.attr("height");  
    thumbs.slice(0,3).clone().appendTo("#iconosRotativo");  
    for (i=0; i<thumbs.length; i++)  
    {  
        $(thumbs[i]).addClass("icono-"+i);  
        $(images[i]).addClass("imagen-"+i);  
    }  
  
    $("#next").click(sift);  
    show(index);  
    setInterval(sift, 8000);  
  
    function sift()  
    {  
        if (index<(thumbs.length-1)){index+=1 ; }  
        else {index=0}  
        show (index);  
    }  
  
    function show(num)  
    {  
        images.fadeOut(400);  
        $(".imagen-"+num).stop().fadeIn(400);  
        var scrollPos = (num+1)*imgHeight;  
        $("#iconosRotativo").stop().animate({scrollTop: scrollPos}, 400);  
    }  
});  
