// Copyright 2009 Nerath Khat
// Peakmoto WP Theme Slideshow
// Jquery Slideshow 

var $imageLength;
var $imageNumber;
$(document).ready ( 
	function(){
		slideshow();
	}
);

function slideshow() {
	//Set the caption background to semi-transparent  
     $('.caption').css({opacity: 0.7});
	 
	 //$('.content').css({opacity: 0});
	 
		$('.slideshow_fader li').each ( 			 
			function (i) { 
				$imageLength = i; 
				$imageNumber = $imageLength;
			}
		);
		setInterval(imageSwitch,5000);    
	}

function imageSwitch(){
	 if($imageNumber == 0) {
		$imageNumber = $imageLength;
		for(var i =$imageLength;i > 0 ;i--){
			$(".slideshow_fader li:eq("+i+")").fadeIn("slow");
		}
		$('.content').html($(".slideshow_fader li:eq("+($imageLength)+") img").attr("rel"));
	} else {
		$(".slideshow_fader li:eq("+$imageNumber+")").fadeOut("slow");
		$('.content').html($(".slideshow_fader li:eq("+($imageNumber-1)+") img").attr("rel"));
		$imageNumber --;
		//alert($imageNumber);
	}
	
	//Set the opacity to 0 and height to 1px  
     //$('.caption').animate({opacity: 0.0}, { queue:false, duration:0 }).animate({height: '50px'}, { queue:true, duration:300 });   
       
     //Animate the caption, opacity to 0.7 and heigth to 100px, a slide up effect  
     //$('.caption').animate({opacity: 0.7},100 ).animate({height: '50px'},500 );
	 
	 //Display the content 
	 //$('.content').animate({opacity:1},100);

}
 
