var Photos = {

	List: [],
	Current: 0,
	AutomaticRotation: true,
	Timer: null,


	Next: function()
	{
		Photos.StopTimer();
	
		if(Photos.Current >= Photos.List.length - 1)
			return;
	
		Photos.Current++;
		Photos.Update();
	},


	Previous: function()
	{
		Photos.StopTimer();
	
		if(Photos.Current <= 0)
			return;
	
		Photos.Current--;
		Photos.Update();
	}, 


	Update: function()
	{
		var Bar = $('.Photos .Bar');
		
		$(Bar).animate({marginLeft: '-' + ((Photos.Current) * 583) + 'px'}, 1000);
		Photos.UpdateInfo();
	},


	Rotate: function()
	{
		if(Photos.AutomaticRotation)
		{
			if(Photos.Current >= Photos.List.length - 1)
				Photos.Current = 0;
			else Photos.Current++;			
		
			Photos.Update();
			Photos.SetTimer();
		} else 
			window.clearTimeout(Photos.Timer);
	},
	
	
	UpdateInfo: function()
	{
		$('.PhotoInfo h6').text(Photos.List[Photos.Current].title);
		$('.PhotoInfo p').text(Photos.List[Photos.Current].content);
	},
	
	
	SetTimer: function()
	{
		if(Photos.AutomaticRotation)
			Photos.Timer = window.setTimeout(Photos.Rotate, 8000);
	},
	
	
	StopTimer: function()
	{
		Photos.AutomaticRotation = false;
		window.clearTimeout(Photos.Timer);
	}

}


$(document).ready(function(){
	
	Photos.SetTimer();
});