function checkForm() {
  thisForm = document.form_signup;	// this sets thisForm to the form object
  theseFields = new Array('email','email','username','password','password','fname','lname','postal_code','country','birth_month','birth_day','birth_year','gender','newsletter','tos_agree');	// theseFields is an array of numeric or name values corresponding to the field names or numbers which need to validated
  theseFieldNames = new Array('Email','Emails','Username','Password','Passwords','First name','Last name','ZIP/Postal Code','Country','Birth Month','Day of the Month','Birth Year','Gender','Newsletter','Agreement');	// theseFieldNames is an array of *user defined* strings correlating to theseFields
  theseTypes = new Array('length','matchemail2','length','length','matchpassword2','length','length','length','selectbox','selectbox','length','length','selectbox','checkboxmin1','checkboxmin1');	// thisType is an array of strings with values of [email,length,numeric]
  theseMessages = new Array('  - Please enter your email address.','  - The email addresses you entered don\'t match.','  - Please enter your desired username.','  - Please enter a password.','  - Your passwords do not match.','  - Please enter your first name.','  - Please enter your last name.','  - Please enter your postal code.','  - Please select your country.','  - Please select the month in which you were born.','  - Please enter which day of the month on which you were born.','  - Please enter the year in which you were born.','  - Please select your gender.','  - Would you like to receieve the GameBattles newsletter?','  - You must agree to our Terms of Service to register.'); // theseMessages is an array of *user defined* strings correlating to theseFields
  numOfFields = theseFields.length;
  maxElementsToDisplay = 10;	// set max items to display when validation fails

  // proceed with validation
  fieldsToCorrect = new Array();	// blank array to hold fields which do not pass validation
  for( i1 = 0; i1 < numOfFields; i1++ ){	// loop through numOfFields
    // generate value for this field
    thisType = theseTypes[i1];
    // generate value for this field
    if( !isNaN(theseFields[i1]) ){	// check if field is specified by number or name
      if( theseTypes[i1].search('selectbox') != -1 ){
        thisValue = thisForm.elements[theseFields[i1]].options[thisForm.elements[theseFields[i1]].selectedIndex].value;
        }else
          if( theseTypes[i1].search('checkbox') != -1 ){
            thisValue = thisForm.thisField;
            }else{
              thisValue = thisForm.elements[theseFields[i1]].value;
              }
            }else{	// field was specified by name
              thisField = theseFields[i1];
              if( theseTypes[i1].search('selectbox') != -1 ){
                thisValue = thisForm.elements[theseFields[i1]].options[thisForm.elements[theseFields[i1]].selectedIndex].value;
                }else
                  if( theseTypes[i1].search('checkbox') != -1 ){
                    thisValue = thisForm[thisField];
                    }else{
                      thisValue = thisForm[thisField].value;
                      }
                    }
            // perform check based on validation type
            if( theseTypes[i1] == 'length' ){	// check if theseTypes[i1] is length
              if( thisValue.length == 0 ){
                fieldsToCorrect[fieldsToCorrect.length] = i1;
                }
              continue;
              }
            if( theseTypes[i1].search('match') != -1 ){	// check if theseTypes[i1] is match
              matchValue = thisForm.elements[theseTypes[i1].substring(5,theseTypes[i1].length)].value;
              if( thisValue != matchValue ){
                fieldsToCorrect[fieldsToCorrect.length] = i1;
                }
              continue;
              }
            if( theseTypes[i1].search('selectbox') != -1 ){	// check to see if type is a select box
              userValue = theseTypes[i1].substring(9,theseTypes[i1].length);
              if( userValue == thisValue ){
                fieldsToCorrect[fieldsToCorrect.length] = i1;
                }
              continue;
              }
            if( theseTypes[i1].search('checkboxmin') != -1 ){	// check to see if type is checkbox minimum
              minNumberOfBoxes = theseTypes[i1].substring(11,theseTypes[i1].length);
              checkboxcount = 0;
              if(thisValue.length != undefined){
                for( icheckbox = 0; icheckbox < thisValue.length; icheckbox++ ){
                  if( thisValue[icheckbox].checked ){
                    checkboxcount++;
                    }
                  }
                }
              else {
                if( thisValue.checked ){
                  checkboxcount++;
                  }
                }
              if( checkboxcount < minNumberOfBoxes ){
                fieldsToCorrect[fieldsToCorrect.length] = i1;
                }
              continue;
              }
            if( i1 >= maxElementsToDisplay - 1 ){
              break;
              }
            }
  messageString = 'Please correct the following information.\n\n';	// set blank message string
  setFocusOn = 'x';	// set to non numeric so it fails isNaN()
  // revised because field names (non numeric) can be passed
  for( i2 = 0; i2 < fieldsToCorrect.length; i2++ ){	// loop though fields which did not pass validation [fieldsToCorrect]
    messageString += theseFieldNames[fieldsToCorrect[i2]] + '\n' + theseMessages[fieldsToCorrect[i2]] + '\n';
    if( i2 == 0 ){	// set focus
      setFocusOn = theseFields[fieldsToCorrect[i2]];
      }
    }
  if( fieldsToCorrect.length > 0 ){	// check to see if all fields passed validation
    alert(messageString);
    // check to see if field name or number needs focus
    if( !isNaN(setFocusOn) && thisForm.elements[setFocusOn]["focus"] ){	// set focus to field number
      thisForm.elements[setFocusOn].focus();
      }else
        if( thisForm[setFocusOn]["focus"] ){	// set focus to field name
          thisForm[setFocusOn].focus();
          }
        return false;
        }else{
          return true;
          }
}

var WIN_SCROLLBARS = 1;
var WIN_RESIZABLE  = 2;
var WIN_MENUBAR    = 4;
var WIN_TOOLBAR	   = 8;
var WIN_STATUS     = 16;
var WIN_CENTER     = 32;
var WIN_LOCATION   = 64;

function gbPop(url, width, height, options) {
  if (url.length <= 0 || width <= 0 || height <= 0) {
    return null;
  }

  var s_options = 'width=' + width + ',height=' + height;

  s_options += options & WIN_CENTER ? ',left=' + ((screen.width - width) / 2) + ',top=' + ((screen.height - height) / 2) : '';
  s_options += options & WIN_SCROLLBARS ? ',scrollbars=1': '';
  s_options += options & WIN_RESIZABLE ? ',resizable=1' : '';
  s_options += options & WIN_MENUBAR ? ',menubar=1' : '';
  s_options += options & WIN_TOOLBAR ? ',toolbar=1' : '';
  s_options += options & WIN_STATUS ? ',status=1' : '';
  s_options += options & WIN_LOCATION ? ',location=1' : '';

  return window.open(url, '_name', s_options);
}

