var arrSourceLogos = new Array(6)
// \x22 = "

arrSourceLogos[0] = '<img src=\x22images/home/logos/net10.gif\x22 alt=\x22\x22 />';
arrSourceLogos[1] = '<img src=\x22images/home/logos/tracfone.gif\x22 alt=\x22\x22 />';
arrSourceLogos[2] = '<img src=\x22images/home/logos/chevy.gif\x22 alt=\x22\x22 />';
arrSourceLogos[3] = '<img src=\x22images/home/logos/mylifetime.gif\x22 alt=\x22\x22 />';
arrSourceLogos[4] = '<img src=\x22images/home/logos/clix.gif\x22 alt=\x22\x22 />';
arrSourceLogos[5] = '<img src=\x22images/home/logos/vegas.gif\x22 alt=\x22\x22 />';
arrSourceLogos[6] = '<img src=\x22images/home/logos/nc-chevy.gif\x22 alt=\x22\x22 />';
arrSourceLogos[7] = '<img src=\x22images/home/logos/rm-chevy.gif\x22 alt=\x22\x22 />';
arrSourceLogos[8] = '<img src=\x22images/home/logos/mas.gif\x22 alt=\x22\x22 />';


var logosHTML = "";
for(i = 0; i < 9; i++)
{
	var randomIndex = Math.floor(Math.random()*arrSourceLogos.length)
	logosHTML += arrSourceLogos[randomIndex];
	arrSourceLogos.splice(randomIndex, 1);
}


$(document).ready(function(){
	$("#client_logos").html(logosHTML);
});

function drawLogos()
{
	
}

var logoWidth = 231 - 26;
var logoPos = 0;
var totalLogos = 8;  //total - 1, first position 0
var allowClientsAnimate = true;
var animatinTime = 500;

function clientsRight()
{
	if(allowClientsAnimate)
	{
		if( logoPos + 1 <= totalLogos)
		{
			allowClientsAnimate = false;
			logoPos = logoPos + 1;
			$("#client_logos").animate(
				{ 
				marginLeft: -(logoPos * logoWidth),
				}, animatinTime, clientsScrollFinished 
			);
			$("#handler").animate(
				{ 
				marginLeft: logoPos * 179 / (totalLogos + 1),
				}, animatinTime 
			);			
		}	
	}
}

function clientsLeft()
{
	if(allowClientsAnimate)
	{
		if( logoPos - 1 >= 0)
		{
			allowClientsAnimate = false;
			logoPos = logoPos - 1;
			$("#client_logos").animate(
				{ 
				marginLeft: -(logoPos * logoWidth),
				}, animatinTime, clientsScrollFinished 
			);
			$("#handler").animate(
				{ 
				marginLeft: logoPos * 179 / (totalLogos + 1),
				}, animatinTime 
			);
		}	
	}
}

function clientsScrollFinished()
{
	allowClientsAnimate = true;
}
/*--- testimonials start ---*/







var testimonialsPos = 0;
var totalTestimonials = 2;  //total - 1, first position 0
var allowTestimonialsAnimate = true;

function testimonialsRight()
{
	if(allowTestimonialsAnimate)
	{
		if( testimonialsPos + 1 <= totalTestimonials)
		{
			allowTestimonialsAnimate = false;
			testimonialsPos = testimonialsPos + 1;
			$("#trace_testimonialsPos").text(testimonialsPos);
			$("#testimonial_" + (testimonialsPos - 1)).fadeOut(animatinTime, function()
															   {
															   	$("#testimonial_" + testimonialsPos).fadeIn(animatinTime);
																testimonialFadeFinished();
															   });
			$("#handler_testimonials").animate(
				{ 
					marginLeft: testimonialsPos * 179 / (totalTestimonials + 1),
				}, 	animatinTime
			);
		}	
	}
}

function testimonialsLeft()
{
	if(allowTestimonialsAnimate)
	{
		if( testimonialsPos - 1 >= 0)
		{
			allowTestimonialsAnimate = false;
			testimonialsPos = testimonialsPos - 1;
			$("#trace_testimonialsPos").text(testimonialsPos);
			$("#testimonial_" + (testimonialsPos + 1)).fadeOut(animatinTime, function()
															   {
															   	$("#testimonial_" + testimonialsPos).fadeIn(animatinTime);
																testimonialFadeFinished();
															   });
			$("#handler_testimonials").animate(
				{ 
					marginLeft: testimonialsPos * 179 / (totalTestimonials + 1),
				}, 	animatinTime
			);
		}	
	}
}

function testimonialFadeFinished()
{
	allowTestimonialsAnimate = true;
}