//PS 2006-7

function checkBoxLength(frm,fld) {
	try { 
		len = document[frm][fld].length;
	}
	catch(e) {
		len = 1;
	}
	return len;
}


function checkBoxCounter(frm,fld) {
	total = 0;
	if (document[frm][fld]) {
		len = checkBoxLength(frm,fld);
		if (len == 1) {
			if (document[frm][fld].checked == true) {
				total = 1;
			}
		}
		else {
			for (c=0; c<len; c++) {
				if (document[frm][fld][c].checked == true) {
					total = total + 1;
				}
			}
		}
	}
	return total;
}

function checkBoxAll(frm,fld) {
	try {
		t = checkBoxLength(frm,fld);
		st = checkBoxCounter(frm,fld);
		action = (st < t) ? true : false;
		if (t==1) {
			document[frm][fld].checked = action;
		}
		else {
			for (c=0; c<t; c++) {
				document[frm][fld][c].checked = action;
			}
		}
	}
	catch(e) {
		alert("Sorry, this function is not available!");
	}
}

function CheckEmail(addy) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(addy) == false) {
		return false;
	}
	else {
		return true;
	}
}

function CheckURL(url) {
	var theLink = new String(url);
	var prefix = "http://";
	if (theLink.length == 0) {
		return false;
	}
	else if (theLink.toLowerCase().indexOf(prefix) != 0) {
		return false;
	}
	else {
		return true;	
	}
}
