function criteriaGetData(){
	var i = document.frmMain.cboRecord.selectedIndex;
	if (i > 0) {
		var strURL = document.frmMain.cboRecord.options[i].value;

		if (strURL != "") {
			window.location.href = strURL; 
		}
	}
}

//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////

function criteriaCheckRecord() {
	var i = document.frmMain.cboRecord.selectedIndex;
	if (i <= 0) {
		alert("You must select a record first.");
		document.frmMain.optAction[0].checked = 1;
	}
}

//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////

function OpenPage (strPage, strWindowName, intHeight, intWidth, intTop, intLeft, bolToolbar, bolMenubar, bolScrollbars, bolResizable, bolLocation, bolDirectories, bolStatus) {
	//Enter 9999 for both intTop and intLeft to Center the window on the screen.
	//Send 1 for True and 0 for False for all boolean parms.
	
	if ((intTop == 9999) && (intLeft == 9999)) {
		//Determine top and left based on screen width/height and window width/height
		iTop = ((screen.availHeight - intHeight) / 2);
		iLeft = (screen.availWidth - intWidth) / 2;
	} else {
		//Set top and left based on parameters passed for intTop and intLeft
		iTop = intTop;
		iLeft = intLeft;
	}
	
	strFeatures = "height=" + intHeight + ",width=" + intWidth + ",top=" + iTop + ",left=" + iLeft
	strFeatures = strFeatures + ",toolbar=" + bolToolbar + ",menubar=" + bolMenubar + ",scrollbars=" + bolScrollbars + ",resizable=" + bolResizable + ",location=" + bolLocation + ",directories=" + bolDirectories + ",status=" + bolStatus
	window.open (strPage, strWindowName, strFeatures);
}

//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////

function showDropCalendar(theCtrl, theSpan) {
	// declare variable
	var SpanBox, CalBox, CalFrame;
	
	// Position our Calendar DIV Tag
	SpanBox = document.all[theSpan];
	CalBox = document.all['drpCal'];
	CalFrame = document.all['CalFrame'];
	
	// Position	
	CalBox.style.left = SpanBox.offsetLeft;
	CalBox.style.top = SpanBox.offsetTop + SpanBox.offsetHeight + 2;
	
	// Update the Source within it
	CalFrame.src = 'common/scripts/popcalendar.asp?type=drop&ctrl='+theCtrl;
	
	// Make it visible
	CalBox.style.display='';
}

//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////

function hideDropCalendar() {
	document.all['drpCal'].style.display='none';
}

//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////

function validEmail(email) {
     invalidChars = "/:,;"

     if (email == "") return false
     
     for (j=0; j<invalidChars.length; j++) {
          badChar = invalidChars.charAt(j)
          if (email.indexOf(badChar,0) != -1) {
               return false
          }
     }
     
     atPos = email.indexOf("@", 1)
     if (atPos == -1) return false
     
     if (email.indexOf("@",atPos+1) != -1) return false
     
     periodPos = email.indexOf(".",atPos)
     if (periodPos == -1) return false
     
     if (periodPos+3 > email.length) return false

     return true
}

//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////

function Validate(which) {
	var pass=true;
	var strError="";
	//if (document.images) {
		for (i=0;i<which.length;i++) {
			var tempobj=which.elements[i];
			if (tempobj.name.substring(0,3)=="req") {
				if (((tempobj.type=="text"||tempobj.type=="textarea"||tempobj.type=="password"||tempobj.type=="file")&&
					tempobj.value=='')||((tempobj.type.toString().charAt(0)=="s")&&
					tempobj.selectedIndex==0))  {
						strError = strError+"- "+tempobj.name.substring(3, 33)+" is blank \n";
				} else {
					if (tempobj.name.substring(3, 33)=="Email") {
						pass=validEmail(tempobj.value);
						if (!pass) {
							strError = strError+"- "+tempobj.name.substring(3, 33)+" is invalid \n";
						}						
					}
				}
			}
		}
	//}
	
	if (strError=="") {
		return true;
	} else {
		alert("The following error(s) occurred:\n"+strError);
		return false;
	}
}

//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////

function deptJump() {
	var i;
	i = document.frmDepartment.cboDepartment.selectedIndex;
	if (document.frmDepartment.cboDepartment.options[i].value != "") {
		location.href = "department.asp?dept=" + document.frmDepartment.cboDepartment.options[i].value;
	} else {
		alert("You must first select a department.");
	}
}

//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////

function dirClearSearch() {
	if (document.frmDirectory.cboSort.selectedIndex == 1) {
		document.frmDirectory.txtSearch.value = "";
		document.frmDirectory.txtSearch.disabled = true;
	} else {
		document.frmDirectory.txtSearch.disabled = false;
	} 
}

//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////

function dirClearSort() {
	if (document.frmDirectory.cboSort.selectedIndex == 1) {
		document.frmDirectory.cboSort.selectedIndex = 0;
	}
}