/********************************************************* Set of JavaScript functions used throughout the database JavaScript Validation 2.0, 19/Mar/2001 Jake Howlett, http://www.codestore.org/ **********************************************************/ /*********************************************************** errorHandler() Used by Netscape to return the error message to the user. Best used only when debuggind in development. Turn on by adding the following line to a form: if (navigator.appName=="Netscape") window.onerror = errorHandler; ***********************************************************/ function errorHandler( e, f, l ) { alert("Error\nFile: " + f + "\nLine: " + l + "\nError:" + e); return true; } /*********************************************************** doDelete is used to delete the from the server The user is first asked to confirm that this is what they want to do. Giving them the chance to cancel the action. This works SIMPLY by changing the end of the URL from "?OpenDocument" to "?DeleteDocument" ************************************************************/ function doDelete() { if ( confirm('Are you sure you want to delete this document?') ){ location.search = "?DeleteDocument"; } } /*********************************************************** trim is a simple function to remove leading/trailing spaces ************************************************************/ function trim(aStr) { return aStr.replace(/^\s{1,}/, "").replace(/\s{1,}$/, "") } /*********************************************************** following two functions call the date picking dialog box ************************************************************/ function myDateDialog(){ var retDay; var retMonth; var retYear; } function openDatePickerDialog(wnd, field, dateFormat) { myDateDialog.retDay=""; myDateDialog.retMonth=""; myDateDialog.retYear=""; var pathname = window.location.pathname; var dlgURL = pathname.substring(0,(pathname.lastIndexOf(".nsf") + 5))+'dlgDatePicker?OpenForm'; if(wnd.showModalDialog(dlgURL,myDateDialog,"dialogHeight:380px;dialogWidth:280px;center")==true){ field.value=dateFormat.replace(/yyyy/, myDateDialog.retYear).replace(/mm/, myDateDialog.retMonth).replace(/dd/, myDateDialog.retDay); //added these two lines to make required icon change field.focus(); field.blur(); }else{ return; } } function addToFavorite(favTitle){ if ((navigator.appVersion.indexOf("MSIE") > 0) && (parseInt(navigator.appVersion) >= 4)) { window.external.AddFavorite(location.href, unescape(favTitle)); } } function checkSave() { alert("If you made changes to this document, the changes are not yet saved.") if (confirm("Click OK to save your changes. Click Cancel to discard any changes.")) { if ( doSubmit(document.forms[0], true ) ) document.forms[0].submit(); } } function view_replace_nodocuments(vMessage){ var h2 = document.getElementsByTagName("h2"); for (var vLoop = 0; vLoop < h2.length; vLoop++){ if (h2[vLoop].childNodes[0].nodeValue == "No documents found"){ h2[vLoop].childNodes[0].nodeValue = vMessage; } h2[vLoop].style.visibility = 'visible'; } } function jsDatePicker( szField, szDate, szAction) { var form = document.forms[0]; var field = form.elements[szField]; if(szAction == "1") { field.value=szDate; } return field.value; } function showResources() { var form = document.forms[0]; var selRes = form.Resources; var selSw = form.resSoftware; var intRes = form.Resources.length; var intSw = form.resSoftware.length; document.all.Software.style.display='none'; document.all.Equipment.style.display='none'; document.all.Phone.style.display='none'; document.all.Misc.style.display='none'; document.all.Other.style.display='none'; document.all.disc.style.display='none'; for (var i = 0; i < intRes; i++) { if (selRes[i].checked) { (selRes[i].value == 'Software') ? document.all.Software.style.display='inline-block' : ''; (selRes[i].value == 'Equipment') ? document.all.Equipment.style.display='inline-block' : ''; (selRes[i].value == 'Phone') ? document.all.Phone.style.display='inline-block' : ''; (selRes[i].value == 'Misc') ? document.all.Misc.style.display='inline-block' : ''; (selRes[i].value == 'Other') ? document.all.Other.style.display='inline-block' : ''; } } for (var i = 0; i < intSw; i++) { if (selSw[i].checked) { (selSw[i].value == 'DISC') ? document.all.disc.style.display='inline-block' : ''; } } } // Window functions v1.01 // http://www.dithered.com/javascript/window/index.html // code by Chris Nott (chris@dithered.com) // modified by Tim Morgan for use on timmorgan.info var winReference = null; // Open a window at a given position on the screen function openPositionedWindow(url, name, width, height, x, y, status, scrollbars, moreProperties, openerName) { var agent = navigator.userAgent.toLowerCase(); if (agent.indexOf("mac")!=-1 && agent.indexOf("msie") != -1 && agent.indexOf("msie 5.0")==-1) { height += 2; if (status) height += 15; } width += (scrollbars != '' && scrollbars != null && agent.indexOf("mac") == -1) ? 16 : 0; var properties = 'width=' + width + ',height=' + height + ',screenX=' + x + ',screenY=' + y + ',left=' + x + ',top=' + y + ((status) ? ',status' : '') + ',scrollbars' + ((scrollbars) ? '' : '=no') + ((moreProperties) ? ',' + moreProperties : ''); var reference = openWindow(url, name, properties, openerName); return reference; } // Open a window at the center of the screen function openCenteredWindow(url, name, width, height, status, scrollbars, moreProperties, openerName, returnRef) { var x = 0; var y = 0; if (screen) x = (screen.availWidth - width) / 2; if (screen) y = (screen.availHeight - height) / 2; if (!status) status == ''; if (!openerName) openerName == ''; var reference = openPositionedWindow(url, name, width, height, x, y, status, scrollbars, moreProperties, openerName); if (returnRef) return reference; } // Core utility function that actually creates the window and gives focus to it function openWindow(url, name, properties, openerName) { var agent = navigator.userAgent.toLowerCase(); if (agent.indexOf("msie") != -1 && parseInt(navigator.appVersion) == 4 && agent.indexOf("msie 5") == -1 && agent.indexOf("msie5") == -1 && agent.indexOf("win") != -1 && url.indexOf('http://') == 0) { winReference = window.open('about:blank', name, properties); setTimeout('if (winReference && !winReference.closed) winReference.location.replace("' + url + '")', 300); } else { winReference = window.open(url, name, properties); } setTimeout('if (winReference && !winReference.closed) winReference.focus()', 200); if (openerName) self.name = openerName; return winReference; } function openDbRelativeURL( url, target ){ //Check we have a target window; target = (target == null ) ? window : target; //Work out the path of the database; path = location.pathname.split('.nsf')[0] + '.nsf/'; target.location.href = path + url; } var isDocBeingSubmitted = false; function navigateAway() { msg = "----------------------------------------------------------\n"; msg += "Your document has not been saved.\n"; msg += "All changes you have made will be lost\n"; msg += "----------------------------------------------------------"; //inbuilt get-out: hold control key to bypass message; if (isDocBeingSubmitted == false && event.ctrlKey == false) event.returnValue = msg; }