/* ------------------------------------------------------------------------
	reverseslide.js
	
	Developped By: Michal Starosta -> http://www.starosta-design.com
	Version: 1.0

	Copyright: Feel free to redistribute the script/modify it, as
			   long as you leave my infos at the top.
------------------------------------------------------------------------- */

(function($){  

    $.fn.slide = function(vars) {     
		var items		   		= $('#slideshow img');
		var items_lenght		= items.length;
		var current_pos  		= 0;
		var start_slide 		= true;
		var time_out     		= (vars.time_out != undefined) ? vars.time_out : 5000;

		
		$('#slideshow_gloss').animate({backgroundPosition: '800px 0'},1000);
		
		$('#slideshow_next').click(function(){
			$('#slideshow ul li').eq(current_pos).fadeOut(1500);
			if(current_pos<items_lenght-1){
				current_pos++;
			}
			else{
				current_pos = 0;
			}
			$('#slideshow ul li').eq(current_pos).fadeIn(1500);
		});
		
		$('#slideshow_prev').click(function(){
			$('#slideshow ul li').eq(current_pos).fadeOut(1500);
			if(current_pos<1){
				current_pos = items_lenght-1;
			}
			else{
				current_pos--;
			}
			$('#slideshow ul li').eq(current_pos).fadeIn(1500);
		});
		
		$('#slideshow_stop').click(function(){
			start_slide = false;
			$('#slideshow_stop').css({'display':'none'});
			$('#slideshow_play').css({'display':'block'});
		});
		
		$('#slideshow_play').click(function(){
			start_slide = true;
			$('#slideshow_play').css({'display':'none'});
			$('#slideshow_stop').css({'display':'block'});
		});

		$(function() {
			setInterval(function() {
				if(start_slide){
					$('#slideshow_next').trigger('click')
				}	
			},time_out);
			
		});
    };  

})(jQuery);  
