$(function()
{
	var setTime = "4000";
	var fadeEffect = "1000";
	
	var time;
	var j = 0;
	var countPhotos = $('.slider').length;
	var oldId = 1;
	var newId = 0;
	var seconds = "0";
	
	
	$("div[class=slider]").css({opacity: '0'});
	$("div[class=slider][id=0]").css({opacity: '1'});
	
	$(document).ready(function()
	{
		makeTime();
	});
	
	function makeTime()
	{
		time = seconds;
		timer();
	}
	
	function timer()							
	{
		var makeInt = parseInt(time);			
		$("body" ).oneTime(makeInt,function()
		{
			seconds = setTime;					
			if(j==0)							
			{
				$("div[class=slider][id=0]").animate({opacity: '1'},50, "swing");	
			}
			if(j != (countPhotos))				
			{
				newId = j;
				$("div[class=slider][id="+newId+"]").animate({opacity: '1'},{duration: +fadeEffect});
				if(oldId != 0)
				{
					$("div[class=slider][id="+oldId+"]").animate({opacity: '0'},{duration: +fadeEffect});				
				}
				oldId = j;						
				j++;
			}
			else								
			{
				
				$("div[class=slider][id="+oldId+"]").animate({opacity: '0'},{duration: +fadeEffect});
				seconds = "0";					
				j=0;							
				
			}
			makeTime();						
		});
			
		
	}		
});
	
