function onSubmitForm() {
  if(document.pressed == 'preview')
  {
   document.myform.action ="preview.php";
  }
  else
  if(document.pressed == 'send')
  {
    document.myform.action ="send.php";
  }
  else
   if(document.pressed == 'reset')
  {
    document.myform.reset();
  }
  return true;
}

function emailvalidation(entered, alertbox)
{
// E-mail Validation by Henrik Petersen / NetKontoret
// Explained at www.echoecho.com/jsforms.htm
// Please do not remove this line and the two lines above.
with (entered)
{
apos=value.indexOf("@");
dotpos=value.lastIndexOf(".");
lastpos=value.length-1;
if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2)
{if (alertbox) {alert(alertbox);} return false;}
else {return true;}
}
} 

function emptyvalidation(entered, alertbox)
{
// Emptyfield Validation by Henrik Petersen / NetKontoret
// Explained at www.echoecho.com/jsforms.htm
// Please do not remove this line and the two lines above.
with (entered)
{
if (value==null || value=="")
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
} 

function formvalidation(thisform)
{
with (thisform)
{
f1 = 0;
f2=0;
f3=0;
f4=0;
if (emptyvalidation(to_name,"The recipient name is empty")==false) {to_name.focus(); f1 = 1;};
if (emailvalidation(to_email,"The recipient E-mail address is illegal")==false) {to_email.focus(); f2 = 1;};
if (emptyvalidation(from_name,"The sender's name is empty")==false) {from_name.focus(); f = 1;};
if (emailvalidation(from_email,"The sender's E-mail address is illegal")==false) {from_email.focus(); f3 = 1;};
if (emptyvalidation(message,"The message field is empty")==false) {f4=1;message.focus();};
//if (f1 == 0 && f2==0 && f3==0 && f4==0) document.pressed = thisform.value;
}
if (f1 == 0 && f2==0 && f3==0 && f4==0) document.pressed = thisform.value;
} 

