
function WebForm(type) {
 if (type == 'webmail') {
  if (!CheckWebFormDetails() )
   {	
    document.form1.submit();
    return true;
   }
  else {
    return false;
   }
 }
}


function CheckWebFormDetails() {

if (!document.form1.name.value.length)
{
document.form1.name.focus()
alert('You have not filled out all of the necessary details.\n\n' +
'Please enter your name.');
return true;
}

if (!document.form1.town.value.length)
{
document.form1.town.focus()
alert('You have not filled out all of the necessary details.\n\n' +
'Please enter the Town where you live.');
return true;
}

if (document.form1.email.value.length)
{
if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.form1.email.value)))
{
document.form1.email.focus()
alert('The format of your email address appears to be incorrect.\n\n' +
      'Could you please carefully check to make sure that you have\n' +
      'entered the email address in the \'Email Address\' field correctly.')
return true;
}
}

if (!document.form1.subject.value.length)
{
document.form1.subject.focus()
alert('You have not filled out all of the necessary details.\n\n' +
'Please enter your subject.');
return true;
}

if (!document.form1.message.value.length)
{
document.form1.message.focus()
alert('You have not filled out all of the necessary details.\n\n' +
'Please enter your message.');
return true;
}

else 
{
return false;
}

}