function mContextMenu()
	{
		return true;
	}
	
	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 the changes to the document.  Click OK if you want to discard the changes and continue.")
			 
			if (answer) 
				{
					window.top.iDocChangeFlag = 0;
					return 0;
				}
			else
				{
					alert ("You must click the SAVE button on the document to save your changes.")
					return 1;
				}
				
			}
		else
			{

			return 0;

			}
		
		}

function mDocChanged()
	{
		//alert('Here');
		window.top.iDocChangeFlag = 1;
	}
	
function mCheckBoxSecurity(NameIn, StateIn, FieldStatusIn)
	{
		
		if (StateIn == 'CHECKED')
			{
				var ChkStatus = true;
			}
		else
			{
				var ChkStatus = false;
			}
			
		if (FieldStatusIn == 'READONLY')
			{
				document.getElementById(NameIn).checked = ChkStatus;
			}
	}
	
function mDocSaved()
	{
		//alert('Here');
		window.top.iDocChangeFlag = 0;
	}

function URLEncode(StringIn)
	{
		
				StringIn = StringIn.replace(" ", "%20");
				StringIn = StringIn.replace("\"", "%22");
				StringIn = StringIn.replace("#", "%23");
				StringIn = StringIn.replace("&", "%26");
				
				return StringIn.replace("+", "%2B");

	}
	
function CleanLink(LinkIn)
	{
		var TempLink = LinkIn;
		
		TempLink = TempLink.replace('http://', ' ');
		TempLink = TempLink.replace('mailto:', ' ');
		
		return TempLink;
	}
	
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 mMultiPickPopup(FieldIDIn, MultiPickGIDIn, SourceParam1In, ValueParam1In, FunctionIn, CheckFilterIn)
	{
		var ChkSum = 0;

		//Check the Check Filter
		if (CheckFilterIn == '')
			{
				ChkSum = 1;
			}
		else
			{
				if  (document.getElementById(FieldIDIn + 'Filter').value != '')
					{
						ChkSum = 1;
					}
				else
					{
						alert('You must select a ' + CheckFilterIn + '.');
					}
			}
	
		if (ChkSum == 1)
			{
			//Figure out the center of the screen
			var stop = (window.screen.availheight / 2) - (275 / 2);
			var sleft = (window.screen.availwidth / 2) - (150 / 2);
			winMultiPickPopup = window.open("/Module/System/MultiPick/MultiPick.asp?FieldID=" + FieldIDIn + "&MultiPickGID=" + MultiPickGIDIn + "&SourceParam1=" + SourceParam1In + "&ValueParam1=" + ValueParam1In + "&Function=" + URLEncode(FunctionIn),"WAI_MULTIPICKPOPUP", "height=275, width=150, top=" + stop + ", left=" + sleft + ", menubar=0, location=0, resizable=0, status=0");
			winMultiPickPopup.focus();
			}	
	}

function FindPopupMV(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) + "&FindMV=1","WAI_FINDPOPUP", "height=400, width=500, top=" + stop + ", left=" + sleft + ", menubar=0, location=0, resizable=0, status=0");
			winFindPopup.focus();
			}	
	}

function DynamicFindPopup(FieldID, 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 FindGID = document.getElementById(FieldID + 'FindID').value;
			var FindDesc = document.getElementById(FieldID + 'FindDesc').value;
			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 CalendarWeek(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 + "&TimeOption=" + TimeOptionIn + "&Mode=Week","WAI_CALENDAR", "height=235, width=216, top=" + stop + ", left=" + sleft + ", menubar=0, location=0, resizable=0, status=0");
		winCalendar.focus();
	}
	
function VOCWeekCalendar(AccountEquipmentGIDIn, FieldIn, WeekStartIn, 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/futuremaker/VOC/VOCWeekCalendar.asp?WeekStart=" + WeekStartIn + "&AccountEquipmentGID=" + AccountEquipmentGIDIn + "&Field=" + FieldIn + "&TimeOption=" + TimeOptionIn + "&Mode=Week","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 mPPEPopup() {
		//Figure out the center of the screen
		var stop = (window.screen.availheight / 2) - (500 / 2);
		var sleft = (window.screen.availwidth / 2) - (300 / 2);
		winPPEPopup = window.open("/images/PPE/PPELegend.asp","WAI_PPE", "height=500, width=300, top=" + stop + ", left=" + sleft + ", menubar=0, location=0, resizable=0, status=0");
		winPPEPopup.focus();
}
	
function OpenEvent(EventGIDIn, TargetDateIn, TargetUserIn)
		{
			//Figure out the center of the screen
			var stop = (window.screen.availheight / 2) - (560 / 2);
			var sleft = (window.screen.availwidth / 2) - (760 / 2);

			if (EventGIDIn == '')
				{
					EventGIDIn = TargetDateIn + '|' + TargetUserIn
				}

			winEventPopup = window.open("/Module/System/DocMenu/DocMenu.asp?MenuLinkID=EventModify&PageLinkID=EventGID&EventGID=" + URLEncode(EventGIDIn),"WAI_EVENT", "height=560, width=760, top=" + stop + ", left=" + sleft + ", menubar=0, location=0, resizable=0, status=0");
			winEventPopup.focus();
		}
		
function mHelp(HelpIDIn)
	{
		//Figure out the center of the screen
		var stop = (window.screen.availheight / 2) - (250 / 2);
			var sleft = (window.screen.availwidth / 2) - (400 / 2);
		winHelp = window.open("/Module/System/Help/Help.asp?HelpID=" + HelpIDIn,"WAI_HELP", "height=250, width=400, top=" + stop + ", left=" + sleft + ", menubar=0, location=0, resizable=1, status=0");
		winHelp.focus();
	}

function OpenControlLink(NameIn, LinkTypeIn)
		{
			var sLink = CleanLink(document.getElementById(NameIn).value);

			if (sLink != '')
				{ 
					if (LinkTypeIn == 'URL')
						{
							winLinkPopup = window.open('http://' + sLink);
							winLinkPopup.focus();
						}
					
					if (LinkTypeIn == 'EMAIL')
						{
							winLinkPopup = window.open('mailto:' + sLink);
						}
					
					
						
				}
		}
