/*
	Main.js - WPP
	76 Design
*/

var RotatingHeader =
{

	// you shouldn't touch these

	current: 0,
	total: 0,
	delayFade: 500,
	delayFadeIn: null,
	rotateInterval: null,

	// start it

	init: function(params)
	{
		this.elements = params.elements;
		this.fadeSpeed = params.fadeSpeed;
		this.intervalSpeed = params.intervalSpeed;
		$(this.elements).hide();
		this.total = $(this.elements).length; // amount of testimonials
		var random = Math.floor(Math.random() * ((this.total - 1) - 0 + 1)); // randomize it
		this.current = random;
		$(this.elements + ":eq(" + random + ")").show();
		this.rotateInterval = window.setInterval("RotatingHeader.rotate();", this.intervalSpeed);
	},

	// rotate through the testimonials

	rotate: function()
	{
		this.checkNext(); // we get the appropriate testimonial if
		$(this.elements).hide();
		$(this.elements + ":eq(" + this.current + ")").fadeIn(this.fadeSpeed);
	},

	// call this function before you use the "this.current" variable.. it will insure you are on the correct testimonial

	checkNext: function()
	{

		if ((this.total - 1) > this.current)
		{
			this.current++;
		}
		else
		{
			this.current = 0;
		}

	},

	checkPrevious: function()
	{

		if (this.current > 0)
		{
			this.current--;
		}
		else
		{
			this.current = (this.total - 1);
		}

	},

	// if they want to manually scroll through the testimonials

	next: function()
	{
		clearInterval(this.rotateInterval);
		this.checkNext();
		$(this.elements).hide();
		$(this.elements + ":eq(" + this.current + ")").show();
	},

	// if they want to manually scroll through the testimonials

	previous: function()
	{
		clearInterval(this.rotateInterval);
		this.checkPrevious();
		$(this.elements).hide();
		$(this.elements + ":eq(" + this.current + ")").show();
	}

}

var RotatingText =
{

	// you shouldn't touch these

	current: 0,
	total: 0,
	delayFade: 500,
	delayFadeIn: null,
	rotateInterval: null,

	// start it

	init: function(params)
	{
		this.elements = params.elements;
		this.fadeSpeed = params.fadeSpeed;
		this.intervalSpeed = params.intervalSpeed;
		$(this.elements).hide();
		this.total = $(this.elements).length; // amount of testimonials
		var random = Math.floor(Math.random() * ((this.total - 1) - 0 + 1)); // randomize it
		this.current = random;
		$(this.elements + ":eq(" + random + ")").show();
		this.rotateInterval = window.setInterval("RotatingText.rotate();", this.intervalSpeed);
	},

	// rotate through the testimonials

	rotate: function()
	{
		this.checkNext(); // we get the appropriate testimonial if
		$(this.elements).hide();
		$(this.elements + ":eq(" + this.current + ")").fadeIn(this.fadeSpeed);
	},

	// call this function before you use the "this.current" variable.. it will insure you are on the correct testimonial

	checkNext: function()
	{

		if ((this.total - 1) > this.current)
		{
			this.current++;
		}
		else
		{
			this.current = 0;
		}

	},

	checkPrevious: function()
	{

		if (this.current > 0)
		{
			this.current--;
		}
		else
		{
			this.current = (this.total - 1);
		}

	},

	// if they want to manually scroll through the testimonials

	next: function()
	{
		clearInterval(this.rotateInterval);
		this.checkNext();
		$(this.elements).hide();
		$(this.elements + ":eq(" + this.current + ")").show();
	},

	// if they want to manually scroll through the testimonials

	previous: function()
	{
		clearInterval(this.rotateInterval);
		this.checkPrevious();
		$(this.elements).hide();
		$(this.elements + ":eq(" + this.current + ")").show();
	}
	
}