function setVisibility(ref,state) {
  document.all[ref].style.visibility=state;
}

function validEmail(str) {
  // are regular expressions supported?
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported)
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}

function emptyField(txtValue) {
  if (txtValue.length == 0) return true;
  for (var i=0; i < txtValue.length; ++i) {
    var ch = txtValue.charAt(i);
    if (ch != ' ' && ch != '\t') return false;
  }
  return true;
}

function getRadioValue(radioGroup) {
  var value = null;
	if (radioGroup.value==undefined) {  // group of more than 1
	  for (var i=0; i<radioGroup.length; i++) {
			if (radioGroup[i].checked) {
				value = radioGroup[i].value;
				break;
			}
		}
	} else {
	  value = radioGroup.value;
		if (value==undefined) {
		  value = null;
		}
	}
	return value;
}