// JScript source code
function isValidEmail(str) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(str)){
		return true;
	}
	else {
		return false;
	}
}

function checkenquiryform(){
	var ftxt = '';

	if (document.enquiryform.Firstname.value==''){
		ftxt += '\n- Please enter your Firstname.';
	}
	
	if (document.enquiryform.Surname.value==''){
		ftxt += '\n- Please enter your Surname.';
	}
	
	if (isValidEmail(document.enquiryform.Email.value)==false){
		ftxt += '\n- Please enter your Email Address.';
	}
	
	if (document.enquiryform.Telephone.value==''){
		ftxt += '\n- Please enter your Telephone Number.';
	}
		
	if (document.enquiryform.Enquiry.value==''){
		ftxt += '\n- Please enter your Enquiry.';
	}
	
	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 checknewsletterform(){
	if (isValidEmail(document.newsletterform.email.value)==false){
		alert('Please enter your Email Address.');
		return false;
	}
	else {
		return true;
	}
}

function clearemailfield(fieldVal){
	if (isValidEmail(fieldVal)==false){
		document.newsletterform.email.value='';
	}
}

/* Search Form */
function checksearch(){
    if (document.thesearchform.Criteria.value==''){
        alert('Please enter your Search Criteria.');
        return false;
    }
    else {
        return true;
    }
}

function mainmenu(){
	$(" #navlist ul ").css({display: "none"}); // Opera Fix
	$(" #navlist li").hover(function(){
			$(this).find('ul:first').css({visibility: "visible",display: "none"}).slideDown(0);
			},function(){
			$(this).find('ul:first').css({visibility: "hidden"});
			});
	}

 $(document).ready(function(){					
	mainmenu()
});

/* Careers Form */
function checkcareersform(){
	var ftxt = '';

	if (document.enquiryform.Firstname.value==''){
		ftxt += '\n- Please enter your Firstname.';
	}
	
	if (document.enquiryform.Surname.value==''){
		ftxt += '\n- Please enter your Surname.';
	}
	
	if (isValidEmail(document.enquiryform.Email.value)==false){
		ftxt += '\n- Please enter your Email Address.';
	}
	
	if (document.enquiryform.Telephone.value==''){
		ftxt += '\n- Please enter your Telephone Number.';
	}
	
	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;
	}
}
