var trainingFeedbackArray = new Array();
var trainingFeedbackPopulated = false;
var trainingRepeatTime = 10;
var x = trainingRepeatTime;
var y = 1;
var trainingTimeoutArray = new Array();

//Definition of a feedback object
function TrainingFeedback(quote){
	this.quote = quote;
}

function populateTrainingFeedbackArray(){
	var trainingFeedbackElement = new TrainingFeedback('100% of attendees said they felt that the Instructor really knew his products and that he added value to the service course.');
	trainingFeedbackArray[trainingFeedbackArray.length] = trainingFeedbackElement;
	
	trainingFeedbackElement = new TrainingFeedback('100% of the attendees found the content and level of training given as “very informative and enforced knowledge of the products”.');
	trainingFeedbackArray[trainingFeedbackArray.length] = trainingFeedbackElement;
	
	trainingFeedbackElement = new TrainingFeedback('100% of service course attendees commented that they had all learnt something they did not know before and improved their skills.');
	trainingFeedbackArray[trainingFeedbackArray.length] = trainingFeedbackElement;
	
	trainingFeedbackElement = new TrainingFeedback('100% of attendees found the practical element enforced the content of the service course, they also found it helpful to have real examples and products whilst training.');
	trainingFeedbackArray[trainingFeedbackArray.length] = trainingFeedbackElement;
	
	trainingFeedbackElement = new TrainingFeedback('100% agreed that the accommodation and hospitality were second to none.');
	trainingFeedbackArray[trainingFeedbackArray.length] = trainingFeedbackElement;
	
	trainingFeedbackElement = new TrainingFeedback('Following the services course, 100% attendees said they felt confident in their ability to carry out servicing following the training.');
	trainingFeedbackArray[trainingFeedbackArray.length] = trainingFeedbackElement;
	
	trainingFeedbackElement = new TrainingFeedback('100% of attendees rated the services course overall as either “fantastic” or “good”.');
	trainingFeedbackArray[trainingFeedbackArray.length] = trainingFeedbackElement;
	
	trainingFeedbackElement = new TrainingFeedback('"Found Carnet to be a very friendly company. Staff product knowledge to be excellent. Company had a wish to produce an excellent product and service"<br/><br/>Mr Ernie Kenney');
	trainingFeedbackArray[trainingFeedbackArray.length] = trainingFeedbackElement;
	
	trainingFeedbackElement = new TrainingFeedback('"Excellent course would recommend"<br/><br/>Steve Bayfield');
	trainingFeedbackArray[trainingFeedbackArray.length] = trainingFeedbackElement;
	
	trainingFeedbackElement = new TrainingFeedback('"I found the training day well structured and most helpful. I would have no trouble recomending this course to other people"<br/><br/>Victor Ford');
	trainingFeedbackArray[trainingFeedbackArray.length] = trainingFeedbackElement;
	
	trainingFeedbackElement = new TrainingFeedback('"Carnet provided a thoroughly comprehensive and informative training day. Carnet have developed a superior flowmeter and their customer support is second to none."<br/><br/>Barry Parkinson');
	trainingFeedbackArray[trainingFeedbackArray.length] = trainingFeedbackElement;
	
	trainingFeedbackElement = new TrainingFeedback('"I thought the whole course was excellent, from the meeting with Mike and Lisa the night before to the photo session at the end. Everything was very professionally done."<br/><br/>Glenn Cuthbertson');
	trainingFeedbackArray[trainingFeedbackArray.length] = trainingFeedbackElement;
	
	trainingFeedbackElement = new TrainingFeedback('"Very welcoming.  Pleasant people to deal with, polite and helpful. Fun and friendly too!!"<br/><br/>Mark Robinson');
	trainingFeedbackArray[trainingFeedbackArray.length] = trainingFeedbackElement;
	
	trainingFeedbackElement = new TrainingFeedback('"Excellent products, manufactured / presented by a professional / above average, close working team."<br/><br/>Colin Barber');
	trainingFeedbackArray[trainingFeedbackArray.length] = trainingFeedbackElement;
	
	trainingFeedbackElement = new TrainingFeedback('"I found the training course to be excellent. From the accommodation down to the hands on practical work we were assigned, I found the whole experience of the course fantastic!"<br/><br/>Alan Marples- Chesterfield Royal Hospital');
	trainingFeedbackArray[trainingFeedbackArray.length] = trainingFeedbackElement;
	
	trainingFeedbackElement = new TrainingFeedback('"It was great to be trained by the engineer who actually designed the product as he gave us an insight to how it was developed. The company appear to be very friendly and made us feel welcome."<br/><br/>Stuart Critchley- Wythenshawe Hospital ');
	trainingFeedbackArray[trainingFeedbackArray.length] = trainingFeedbackElement;
	
	trainingFeedbackElement = new TrainingFeedback('"The course was of a very high calibre in both content and delivery. The best one-day course I have attended. It mirrored the high quality products produced by the Carnet/BPR partnership."<br/><br/>Alan Phipps- Norfolk and Norwich University Hospital ');
	trainingFeedbackArray[trainingFeedbackArray.length] = trainingFeedbackElement;
	
	trainingFeedbackElement = new TrainingFeedback('"A really quality piece of British engineering combined with a practical service course provided by the actual designer of the product gives insight into the hows and whys and shows a continued commitment to product development."<br/><br/>Robert Booth – Wythenshawe Hospital ');
	trainingFeedbackArray[trainingFeedbackArray.length] = trainingFeedbackElement;

	trainingFeedbackPopulated = true;
}
	
	
	
function genRandomTrainingFeedback(){
	if(!trainingFeedbackPopulated){
		populateTrainingFeedbackArray();
	}
	randomNum = (Math.round((Math.random()*(trainingFeedbackArray.length-1))));
	return trainingFeedbackArray[randomNum];
}

function setTrainingFeedbackTimer(id){
	 if(id != null){
	 	if(!arrayContains(trainingTimeoutArray, id)){
			trainingTimeoutArray[trainingTimeoutArray.length] = id;
	 	}
	 }
	 setTimeout("refreshTrainingTimeoutElements()", 20000);
}

function generateTrainingHtml(){
	trainingFeedback = genRandomTrainingFeedback();
	
	var html = '<div style="height:140px;">';

	html += '<p>'+trainingFeedback.quote;
	html += '</p></div>';
	/*trainingFeedback = genRandomTrainingFeedback();
	html += '<br/><p>'+trainingFeedback.quote+'</p>';*/
	
	html += '<div style="vertical-align:bottom; text-align:center;"><p><a style="font-size:16px; font-weight:bold;" href="/training-feedback.html" target="_blank">View All</a></p></div>';
	
	return html;
}

function populateTrainingFeedbackDivById(elementId){
	var element = document.getElementById(elementId);
	element.innerHTML = generateTrainingHtml();
}

function refreshTrainingTimeoutElements(){
	for(var i=0; i < trainingTimeoutArray.length; i++){
		populateTrainingFeedbackDivById(trainingTimeoutArray[i]);
	}
	setTrainingFeedbackTimer();
}