<!--
//
// Javascript input handling 
//

// Get select value
function selectValue(aSelect){
  var key = aSelect.options[aSelect.selectedIndex].value;
	return key
}

// Get select text
function selectText(aSelect) {
  var text = aSelect.options[aSelect.selectedIndex].text;
  return text;
}

// Set select value
function setSelectValue(aSelect, aValue) {
	for (var i = 0; i < aSelect.length; i++) {
  	aSelect.options[i].selected = (aSelect.options[i].value == aValue);
	}
}

// Radiobutton is checked
function isChecked(aRadio){
  var flag = false;
	if (aRadio.length > 0) {
    for (var i = 0; i < aRadio.length; i++){
      if (aRadio[i].checked){
        flag = true;
      }
		} 
	} else {
	  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, commas or semi-colons 
  if ((aEmail.indexOf(" ") + 1) > 0) {
    return true;
  }
  if ((aEmail.indexOf(",") + 1) > 0) {
    return true;
  }
  if ((aEmail.indexOf(";") + 1) > 0) {
    return true;
  }
  // Check position of @
  var 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;
}

// Make sure both check boxes checked
function checkBoth(aCheckBox1, aCheckBox2) {
  if (aCheckBox1.checked) {
    aCheckBox2.checked = true;
  }
}

// Make sure both check boxes unchecked
function uncheckBoth(aCheckBox1, aCheckBox2) {
  if (!aCheckBox1.checked) {
    aCheckBox2.checked = false;
  }
}


//-->
