/*INCLUDE FILE WITH MANY MANY MANY FUNCTIONS*/

function rollFunction(sImgName,sFileName) {
	document.images[sImgName].src = sFileName;
}

function lblClick(sForm,sName,iType) {
  if (iType == '') {
    if (document.forms[sForm].all[sName].checked == false) { document.forms[sForm].all[sName].checked = true; }
		else { document.forms[sForm].all[sName].checked = false; }
	} else { document.forms[sForm].all[sName].checked = true; }
}

function checkValue(sForm,sName) {
  if (document.forms[sForm].all[sName].value == '') { return false }
  else { return true }
}

function validateEmail(sForm,sName) {
	bInvalid = false;
	if (document.forms[sForm].all[sName].value.indexOf('@') <= -1) { bInvalid = true }
	else { if (document.forms[sForm].all[sName].value.indexOf('.') <= -1) { bInvalid = true }}
	
	if (bInvalid == true) {
	  alert("You must enter a VALID Email Address.\n(ex.JohnSmith@email.com)");
	  return false;
	} else { return true }
}

function checkForm() {
	var bSubmitForm = true;
	var iElements = arguments.length;
	var sForm = arguments[0];
	var x = 1;

	while (x<iElements) {
		sField = arguments[x];
		sName = arguments[x+1];

		if (sField == 'txtEmail') {
			if (validateEmail(sForm,sField)) { bSubmitForm = true } else { bSubmitForm = false }
		}
		else if (sField.indexOf('rad') == 0) {
			iLength = document.forms[sForm].all[sField].length;
			bRadButton = false;
			for (y=0;(y<iLength);y++) {
				if (document.forms[sForm].all[sField][y].checked == true) {
					bRadButton = true;
				}
			}
			if (bRadButton == false) { alert("You need to select a value for " + sName); bSubmitForm = false; }
		}
		else {
			if (checkValue(sForm,sField) == false) { alert("You need to input a value for " + sName); bSubmitForm = false; }
		}
		x = x+2;
	}
	if (bSubmitForm == true) { document.forms[sForm].submit(); }
}

function confirmDelete(sMessage) {
	if (confirm(sMessage) == true)
	  { return true }
	else
	  { return false }
}

function openWindow(sURL,sName,iWidth,iHeight) {
	window.self.open(sURL,sName,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=' + iWidth + ',height=' + iHeight);
}
