/*
Slideshow.
	Danny Schoenberg (dan@cazarin.com)
	Requires jQuery 1.2.1
	Example markup and style information listed below. 
	Divs may be styled as long as their id's remain intact.
	History:
	10/22/07		Completeion of v.1
	Requires jQuery 1.2.1
	Example markup and style information listed below.  

*************STYLE*************



*************MARKUP*************

*/


var currentSlideShowImage = 0;
$(function() {
	var slideShowImages = $('.photo p');
	$('.photo p:gt(0)').each(function(index) { 
		$(this).hide();
	}); 
	$('.slideshow .slideshowIndexCurrent').text(1);
	$('.slideshow .slideshowIndexTotal').text(slideShowImages.length);
	$('.thumbnails img').each(function(index) {
		$(this).css("cursor","pointer");
		$(this).attr("alt", index);
		$(this).click(function(e) {
			lastSlide = currentSlideShowImage;
			currentSlideShowImage = $(this).attr("alt");
			if(currentSlideShowImage < 0) {
				currentSlideShowImage = 0;
			}
			if(lastSlide != currentSlideShowImage) {						
				$('.slideshow .slideshowIndexCurrent').text(parseInt(currentSlideShowImage)+1);
				slideShowImages.each(function(index) { 
					if(index == currentSlideShowImage) {	
						//$(this).fadeIn("normal");
						$(this).show();
					} else {
						if($(this).css("display") != "none"){
							//$(this).fadeOut("normal");
							$(this).hide();
						}
					}
				}); 
			}
		});					
	});
	
	$('.next').click(function(){
		lastSlide = currentSlideShowImage;
		currentSlideShowImage++;
		if(currentSlideShowImage >= slideShowImages.length) {
			currentSlideShowImage = slideShowImages.length - 1;
		}
		if(lastSlide != currentSlideShowImage) {
			$('.slideshow .slideshowIndexCurrent').text(parseInt(currentSlideShowImage) + 1);
			slideShowImages.each(function(index) { 
				if(index == currentSlideShowImage) {	
					//$(this).fadeIn("normal");
					$(this).show();
				} else {
					if($(this).css("display") != "none"){
						//$(this).fadeOut("normal");
						$(this).hide();
					}
				}
			}); 
		};
		return false;
	});					


	$('.prev').click(function(){
		lastSlide = currentSlideShowImage;
		currentSlideShowImage--;
		if(currentSlideShowImage < 0) {
			currentSlideShowImage = 0;
		}
		if(lastSlide != currentSlideShowImage) {						
			$('.slideshow .slideshowIndexCurrent').text(parseInt(currentSlideShowImage) +1);
			slideShowImages.each(function(index) { 
				if(index == currentSlideShowImage) {	
					//$(this).fadeIn("normal");
					$(this).show();
				} else {
					if($(this).css("display") != "none"){
						//$(this).fadeOut("normal");
						$(this).hide();
					}
				}
			}); 
		};
		return false;
	});					
});


$(function(){
	$(".showThumbs").toggle(
		function(){
			$(".thumbnails").slideDown();
			$(".showThumbs").text("hide thumbnails");
			return false;
		},
		function(){
			$(".thumbnails").slideUp();
			$(".showThumbs").text("show thumbnails");
			return false;
		}
	);

});


