// JS Functions

//DROP-DOWN NAV
startList = function() {
	if (document.getElementById) {
		navRoot = document.getElementById("mainnav");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
}
window.onload=startList;


// Form Validation
function isValidEmail(str) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(str)){
		return true;
	}
	else {
		return false;
	}
}

function checkcontactform(){
	var ftxt = '';
	
	if (document.contactform.Name.value==''){
		ftxt += '\n- Please enter a Name.';
	}
	
	if (document.contactform.Area_of_business.value==''){
		ftxt += '\n- Please enter an Area of Business.';
	}
	
	if (document.contactform.Comment.value==''){
		ftxt += '\n- Please enter a Comment.';
	}
	

	if (ftxt!==''){
		alert('One or more errors were found while submitting this form. The errors found are displayed below.\n' + ftxt + '\n\nPlease correct the above errors and try again.');
		return false;
	}
	else {
		return true;
	}
}




function checkcockerelform(){
	var ftxt = '';
	
	if (document.cockerelform.name.value==''){
		ftxt += '\n- Please enter a Name.';
	}
	
	if (document.cockerelform.postcode.value==''){
		ftxt += '\n- Please enter a Postcode.';
	}
	
	if (document.cockerelform.tel.value==''){
		ftxt += '\n- Please enter a Telephone number.';
	}
	
	if (document.cockerelform.email.value==''){
		ftxt += '\n- Please enter an Email address.';
	}
	

	if (ftxt!==''){
		alert('One or more errors were found while submitting this form. The errors found are displayed below.\n' + ftxt + '\n\nPlease correct the above errors and try again.');
		return false;
	}
	else {
		return true;
	}
}




function setQty (enabled,id){
	t = document.getElementById(id)
	if(enabled){
			t.value='1';
			t.disabled=false;
	} else {
			t.value='0';
			t.disabled=true;
	}
	
}


