function mContextMenu()
	{
		return true;
	}

/////////////////////////////////////////////////

//Catch Key methods.  Used to control Enter Key for buttons.

//Put onkeydown="CatchKey(); in body tag of pages that need controlling.

/////////////////////////////////////////////////

function CatchKeys(eventPassed)

{
	
	var agent = navigator.userAgent.toLowerCase();
	var isIE = (agent.indexOf('msie') != -1);



   var wEvent;
   var keyCode;
   var sender;

	if (isIE)
	
		{                   
		
		   wEvent = window.event;
		
		   keyCode = wEvent.keyCode;
		
		   sender = wEvent.srcElement;
		
		}
	
	   else
	
	   {
	
            wEvent = eventPassed;
	         keyCode = wEvent.keyCode;
            sender = wEvent.target;
	
	   }           
        		if (sender.type == 'text' || sender.type == 'textarea')
        			{
        				//Dont catch backspace key for textarea controls.
						var FieldStatus = sender.getAttribute("FieldStatus");
		
						if (FieldStatus == 'RO')
							{
								CancelKey(wEvent, keyCode);
							}
        			}
        		else
					{
						CancelKey(wEvent, keyCode);
		            
					}

}

function CancelKey(wEvent, keyCode)

{ 
	var agent = navigator.userAgent.toLowerCase();
	var isIE = (agent.indexOf('msie') != -1);

            if (isIE)

            {

                        if (keyCode == 8)

                        {                       

                                    wEvent.cancelBubble = true;

                                    wEvent.returnValue = false; 

                        } 

            }

            else

            {

                        if (keyCode == 8)

                        {                       

                                    wEvent.stopPropagation();

                                    wEvent.preventDefault();

                        } 

            }           

}



	
	function mDocCheck()
		{
		if (window.top.iDocChangeFlag == 1)
			{
			
			var answer = confirm ('STOP! - You have made changes to the current document. Click CANCEL to go back and save your changes.');
			 
			if (answer) 
				{
					window.top.iDocChangeFlag = 0;
					return 0;
				}
			else
				{
					return 1;
				}
				
			}
		else
			{

			return 0;

			}
		
		}

function ClassChange(IDIn, ClassIn)
		{
			document.getElementById(IDIn).className = ClassIn;
		}

		
function mDocChanged(frm)
	{
		//alert('Here');
		window.top.iDocChangeFlag = 1;
		window.top.fDocForm = frm;
		window.top.fFrame = self;
	}
	
function mDocSaved()
	{
		//alert('Here');
		window.top.iDocChangeFlag = 0;
	}

function URLEncode(s)
	{
		s = s.replace(" ", "%20");
		s = s.replace("\"", "%22");
		s = s.replace("#", "%23");
		s = s.replace("&", "%26");
		
		return s.replace("+", "%2B");
	}
	
function mJSFilePath(s)
	{
		s = s.replace("\"", "\\");
		
		return s;
	}

function FindPopup(FindGID, FieldID, FindDesc, FindFunction, CheckFilter)
	{
		var ChkSum = 0;

		//Check the Check Filter
		if (CheckFilter == '')
			{
				ChkSum = 1;
			}
		else
			{
				if  (document.getElementById(FieldID + 'Filter').value != '')
					{
					ChkSum = 1;
					}
				else
					{
						alert('You must select a ' + CheckFilter + '.');
					}
			}			
		
		if (ChkSum == 1)
			{
			//Figure out the center of the screen
			var stop = (window.screen.availheight / 2) - (500 / 2);
			var sleft = (window.screen.availwidth / 2) - (400 / 2);
			var FindFilterData = document.getElementById(FieldID + 'Filter').value
			winFindPopup = window.open("/module/system/find/find.asp?FindGID=" + FindGID + "&FieldID=" + URLEncode(FieldID) + "&FindDesc=" + URLEncode(FindDesc) + "&FindFilterData=" + URLEncode(FindFilterData) + "&FindFunction=" + URLEncode(FindFunction),"WAI_FINDPOPUP", "height=400, width=500, top=" + stop + ", left=" + sleft + ", menubar=0, location=0, resizable=0, status=0");
			winFindPopup.focus();
			}	
	}

