// JavaScript Document
function validEmail(email)
{
   invalidChars = " /:,;"

   if (email == "")
      return false

   for (i=0; i<invalidChars.length; i++)
   {
      badChar = invalidChars.charAt(i)

      if (email.indexOf(badChar,0)>-1)
         return false
   }

   atPos = email.indexOf("@",1)

   if (atPos == -1)
      return false

   if (email.indexOf("@",atPos+1) != -1)
      return false

   periodPos = email.indexOf(".",atPos)

   if (periodPos == -1)
      return false

   if (periodPos+3 > email.length)
      return false

   return true
}

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        //if (((c < "0") || (c > "9"))) return false;
        if ((c < "0") || (c > "9") || (c != "+")) return false;
    }
    // All characters are numbers.
    return true;
}

function submitIt (joinForm)
{
   titleChoice = joinForm.title.selectedIndex
   if (joinForm.title.options[titleChoice].value == "")
   {
      alert ("You must select a title.")
	  return false
   }

   if (joinForm.fName.value == "")
   {
      alert("Please enter your first name.")
	  return false
   }

   if (joinForm.sName.value == "")
   {
      alert("Please enter your surname.")
	  return false
   }

   if (joinForm.company.value == "")
   {
      alert("Please enter a company.")
	  return false
   }

   //if (joinForm.intCode.value == "" || isInteger(joinForm.intCode.value) == false)
   //if (joinForm.intCode.value == "" )
   //{
   //   alert("Please enter a valid international access code of telephone.")
   //   joinForm.intCode.value=""
   //   joinForm.intCode.focus()
   //   return false
   //}

   //if (joinForm.areaCode.value == "" || isInteger(joinForm.areaCode.value) == false)
   if (joinForm.areaCode.value == "")
   {
      alert("Please enter a valid area code of telephone.")
      joinForm.areaCode.value=""
      joinForm.areaCode.focus()
      return false
   }
	  
   //if (joinForm.phone.value == "" || isInteger(joinForm.phone.value) == false)
   if (joinForm.phone.value == "")
   {
      alert("Please enter a valid phone number.")
      joinForm.phone.value=""
      joinForm.phone.focus()
      return false
   }

/*
   if (joinForm.intCode2.value == "")
   {
      alert("Please enter a valid international access code of fax.")
      joinForm.intCode2.value=""
      joinForm.intCode2.focus()
      return false
   }

   if (joinForm.areaCode2.value != "")
   {
      if (isInteger(joinForm.areaCode2.value) == false)
      {
         alert("Please enter a valid area code of fax.")
	     joinForm.areaCode2.value=""
	     joinForm.areaCode2.focus()
         return false
      }
   }
	  
   if (joinForm.fax.value != "")
   {
      if (isInteger(joinForm.fax.value) == false)
      {
         alert("Please enter a valid fax number.")
	     joinForm.fax.value=""
         joinForm.fax.focus()
         return false
      }
   }
*/

   if (!validEmail(joinForm.email.value))
   {
      alert("Invalid format. Please enter your email address again.")
      return false
   }

   return true
}

