<!--
//
// Javascript input handling 
//
// Depends on browser values set in browser.js
//

// Get select value
function selectValue(aSelect){
  var key = aSelect.options[aSelect.selectedIndex].value;
  return key;
}

// Set select value
function setSelectValue(aSelect, aValue){
	var options = aSelect.options;
	for (i = 0; i < options.length; i++) {
		if (options[i].value.indexOf(aValue) == 0) {
			options[i].selected = true;
		} else {
			options[i].selected = false;
		}
	}
	return true;
}

// Radiobutton is checked
function isChecked(aRadio){
  var flag = false;
  for (var i = 0; i < aRadio.length; i++){
    if (aRadio[i].checked){
      flag = true;
    }
  }
  return(flag)
}

// Radio button value
function radioValue(aRadio){
  for (var i = 0; i < aRadio.length; i++){
    if (aRadio[i].checked){
      return(aRadio[i].value);
    }
  }
}

// See if this looks like a valid email address
function invalidEmail(aEmail) {
  // Can't be empty
  if (aEmail == "") {
    return true;
  }
  // Can't contain spaces 
  var pos = aEmail.indexOf(" ") + 1;
  if (pos > 0) {
    return true;
  }
  // Check position of @
  pos = aEmail.indexOf("@") + 1;
  if ((pos < 2) ||
      (pos > (aEmail.length - 3))) {
    return true; 
  }
  // Check position of . after @
  var tempEmail = new String(aEmail.substring(pos, aEmail.length));
  pos = tempEmail.indexOf('.') + 1;
  if ((pos < 2) ||
      (pos > (tempEmail.length - 1))) {
    return true; 
  }
  // Looks like a valid email address
  return false;
}

//-->
