// JScript source code
function isValidEmail(str) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(str)){
		return true;
	}
	else {
		return false;
	}
}

function checkenquiry(){
	var ftxt = '';

	if (document.enquiry.Name.value==''){
		ftxt += '\n- Please enter your Name.';
	}
	
	if (document.enquiry.Company.value==''){
		ftxt += '\n- Please enter your Company.';
	}
	
	if (document.enquiry.Telephone.value==''){
		ftxt += '\n- Please enter your Telephone Number.';
	}
	
	if (isValidEmail(document.enquiry.email.value)==false){
		ftxt += '\n- Please enter your Email Address.';
	}
	
	if (document.enquiry.subject.value==''){
		ftxt += '\n- Please select an enquiry Subject.';
	}
	
	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 checkcallform(){
	var ftxt = '';
	
	if (document.callform.Name.value==''){
		ftxt += '\n- Please enter your Name.';
	}
	
	if (document.callform.Company.value==''){
		ftxt += '\n- Please enter your Company Name.';
	}
	
	if (document.callform.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;
	}
}

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='';
	}
}

function mainmenu(){
	$(" #navlist ul ").css({display: "none"}); // Opera Fix
	$(" #navlist li").hover(function(){
			$(this).find('ul:first').css({visibility: "visible",display: "none"}).slideDown(100);
			},function(){
			$(this).find('ul:first').css({visibility: "hidden"});
			});
	}

 $(document).ready(function(){					
	mainmenu()
});

/* Register Form */
function checkregisterform(){
    var ftxt = '';
    
    if (document.registerform.Name.value==''){
        ftxt += '\n- Please enter your Name.';
    }
    
    if (document.registerform.Company.value==''){
        ftxt += '\n- Please enter your Company Name.';
    }
    
    if (document.registerform.Address.value==''){
        ftxt += '\n- Please enter your Address.';
    }
    
    if (document.registerform.Postcode.value==''){
        ftxt += '\n- Please enter your Postcode.';
    }
    
    if (isValidEmail(document.registerform.Email.value)==false){
        ftxt += '\n- Please enter your Email Address.';
    }
    
    if (document.registerform.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;
	}
}

/* Download Login */
function checkdownloadlogin(){
    var ftxt = '';
    
    if (document.downloadlogin.Username.value==''){
        ftxt += '\n- Please enter your Username.';
    }
    
    if (document.downloadlogin.Password.value==''){
        ftxt += '\n- Please enter your Password.';
    }
    
    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;
	}
}

/* Forgotten Form */
function checkforgottenform(){
    if (isValidEmail(document.forgottenform.Email.value)==false){
        alert('Please enter your Email Address.');
        return false;
    }
    else {
        return true;
    }
}
