


function checkInput(submitVal)
{
    var theForm = document.registerForm;
    //alert(" in checkInput");
    var newPassword1 = theForm.elements['member[password]'];
    var newPassword2 = theForm.elements['member[password2]'];
  
    checkCountry();
   
    if ((newPassword1.value.length < 5) || (newPassword2.value.length < 5))
    {
        alert("Password should have at least 5 (five) characters");
        return (false);
    }
 
    if (newPassword1.value != newPassword2.value)
    {
        alert("Your passwords don't match; please try again.");
        return (false);
    }

    if(!validateAge())
    {
       alert("Sorry, you must be at least 18 years of age to register for the Lightspeed Consumer Panel.");
       return false;
    }

    doSubmit(submitVal);
    return (true);
}

function validateAge()
{
  //change element names
  // return true til update
  return true;

  var formElms = document.registerForm.elements;
  var monthList = formElms['member[birthmonth]'];
  var dayList = formElms['member[birthday]'];
  var yearList = formElms['member[birthyear]'];

  var monthDOB = monthList.options[monthList.selectedIndex].value;
  var dayDOB = dayList.options[dayList.selectedIndex].value;
  var yearDOB = yearList.options[yearList.selectedIndex].value;

  if(monthDOB=='0' || dayDOB=='0' || yearDOB=='0') return true;
  
  var Today = new Date();
  var monthToday = Today.getMonth()+1;
  var dayToday = Today.getDate();
  var yearToday = Today.getYear();

  if(yearToday < 1900) yearToday += 1900;

  var month18 = parseInt(monthDOB);
  var day18 = parseInt(dayDOB);
  var year18 = parseInt(yearDOB) + 18;

  if(yearToday > year18) return true;
  if(yearToday == year18) {
	if(monthToday > month18) return true;
	if(monthToday == month18) {
	  if(dayToday >= day18) return true;
	}
  }

  alert("Sorry, you must be at least 18 years of age to register for the Lightspeed Consumer Panel.");
  return false;
}

function checkCountry()
{
  //change element names
  // return true til update
  return true;

  var formElms = document.registerForm.elements;
  var stateList = formElms['member[state]'];
  var countryList = formElms['member[countrycode]'];

  var newState = stateList.options[stateList.selectedIndex].value;
  if(newState >= 2 && newState <= 52) { countryList.options[1].selected = true; }
  else if(newState >= 54 && newState <= 67) { countryList.options[2].selected = true; }
}




function doSubmit(a)
{
     document.registerForm.fs.value='A';  
     //alert(' doSubmit() - fs value: '+document.coRegForm.fs.value);
     //var inputCheckStatus = checkInput();
     //alert("check input status: "+inputCheckStatus);
     //if(inputCheckStatus ==false)
     //  return false;
        document.registerForm.submit();
}

function popup (url) {
  window.open(url, 'new', 'scrollbars=yes, width=420, height=375');
}



function jsAlert()
{
  alert("To join, you must click I Agree to acknowledge that you have read and accept the Terms and Conditions and the Privacy Policy.  If you don't, your membership application will not be processed, and the information you have entered will not be retained.");
}

