var flagShuffle = false;
window.setInterval('initTestemonials()',8000);

function initTestemonials(){
	try {
		// check if testemonialbox exists
		if (!$('testemonialbox')) {
			return false;
		} else {
			// hide all testemonials first
			testemonials = $('testemonialbox').getElementsByClassName('testemonial');
			for (var i=0; i < testemonials.length; i++) {
				testemonials[i].style.display = 'none';
			};
			// shuffle all available quotes
			function shuffleQuote() {
				ranUnrounded = Math.random()*testemonials.length;
				currentQuoteNo = Math.floor(ranUnrounded);
				currentQuote = testemonials[currentQuoteNo];
				flagShuffle = true;
			}	
			// slide to next quote
			function slideThru() {
				if (currentQuoteNo == testemonials.length) {
					currentQuoteNo = 0;
				} else {
					nextQuoteNo = currentQuoteNo++;
				}
				nextQuote = testemonials[nextQuoteNo];
				nextQuote.style.display = 'block';
			}
			// call shuffle function once
			if (flagShuffle == false) { shuffleQuote(); };
			// call slide function through interval
			slideThru();
			return true;
		}
	} catch(e) {
		//fail silently
	}
}