// Function to SELECT ALL the records on a listing page
function SelectAll(source,formName,chkBoxName) {
	// first look for the number of form elements in the given form
	// this will count even the buttons etc
	var maxs = document.forms[formName].length-1;
	// now look through the items
	for (i = 0; i <= maxs; i++)
		// check if we are at a checkbox if not ignore
   		if (document.forms[formName][i].type == 'checkbox')
			// check if our checkbox is really in the list of required checkboxes
			if (document.forms[formName][i].name == chkBoxName)
				// check all boxes if selector is checked and vice versa
				document.forms[formName][i].checked = source.checked;					

}

// Used to DELETE the RECORDS selected on a listing page
function confirmDelete() 
{ 
	var n_DeleteItems = document.getElementsByName('chkDeleteItems[]');
	for (var i=0; i < n_DeleteItems.length; i++) 
		if (n_DeleteItems[i].checked) 
			return confirm("Are you sure you want to delete the selected records?"); 

// if no record/item is selected then this will not let the form to be submitted.
	alert("Please select a record to delete.");
	return false; /* best to return explicit false to stop submission */ 
} 