<!--
 //=================================================================//
var ValidateElement = new Array;
var ValidateFlags = new Array;
var ValidatorCount = 0;
//=================================================================//
function getObj(name)
{
  if (document.getElementById) //IE
  {
  	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all) //NETSCAPE 6
  {
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers) //NETSCAPE 4 & MOZILLA
  {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
}
//=================================================================//
function chk2txt(chk,txt) {
 txt.value='';
 for (var i=0;i<chk.length;i++) if (chk[i].checked) txt.value+=chk[i].value + ",";
}

//=================================================================//
function IsText(string) {
    if (!string) return false;
    var Chars = "%$£&!'";
    for (var i = 0; i < string.length; i++) {
       if (Chars.indexOf(string.charAt(i)) == -1)
          return false;
    }
    return true;
} 
//=================================================================//
function IsNumeric(string) {
    if (!string) return false;
    var Chars = "-0123456789.";
    for (var i = 0; i < string.length; i++) {
       if (Chars.indexOf(string.charAt(i)) == -1)
          return true;
    }
    return false;
} 
//=================================================================//
function isEmpty(s) {
    val = new String(s.value);
    return ((val == null) || (val.length == 0)) }
//=================================================================//

function validate(formNo) {
	if (formNo == null) formNo = 0;
	PassValidate = true;
	PassValidateMessage = '';
	for (var i = 0; i < ValidateElement.length; i++) {
		var ErrorMarker = new getObj(["ErrorMarker_" + ValidateElement[i][0]]);
		ErrorMarker.style.visibility = 'hidden';
		// Check for Null
		if (ValidateFlags[i][0] != "false") {
			if (isEmpty(document.forms[formNo][ValidateElement[i][0]])) { 
				PassValidate = false;
				PassValidateMessage = PassValidateMessage + "- " + ValidateElement[i][1] + " is a required value.\n"
				ErrorMarker.style.visibility = 'visible';
				document.forms[formNo][ValidateElement[i][0]].focus();
				//break
			}
		}
		// Check required text
		if (ValidateFlags[i][1] != "false") {
			if (IsText(document.forms[formNo][ValidateElement[i][0]].value)) {
				PassValidate = false;
				PassValidateMessage = PassValidateMessage + "- " + ValidateElement[i][1] + " must not contain the characters %$£&!'.\n"
				ErrorMarker.style.visibility = 'visible';
				document.forms[formNo][ValidateElement[i][0]].focus();
				//break;
			}
		}
		// Check valid email
		if (ValidateFlags[i][2] != "false") {
			if (document.forms[formNo][ValidateElement[i][0]].value.indexOf("@")==-1) {
				PassValidate = false;
				PassValidateMessage = PassValidateMessage + "- " + ValidateElement[i][1] + " is not a valid email address.\n"
				ErrorMarker.style.visibility = 'visible';
				document.forms[formNo][ValidateElement[i][0]].focus();
				//break;
			}
		}
		// Check valid integer
		if (ValidateFlags[i][3] != "false") {
			if (IsNumeric(document.forms[formNo][ValidateElement[i][0]].value)) {
				PassValidate = false;
				PassValidateMessage = PassValidateMessage + "- " + ValidateElement[i][1] + " must be a numeric value.\n"
				ErrorMarker.style.visibility = 'visible';
				document.forms[formNo][ValidateElement[i][0]].focus();
				//break;
			}
		}
	}
	if (PassValidate == false) {
		alert("Please address the following errors:\n"+PassValidateMessage);
	} else {
		document.forms[formNo].submit();
	}
}
//=================================================================//
function addNewValidator(fieldName,fieldTitle,bRequired,bText,bEmail,bInt) {
	// add to array
	ValidateElement[ValidatorCount] = new Array(fieldName,fieldTitle);
	ValidateFlags[ValidatorCount] = new Array(bRequired,bText,bEmail,bInt);
	//write indicator class
	document.write("<DIV id='ErrorMarker_"+fieldName+"' style='position:absolute;visibility:hidden;color:red;'>&nbsp;(!)</DIV>")
	//incriment validator count
	ValidatorCount++;
}

function DeleteItem(pID) {
var deldialogue = confirm("This will delete this record.  Are you sure?");
if (deldialogue == true) {
	document.forms[0].DeleteID.value = pID;
	window.focus();
	document.forms[0].submit();
} else {
	window.focus();
	}
}
//=================================================================//
 function daysinmonth(lnMonth,lnYear) {
var dt1, cmn1, cmn2, dtt, lflag, dycnt, lmn
lmn = lnMonth-1
dt1 = new Date(lnYear,lmn,1)
cmn1 = dt1.getMonth()
dtt=dt1.getTime()+2332800000
lflag = true
dycnt=28
while (lflag) {
   dtt = dtt + 86400000
   dt1.setTime(dtt)
   cmn2 = dt1.getMonth()
   if (cmn1!=cmn2) {
      lflag = false }
   else {dycnt = dycnt + 1}}
if (dycnt > 31) {dycnt = 31}
return dycnt
}

function setdays(sobjname, datemode){
var dobj = eval(sobjname + "d")
var mobj = eval(sobjname + "m")
var yobj = eval(sobjname + "y")
var hobj = eval(sobjname)
var monthdays = daysinmonth(mobj.options[mobj.selectedIndex].value,yobj.options[yobj.selectedIndex].value)
var selectdays = dobj.length
var curdy = dobj.options[dobj.selectedIndex].value
if (curdy.length==1) {curdy = "0"+curdy}
var curmn = mobj.options[mobj.selectedIndex].value
if (curmn.length==1) {curmn = "0"+curmn}
var curyr = yobj.options[yobj.selectedIndex].value
if (selectdays > monthdays) {
   for (var dlp=selectdays; dlp > monthdays; dlp--) {
       dobj.options[dlp-1] = null }}
else if (monthdays > selectdays) {
   for (var dlp=selectdays; dlp < monthdays; dlp++) {
       dobj.options[dlp] = new Option(dlp+1,dlp+1) }}       
if (curdy > monthdays) {
   dobj.options[monthdays-1].selected = true
   curdy = monthdays }
if (datemode==1) {
   var curdate = curmn+"/"+curdy+"/"+curyr }
else if (datemode==2) {
   var curdate = curdy+"/"+curmn+"/"+curyr }
else if (datemode==3) {
   var curdate = curyr+curmn+curdy }
else if (datemode==4) {
   var cdate = new Date(curyr,curmn-1,curdy)
   var curdate = cdate.toGMTString() }
hobj.value = curdate
}
//-->