<!--

// Short functions below in alphabetical order for easy Find / Edit.
// More complex functions are below these...
		
	function ChangeParentLocation(ParentURL){self.parent.location.href = ParentURL;}
	
	function ConfirmAction(PageURL){var agree=confirm("Please confirm...");
		if (agree){self.location.href=PageURL;}
		else{return false;}}
		
	function ConfirmCopy(PageURL){var agree=confirm("Please confirm...");
		if (agree){self.location.href=PageURL;}
		else{return false;}}
		
	function DeleteRecord(strTable,intID){
		if (confirm("Please confirm record deletion. Note: This action cannot be undone.")==true)
			{var URL = "record_delete.asp?table=" + strTable + "&ID=" + intID;
			window.location.href = URL;}
		else{return false;}}
		
	function FullScreen(){window.moveTo(60,0);
		window.resizeTo((screen.width - 60), screen.height);}
		
	function ResizeWindow(){window.moveTo(100,100);
		window.resizeTo(200, 200);}
		
	function GetParentPage(PageURL){parent.location.href=PageURL}
	
	function GotoPageNewWindow(PageURL){self.location.href=PageURL;}
		
	function Highlight(RowID){document.getElementById("RowID_"+RowID).style.backgroundColor='rgb(150,150,150)';
		document.getElementById("RowID_"+RowID).style.color='rgb(255,255,198)';}	
	
	function Highlight_Off(RowID){document.getElementById("RowID_"+RowID).style.backgroundColor='rgb(255,255,198)';
		document.getElementById("RowID_"+RowID).style.color='rgb(50,50,50)';}
		
	function iFrameHeight(FormName){document.getElementById(FormName).height = (document.body.clientHeight) - 90;}
		
	function iFrameHeight_Sub(FormName){document.getElementById(FormName).height = (document.body.clientHeight) - 30;}
		
	function PrintInvoice(intID){var URL = "invoice_print.asp?ID=" + intID;
		window.open(URL);}
		
	function PrintQuote(intID){var URL = "quote_print.asp?ID=" + intID;
		window.open(URL);}
		
	function PrintRecord(SQL,PageTitle){var URL = "Record_Print.asp?SQL=" + SQL + "&PageTitle=" + PageTitle;
		window.open(URL);}
		
	function PrintTableSearch(strTable,strSearch,strPageTitle,strOrderBy)
		{var URL = "Table_Search_Print.asp?Table=" + strTable + "&Search=" + strSearch + "&PageTitle=" + strPageTitle + "&OrderBy=" + strOrderBy;
		window.open(URL);}

	function Search(strSearch, strTable){var URL = "Search_Table.asp?Search=" + strSearch + "&Table=" + strTable;
		frames['Subform'].location.href = URL;}

	function showStatus(sMsg){window.status = sMsg;
		return true;}
		
	function WindowCloser(){opener.location.reload(true);
		this.close();}
		
	function WindowCloserParent(){parent.window.close();}

// More complex start here...
		
	function DropDownMenu(){
		document.write ("<div id='object1' style='text-align=right; position=absolute; visibility=show; left=660px; top=10px; z-index=2;'>");
		document.write ("<form name='search' action='search.asp?'>");
		document.write ("<font color=rgb(255,255,198)>Type in search item & press 'Enter'</font>&nbsp;")
		document.write ("<input type='text' name='search'");
		document.write ("style='width=120; background=rgb(255,255,198); font-family=Verdana; font-size=10px;'>");
		document.write ("</form>");
		document.write ("<form name='menu'>");
		document.write ("<select name='site' size='1' onChange='javascript: window.location.href = document.menu.site.options[document.menu.site.selectedIndex].value;'");
		document.write ("style='width=120; background=rgb(255,255,198); font-family=Verdana; font-size=10px;'>");
		document.write ("<option value=''>Main Menu:");
		document.write ("<option value='clients.asp?orderby=ID'>Clients</option>");
		document.write ("<option value='diary.asp?orderby=ID'>Diary</option>");
		document.write ("<option value='jobs.asp?orderby=ID'>Jobs (All Open)</option>");
		document.write ("<option value='jobsclosed.asp?orderby=ID'>Jobs (All Closed)</option>");
		document.write ("<option value='reports.asp'>Reports</option>");
		document.write ("<option value='table.asp?table=users&orderby=ID'>Users</option>");
		document.write ("</select>");
		document.write ("</form>");
		document.write ("</div>");}

