window.onerror = reportError; // assign error handler function reportError(message, url, lineNumber, alertUser){ //show the user the error message var errMsg = "The following Javascript error has occurred:-%OD%OAURL: "+ url + "%OD%OALINE: " + lineNumber + "%OD%OAERROR: " + message if (alertUser!=false){ alert( errMsg ); } //redirect the user to a error occured page var pathName = location.pathname.split('.nsf'); self.location = "http://"+ location.host + pathName[0] + ".nsf/frmJSErrors?openform&e=" + errMsg return true; } function addressBox(fieldName, ListField, ButtonName) {var pathName; pathName = location.pathname.split('.nsf'); document.forms[0].PopupList.value = document.forms[0][ListField].value; document.forms[0].ButtonName.value = ButtonName ; abURL = "WebSelectionBox?OpenForm"; addressField = fieldName; popupWin=openDialogBox( abURL, "300","370"); } function addressBoxSingle(fieldName, ListField, ButtonName) {var pathName; pathName = location.pathname.split('.nsf'); document.forms[0].PopupList.value = document.forms[0][ListField].value; document.forms[0].ButtonName.value = ButtonName ; abURL = "WebSelectionBoxSingle?OpenForm"; addressField = fieldName; popupWin=openDialogBox( abURL, "300","370"); } function edit() //function to put the document in edit mode { var locstr = new String(self.location); var newstr = locstr.toLowerCase().replace("read","edit") ; self.location = newstr; } /*Common JavaScript functions*/ var newWind function openDialogBox(urlString,height,width){ /*this function open a dialog box and center's it*/ var url, pathName pathName = location.pathname.split('.nsf'); url = pathName[0] + '.nsf/' + urlString; if ( !newWind || newWind.closed) { newWind = launchCenter(url,'center',height,width); newWind.focus() } else { //bring existing subwindow to the front newWind.focus() } } /*end function openDialogBox*/ function launchCenter(url, name, height, width) { var str = "height=" + height + ",innerHeight=" + height; str += ",width=" + width + ",innerWidth=" + width + " scrollbars=no"; if (window.screen) { var ah = screen.availHeight - 30; var aw = screen.availWidth - 10; var xc = (aw - width) / 2; var yc = (ah - height) / 2; str += ",left=" + xc + ",screenX=" + xc; str += ",top=" + yc + ",screenY=" + yc; } return window.open(url, name, str); } /*end function launchCenter*/ function removeAttachments(category,odocid) { /*call function to delete attachment*/ /*param: category the document belongs to */ var form = document.forms[0]; var documents; documents = getSelectedDocuments(form.selecteddocs); if (documents != "") { if( confirm( " Are you sure you want to remove attachments?" ) ) { openDelWindow(documents,category,odocid); } } else { alert("You must select a document to delete"); } } function openDelCommentsWindow( docid ){ /*launch invisible window to delete attachment*/ frm = document.forms[0]; var url, pathName, elemName pathName = location.pathname.split('.nsf'); elemName = "agtDeleteComments?OpenAgent&docid=" + docid url = pathName[0] + '.nsf/' + elemName; if ( !newWind || newWind.closed) { newWind = window.open(url,"del", "toolbar=false,location=false,directories=false,status=false,menubar=false,scrollbars=false,resizable=false,width=1,height=1, left=1, top=1" ) } else { //bring existing subwindow to the front newWind.focus() } } function openDelWindow( key, category,odocid ){ /*launch invisible window to delete attachment*/ frm = document.forms[0]; var url, pathName, elemName pathName = location.pathname.split('.nsf'); elemName = "agtDeleteAttachments?OpenAgent&u=" + key + "&c=" + category + "&oid=" + odocid url = pathName[0] + '.nsf/' + elemName; if ( !newWind || newWind.closed) { newWind = window.open(url,"del", "toolbar=false,location=false,directories=false,status=false,menubar=false,scrollbars=false,resizable=false,width=1,height=1, left=1, top=1" ) } else { //bring existing subwindow to the front newWind.focus() } } function getSelectedDocuments(obj) { /*given a checkbox object this function returns the selections*/ var documents = ""; var checklen; var field = obj if (isNaN(field.length)) { if (field.checked == true) return field.value } else { for( i = 0; i < field.length; i++ ) { if( field[i].checked && field[i].value != "" ) { if( documents == "" ) { documents = field[i].value; } else { documents = documents + ";" + field[i].value; } } } // end for } return documents; } // function getSelectedDocuments function refreshDoc( sAnchor ) { if( sAnchor == "" || sAnchor == null ) { _doClick( "$Refresh", this, null, null ); } else { _doClick( "$Refresh", this, "_self", "#" + sAnchor ); } } function openDBRelativeURL( elemName ){ pathName = location.pathname.split('.nsf'); location.href = pathName[0] + '.nsf/' + elemName; } var browser = (navigator.appName == 'Microsoft Internet Explorer' && navigator.appVersion.indexOf('3') > -1) ? '$ie3' : '$nn'; function fieldZoomBox( fieldName ) { var zfURL = 'frmFieldZoom?ReadForm'; zoomField = fieldName; var zoomWin=openDialogBox(zfURL,'500','600'); } function fieldZoomBox1( fieldName ) { var zfURL = 'frmFieldZoom?ReadForm'; zoomField = fieldName; var zoomWin=openWindow1(zfURL,'500','600'); } //this function opens a new window with the specified url, window name, width and height function openWindow(url) { var specs = "toolbar=no,directories=no,status=no,resizable=no,scrollbars=no,width=620,height=320,top=28,left=5"; if ( !newWind || newWind.closed) { newWind = window.open(url,"windowName", specs); } else { //bring existing subwindow to the front newWind.focus() } } function setFieldFocusColor(obj,status) { /*this function set the background color of field that has focus*/ if (status==1) { (!valStatus) ? obj.style.backgroundColor="orange" : obj.style.backgroundColor='beige' valStatus = true; } else { (!valStatus) ? obj.style.backgroundColor="orange" : obj.style.backgroundColor='white' } } function checkKey(e, pattern) { //validate pattern var kcode = ( e.keyCode ) ? e.keyCode : e.charCode; return (e.keyCode==9 || e.keyCode==32 ? true : pattern.test ( String.fromCharCode ( kcode ) ) ); } function doCookie(cookieName, value) { if(document.cookie) { index = document.cookie.indexOf(cookieName); } else { index = -1; } if (index == -1) document.cookie = cookieName+"=" + value + ";expires=Tuesday, 01-Apr-2020 08:00:00 GMT"; else { countbegin = (document.cookie.indexOf("=", index) + 1); countend = document.cookie.indexOf(";", index); if (countend == -1) { countend = document.cookie.length; } document.cookie=cookieName+"="+value+";expires=Tuesday, 01-Apr-2020 08:00:00 GMT"; } } function getCookie(name) { var dc = document.cookie; var prefix = name + "="; var begin = dc.indexOf("; " + prefix); if (begin == -1) { begin = dc.indexOf(prefix); if (begin != 0) return null; } else begin += 2; var end = document.cookie.indexOf(";", begin); if (end == -1) end = dc.length; return unescape(dc.substring(begin + prefix.length, end)); } function redirectToView() { var view = getCookie("SSFLastView"); openDBRelativeURL(unescape(view)); } function hideFields(theFormName){ var theForm; if (document.forms[theFormName]){ theForm = document.forms[theFormName]; for(var i=0;i 0 ? unescape(r).split(',') : '') } function getSelectedkeys(obj) { var form = document.forms[0]; var selected = new Array(); var field = obj; var x = 0; if (isNaN(field.length)) { if (field.checked == true) {selected[0]=field.value; return selected;} } else { for ( var i = 0; i < obj.length; i++ ) { if ( obj[i].checked) { selected[x] = obj[i].value; x++; } } } return selected } function openDialogBoxFileMenu(urlString,height,width){ /*this function open a dialog box and center's it*/ var url, pathName pathName = location.pathname.split('.nsf'); url = pathName[0] + '.nsf/' + urlString; if ( !newWind || newWind.closed) { newWind = launchCenterFileMenu(url,'center',height,width); newWind.focus() } else { //bring existing subwindow to the front newWind.focus() } } /*end function openDialogBox*/ function launchCenterFileMenu(url, name, height, width) { var str = "height=" + height + ",innerHeight=" + height; str += ",width=" + width + ",innerWidth=" + width + " scrollbars=yes"; if (window.screen) { var ah = screen.availHeight - 30; var aw = screen.availWidth - 10; var xc = (aw - width) / 2; var yc = (ah - height) / 2; str += ",left=" + xc + ",screenX=" + xc; str += ",top=" + yc + ",screenY=" + yc; str += ", menubar=yes" } return window.open(url, name, str); } /*end function launchCenter*/ function resizeWin() { if (document.all) { winHeight=document.all['bodyArea'].offsetHeight; winWidth=document.all['bodyArea'].offsetWidth; } // add 30 to the width for a border // add 60 to the height to account for a border + the titlebar window.resizeTo(winWidth+30,winHeight+60); //centre the window //if (window.moveTo) //window.moveTo((screen.availWidth-winWidth)/2,(screen.availHeight-winHeight)/2); } function Display(min, sec) { var disp; if (min <= 9) disp = " 0"; else disp = " "; disp += min + ":"; if (sec <= 9) disp += "0" + sec; else disp += sec; return (disp); } function Down() { sec--; if (sec == -1) { sec = 59; min--; } window.status = "Session will time out in: " + Display(min, sec); if (min == 0 && sec == 0) { alert("Please push the Save button to ensure your connection does not time out, and your work is not lost."); } else down = setTimeout("Down()", 1000); } function timeIt() { min = 10; sec = 0; Down(); } function search() { var frm = document.forms[0]; var viewtype = frm.SearchType.options[frm.SearchType.selectedIndex].text; switch(viewtype) { case "Confirmation No": var viewname = "WebEventRegistrationbyConfNo"; break; case "Surname": var viewname = "WebEventRegistrationbySurname"; break; case "Company": var viewname = "WebEventRegistrationbyCompany"; break; case "Email Address": var viewname = "WebEventRegistrationbyEmail"; break; default: } var searchval = frm.searchstring.value.toLowerCase(); openDBRelativeURL(viewname + "?openview&RestricttoCategory="+searchval); } function resetView() { // openDBRelativeURL("WebEventRegistration?openview&login"); var frm = document.forms[0]; frm.searchstring.value = ''; frm.SearchType.selectedIndex = 0; } function CancelRegistration(sname,docid,ecode) { rExp = /~/gi; if( confirm( "Cancel registration for " + sname.replace(rExp," ") + " ?" ) ) { openDBRelativeURL("agtcancelseminar?openagent&e=WorkSafe&id="+docid+"&e="+ecode); } } function markPaid(sname,docid, ecode) { rExp = /~/gi; if( confirm( "Mark 'Paid' for " + sname.replace(rExp," ") + "?" ) ) { openDBRelativeURL("agtmarkpaid?openagent&id="+docid+"&e="+ecode); } } function markAccept(sname,docid, ecode) { rExp = /~/gi; if( confirm( "Mark 'Accept' for " + sname.replace(rExp," ") + "?" ) ) { openDBRelativeURL("agtmarkaccept?openagent&id="+docid+"&e="+ecode); } } function markDecline(sname,docid, ecode) { rExp = /~/gi; if( confirm( "Mark 'Decline' for " + sname.replace(rExp," ") + "?" ) ) { openDBRelativeURL("agtmarkdecline?openagent&id="+docid+"&e="+ecode); } } function markInvIssued(sname,docid, ecode) { rExp = /~/gi; if( confirm( "Mark 'Invoice Issued' for " + sname.replace(rExp," ") + "?" ) ) { openDBRelativeURL("agtmarkinvissued?openagent&id="+docid+"&e="+ecode); } } function cal(frmName,fldName){ var obj = eval("document.forms['"+frmName+"'].elements['"+fldName+"']") var theCal = new calendar1(obj) theCal.year_scroll-true theCal.time_comp=false theCal.popup() } function replaceSubstring(inputString, fromString, toString) { // Goes through the inputString and replaces every occurrence of fromString with toString var temp = inputString; if (fromString == "") { return inputString; } if (toString.indexOf(fromString) == -1) { // If the string being replaced is not a part of the replacement string (normal situation) while (temp.indexOf(fromString) != -1) { var toTheLeft = temp.substring(0, temp.indexOf(fromString)); var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length); temp = toTheLeft + toString + toTheRight; } } else { // String being replaced is part of replacement string (like "+" being replaced with "++") - prevent an infinite loop var midStrings = new Array("~", "`", "_", "^", "#"); var midStringLen = 1; var midString = ""; // Find a string that doesn't exist in the inputString to be used // as an "inbetween" string while (midString == "") { for (var i=0; i < midStrings.length; i++) { var tempMidString = ""; for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; } if (fromString.indexOf(tempMidString) == -1) { midString = tempMidString; i = midStrings.length + 1; } } } // Keep on going until we build an "inbetween" string that doesn't exist // Now go through and do two replaces - first, replace the "fromString" with the "inbetween" string while (temp.indexOf(fromString) != -1) { var toTheLeft = temp.substring(0, temp.indexOf(fromString)); var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length); temp = toTheLeft + midString + toTheRight; } // Next, replace the "inbetween" string with the "toString" while (temp.indexOf(midString) != -1) { var toTheLeft = temp.substring(0, temp.indexOf(midString)); var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length); temp = toTheLeft + toString + toTheRight; } } // Ends the check to see if the string being replaced is part of the replacement string or not return temp; // Send the updated string back to the user } // Ends the "replaceSubstring" function function Left(str, n){ if (n <= 0) return ""; else if (n > String(str).length) return str; else return String(str).substring(0,n); } function Right(str, n){ if (n <= 0) return ""; else if (n > String(str).length) return str; else { var iLen = String(str).length; return String(str).substring(iLen, iLen - n); } }