function Constant(ConstantTitleIn, ConstantNameIn)
	{
		//Figure out the center of the screen
		var stop = (window.screen.availheight / 2) - ((window.screen.availHeight - 600) / 2);
		var sleft = (window.screen.availwidth / 2) - ((window.screen.availWidth - 1000) / 2);
		winConstant = window.open("/module/system/Constant/Constant.asp?ConstantTitle=" + URLEncode(ConstantTitleIn) + "&ConstantName=" + URLEncode(ConstantNameIn),"WAI_CONSTANT", "height=" + (window.screen.availHeight - 600) + ", width=" + (window.screen.availWidth - 1000) + ", top=" + stop + ", left=" + sleft + ", menubar=0, location=0, resizable=0, status=0");
		winConstant.focus();
	}
	
function Calendar(FieldIn, TimeOptionIn)
	{
		//Figure out the center of the screen
		var stop = (window.screen.availheight / 2) - ((window.screen.availHeight - 600) / 2);
		var sleft = (window.screen.availwidth / 2) - ((window.screen.availWidth - 1000) / 2);
		var SelDateIn = document.getElementById(FieldIn).value;
		winCalendar = window.open("/module/system/calendar/calendar.asp?Field=" + FieldIn + "&SelDate=" + SelDateIn + "&TimeOption=" + TimeOptionIn,"WAI_CALENDAR", "height=235, width=216, top=" + stop + ", left=" + sleft + ", menubar=0, location=0, resizable=0, status=0");
		winCalendar.focus();
	}
	
function mCalendarv2(FieldIn, FunctionIn, TimeOptionIn)
	{
		//Figure out the center of the screen
		var stop = (window.screen.availheight / 2) - ((window.screen.availHeight - 600) / 2);
		var sleft = (window.screen.availwidth / 2) - ((window.screen.availWidth - 1000) / 2);
		var SelDateIn = document.getElementById(FieldIn).value;
		winCalendar = window.open("/module/system/calendar/calendar.asp?Field=" + FieldIn + "&SelDate=" + SelDateIn + "&TimeOption=" + TimeOptionIn + "&Function=" + FunctionIn,"WAI_CALENDAR", "height=235, width=216, top=" + stop + ", left=" + sleft + ", menubar=0, location=0, resizable=0, status=0");
		winCalendar.focus();
	}
	
function NotePopup(NoteLinkIDIn, NoteLinkDescIn)
	{
		//Figure out the center of the screen
		var stop = (window.screen.availheight / 2) - (500 / 2);
		var sleft = (window.screen.availwidth / 2) - (400 / 2);
		winNotesPopup = window.open("/module/system/note/note.asp?NoteLinkID=" + NoteLinkIDIn + "&NoteLinkDesc=" + URLEncode(NoteLinkDescIn),"WAI_NOTES", "height=400, width=500, top=" + stop + ", left=" + sleft + ", menubar=0, location=0, resizable=0, status=0");
		winNotesPopup.focus();
	}

function mNotePopup(NameIn, NoteLinkGIDIn, NoteWindowTitleIn)
	{
		//Figure out the center of the screen
		var vWinWidth = 500;
		var vWinHeight = 400;
		var vWinTop = (screen.height / 2) - (vWinHeight / 2);
		var vWinLeft = (screen.width / 2) - (vWinWidth / 2);
		winNotePopup = window.open("/module/system/note/note.asp?Name=" + NameIn + "&NoteLinkGID=" + NoteLinkGIDIn + "&NoteWindowTitle=" + URLEncode(NoteWindowTitleIn),"WAI_NOTE", "height=" + vWinHeight + ", width=" + vWinWidth + ", top=" + vWinTop + ", left=" + vWinLeft + ", menubar=0, location=0, resizable=0, status=0");
		winNotePopup.focus();
	}

