	/*--------------------------------------------------------------------------*/
	/*	FORM VARIABLES															*/
	/*--------------------------------------------------------------------------*/
	
	/*--------------------------------------------------------------------------*/
	/*	EVENT HANDLERS															*/
	/*--------------------------------------------------------------------------*/
	function Save_OnClick()
	{
		var bReturn = true;
		var oMessageBox;
		var sMsg;
		var sColor;

		if (typeof(Page_ClientValidate) == 'function') bReturn = Page_ClientValidate();

		if (!bReturn)
		{
			sMsg = 'Please enter required fields and correct formatting.\n\nRequired fields are denoted with an asterisk(*).';
			sColor = 'Red';
		}	
		else
		{
			sMsg = 'Please wait while your changes are validated and saved ...';
			sColor = 'Black';
		}

		oMessageBox = document.getElementById('MessageBar1_divMessage');
		if (oMessageBox != null) 
		{
			oMessageBox.style.color = sColor;
			writeInnerText(oMessageBox,sMsg);
		}
		
		return bReturn;
	}

	function Search_OnClick()
	{
		var oMessageBox;
		var sMsg;
		var sColor;
		var txtKeyword;

		txtKeyword = document.getElementById('txtKeyword');
		if (txtKeyword != null)
		{
			if (Trim(txtKeyword.value) == '')
			{
				sMsg = 'Please enter a keyword for the search.';
				sColor = 'Red';
				
				oMessageBox = document.getElementById('MessageBar1_divMessage');
				if (oMessageBox != null) 
				{
					oMessageBox.style.color = sColor;
					writeInnerText(oMessageBox,sMsg);
				}
			}
			else
			{
				window.location.href = 'EmployeeSearch.aspx?Keyword=' + Trim(txtKeyword.value);
			}
		}
		
		//Don't allow a form submit
		return false;
	}

	/*--------------------------------------------------------------------------*/
	/*	FUNCTIONS																*/
	/*--------------------------------------------------------------------------*/

	/*--- addPicture ---*/
	function addPicture(lEmpID) 
	{
		var arrParms;
		var hidPicturePath;
		var imgPicture;
		var linkPicture;
		var sSettings;

		//Initialize variables.
		arrParms = new Array(lEmpID,'');
		hidPicturePath = document.getElementById('hidPicturePath');
		imgPicture = document.getElementById('imgPicture');
		linkPicture = document.getElementById('linkPicture');
		sSettings = "center:yes;resizable:no;dialogHeight:375px;dialogWidth:300px";
		
		arrParms = window.showModalDialog(getHostURL() + "/EmployeeMaintenance/UploadImage.aspx", arrParms, sSettings);
		if (arrParms != null)
		{
			imgPicture.src = 'pics/' + arrParms[1];;
			imgPicture.style.display='';
			hidPicturePath.value = arrParms[1];
			linkPicture.href = 'javascript:removePicture(' + lEmpID + ');';
			linkPicture.childNodes(0).src = 'images/btnRemovePicture.gif';
		}
	}
	
	/*--- changeEnterToTab ---*/
	function changeEnterToTab(event,elem)
	{
		var oElement = null;
		
		//We want to control the Enter key for conditions causing the form to unintentially 
		//submit.  See the articles describing the default button behaviour and forms.
		//Because we cannot override the keyCode for Mozilla browsers, we have no efficient
		//means for converting an Enter key to a Tab.  Consequently, we will explicitly
		//specify the next control to have focus as needed.  
		
		//If the Enter key was pressed ...
		if ( event.keyCode == 13) 
		{ 
			//Change focus to the specified control if it is found and enabled.
			oElement = document.getElementById(elem);						
			//if (oElement != null && !oElement.disabled) oElement.focus();
			if (oElement != null) oElement.focus();

			//Cancel the Enter key.
			//event.stopPropagation;					
			//event.preventDefault;			
			return false;
		}		
		
		return true;
	}

	/*--- convertInt ---*/
	function convertInt(sVal)
	{
		//Leading zeros must be stripped for parseInt to function correctly.
		while (sVal.charAt(0) == '0' && sVal.length > 1)
			sVal = sVal.substring(1, sVal.length);

		return parseInt(sVal);
	}	
			
	/*--- editOfficeHours ---*/
	function editOfficeHours(lID,sBuilding,sRoom,sTimeBegin,sTimeEnd,bMon,bTue,bWed,bThur,bFri,bSat,bSun) 
	{
		var arrParms;
		var btnUpdateGrid;
		var hidUpdateGridParms;
		var sSettings;
		var sParmString;

		//Initialize popup parameters.
		arrParms = new Array(sBuilding,sRoom,sTimeBegin,sTimeEnd,bMon,bTue,bWed,bThur,bFri,bSat,bSun);
		sSettings = "center:yes;resizable:no;dialogHeight:400px;dialogWidth:325px";
		
		arrParms = window.showModalDialog(getHostURL() + "/EmployeeMaintenance/OfficeHours.aspx", arrParms, sSettings);
		if (arrParms != null)
		{
			//Initialize working variables
			hidUpdateGridParms = document.getElementById("hidUpdateGridParms");
			btnUpdateGrid = document.getElementById("btnUpdateGrid");
			sParmString = lID + "@" + arrParms[0] + "@" + arrParms[1] + "@" + arrParms[2] + "@" + arrParms[3] + "@" + arrParms[4] + "@" + arrParms[5] + "@" + arrParms[6] + "@" + arrParms[7] + "@" + arrParms[8] + "@" + arrParms[9]+ "@" + arrParms[10];
			
			hidUpdateGridParms.value = sParmString;
			btnUpdateGrid.click();					
		}
	}

	/*--- getHostURL ---*/
	function getHostURL()
	{
		var sHostURL;
		var sPath;
		
		sPath = window.location.pathname;
		if (window.location.search != null) sPath = sPath + window.location.search;
		
		sHostURL = window.location.href.replace(sPath,'');
		
		return sHostURL;
	}
	
	/*--- getTime ---*/
	function getTime(sHH,sMM,sAMPM)
	{
		var iHH;
		var iMM;
		var sTime 

		iHH = convertInt(sHH);
		iMM = convertInt(sMM);
						
		//If military time is used, automatically reset to PM.	
		if (iHH > 12)
		{ 
			iHH = iHH - 12;
			sAMPM = 'PM';
		}

		//Format with leading zeros.
		sTime = Right('0' + iHH,2) + ':' + Right('0' + iMM,2) + ' ' + sAMPM;

		return sTime;
	}
			
	/*--- Left ---*/
	function Left(str, n)
	{
		if (n <= 0)
			return "";
		else if (n > String(str).length)
			return str;
		else
			return String(str).substring(0,n);
	}

	/*--- LTrim ---*/
	function LTrim(sValue)
	{
		var w_space = String.fromCharCode(32);
		if(v_length < 1)
		{
			return"";
		}
		
		var v_length = sValue.length;
		var strTemp = "";
		var iTemp = 0;

		while(iTemp < v_length)
		{
			if(sValue.charAt(iTemp) == w_space)
			{
			}
			else
			{
				strTemp = sValue.substring(iTemp,v_length);
				break;
			}
			iTemp = iTemp + 1;
		}

		return strTemp;
	}

	/*--- loadSecureApp ---*/
	function loadSecureApp(sPath)
	{
		//Secure paths cannot use relative references so we must manually build the path.
		//window.location.href = getHostURL().replace('http:','https:') + sPath;
		window.location.href = 'https://' + window.location.hostname + sPath;

		return false;
	}	
	
	/*--- openSectionInfo ---*/
	function openSectionInfo(sSemester,sSectionNum)
	{
		var winHeight = 500;
		var winWidth = 600;
		var winLeft = (screen.width - winWidth) / 2;
		var winTop = (screen.height - winHeight) / 2;
		var sSettings;
		var sURL;

		//Initialize working variables.
		sSettings = 'width=' + winWidth + ',height=' + winHeight + ',left=' + winLeft + ',top=' + winTop + ',resizable=yes';
		sURL = 	'SectionInfo.aspx?Semester=' + sSemester + '&SectionNum=' + sSectionNum;
			
		//Launches the SectionInfo page in a modeless popup window.
		launcher=window.open(sURL,'SectionInfo',sSettings);
		launcher.focus();
	}
	
	/*--- removePicture ---*/
	function removePicture(lEmpID) 
	{
		var hidPicturePath;
		var imgPicture;
		var linkPicture;
		
		//Initialize variables.
		hidPicturePath = document.getElementById('hidPicturePath');
		imgPicture = document.getElementById('imgPicture');
		linkPicture = document.getElementById('linkPicture');
		
		imgPicture.src = null;
		imgPicture.style.display='none';
		hidPicturePath.value = '';
		linkPicture.href = 'javascript:addPicture(' + lEmpID + ');';
		linkPicture.childNodes(0).src = 'images/btnAddPicture.gif';
	}
	
	/*--- Right ---*/
	function Right(str, n)
	{
		if (n <= 0)
			return "";
		else if (n > String(str).length)
			return str;
		else 
		{
			var iLen = String(str).length;
			return String(str).substring(iLen, iLen - n);
		}
	}
	
	/*--- RTrim ---*/
	function RTrim(sValue)
	{
		var w_space = String.fromCharCode(32);
		var v_length = sValue.length;
		var strTemp = "";
		if(v_length < 0)
		{
			return"";
		}
		var iTemp = v_length -1;

		while(iTemp > -1)
		{
			if(sValue.charAt(iTemp) == w_space)
			{
			}
			else
			{
				strTemp = sValue.substring(0,iTemp +1);
				break;
			}
			iTemp = iTemp-1;
		}
		
		return strTemp;
	}

	/*--- Trim ---*/
	function Trim(sValue)
	{
		if(sValue.length < 1)
		{
			return"";
		}
		
		sValue = RTrim(sValue);
		sValue = LTrim(sValue);
		if(sValue=="")
		{
			return "";
		}
		else
		{
			return sValue;
		}
	}

	/*--- validTime ---*/
	function validTime(sHH,sMM,sAMPM)
	{
		var bValid = true;
		var iHH;
		var iMM;
		var oRegExpTime = /^\d{1,2}:\d{1,2}$/;
		var sTime 

		//Validate the time format				
		sTime = Trim(sHH) + ':' + Trim(sMM);
		if (sTime.match(oRegExpTime))
		{
			iHH = convertInt(sHH);
			iMM = convertInt(sMM);
			
			if (iHH < 1 || iHH > 24) 
				bValid = false;
			else if (iMM < 0 || iMM > 59) 
				bValid = false;
			else if (iHH < 13 && sAMPM == '') 
				bValid = false;
		} 
		else
		{
			bValid = false;
		}

		return bValid;
	}

	/*--- validTimeRange ---*/
	function validTimeRange(sTimeBegin,sTimeEnd)
	{
		var bValid = true;
		var iTimeBegin;
		var iTimeEnd;
		
		sTimeBegin = sTimeBegin.replace('12','00');
		if (sTimeBegin.indexOf('PM') > -1)
			iTimeBegin = convertInt(sTimeBegin.replace(':','').substr(0,4)) + 1200
		else
			iTimeBegin = convertInt(sTimeBegin.replace(':','').substr(0,4))

		sTimeEnd = sTimeEnd.replace('12','00');
		if (sTimeEnd.indexOf('PM') > -1)
			iTimeEnd = convertInt(sTimeEnd.replace(':','').substr(0,4)) + 1200
		else
			iTimeEnd = convertInt(sTimeEnd.replace(':','').substr(0,4))

		//alert(iTimeBegin + ':' + iTimeEnd);
		if (iTimeBegin >= iTimeEnd) bValid = false;
			
		return bValid;
	}

	/*--- writeInnerText ---*/
	function writeInnerText(e,sText)
	{
		var oChild;
		var oNode;

		//This function is neccessary as the W3C web standards don't support innerText.
		
		//If a valid element has been provided, write the appropriate text string.
		if (e != null && sText != null)
		{
			//Remove all but the first text node which will be replaced.
			for (j=e.childNodes.length;j > 1;j--)
			{
				oChild = e.childNodes[j-1];
				e.removeChild(oChild);
			}

			oNode = document.createTextNode(sText);
			e.replaceChild(oNode, e.childNodes[0]);
		}
	}
	
	/*--------------------------------------------------------------------------*/
	/*	WINDOWS EVENTS															*/
	/*--------------------------------------------------------------------------*/

