function form_validate(contract)
{
   var company, email, contact, phone;
   company = document.Contract.EXHIBITOR_COMPANY.value;
   email = document.Contract.EXHIBITOR_CONTACT_EMAIL.value;
   contact = document.Contract.EXHIBITOR_PRIMARY_CONTACT.value;
   phone = document.Contract.EXHIBITOR_CONTACT_PHONE.value;
   isOK = true;

      if (company == "")
         {
           alert("Please enter your company name.");
            contract.EXHIBITOR_COMPANY.focus();
           return false;
          }
 
      if (contact == "")
          {
           alert("Please enter the name of the contact person.");
           contract.EXHIBITOR_PRIMARY_CONTACT.focus();
           return false;
          }

       if (phone == "")
          {
           alert("Please enter the phone number of the contact person.");
           contract.EXHIBITOR_CONTACT_PHONE.focus();
           return false;
           }
     if (email == "")
          {
             alert("Please enter the email address of the contact person.");
             contract.EXHIBITOR_CONTACT_EMAIL.focus();
             return false;
           }

// JavaScript code to check email form

   //  Will check for @, period after @ and text in between
    var addr = contract.EXHIBITOR_CONTACT_EMAIL.value;
     if (addr == "" || addr==null)
            {  alert ("Please enter the exhibitor contact email address");
                contract.EXHIBITOR_CONTACT_EMAIL.focus();
                return false;  }

    var in_space = addr.indexOf(" ");
    if (in_space != -1)
      { alert ("Email address should contain no spaces and be of the form jdoe\@aol.com");
         contract.EXHIBITOR_CONTACT_EMAIL.focus();
          return false;  }

    var len = addr.length;
    var alpha = addr.indexOf("@");
    var last_alpha = addr.lastIndexOf("@");
    if (alpha != last_alpha)
       {  alert ("Bad email address. Should contain only one @ and be of the form jdoe\@aol.com");
           contract.EXHIBITOR_CONTACT_EMAIL.focus();
           return false; }

    // No @, in first position, or name too short
    if (alpha == -1 || alpha == 0 || len<6 )
       {  alert ("Bad email address. Should contain an @ and be of the form jdoe\@aol.com");
           contract.EXHIBITOR_CONTACT_EMAIL.focus();
           return false; }

     var last_p = addr.lastIndexOf(".");
          // Be sure period at least two spaces after @, but not last char.
     if (last_p - alpha < 2 || last_p == (len - 1) )
        {  alert ("Bad email address. Should contain a period after the @ and be of the form jdoe\@aol.com");
           contract.EXHIBITOR_CONTACT_EMAIL.focus();
            return false; }

    return true;
 }


function calculate_investment()
{
   var cost1, cost2, cost3, cost4, qty1, qty2, qty3, qty4, investment;
   qty1 = document.Contract.EXHIBITOR_QTY1.value;
   qty2 = document.Contract.EXHIBITOR_QTY2.value;
   qty3 = document.Contract.EXHIBITOR_QTY3.value;
   qty4 = document.Contract.EXHIBITOR_QTY4.value;

   if ((qty1 == "NaN") || (qty1 < 0) || ((qty1%1) != 0) )
   {
      window.status = "Please enter positive integers in the Quantity fields";
      document.Contract.EXHIBITOR_QTY1.value = "";
      qty1 = 0;
   }
   if ((qty2 == "NaN") || (qty2 < 0) || ((qty2%1) != 0))
   {
      window.status = "Please enter positive integers in the Quantity fields";
      document.Contract.EXHIBITOR_QTY2.value = "";
      qty2 = 0;
   }
   if ((qty3 == "NaN") || (qty3 < 0) || ((qty3%1) != 0))
   {
      window.status = "Please enter positive integers in the Quantity fields";
      document.Contract.EXHIBITOR_QTY3.value = "";
      qty3 = 0;
   }
   if ((qty4 == "NaN") || (qty4 < 0) || ((qty4%1) != 0))
   {
      window.status = "Please enter positive integers in the Quantity fields";
      document.Contract.EXHIBITOR_QTY4.value = "";
      qty4 = 0;
   }

   cost1 = qty1 * 7500;
   cost2 = qty2 * 15000;
   cost3 = qty3 * 25000;
   cost4 = qty4 * 2500;
   investment = cost1 + cost2 + cost3 + cost4;

   document.Contract.EXHIBITOR_COST1.value = cost1;
   document.Contract.EXHIBITOR_COST2.value = cost2;
   document.Contract.EXHIBITOR_COST3.value = cost3;
   document.Contract.EXHIBITOR_COST4.value = cost4;
   document.Contract.EXHIBITOR_TOTAL.value = investment;
}
