	var currentImage;
	var currentCaption;
    var currentIndex = -1;
    var currentIndex1 = -1;
    var interval;
    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() {
                	$(currentImage).fadeOut(1000, function() {
					    myTimer = setTimeout("showNext()", 3000);
					    //$(this).slideUp(500, function(){})
					    //$(this).css({'display':'none','z-index':1})
					});
                }
            }
          //  $(indexImage).css({'display':'block', 'opacity':1});
        	$(indexImage).fadeIn(1000, function(){
        		//$(indexImage).css({'display':'block', 'opacity':1});
        	}
        	)
            currentImage = indexImage;
            currentIndex = index;
            $('#thumbs li').removeClass('active');
            $($('#thumbs li')[index]).addClass('active');
        }
    }
    
    function showNext(){
        var len = $('#bigPic img').length;
        var next = currentIndex < (len-1) ? currentIndex + 1 : 0;
        var len1 = $('#captions p').length;
        var next1 = currentIndex1 < (len-1) ? currentIndex1 + 1 : 0;
        showImage(next);
        showCaption(next1);
    }
    
    function showCaption(index1){
        if(index1 < $('#captions p').length){
        	var indexImage1 = $('#captions p')[index1]
            if(currentCaption){   
            	if(currentCaption != indexImage1 ){
                    $(currentCaption).css('z-index',2);
                    clearTimeout(myTimer);
                    $(currentCaption).fadeOut(500, function() {
                    	$(indexImage1).fadeIn(500, function(){})
					   // myTimer = setTimeout("showNext()", 3000);
					    //$(this).css({'display':'none','z-index':1})
					});
                }
            }
           // $(indexImage1).css({'display':'block', 'opacity':1});
            else{
            	$(indexImage1).fadeIn(500, function(){});
            }
        	currentCaption = indexImage1;
            currentIndex1 = index1;
            
        }
    }
    
    function showNextCaption(){
        var len = $('#captions p').length;
        var next = currentIndex1 < (len-1) ? currentIndex1 + 1 : 0;
        showCaption(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);
        	showCaption(parseInt(count)-1);
        });
	});



    $(document).ready(function() {
    	$(".flower_title").mouseover( function(){    

    		 $(this).children("img").css('display','block');
    	}), 
    	$(".flower_title").mouseleave( function() {
    		$(this).children("img").css('display','none');
    		});
    	});
