function updateAllChecks(ch, how) {
    if (ch) {
        if (ch.length) {
            for (var i = 0; i < ch.length; i++) {
                ch[i].checked = how && !ch[i].disabled;
            }
        } else {
            ch.checked = how && !ch.disabled;
        }
    }
}

function toggleVisibility(id, NNtype, IEtype, WC3type) {
    if (document.getElementById) {
        eval("document.getElementById(id).style.visibility = \"" + WC3type + "\"");
    } else {
        if (document.layers) {
            document.layers[id].visibility = NNtype;
        } else {
            if (document.all) {
                eval("document.all." + id + ".style.visibility = \"" + IEtype + "\"");
            }
        }
    }
}

function errorOut(msg, fld) {
    alert(msg);
    fld.focus();
    return false;
}

function getCheckedValue(radioObj) {
    var ret_val = '';
    if (radioObj) {
        var radioLength = radioObj.length;
	if(radioLength == undefined) {
            if(radioObj.checked) ret_val = radioObj.value;
        } else {
            for(var i = 0; i < radioLength; i++) {
                if (radioObj[i].checked) ret_val = ret_val + ',' + radioObj[i].value;
            }
            if (ret_val != '') ret_val = ret_val.substring(1);
        }
    }
    return ret_val;
}

// set the radio button with the given value as being checked
// do nothing if there are no radio buttons
// if the given value does not exist, all the radio buttons
// are reset to unchecked
function setCheckedValue(radioObj, newValue) {
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}

function isValidEmail(str) {
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
 
}