//******************** DATE INPUT MASK - starts here ***********************************************
	function inputmask(str,textbox,loc,delim)
		{
			var locs = loc.split(',');
				for (var i = 0; i <= locs.length; i++)
					{
						for (var k = 0; k <= str.length; k++)
							{
								if (k == locs[i])
									{
										if (str.substring(k, k+1) != delim)
											{
												if (event.keyCode != 8)
													{ //backspace
														str = str.substring(0,k) + delim + str.substring(k,str.length);
													}
											}
									}
							}
					}
			textbox.value = str
		}
//******************** DATE INPUT MASK - ends here ***************************************************

//******************** CALENDAR (CAL.ASP) calling code starts here ***********************************
	function y2k(number)
		{
			return (number < 1000) ? number + 1900 : number;
		}
	
		var today = new Date();
		var day   = today.getDate();
		var month = today.getMonth();
		var year  = y2k(today.getYear());
	
	function padout(number)
		{
			return (number < 10) ? '0' + number : number;
		}
	
	function restart(formname, fieldname)	
		{
			document.forms[formname].elements[fieldname].value = '' + padout(day) + '/' + padout(month - 0 + 1) + '/' + year;
			//document.Add.dob.value = '' + padout(day) + '/' + padout(month - 0 + 1) + '/' + year;
			mywindow.close();
		}
	
	function calendar_popup(formname,fieldname)
		{
			var strFieldName = fieldname
			// Detect if the browser is IE or not.
			// If it is not IE, we assume that the browser is NS.
			var IE = document.all?true:false
			// If NS -- that is, !IE -- then set up for mouse capture
			if (!IE) document.captureEvents(Event.MOUSEMOVE)
			// Temporary variables to hold mouse x-y pos.s
			var tempX = 0
			var tempY = 0
			if (IE)
				{ // grab the x-y pos.s if browser is IE
					tempX = event.clientX + document.body.scrollLeft
					tempY = event.clientY + document.body.scrollTop
				}
			else
				{  // grab the x-y pos.s if browser is NS
				tempX = e.pageX
				tempY = e.pageY
				}  
			// catch possible negative values in NS4
			if (tempX < 0){tempX = 0}
			if (tempY < 0){tempY = 0}  
			//then open the calendar window at the mouse position
			mywindow=open('../../../cal.asp','myname','resizable=no, width=205, height=170, top=' + tempY + ', left=' + tempX );
			strURL = '../../../cal.asp?formname=' + formname + '&fieldname=' + fieldname;
			mywindow.location.href = strURL;
			if (mywindow.opener == null) mywindow.opener = self;
		}
//******************** CALENDAR (CAL.ASP) calling code ends here ***********************************

	function validateForm(strRealName, strEmail)
		{
			windowProperties = "toolbar=no, menubar=no, scrollbars=no, statusbar=no, resizable=no, location=no, directories=no, dependent=yes, "
			windowProperties = windowProperties + "statusbar=no, width=200, height=80, left=200, top=344"
			
			if (strRealName=="")
			{
				newWindow = window.open ("","", windowProperties)
				dialogOption = 1
				dialogBoxHTMLValidate()
				return false
			}
			if (strRealName=="Enter your name")
			{
				newWindow = window.open ("","", windowProperties)
				dialogOption = 1
				dialogBoxHTMLValidate()
				return false
			}
	
			if (strEmail=="")
			{
				newWindow = window.open ("","", windowProperties)
				dialogOption = 2
				dialogBoxHTMLValidate()
				return false
			}
			if (strEmail=="Enter your email")
			{
				newWindow = window.open ("","", windowProperties)
				dialogOption = 2
				dialogBoxHTMLValidate()
				return false
			}			
		}
-->