function checkpoint(s) {
  alert("This is rars js function checkpoint");
  return false;
  }

/************************************************************************
  Javascript RARSFest Ticket Database Functions
  by K4HM - Hank Montgomery       k4hm@arrl.net
************************************************************************/


  

/   <!-- Original:  Eric King (eric_andrew_king@hotmail.com) -->       /
/    <!-- Web Site:  http:\\redrival.com\eak -->                       /
/    <!-- This script and many more are available free online at -->   /
/    <!-- The JavaScript Source!! http:\\javascript.internet.com -->   /

      function NewWindow(mypage, myname, w, h, scroll) {
        var winl = (screen.width - w) / 2;
        var wint = (screen.height - h) / 2;
        winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
        win = window.open(mypage, myname, winprops)
        if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
      }


function xnewwindow() 
{ 
window.open('help.html','jav','width=300,height=200,resizable=yes'); 
} 



/**************************************************************
** Javascripts for Member Profile functions                  **
** vallogin()  Verifies user provided userid and password    **
**************************************************************/
function vallogin(s)
  {
    /* alert("Checking for blank Passwword or UseerID"); */
    var txtPass = s.tryPassword.value;
    var txtUser = s.tryUserid.value;
    if (txtPass == '' || txtUser == '') {
      alert("A blank Userid or Password is not allowed.");
      s.screen.value = "";
      s.tryUserid.focus();
      return false;
    } else {
      return true;
    }
  }


/********************************************************
** valGetPwd()  Verifies user gave userid to get password                                                 
********************************************************/
    function valGetPwd(s)
    {
//      alert('This is function valGetPwd in library js/rars.js');
      var txtUser = s.tryUserid.value;
      if (txtUser.length == 0)
        {
        alert("Please enter your Userid");
        s.tryUserid.focus();
        return false;
        }
      s.screen.value = "GetPwd";
      return true;
    }   
  
/**********************************************************
** valSearch()  Verifies user provided some search criteria
**********************************************************/
function valSearch(s) {
  var txtCall = s.txtCallsign.value;
  if (txtCall.length == 0) {
    var txtName = s.txtName.value;
    if (txtName.length == 0) {
      alert("You must enter something in the callsign or name field.");
      s.txt.CallSign.focus();
      return false;
      }
    }
  return true;
  }
    


/**********************************************************
** valForm()  Verifies user filled all required fields 
**********************************************************/
function valForm(s)
  {
//    var txtCall = s.txtCallSign.value;
//    if (txtCall.length == 0) {
//      alert("Please enter a CallSign");
//      s.txtCallSign.focus();
//      return false;
//    }

//        s.txtCall.value = txtCallSign.toUpperCase(); //  Convert Callsign to upper case

    var txt_Name = s.txtName.value;
    if (txt_Name.length == 0) {
      alert("Please enter a name");
      s.txtName.focus();
      return false;
    }

    var txtAddr1 = s.txtAddr1.value;
    if (txtAddr1.length == 0) {
      alert("Please enter an address");
      s.txtAddr1.focus();
      return false;
    }
    var txtCity = s.txtCity.value;
    if (txtCity.length == 0) {
      alert("Please enter a city");
      s.txtCity.focus();
      return false;
    }
    var txtState = s.txtState.value;
    if (txtState.length != 2) {
      alert("Please enter a valid 2-character state code");
      s.txtState.focus();
      return false;
    }
    s.txtState.value = txtState.toUpperCase(); //  Convert State to upper case

    var txtZip = s.txtZip.value;
    if (txtZip.length != 5 && txtZip.length != 10) {
      alert("Please enter a 5-digit or 10-digit zip code");
      s.txtZip.focus();
      return false;
    }
    return true;
  }


/**********************************************************
** valForm()  Verifies user filled all required fields
function valProfForm(s)
  {
    alert("This is the profile validation function");
    return false;
)
**********************************************************/


//
//
//    var txtCall = s.txtCallSign.value;
//    if (txtCall.length == 0) {
//      alert("Please enter a CallSign");
//      s.txtCallSign.focus();
//      return false;
//    }

