var currSlide = 1;
var totalSlides = 1;
var slideHeight = 302;
var motionTime = 600;
	
$(document).ready(function() {
	totalSlides = $('.testimonial_text_container').length;
	
	$('.testimonial_text_container:eq(0)').before(
		$('.testimonial_text_container:eq(' + (totalSlides - 1) + ')').clone()
	);
	
	$('.testimonial_text_container:eq(' + totalSlides + ')').after(
		$('.testimonial_text_container:eq(1)').clone()
	);
	
	$('#testimonial_slide').animate({"top": '-=' + slideHeight}, 0);
	$('#testimonial_slide *').css({"visibility": "visible"});
});

function slide_up()
{
	if($.browser.msie && ($.browser.version == 7))
	{
		$('#testimonial_slide').animate({"top": '-=' + slideHeight}, motionTime, function() {
			currSlide++;
			
			if(currSlide > totalSlides)
			{
				$('#testimonial_slide').animate({"top": '+=' + (slideHeight * totalSlides)}, 0);
				
				currSlide = 1;
			}
		});
	}
	else
	{
		currSlide++;
		toMoveBy = parseInt($('.testimonial_text_container:eq(' + currSlide + ')').position().top) + getCSSVal($('#testimonial_slide'), 'top');
		vSlider = new slidable($('#testimonial_slide'), toMoveBy, 'vertical', motionTime, 'vSlider');
		setTimeout('handleFirstLast();', motionTime + 5);
	}
}

function slide_down()
{
	if($.browser.msie && ($.browser.version == 7))
	{
		$('#testimonial_slide').animate({"top": '+=' + slideHeight}, motionTime, function() {
			currSlide--;
	
			if(currSlide < 1)
			{
				$('#testimonial_slide').animate({"top": '-=' + (slideHeight * totalSlides)}, 0);
				currSlide = totalSlides;
			}
		});
	}
	else
	{
		currSlide--;
		toMoveBy = parseInt($('.testimonial_text_container:eq(' + currSlide + ')').position().top) + getCSSVal($('#testimonial_slide'), 'top');
		vSlider = new slidable($('#testimonial_slide'), toMoveBy, 'vertical', motionTime, 'vSlider');
		setTimeout('handleFirstLast();', motionTime + 100);
	}
}

function handleFirstLast()
{
	if(currSlide > totalSlides)
	{
		currSlide = 1;
		toMoveBy = parseInt($('.testimonial_text_container:eq(' + currSlide + ')').position().top) + getCSSVal($('#testimonial_slide'), 'top');
		vSlider = new slidable($('#testimonial_slide'), toMoveBy, 'vertical', 0, 'vSlider');
	}
	else if(currSlide < 1)
	{
		currSlide = totalSlides;
		toMoveBy = parseInt($('.testimonial_text_container:eq(' + currSlide + ')').position().top) + getCSSVal($('#testimonial_slide'), 'top');
		vSlider = new slidable($('#testimonial_slide'), toMoveBy, 'vertical', 0, 'vSlider');
	}
}
