var homeSlideIntTime = 8000;
var homeSlideSlideTime = 500;
var homeSlideInt;
$('#welcome-slides').ready
(
	function()
	{
		$('#welcome-slides .slide').each
		(
			function(i)
			{
				if(i > 0)
				{
					$(this).css('left','560px');
				}
				
				var pic = $(this).children('a')
				pic.remove();
				
				$(this).html('<div>' + $(this).html() + '</div>');
				$(this).prepend(pic.html());
				
				var msg = $(this).children('div');
				
				//msg.css('margin-top',Math.round(($('#welcome-slides').height() - msg.height()) / 2) + 'px');
				
			}
		)
		
		if($('#welcome-slides .slide').size() > 1)
		{
			homeSlideInt = setInterval(slideWelcomeSlides,homeSlideIntTime);	
		}
	}
);

function slideWelcomeSlides()
{
	$('#welcome-slides .slide:eq(1)').animate(
				{
					left: '-=' + $('#welcome-slides').width()
				},
				homeSlideSlideTime,
				'swing',
				moveFirstSlide
				);
	
	/*each
	(
		function(i)
		{
			if($(this).position().left != 0)
			{
				$(this).animate(
				{
					left: '-=' + $('#welcome-slides').width()
				},
				homeSlideSlideTime,
				'swing',
				moveFirstSlide
				);
			}
		}
	)*/
}

function moveFirstSlide()
{
	var first = $('#welcome-slides .slide:eq(0)');
	first.remove();
	$('#welcome-slides').append(first);
	first.css('left',$('#welcome-slides').width() + 'px');
}

function moveFirstSlide2()
{
	var done = true;
	
	$('#welcome-slides .slide').each
	(
		function()
		{
			if($(this).position().left != 0)
			{
				done = false;	
			}
		}
	)
	
	if(done)
	{
		$('#welcome-slides .slide').each
		(
			function(i)
			{
				$(this).css('left', i * $('#welcome-slides').width());
			}
		)
	}
}