function TrackPopup(IDIn, TrackCategoryIn, TrackLinkGIDIn, NameValueIn, ShowStatusIn, ShowDueDateIn, ShowBallIn, CloseAddIn)
	{
		//Figure out the center of the screen
		var stop = (window.screen.availheight / 2) - (500 / 2);
		var sleft = (window.screen.availwidth / 2) - (400 / 2);
		winTrackPopup = window.open("/module/system/Track/Track.asp?ID=" + IDIn + "&TrackLinkGID=" + TrackLinkGIDIn + "&TrackCategory=" + URLEncode(TrackCategoryIn) + "&NameValue=" + NameValueIn + "&ShowStatus=" + ShowStatusIn + "&ShowDueDate=" + ShowDueDateIn + "&ShowBall=" + ShowBallIn + "&CloseAdd=" + CloseAddIn,"WAI_TRACK", "height=400, width=500, top=" + stop + ", left=" + sleft + ", menubar=0, location=0, resizable=0, status=0");
		winTrackPopup.focus();
	}
	
function StyleReservePopup(StyleGIDIn, StyleIDIn)
	{
		//Figure out the center of the screen
		var stop = (window.screen.availheight / 2) - (500 / 2);
		var sleft = (window.screen.availwidth / 2) - (400 / 2);
		winReservePopup = window.open("/module/FutureMaker/Style/Reserve/Reserve.asp?StyleGID=" + StyleGIDIn + "&StyleID=" + URLEncode(StyleIDIn),"WAI_RESERVE", "height=400, width=500, top=" + stop + ", left=" + sleft + ", menubar=0, location=0, resizable=0, status=0");
		winReservePopup.focus();
	}
	
function StyleApprovalPopup(StyleGIDIn, StyleIDIn)
	{
		//Figure out the center of the screen
		var stop = (window.screen.availheight / 2) - (500 / 2);
		var sleft = (window.screen.availwidth / 2) - (400 / 2);
		winApprovalPopup = window.open("/module/FutureMaker/Style/Approval/Approval.asp?StyleGID=" + StyleGIDIn + "&StyleID=" + URLEncode(StyleIDIn),"WAI_Approval", "height=400, width=500, top=" + stop + ", left=" + sleft + ", menubar=0, location=0, resizable=0, status=0");
		winApprovalPopup.focus();
	}
	
function mFieldRevisionHistoryPopup(FieldRevisionGIDIn, TableKeyGIDIn)
	{
		//Figure out the center of the screen
		var vWinWidth = 500;
		var vWinHeight = 200;
		var vWinTop = (screen.height / 2) - (vWinHeight / 2);
		var vWinLeft = (screen.width / 2) - (vWinWidth / 2);
		
		winFieldRevisionHistoryPopup = window.open("/module/FutureMaker/Revision/FieldRevisionHistory.asp?FieldRevisionGID=" + FieldRevisionGIDIn + "&TableKeyGID=" + TableKeyGIDIn,"WAI_FieldRevisionHistory", "height=" + vWinHeight + ", width=" + vWinWidth + ", top=" + vWinTop + ", left=" + vWinLeft + ", menubar=0, location=0, scrollbars=1, resizable=0, status=0");
		winFieldRevisionHistoryPopup.focus();
	}

function mErrorBox(vErrorDesc, vError)
	{
		if (vError == '')
		{
			document.getElementById('ErrorBox').innerHTML = '';
		}
		else
		{
			document.getElementById('ErrorBox').innerHTML = '<table bgcolor="#995353" cellpadding="0" cellspacing="1" width="100%"><tr><td><table bgcolor="#EFEFEF" width="100%"><tr><td valign="top">&nbsp;&nbsp;<img src="/Images/iconWarning.gif" width="20" height="20" align="absmiddle"></td><td style="padding-top: 5px;" width="100%"><span class="textErrorMessage">' + vErrorDesc + '</br>' + vError + '</span></td></tr></table></td></tr></table>';
		}
	}

