// 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.Name.value==''){
		ftxt += '\n- Please enter your Name.';
	}
	
	if (document.enquiryform.Company.value==''){
		ftxt += '\n- Please enter your Company.';
	}
	
	if (document.enquiryform.Telephone.value==''){
		ftxt += '\n- Please enter your Telephone Number.';
	}
	
	if (isValidEmail(document.enquiryform.email.value)==false){
		ftxt += '\n- Please enter your 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 checkapplyform(){
	var ftxt = '';

	if (document.applyform.Name.value==''){
		ftxt += '\n- Please enter your Name.';
	}
	
	if (document.applyform.Telephone.value==''){
		ftxt += '\n- Please enter your Telephone Number.';
	}
	
	if (isValidEmail(document.applyform.email.value)==false){
		ftxt += '\n- Please enter your 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;
	}
}

/* Mailing List Form */
function checkmailingform() {
    var ftxt = '';

    if (document.mailingform.Name.value == '') {
        ftxt += '\n- Please enter your Name.';
    }

    if (document.mailingform.Company.value == '') {
        ftxt += '\n- Please enter your Company.';
    }

    if (document.mailingform.Telephone.value == '') {
        ftxt += '\n- Please enter your Telephone Numbr.';
    }

    if (isValidEmail(document.mailingform.email.value) == false) {
        ftxt += '\n- Please enter your 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;
	}
}
