<!--
//
// Javascript input handling 
//
// Depends on browser values set in browser.js
//

// Get select value
function selectValue(aSelect){
  if (isIE) {
    var key = aSelect.value;
  } else {
    var key = aSelect[aSelect.selectedIndex].value;
  }
  return key;
}

// Get select text
function selectText(aSelect) {
	var text = aSelect.options[aSelect.selectedIndex].text;
	return text;
}

// 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(i);
    }
  }
}

// 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;
}

//-->
