leaving=true;
function checkStep1(){
  var why = "";

  why += checkFirst(document.getElementById('fname').value);
  why += checkEmail(document.getElementById('email').value);
  why += checkBday(document.getElementById('birth_mo').value,
                   document.getElementById('birth_day').value,
                   document.getElementById('birth_year').value);
  why += checkGender(document.getElementById('step1').gender);

  if (why != "") {
     alert("Oops! Please fix the errors listed below:\n\n" + why);
     return false;
  }

  leaving=false;
  return true;
}

function checkLogin() {
    var why = "";

    why += checkUserID(document.forms['dologin'].elements['user'].value);
    why += checkPassword(document.forms['dologin'].elements['pass'].value);

    if (why != "") {
       alert("Oops! Please fix the errors listed below:\n\n" + why);
       return false;
    }

    leaving=false;
    return true;
}

function checkFirst (strng) {
     var error = "";
     if (strng == "") { error = "You forgot to enter your First name.\n"; }
     return error;
}

function checkEmail (email) {
  var emailregex =
  /^(?:[a-z0-9!#$%&\'\*\+\-/=\?\^_`\{\|\}~])+(?:\.([a-z0-9!#$%&\'\*\+\-/=\?\^_`\{\|\}~])+)*@(?:(?:(?:[a-z0-9]{1,63})|(?:[a-z0-9](?:[a-z0-9\-]){0,61}[a-z0-9]))\.)+(?:com|net|org|edu|aero|asia|biz|cat|coop|gov|info|int|jobs|mil|mobi|museum|name|pro|tel|travel|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zr|zw)$/i;
  if (email == "" || ! emailregex.test(email)) {
    return "You did not enter a valid Email address.\n";
  }
  return "";
}

function checkBday(birth_mo, birth_day, birth_year){
    if ((birth_mo == '') || (birth_day == '') || (birth_year == '')){
        return "Please enter your Date of Birth.\n";
    }
    return '';
}

function checkGender(gender){
    var cnt = -1;
    for (var i=gender.length-1; i > -1; i--){
        if (gender[i].checked){ return '';}
    }

    return "Please select your gender.\n";
}

function resend(){
  var resendWin = window.open("sendpass.cgi", "resendWin", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=400,height=300,xscreen=0,yscreen=0,top=0,left=0");
}

function showPop(strFile){
  var newWin = window.open(strFile, "newWin", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=600,height=500,xscreen=0,yscreen=0,top=0,left=0");
}

function checkUserID (strng) {
     if (strng.length < 5) {
       return "You entered an invalid User ID or Email.\n";
     }
     return "";
}

function checkPassword (strng) {

  if ((strng.length < 4) || (strng.length > 20)) {
    return "You entered an invalid Password.\n";
  }
  return "";
}

function exitPop(strFile){

  if (leaving == 1) {
    var newWin = window.open(strFile, "newWin", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=500,height=500,xscreen=0,yscreen=0,top=0,left=0");
  }

}

function getWindowWidth() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return myWidth;
}