function mFailureBox(vErrorDesc, vError)
		{
			document.getElementById('MessageBox').innerHTML = '<table cellpadding="0" cellspacing="0" width="100%"><tr><td style="padding: 2px 0 2px 0;"><table bgcolor="#995353" cellpadding="0" cellspacing="1" width="100%"><tr><td><table bgcolor="#ffeded" width="100%" border="0"><tr><td valign="top" style="padding: 5px 5px 5px 5px;"><img src="/Images/Error_Icon.gif" width="15" height="15" align="absmiddle"></td><td style="padding-top: 4px;" width="100%" valign="top"><span class="textErrorMessage">' + vErrorDesc + '</br>' + vError + '</span></td></tr></table></td></tr></table></td></tr></table>';
		}
	
function mSuccessBox(vSuccessDesc)
		{
			document.getElementById('MessageBox').innerHTML = '<table cellpadding="0" cellspacing="0" width="100%"><tr><td style="padding: 2px 0 2px 0;"><table bgcolor="#539953" cellpadding="0" cellspacing="1" width="100%"><tr><td><table bgcolor="#edffed" width="100%" border="0"><tr><td valign="top" style="padding: 5px 5px 5px 5px;"><img src="/Images/Success_Icon.gif" width="14" height="14" align="absmiddle"></td><td style="padding-top: 4px;" width="100%" valign="top"><span class="textSuccessMessage">' + vSuccessDesc + '</span></td></tr></table></td></tr></table></td></tr></table>';
		}

function isDate(DateIn) {
    var RegExPattern = /^(?=\d)(?:(?:(?:(?:(?:0?[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0?[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})|(?:0?2(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))|(?:(?:0?[1-9])|(?:1[0-2]))(\/|-|\.)(?:0?[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2}))($|\ (?=\d)))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\ [AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$/;
    if ((DateIn.match(RegExPattern)) && (DateIn.value!='')) {
        return true;
    } else {
        return false;
    } 
}

function mNoteAlert() {
		alert('Please click the magnify icon to the right to add a note.');
	}
	
function isNumeric(pString)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < pString.length && IsNumber == true; i++) 
      { 
      Char = pString.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }

function mFileUpload(pFileUploadID, pFileFieldID) {
			//Figure out the center of the screen
			var vWinWidth = 450;
			var vWinHeight = 175;
			var vWinTop = (screen.height / 2) - (vWinHeight / 2);
			var vWinLeft = (screen.width / 2) - (vWinWidth / 2);
			winFileUpload = window.open("/module/system/fileupload/fileupload.asp?FileUploadID=" + pFileUploadID + "&FileFieldID=" + pFileFieldID,"WIN_FILEUPLOAD", "height=" + vWinHeight + ", width=" + vWinWidth + ", top=" + vWinTop + ", left=" + vWinLeft + ", menubar=0, location=0, resizable=0, status=0");
			winFileUpload.focus();
	}

function mAlertPopup(EntityID, EntityGID)
	{
		//Figure out the center of the screen
		var vWinWidth = 700;
		var vWinHeight = 400;
		var vWinTop = (screen.height / 2) - (vWinHeight / 2);
		var vWinLeft = (screen.width / 2) - (vWinWidth / 2);
		winAlertPopup = window.open("/module/System/Alert/AlertList.asp?EntityID=" + EntityID + "&EntityGID=" + EntityGID,"WAI_ALERT", "height=" + vWinHeight + ", width=" + vWinWidth + ", top=" + vWinTop + ", left=" + vWinLeft + ", menubar=0, scrollbars=1, location=0, resizable=0, status=0");
		winAlertPopup.focus();
	}

	function isDate(DateIn) {
    var RegExPattern = /^(?=\d)(?:(?:(?:(?:(?:0?[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0?[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})|(?:0?2(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))|(?:(?:0?[1-9])|(?:1[0-2]))(\/|-|\.)(?:0?[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2}))($|\ (?=\d)))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\ [AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$/;
    if ((DateIn.match(RegExPattern)) && (DateIn.value!='')) {
        return true;
    } else {
        return false;
    } 
}

