   function disableForm(theform) {
      if (document.all || document.getElementById) {
         for (i = 0; i < theform.length; i++) {
            var tempobj = theform.elements[i];
               if (tempobj.type.toLowerCase() == "submit" || tempobj.type.toLowerCase() == "reset")
                  tempobj.disabled = true;
         }
         return true;
      }
   //continues to submit with button enabled in old browsers
   }

   function checkAll() {

      if(!checkEmailName()) {
         return false;
      }

      if(!checkEmail()) {
         return false;
      }

      if (document.form1.reqname.value == '') {
         alert("Please enter an Alert name");
         return false;
      }

   }

   function checkAll2() {
      if (document.form2.privacy.checked==false) {
         alert("Please confirm you accept the Privacy Policy");
         return false;
      }

   }

   function checkEmailName() {

      if(document.form1.emailname.value.length == 0) {
         alert("Please enter your First name");
         document.form1.emailname.focus();
         return false;
      }
      if(document.form1.emailname2.value.length == 0) {
         alert("Please enter your Surname");
         document.form1.emailname2.focus();
         return false;
      }
      return true;

   }

   function checkEmail() {

      if(document.form1.email.value.length == 0) {
         alert("Please enter your Email");
         document.form1.email.focus();
         return false;
      } else {
         return echeck(document.form1.email.value);
      }

   }

   function echeck(str) {

      var at="@"
      var dot="."
      var lat=str.indexOf(at)
      var lstr=str.length
      var ldot=str.indexOf(dot)
      if (str.indexOf(at)==-1){
         alert("Please enter a valid email address")
         document.form1.email.focus()
         document.form1.email.select()
         return false
      }

      if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
         alert("Please enter a valid email address")
         document.form1.email.focus()
         document.form1.email.select()
         return false
      }

      if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
         alert("Please enter a valid email address")
         document.form1.email.focus()
         document.form1.email.select()
         return false
      }

      if (str.indexOf(at,(lat+1))!=-1){
         alert("Please enter a valid email address")
         document.form1.email.focus()
         document.form1.email.select()
         return false
      }

      if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
         alert("Please enter a valid email address")
         document.form1.email.focus()
         document.form1.email.select()
         return false
      }

      if (str.indexOf(dot,(lat+2))==-1){
         alert("Please enter a valid email address")
         document.form1.email.focus()
         document.form1.email.select()
         return false
      }

      if (str.indexOf(" ")!=-1){
         alert("Please enter a valid email address")
         document.form1.email.focus()
         document.form1.email.select()
         return false
      }

      return true
   }

   function ToggleSuburbs() {
     if (document.form2.state.options[document.addmem.state.selectedIndex].value==1) {
          showstateACT.style.display="block";
     } else if (document.form2.state.options[document.addmem.state.selectedIndex].value==2) {
          showstateNSW.style.display="block";
     }
   }

   function removeSpaces(text) {
      string = text.value;
      var tstring = "";
      string = '' + string;
      splitstring = string.split(" ");
      for(i = 0; i < splitstring.length; i++)
         tstring += splitstring[i];

      text.value=tstring;
   }

   function valid(which) {
   if (which.whatstate.value == -1) {
      alert('Please make sure you have selected a state');
      return false;
   }
   return(true);
   }

function testMe(form)
{
var ctr = 0;
var mctr = 10; /* this is the maximum number of options you want selected */

for (var i=0; i<form.options.length; i++)
{
if (form.options[i].selected==true)
ctr++;
}

if (ctr>mctr)
{
alert("You have selected too many options, only " + mctr + " are permitted.");
return false;
}

return true;
}


