// Application specific Javascript functions
  function checkForm(f)
  {
    //var f = getActivatedObject(e);
    //  alert ("Here in checkForm");
    //  alert ("Name=" + f.name);
    // alert ("bp=" + f.buttonPressed.value);

    /*   To test the chosen option in a Select statement:
              var opt=this.selectname.selectedIndex;
              var field=this.selectname.options[opt].text;
              (Can use value instead of text if the option statements have a value clause)

         To test the value of the selected radio button
              var radioLength = this.radioname.length;
              var radioValue = "";
              for (var i=0; i < radioLength; i++)
              {
                if (this.radioname[i].checked)
                {
                  radioValue = this.radioname[i].value;
                  break;
                }
              }
    */
    /*
    if (f.buttonPressed.value=="Cancel") {return true;}
    if (f.buttonPressed.value=="Delete")
    {
      if (confirm("Are you really sure you want to delete this record?"))
      {return true;}
      else {return false;}
    }
    */
    if (f.type)
    { // Button pressed
      if (f.name.value =="Cancel") {return true;}
    }
    if (f.type)
    {
      if (f.name.value =="Copy") {return true;}
    }
    if (f.name.value=="Delete")
    {
      if (confirm("Are you really sure you want to delete this record?"))
      {return true;}
      else {return false;}
    }


    var errMsg="";
    var confirmMessage ="";
    switch (f.name)
    {

      case "contactForm":
        if (empty (f.contactName.value))
        {
           if (errMsg=="")  {f.contactName.focus();}
           errMsg+="Please enter your Name\n";
        }

        /*
        if (empty (f.contactCompany.value))
        {
           if (errMsg=="")  {f.contactCompany.focus();}
           errMsg+="Please enter your contactCompany Name\n";
        }


        // if (empty (f.contactAddress1.value) && empty (f.contactAddress2.value) && empty (f.contactAddress3.value))
        if (empty (f.contactAddress1.value))
        {
           if (errMsg=="")  {f.contactAddress1.focus();}
           errMsg+="Please enter your Address\n";
        }

        if (empty (f.contactPostcode.value))
        {
           if (errMsg=="")  {f.contactPostcode.focus();}
           errMsg+="Please enter your contactPostcode\n";
        }
        */
        if (empty (f.contactPhone.value))
        {
           if (errMsg=="")  {f.contactPhone.focus();}
           errMsg+="Please enter your Telephone number\n";
        }
        /*
        else
        {
          if (!empty (f.contactEmail.value) && !checkEmail (f.contactEmail.value))
          {
            if (errMsg=="")  {f.contactEmail.focus();}
            errMsg+="That Email address is not valid\n";
          }
        }
        */

        if (empty (f.contactMessage.value))
        {
           if (errMsg=="")  {f.contactMessage.focus();}
           errMsg+="Please enter details of your Enquiry\n";
        }
        /*
        if (empty (f.contactSpare02.value))
        {
           if (errMsg=="")  {f.contactSpare02.focus();}
           errMsg+="Please enter your contactSpare02\n";
        }

        if (empty (f.contactSpare03.value))
        {
           if (errMsg=="")  {f.contactSpare03.focus();}
           errMsg+="Please enter your contactSpare03\n";
        }

        if (empty (f.contactSpare04.value))
        {
           if (errMsg=="")  {f.contactSpare04.focus();}
           errMsg+="Please enter your contactSpare04\n";
        }

        if (empty (f.contactSpare05.value))
        {
           if (errMsg=="")  {f.contactSpare05.focus();}
           errMsg+="Please enter your contactSpare05\n";
        }

        if (empty (f.contactSpare06.value))
        {
           if (errMsg=="")  {f.contactSpare06.focus();}
           errMsg+="Please enter your contactSpare06\n";
        }

        if (empty (f.contactSpare07.value))
        {
           if (errMsg=="")  {f.contactSpare07.focus();}
           errMsg+="Please enter your contactSpare07\n";
        }

        if (empty (f.contactSpare08.value))
        {
           if (errMsg=="")  {f.contactSpare08.focus();}
           errMsg+="Please enter your contactSpare08\n";
        }

        if (empty (f.contactSpare09.value))
        {
           if (errMsg=="")  {f.contactSpare09.focus();}
           errMsg+="Please enter your contactSpare09\n";
        }

        if (empty (f.contactSpare10.value))
        {
           if (errMsg=="")  {f.contactSpare10.focus();}
           errMsg+="Please enter your contactSpare10\n";
        }

        if (empty (f.contactSpare11.value))
        {
           if (errMsg=="")  {f.contactSpare11.focus();}
           errMsg+="Please enter your contactSpare11\n";
        }

        if (empty (f.contactSpare12.value))
        {
           if (errMsg=="")  {f.contactSpare12.focus();}
           errMsg+="Please enter your contactSpare12\n";
        }

        if (empty (f.contactSpare13.value))
        {
           if (errMsg=="")  {f.contactSpare13.focus();}
           errMsg+="Please enter your contactSpare13\n";
        }

        if (empty (f.contactSpare14.value))
        {
           if (errMsg=="")  {f.contactSpare14.focus();}
           errMsg+="Please enter your contactSpare14\n";
        }

        */
      break;

      default:
      return true;
    }

    if (errMsg!="")
    {
      alert(errMsg);
      return false;
    }
    else
    {
       if (confirmMessage!="")
       {
         if (confirm(confirmMessage)) {return true;}
         else {return false;}
       }
       else {return true;}
    }
  }