needColor = 102; // Color of testimonials
fade_timer = null;
this_ttm = -1;
next_ttm = 0;
var el = 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 + 4;
	if (color < 256) {
		fader = setTimeout("ttm_fadeout_process(obj,"+color+")",20);
		ttm_done = false;
	} else {
		frame = select_object("switchoff");
		obj.style.display = "none";
		if (frame) { frame.style.display = "none"; }
		fader = setTimeout("ttm_fadein('ttm"+next_ttm+"')", 500);
	}
}

// FADE IN
function ttm_fadein(obj_id) {
	frame = select_object("switchoff");
	obj = select_object(obj_id);
	obj.style.display = "inline";
	if (frame) { frame.style.display = "block"; }
	ttm_fadein_process(obj,256);
}

function ttm_fadein_process(obj,color) {
	obj.style.color = "rgb("+color+","+color+","+color+")";
	color = color - 4;
	if (color > needColor) {
		fader = setTimeout("ttm_fadein_process(obj,"+color+")",20);
		ttm_done = false;
	} else {
		next_ttm++;
		if (next_ttm == customerquotes.length) next_ttm=0;

		this_ttm++;
		if (this_ttm == customerquotes.length) this_ttm=0;

		fader = setTimeout("ttm_fadeout('ttm"+this_ttm+"')",customerquotes[next_ttm][2]*2);
		ttm_done = true;
	}
}

function open_url(url) {
	if (url != "") {
		window.open(url,"QuotesWindow","");
	}
}

// INIT
function show_ttm() {
    for(i=0; i<customerquotes.length; i++) {
        document.write('<div style="display:none;" id="ttm'+i+'">');
        document.write('<a class="textTsm" onClick="open_url(\'' + customerquotes[i][3] + '\');">');
        document.write('<p class="quote">'+customerquotes[i][0]+'</p>');
        document.write('<p class="quoteauthor">'+customerquotes[i][1]+'</p></a></div>');
    }
    ttm_slideshow_start()
}
function ttm_slideshow_start() {
	ttm_fadein("ttm0");
}

