﻿var matcv = new function() {
	var oTestimonials = [
		{"source":"Project Manager, Single Sign On", "quote":"Successfully trained many newer staff members"},
		{"source":"Project Manager, Single Sign On", "quote":"Communicates very well with stakeholders (even the tricky ones!)"},
		{"source":"Project Manager, Single Sign On", "quote":"Very flexible and proactive in solving problems"},
		{"source":"Project Manager, Single Sign On", "quote":"Good persuasive skills"},
		{"source":"Project Manager, Single Sign On", "quote":"A good listener"},
		{"source":"Project Manager, BBC2", "quote":"Did everything possible to ensure the site was ready to launch on time"},
		{"source":"Project Manager, BBC2", "quote":"Always helpful"},
		{"source":"Project Manager, BBC2", "quote":"Mat did a first class job"},
		{"source":"Project Manager, BBC2", "quote":"Mat was critical in our successful launch of BBC2"},
		{"source":"Project Manager, BBC iPlayer", "quote":"Good at thinking through problems"},
		{"source":"Project Manager, BBC iPlayer", "quote":"Professional manner"},
		{"source":"Anonymous feedback", "quote":"Friendly and approachable manner"},
		{"source":"Anonymous feedback", "quote":"Ability to get on with a wide range of different people"},
		{"source":"Anonymous feedback", "quote":"Effectively resolves issues between team members"},
		{"source":"Anonymous feedback", "quote":"Efficient and organised in his work"},
		{"source":"Anonymous feedback", "quote":"Driven to get things done the right way"},
		{"source":"Anonymous feedback", "quote":"Made new team members feel welcome"},
		{"source":"Anonymous feedback", "quote":"Works closely with other discipline groups, educating and learning from them"},
		{"source":"Anonymous feedback", "quote":"Open to investigating new ideas and ways of doing things"},
		{"source":"Anonymous feedback", "quote":"Is adept at influencing and persuading, and finding the middle ground between conflicting points of view, while still driving progress"},
		{"source":"Anonymous feedback", "quote":"Has a genuine passion for a BBC developer community"},
		{"source":"Anonymous feedback", "quote":"Is supportive of others, as when, for example, helping plan and run the PHP training sessions."},
		{"source":"Anonymous feedback", "quote":"Knuckles down and persists through difficult tasks."},
		{"source":"Anonymous feedback", "quote":"Produces well thought through products and solutions."},
		{"source":"Anonymous feedback", "quote":"Is good at explaining technical issues to non-technical people."},
		{"source":"Anonymous feedback", "quote":"Is honest, pragmatic and organised."},
		{"source":"Line manager, BBC", "quote":"Dependable & reliable"},
		{"source":"LinkedIn reference", "quote":"Has the rare skill of being able to manage someone without making them feel managed"},
		{"source":"LinkedIn reference", "quote":"Is a very talented developer who is easy to work with and for"},
		{"source":"Line manager, BBC", "quote":"Always looks for hidden parts of a task that might otherwise be left undone"},
		{"source":"Line manager, BBC", "quote":"Good sense of humour"},
		{"source":"Line manager, BBC", "quote":"A joy to work with"},
		{"source":"Line manager, BBC", "quote":"Takes a positive proactive approach and is self-motivating"},
		{"source":"Line manager, BBC", "quote":"Versatile in his role"},
		{"source":"Line manager, BBC", "quote":"Takes an interest in other disciplines"}
	];

	// Writes a random testimonial to the bottom of the page
	this.populateTestimonials = function(){
		if(!document.getElementById || !document.getElementById('testimonial')){ return false }
		
		var x = Math.floor(Math.random()*oTestimonials.length);
		document.getElementById('testimonial').innerHTML="<blockquote>&ldquo;"+oTestimonials[x].quote+"&rdquo;</blockquote><cite>- "+oTestimonials[x].source+".</cite><p><a href='javascript:matcv.populateTestimonials();'>Change quote</a> - <a href='testimonials.html'>About these quotes</a></p>";
	}

	// Rebuilds email address into human readable form
	this.tidyEmail = function() {
		if(!document.getElementById || !document.getElementById('testimonial')){ return false }

		var where = "@",
			mail = "cv2010" + where + "hampson." + "org.uk";
		document.getElementById('email').innerHTML='<a href="mailto:'+mail+'">'+mail+'</a>';
		document.getElementById('emailExplanation').style.display="none";
	}
	
	// General purpose multiple onload handler (public)
	this.addLoadEvent = function(func) { 
		var oldonload = window.onload; 
		if (typeof window.onload != 'function') { 
			window.onload = func; 
		} else { 
			window.onload = function() { 
				if (oldonload) { 
					oldonload(); 
				}	
				func(); 
			} 
		} 
	} 
}
matcv.addLoadEvent(matcv.populateTestimonials);