      var currentImage;

	var totalimage=5;

            var currentIndex = -1;

            var interval;
			var showDiv = '#bigPic';

            function showImage(index){

                if(index < $('#bigPic img').length){

                    var indexImage = $('#bigPic img')[index]

                    if(currentImage){

                        if(currentImage != indexImage ){

                            $(currentImage).css('z-index',2);

                            clearTimeout(myTimer);

                            $(currentImage).fadeOut(250, function() {

                                //myTimer = setTimeout("showNext()", 3000);

                                $(this).css({'display':'none','z-index':1})

                            });

                        }

                    }

                    $(indexImage).css({'display':'block', 'opacity':1});

                    currentImage = indexImage;

                    currentIndex = index;

                    imageindex=index+1;

                    var cimage;

                    for (i=1;i<=totalimage;i++){

                        cimage="images/carousel/button-"+i+".jpg";



                    $("#img"+i).attr("src",cimage);

                    }

                    cimage="images/carousel/button-"+imageindex+".jpg";

                    $("#img"+imageindex).attr("src",cimage);



                    $('#thumbs li').removeClass('active');

                    $($('#thumbs li')[index]).addClass('active');

                }

            }

    

            function showNext(){

                var len = $(showDiv+' img').length;

                var next = currentIndex < (len-1) ? currentIndex + 1 : 0;
				
                showImage(next);

            }



    

            var myTimer;

    

            $(document).ready(function() {

                //myTimer = setTimeout("showNext()", 3000);

                showNext(); //loads first image

                $('#thumbs li').bind('click',function(e){

                    var count = $(this).attr('rel');

                    showImage(parseInt(count)-1);

                });


/*
$("#thumbs li").hover(

        function () {

       	       var count = $(this).attr('rel');

                cimage="images/carousel/button-"+count+"-hover.jpg";

                $("#img"+count).attr("src",cimage);

         },

         function(){

        	for (i=1;i<=totalimage;i++){

                   cimage="images/carousel/button-"+i+".jpg";

                    if ($("#img"+i).parent().attr("class")!="active"){

                    $("#img"+i).attr("src",cimage);

                    }

                }

         }



    );

*/

        

            });

    



        
