var index;
var numimages = 5;
var numtests = 5;

$(document).ready(function() {			   
	index=Math.floor(Math.random()*numimages)	+ 1;
	testindex=Math.floor(Math.random()*(numtests -1))	+ 1;
	$('#bg-image-container').css('background', 'url("http://vpmdev.com/CMSDC/dress/bg-body-' + index + '.jpg") no-repeat scroll center top transparent');
	changeTestimonial(1);
	window.setInterval('changeBG()', 8000);
});

function changeBG() {
	index++;
	temp = ((index) % numimages) + 1;
	$('#imagequote_quote_testimonial').fadeOut(500);
	$('#bg-image-container')
		.fadeOut(500, function(){
			$('#bg-image-container').css('background', 'url("http://vpmdev.com/CMSDC/dress/bg-body-' + temp + '.jpg") no-repeat scroll center top transparent')
			.fadeIn(1000);		
			changeTestimonial(temp);
			$('#imagequote_quote_testimonial').fadeIn(1000);
		});
	
}

function changeTestimonial(index) {
	if(index == 6) index = 1;
	newt = $('#test-' + index).val(); //Get value of hidden input
	place = newt.indexOf('|');		  //Get the position of the pipe, gives us the author.
	quote = newt.substring(0, place);
	author = newt.substring(place+1);
	output = "\"" +quote + '"<br /><span>' + author + '</span>';
	$('#imagequote_quote_testimonial').html(output);
}
