// styleadj.js
// by Jake Waskett, http://www.irwelldesign.co.uk
// (C) Paul Hill, 2006

// this script fades in and out between N testimonials

// testimonials
var testimonials = new Array(
"&lsquo;It was with some trepidation that I went to be hypnotised by Paul. He put me at ease straight away explaining everything thoroughly. I found the whole experience relaxing and at the same time thought provoking. I always came away feeling more confident in my self and better able to face the world. I would highly recommend him as I have already to friends and family.&rsquo; <span class=\"testName\">&mdash; Helena</span>",
"&lsquo;I would like to extend my heartfelt thanks and gratitude to Paul for being my therapist, counsellor and \"good friend\" during some of the most difficult and stressful times of my life.&rsquo; <span class=\"testName\">&mdash; Tony &ndash; Cancer Patient &ndash; Stockport</span>");

var crntTest = 0;
var state = 1;
var count = 13;
var shade = 138;

function switchTestimonial()
{
	crntTest += 1;
	if (crntTest >= testimonials.length)
		crntTest = 0;
	document.getElementById("testimonial").innerHTML = testimonials[crntTest];
}

var hexits = "012345679abcdef";

function toHex2(ival)
{
	var sval;

	if (ival > 255)
		return "ff";

	sval = ival.toString(16);
	if (sval.length < 2)
		sval = "0" + sval;
	return sval;
}

function fadeTestimonial()
{
	if (state == 0)
		shade -= 12;
	else
		shade += 12;

	document.getElementById("testimonial").style.color = "#" + toHex2(shade) + toHex2(shade) + toHex2(shade);
}

function updateFn()
{
	// arrange to be called again
	setTimeout("updateFn()", 100);

	count -= 1;
	if (count <= 0)
	{
		// rotate states
		state += 1;
		if (state > 2)
		{
			state = 0;
			switchTestimonial();
		}

		// init count
		if (state == 0)
			count = 10; /* 1 second */
		else if (state == 1)
			count = 50;	/* 5 seconds */
		else if (state == 2)
			count = 10; /* 1 second */
	}
	else if (state != 1)
	{
		fadeTestimonial();
	}
}



function initPage()
{
	if (document.getElementById)
	{
		// DOM-capable browser
		updateFn();
	}
}

