// JScript source code
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 your Name.';
	}

	if (document.contactform.Telephone.value == '') {
		ftxt += '\n- Please enter your Telephone Number.';
	}

	if (isValidEmail(document.contactform.email.value) == false) {
		ftxt += '\n- Please enter your Email Address.';
    }

    if (document.contactform.Enquiry.value == '') {
        ftxt += '\n- Please enter your Enquiry.';
    }

	if (document.contactform.Message.value == '') {
		ftxt += '\n- Please enter your Message.';
	}
	
	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 clearemailfield(fieldVal){
	if (isValidEmail(fieldVal)==false){
		document.newsletterform.email.value='';
	}
}

function clearText(field){
    if (field.defaultValue == field.value) field.value = '';
    else if (field.value == '') field.value = field.defaultValue;
}

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()
});

/* Top Login Form */
function checktoplogin() {
    var ftxt = '';

    if (document.toplogin.Username.value == '') {
        ftxt += '\n- Please enter a Username.';
    }

    if (document.toplogin.Password.value == '') {
        ftxt += '\n- Please enter a 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;
    }
}

/* Main Login Form */
function checkmainlogin() {
    var ftxt = '';

    if (document.mainmemberlogin.Username.value == '') {
        ftxt += '\n- Please enter a Username.';
    }

    if (document.mainmemberlogin.Password.value == '') {
        ftxt += '\n- Please enter a 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.EmailAddress.value) == false) {
        alert('Pleae enter your Email Address.');
        return false;
    }
    else {
        return true;
    }
}
