// Testimonials Init
// Author: Robin Raszka

needColor = 102; // Color of testimonials
fade_timer=null;
this_ttm=-1;
next_ttm=0;

function select_object(object) {
	if(!document.all) {
		var obj=document.getElementById(object);
	} else {
		eval('var obj=document.all.'+object+';');
	}
	
	return obj;
}

// FADE OUT
function ttm_fadeout(id) {
	obj = select_object(id);
	ttm_fadeout_process(obj,needColor);
}

function ttm_fadeout_process(obj,color) {
	obj.style.color = "rgb("+color+","+color+","+color+")";
	color = color + 2;
	if (color < 256) {
		fader = setTimeout("ttm_fadeout_process(obj,"+color+")",1);
		ttm_done = false;
	} else {
		obj.style.display = "none";
		fader = setTimeout("ttm_fadein('ttm"+next_ttm+"')", 500);
	}
}

// FADE IN
function ttm_fadein(obj_id) {
	obj = select_object(obj_id);
	obj.style.display = "inline";
	ttm_fadein_process(obj,256);
}

function ttm_fadein_process(obj,color) {
	obj.style.color = "rgb("+color+","+color+","+color+")";
	color = color - 2;
	if (color > needColor) {
		fader = setTimeout("ttm_fadein_process(obj,"+color+")",1);
		ttm_done = false;
	} else {
		next_ttm++;
		if (next_ttm == testimonials.length) next_ttm=0;
	
		this_ttm++;
		if (this_ttm == testimonials.length) this_ttm=0;
		
		fader = setTimeout("ttm_fadeout('ttm"+this_ttm+"')",testimonials[next_ttm][2]);
		ttm_done = true;
	}
}

// INIT
function show_ttm() {
	for(i=0; i<testimonials.length; i++) {
		document.write('<a href="'+testimonials[i][1]+'" style="color:#ffffff; display:none;" id="ttm'+i+'" '+testimonials[i][2]+'>'+testimonials[i][0]+'</a>');
	}
	
	ttm_slideshow_start()
}

function ttm_slideshow_start() {
	ttm_fadein("ttm0");
}

function clickMe() {
	if (ttm_done == true) {
		clearTimeout(fader);
		ttm_fadeout("ttm" + this_ttm);
	}
}

document.write("<script type=\"text/javascript\" src=\"templates/itk/js/data.js\"></script>");