// JavaScript Document

function get_randomNum(maxInt)
{
	var num = Math.floor(Math.random()*maxInt);
	return num;
}
$(function(){
	 var testimonial_list ="";
	 
	 $('body').append('<div id="load-test"></div>');
	 
	$('div#load-test').css({'display':"none"}).load("/Testimonials/default.aspx .testimonial",{}, function(){
		testimonial_list ="";
		if($('body').is('#home'))
		{
			$('div#load-test .testimonial').each(function(){
				testimonial_list += '<li class="tcycle">';
				$(this).find('p').each(function(){
					if(!($(this).is('.names')))
					{
						testimonial_list +='<blockquote class="testimonial-quote">' + $(this).html() + '</blockquote>';
					}
					else
					{
						testimonial_list +='<p class="author">&#8212; ' + $(this).html() + '</p>';
					}
				});
				testimonial_list +='<span style="font-size:1.2em;text-align:right;display:block;">[ <a href="/Testimonials/default.aspx" style="color:white;">View more testimonials</a> ]</span>';
				testimonial_list +='</li>';
			});
			
				$('div#testimonial-block ul').append(testimonial_list);
				
				$('body#home div#testimonial-block ul').cycle({timeout:12000});
		}
		else
		{
			var testimonialNum = $('div#load-test .testimonial').length;
			testimonial_list += '<li class="tcycle">';
			$('div#load-test .testimonial').eq(get_randomNum(testimonialNum)).find('p').each(function(){
				if(!($(this).is('.names')))
					{
						testimonial_list +='<blockquote class="testimonial-quote">' + $(this).html() + '</blockquote>';
					}
					else
					{
						testimonial_list +='<p class="author">&#8212; ' + $(this).html() + '</p>';
					}
			});
			testimonial_list +='<span style="font-size:1.2em;text-align:right;display:block;">[ <a href="/Testimonials/default.aspx" style="color:white;">View more testimonials</a> ]</span>';
			testimonial_list +='</li>';
			$('div#testimonial-block ul').append(testimonial_list);
			
		}
	});
});