function Cls( e ) {
   document.getElementById( e ).innerHTML = ""
   document.getElementById('confirm').style.visibility='hidden'
}

function remind_chkfields() {
   var fields = new Array( 'email', 'pwd', 'cnf' )
   var i
   var error = 0
   var id = ""
   var element
   var msg = ""
   var email = document.getElementById( 'email' ).value
   var pwd = document.getElementById( 'pwd' ).value
   var cnf = document.getElementById( 'cnf' ).value

   for (i = 0; i < 3; i++) {
      element = document.getElementById( fields[i] )
      id = fields[i] + "stat"

      switch(i) {
         case 1:   // pwd
                 if (element.value.length < 6) {
                    document.getElementById( id ).innerHTML = "<font color='red'><b>&lt;--- Uh oh!</bd></font>"
                    error++
                 }
                 break
         case 2:   // cnf
                 if ( (pwd != cnf) || (element.value.length < 6) ) {
                    document.getElementById( id ).innerHTML = "<font color='red'><b>&lt;--- Uh oh!</bd></font>"
                    error++
                 }
                 break
         default:  // email
                 if (element.value.length < 7) {
                    document.getElementById( id ).innerHTML = "<font color='red'><b>&lt;--- Uh oh!</bd></font>"
                    error++
                 }
                 break
      }
   }

   // make sure they fill fields in first.  then check for dupe email
   if (! error ) {
   //   alert('no errors.  seeing if we know email')

      var action = "/cgi-bin/chkemail.cgi"
      doquery(method,action,email)
   // we need to check email and cell fields now   returns id if matched
   //   alert("GOT: (" + data + ")")

      if ( data != "OK") {
         alert('I think we know you from somewhere. (' + data + ')')
    //     alert('I think we know you from somewhere.')
         error = 1
      }
   }

   if (! error) {
      var q = document.getElementById( 'email' ).value + '~' + document.getElementById( 'pwd' ).value 
    //  alert('still no errors.  sending email and pwd: ' + q)
      var newaction = "/cgi-bin/newuser.cgi"
      doquery(method,newaction,q)
      if (data == "OK") {
         document.getElementById('confirm').innerHTML = "You should receive an email momentarily.  Respond to that message, and you\'ll be reminding in no time flat."
       
         document.getElementById('confirm').style.visibility='visible'
      }
      else {
         alert("Uh oh: data = " + data)
      }
   }
   else {
      if (error == 1) {
         msg = "that error"
      }
      else {
         msg = "those " + error + " errors"
      }
      document.getElementById('confirm').innerHTML = "Please go back and correct " + msg + ".  We\'re not off to a good start.  Thank you."
      document.getElementById('confirm').style.visibility='visible'
   }
}

function remind_chkbuddy() {
   var i
   var error = 0
   var id = ""
   var element
   var msg = ""
   var email = document.getElementById( 'email' ).value

   if ( (email.length < 7) || (email.charAt('@') < 0) ) {
      document.getElementById( 'emailstat' ).innerHTML = "<font color='red'><b>&lt;--- Uh oh!</bd></font>"
      error++
   }

   if (! error ) {
     alert('no errors.  seeing if we know email')

      var action = "/cgi-bin/chkemail.cgi"
      doquery(method,action,email)
   // we need to check email and cell fields now   returns id if matched
   //   alert("GOT: (" + data + ")")

      if ( data == "OK") {  // <-  BUDDY IS UNKNOWN !
         alert('You buddy needs to join The Reminders first.')
         error = 1
      }
   }

   if (! error) {
      var q = document.getElementById( 'email' ).value + '~' + document.getElementById( 'pwd' ).value 
    //  alert('still no errors.  sending email and pwd: ' + q)
      var newaction = "/cgi-bin/newbuddy.cgi"
      doquery(method,newaction,q)
      if (data == "OK") {
         document.getElementById('confirm').innerHTML = ""
       
         document.getElementById('confirm').style.visibility='visible'
      }
      else {
         alert("Uh oh: data = " + data)
      }
   }
   else {
      if (error == 1) {
         msg = "that error"
      }
      else {
         msg = "those " + error + " errors"
      }
      document.getElementById('confirm').innerHTML = "Please go back and correct " + msg + ".  We\'re not off to a good start.  Thank you."
      document.getElementById('confirm').style.visibility='visible'
   }
}

