// JScript source code
function isValidEmail(str) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(str)){
		return true;
	}
	else {
		return false;
	}
}

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 checkcontactform(){
    var ftxt = '';
    
    if (document.contactform.Name.value==''||document.contactform.Name.value=='Name'){
        ftxt += '\n- Please enter your Name.';
    }
    
    if (document.contactform.Company.value==''||document.contactform.Company.value=='Company'){
        ftxt += '\n- Please enter your Company Name.';
    }
    
    if (document.contactform.TelNo.value==''||document.contactform.TelNo.value=='Tel No.'){
        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==''||document.contactform.Enquiry.value=='Enquiry'){
        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 clearText(field){
    if (field.defaultValue == field.value) field.value = '';
    else if (field.value == '') field.value = field.defaultValue;
}

function mainmenu(){
	$(" #nav_list ul ").css({display: "none"}); // Opera Fix
	$(" #nav_list 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()
});

function checknewsletterregister(){
	var ftxt = '';
	
	if (document.newsletterregister.Name.value==''||document.newsletterregister.Name.value=='Name'){
		ftxt += '\n- Please enter your Name.';
	}
	
	if (document.newsletterregister.Company.value==''||document.newsletterregister.Company.value=='Company'){
		ftxt += '\n- Please enter your Company Name.';
	}
	
	if (document.newsletterregister.TelephoneNumber.value==''||document.newsletterregister.TelephoneNumber.value=='Telephone Number'){
		ftxt += '\n- Please enter your Telephone Number.';
	}
	
	if (isValidEmail(document.newsletterregister.EmailAddress.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;
	}
}
