//validate the contact form
function checkContactForm(form) {

	var error = false;
	var errorText = 'You must correct the following errors before continuing:' + "\n";

	if (form.elements.name.value == '') { 
		error = true;
		errorText = errorText + "\n" + '* You must enter your name.';
	}
	
	if (form.elements.email.value == '') { 
		error = true;
		errorText = errorText + "\n" + '* You must enter your email address.';
	}
	
	if (form.elements.enquiry.value == '') { 
		error = true;
		errorText = errorText + "\n" + '* You must enter an enquiry.';
	}	
	
	if (error) {	
		alert(errorText);
		return false;
	} else {
		return true;
	}
}

//Extended accordion function
var ExtendedAccordion = Accordion.extend({
	showAll: function() {
		var obj = {};
		this.elements.each(function(el, i){
			obj[i] = {};
			this.fireEvent('onActive', [this.togglers[i], el]);
			for (var fx in this.effects) obj[i][fx] = el[this.effects[fx]];
		}, this);
		return this.start(obj);
	},
	hideAll: function() {
		var obj = {};
		this.elements.each(function(el, i){
			obj[i] = {};
			this.fireEvent('onBackground', [this.togglers[i], el]);
			for (var fx in this.effects) obj[i][fx] = 0;
		}, this);
		return this.start(obj);
	}
});

//fade the tabs at the top
window.addEvent('domready', function() {
									 
									
	var el = $('nav2');
	el.fade(0.7);
	
	$('nav2').addEvent('mouseover', function(e) {
		e.stop();
		el.fade(1);
	});
	
	$('nav2').addEvent('mouseout', function(e) {
		e.stop();
		el.fade(0.7);
	});	
	
	var ello = $('nav3');
	ello.fade(0.7);
	
	$('nav3').addEvent('mouseover', function(e) {
		e.stop();
		ello.fade(1);
	});
	
	$('nav3').addEvent('mouseout', function(e) {
		e.stop();
		ello.fade(0.7);
	});	
	
	if (document.getElementById('nav4')) { 
		var elloello = $('nav4');
		elloello.fade(0.7);
		
		$('nav4').addEvent('mouseover', function(e) {
			e.stop();
			elloello.fade(1);
		});
		
		$('nav4').addEvent('mouseout', function(e) {
			e.stop();
			elloello.fade(0.7);
		});		
	}
	
});
