// Set timers
var menu = new Object;
menu.hidedelay = 200;
menu.opendelay = 100;
menu.slidedelay = 150;

var testimonials = new Object;
testimonials.current = 1; //staring testimonial
testimonials.numberof = 3; //number of testimonials 
testimonials.rotatetime = 8000; //time to show each testimonail
testimonials.array = new Array;
testimonials.array[0] = '<img src="/skins/sre/images/quote-start.gif" alt="" class="start">'+
						'<p><strong>SRE</strong> supports our on-going sustainability work at Chetwoods<br />'+
						'through their <strong>sound technical analysis</strong> and <strong>strong understanding</strong> of<br />'+
						'the <strong>sustainability and energy issues</strong> facing<br />'+
						'both the practice and our clients.  We are very pleased with the<br />'+
						'<strong>proactive, reliable and personable</strong> service <strong>SRE</strong> provides for us.</p>'+
						'<p class="source">Laurie Chetwood, Chetwoods Architects, London</p>'+
						'<img src="/skins/sre/images/quote-end.gif" alt="" class="end">';
testimonials.array[1] = '<img src="/skins/sre/images/quote-start.gif" alt="" class="start">'+
						'<p><strong>SRE</strong> provided a thorough, <strong>detailed and intelligible</strong><br />'+
						'assessment of our existing heating systems. This <br />'+
						'<strong>analysis and, advice</strong> on both replacement systems and procurement, <br />'+
						'have helped us <strong>reduce our annual costs by over 60%</strong><br />'+
						'<p class="source">Simon Lund, Hambledon Farm, West Sussex</p>'+
						'<img src="/skins/sre/images/quote-end.gif" alt="" class="end">';
testimonials.array[2] = '<img src="/skins/sre/images/quote-start.gif" alt="" class="start">'+
						'<p><strong>SRE</strong> responded <strong>quickly and effectively</strong> to our client\'s tight <br />'+
						'schedule and produced excellent supporting <br />'+
						'documentation within a short timeline leading<br />'+
						'to a <strong>successful outcome</strong>.<br />'+
						'<p class="source">Philippa Gavey, Paul Brookes Architects</p>'+
						'<img src="/skins/sre/images/quote-end.gif" alt="" class="end">';

$(document).ready (function()
{ 
	$("li.submenu").hover(
		function(){
			if (this.active == 1) {
				clearTimeout(this.timeout);
			} else {
				this.opentimeout = setTimeout ("openMenu('"+$(this).id()+"')", menu.opendelay);
			}
		},
		function(){
			if (this.active == 1) {
				this.timeout = setTimeout ("closeMenu('"+$(this).id()+"')", menu.hidedelay);
			} else {
		    	clearTimeout(this.opentimeout);
			}		
		}
	);	
	$("li.submenu>a").attr("href", "#"); //hijack teh index page links and turn them off
	//hijack the close button the messagesbox
	$("#messagebox>a.close ").each(function(){
		$(this).bind("click", function(){
			$("#messagebox").fadeOut();
		})	
	});
	//rotate the testimonials
	if ( ($("#testimonial").size()) == 1)
	{//if we have template 9 present on the page we are on the splash page
		testimonials.timeout = setTimeout ("changetestimonial()", testimonials.rotatetime);
	}
});

openMenu = function (menuId)
{
	$("#"+menuId).find("ul").slideDown(menu.slidedelay);
	$("#"+menuId).find("a.top").addClass("on");
	document.getElementById(menuId).active = 1;
}

closeMenu = function (menuId)
{
	$("#"+menuId).find("ul").slideUp(menu.slidedelay);
	$("#"+menuId).find("a.top").removeClass("on");
	document.getElementById(menuId).active = 0;
}


function changetestimonial()
{
	if ( testimonials.current == testimonials.numberof )
	{
		testimonials.current = 1;
	}
	else
	{
		testimonials.current++;
	}
	$("#testimonial").html(testimonials.array[testimonials.current-1]);		
	testimonials.timeout = setTimeout ("changetestimonial()", testimonials.rotatetime);
}