function checkEmail(value) {
  var f = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  if (value == null || value == '') {return false};
  if (!f.test(value)) {return false;}
  return true;
}
function checkUserName(value) {
  if (value.length < 5) return false;
  return true;
}  	
function checkPassword(value) {
  if (value.length < 6) return false;
  return true;
}
	
function updateErrDiv(id, er) {
  var err=document.getElementById(id);
  err.innerHTML='';
  var di=document.createElement('DIV');
  di.id='errorExplanation';
  var h2=document.createElement('H2');
  h2.appendChild(document.createTextNode('Problems with input'));
  di.appendChild(h2);
  var ul=document.createElement('UL');
  for (var i=0; i< er.length; i++) {
	var li=document.createElement('LI');
	li.appendChild(document.createTextNode(er[i]));
	ul.appendChild(li);
  }
  di.appendChild(ul);
  di.appendChild(document.createElement('BR'));
  di.appendChild(document.createTextNode('Please correct errors and re-submit'));
  err.appendChild(di);
}

/*  Change between US State and Province input elements
 *  when country is select.
 *  id => value selected
 *  usid => value for US
 *  selem => state element id (optional)
 *  pelem => province element id (optional)
 */
function onCountrySelect(id, usid, selem, pelem) {
	if (!selem) {
		selem = 'states'
	}
	if (!pelem) {
		pelem = 'provinces'
	}
	if (id == usid) {
	  document.getElementById(selem).style.display = "inline";
	  document.getElementById(pelem).style.display = "none";
	} else {
	  document.getElementById(selem).style.display = "none";
	  document.getElementById(pelem).style.display = "inline";
	}
}