//        s.txtCall.value = txtCallSign.toUpperCase(); //  Convert Callsign to upper case
function valProfForm(s)
  {
//alert("Checkpoint");

    var txt_FName = s.FName.value;
    if (txt_FName.length == 0) {
      alert("Please enter a first name");
      s.FName.focus();
      return false;
    }

    var txt_LName = s.LName.value;
    if (txt_LName.length == 0) {
      alert("Please enter a last name");
      s.LName.focus();
      return false;
    }

    var txtStreet = s.Street.value;
    if (txtStreet.length == 0) {
      alert("Please enter an address");
      s.Street.focus();
      return false;
    }
    
    var txtCity = s.City.value;
    if (txtCity.length == 0) {
      alert("Please enter a city");
      s.City.focus();
      return false;
    }

    var txtState = s.State.value;
    if (txtState.length != 2) {
      alert("Please enter a valid 2-character state code");
      s.State.focus();
      return false;
    }
    s.State.value = txtState.toUpperCase(); //  Convert State to upper case

    var txtZip = s.Zip.value;
    if (txtZip.length != 5 && txtZip.length != 10) {
      alert("Please enter zip code in format nnnnn or nnnnn-nnnn");
      s.Zip.focus();
      return false;
    }
    return true;
  }
  
  
/********************************************************
** valNewMember()  Verifies required fields on membership application
********************************************************/

function valNewMember(s) {
  //alert("This is rars.org/js/rars.js function valNewMember");
    
    var mtype = s.MemberType.value;
    if (mtype == '') {
      alert('Please select a member type');
      return false;
    }


    var NewUser = s.Userid.value;
    s.Userid.value = NewUser.toUpperCase(); //  Convert Userid to upper case
    if (NewUser.length < 4 || NewUser.length > 6) {
      alert("Please enter 4-6 character UserID.  \\nPreferrably the call sign for licensed member, \\nelse try the first 2 letters of the First Name \\nand the first 2 letters of the Last Name \\nfor a total length of 4 characters)");
      s.Userid.focus();
      return false;
    }
    
    
    var checkEmail = s.Email.value;
    if (checkEmail.length == 0) {
      alert("You must enter an email address");
      return false;
    }

    if ((checkEmail.indexOf('@') < 1) || ((checkEmail.charAt(checkEmail.length-4) != '.') && (checkEmail.charAt(checkEmail.length-3) != '.')))  {
      alert("You have entered an invalid email address. Please try again.");
      s.Email.select();
      return false;
    } 
    
    var Password = s.UserPassword.value;
    if (Password.length < 4 || Password.length > 16) {
      alert("Please enter 4-16 character Password to be assigned to this User-ID");
      s.UserPassword.focus();
      return false;
    }
    
  var str=s.Email.value;
  var msg='Invalid Email Addresss';
  //alert('checking email addr ='+ str);
  var _at="@";
  var _dot=".";
  var _spc=" ";
  var _lat=str.indexOf(_at) * 1;    
  var _lstr=str.length * 1;
  var _ldot=str.lastIndexOf(_dot) * 1;
  var _lspc=str.lastIndexOf(_spc) * 1;

  if (_lstr < 1*1) {         //check for missing or blank email address
    alert("Email Address is blank.\\nPlease Enter an Email Address");
    s.Email.focus();
    return false;
  }
  
  if (_lspc > 0) {
    alert("Spaces are not allowed in email addresses");
    s.Email.focus();
    return false;
    }
//alert ('Last @ is at location ' + _lat);
  if (_lat < 1) {
    alert(msg + '- must have mailbox name followed by @ symbol and server name.\\nExample: yourname@yourserver.net');
    s.Email.focus();
    return false;
  }
//alert ('Passed the AT test');
//alert ('Last dot is at location ' + _ldot);

  if (_ldot < _lat+2){
    alert(msg + '\\nA server name is required after the @ symbol.\\nExample: yourname@yourserver.net');
    return false;
  }
//alert ('Passed the dot after at test');
//alert ('Length of string is  ' + _lstr);
  if (_ldot+2 > _lstr){
    alert(msg + '\\n Mail server name can not end with a dot.');
    return false;
  }
//alert ('Passed the ending dot test');
  
  if (_ldot == _lstr){
    alert(msg);
    return false;
  }

  s.mode.value = "insert";
  return true;
}
