<!--

// 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 ClearDate (strField) {document.getElementById(strField).value = '';}
	
	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 GetParentPage(PageURL){parent.location.href=PageURL}
	
	function GotoPageNewWindow(PageURL){window.open(PageURL,"","");}
		
	function Highlight(RowID)
		{document.getElementById("RowID_" + RowID).style.backgroundColor='rgb(34,63,130)';
		document.getElementById("RowID_" + RowID).style.color='rgb(255,255,255)';}	
	
	function Highlight_Off(RowID)
		{document.getElementById("RowID_" + RowID).style.backgroundColor='rgb(255,255,255)';
		document.getElementById("RowID_" + RowID).style.color='rgb(50,50,50)';}
		
	function Highlight_Off_Even(RowID)
		{document.getElementById("RowID_" + RowID).style.backgroundColor='rgb(203,232,246)';
		document.getElementById("RowID_" + RowID).style.color='rgb(50,50,50)';}
		
	function iFrameHeight(HeaderBarHeight, FormName){
		var hei;
		if (self.innerHeight) // detects all browser types except Explorer...
			{hei = self.innerHeight;}
		else if (document.documentElement && document.documentElement.clientHeight)	// detects Explorer 6 in Strict Mode...
			{hei = document.documentElement.clientHeight;}
		else if (document.body) // detects other Explorers...
			{hei = document.body.clientHeight;}
		hei = hei - (HeaderBarHeight * 1.5);
		hei = hei + 'px';
		document.getElementById(FormName).style.height = hei;}
		
	function iFrameHeight_Sub(FormName, HeaderBarHeight)
		{var y = 0;
		y = (HeaderBarHeight - 37);
		y = (document.body.clientHeight) - y;
		document.getElementById(FormName).height = y;}
		
	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 PrintTableSearch(strTable,strSearch,strPageTitle,strOrderBy)
		{var URL = "Table_Search_Print.asp?Table=" + strTable + "&Search=" + strSearch + "&PageTitle=" + strPageTitle + "&OrderBy=" + strOrderBy;
		window.open(URL);}
		
	function ResetDate (strField) {document.getElementById(strField).value = 'dd/mm/yyyy';}

	function Search(strURL, strField, strTable){
		var strSearch = document.getElementById(strField).value
		var URL = strURL + "?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 (Calendar.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;
		mywindow.close();}

	function calendar_popup(formname,fieldname){
		//Get the mouse position...
		var posx = 0;
		var posy = 0;
		if (!e) var e = window.event;
		if (e.screenX || e.screenY){
			posx = e.screenX;
			posy = e.screenY;}
		else if (e.screenX || e.screenY){
			posx = e.screenX + document.body.scrollLeft + document.documentElement.scrollLeft;
			posy = e.screenY + document.body.scrollTop + document.documentElement.scrollTop;}
		//then open the calendar window at the mouse position
		mywindow=open('Calendar.asp','myname','resizable=no, width=205, height=165, top=' + (posy - 185) + ', left=' + (posx - 235) );
		strURL = 'Calendar.asp?formname=' + formname + '&fieldname=' + fieldname;
		mywindow.location.href = strURL;
		if (mywindow.opener == null) mywindow.opener = self;}
//******************** CALENDAR (Calendar.asp) calling code ends here *********************************
