function addOption (sel) { // ==================================== //adds an option to the required drop down var tpTxt=prompt("Please enter the option required and press OK", "") if (tpTxt!=null && tpTxt!=""){ var found=-1; for (i=0;i < sel.options.length;i++) {if (sel.options[i].text==tpTxt) {found=i;}} if (found>-1) { alert (tpTxt + " is already in the list."); sel.options[found].selected = true} else { newOpt = new Option(tpTxt, 'value'); sel.options.length++; sel.options[sel.length-1].text = newOpt.text; sel.options[sel.length-1].value = newOpt.value; sel.options[sel.length-1].selected = true;}} } function mandatoryInfo ( ) { // ==================================== //this function displays a warning msg alert('This icon indicates a mandatory field.'); } function saveDocument() { // ==================================== // this function validates the current doc and submits it if ok if (validate()) document.forms[0].submit(); } function editDocument() { // ==================================== // this function puts the current document in edit mode openDbURL ('lookup0/' + document.forms[0].docId.value + '?EditDocument'); } function deleteDocument() { // ==================================== // this function deletes the current document deleteConfirm=confirm ('This will permanently delete this document.\nAre you sure you want to proceed?'); if (deleteConfirm) { openDbURL ('lookup0/' + document.forms[0].docId.value + '?DeleteDocument')} } function printDocument() { // ==================================== if (document.forms[0].IsNewDoc.value==1){ alert ( "Please save this report before printing it.")} else{ openDbURL ("lookup4/" + document.forms[0].docId.value + '?openDocument'); // window.print(); } } function ReplaceChar ( theString, findChar , repChar ) { // ==================================== //this function replaces findChar with repChard in a string trimString=""; for ( i = 0; i < theString.length; i++) { theChar=theString.substring ( i, i+1); if ( theChar == findChar) { trimString += repChar } else { trimString+=theString.substring ( i, i+1); } } return (trimString); } function ReplaceString(EntryString,Find,Replace) // ==================================== //this function replaces Find with Replace in a string {while(EntryString.indexOf(Find)!=-1) { EntryString=EntryString.substring(0,EntryString.indexOf(Find))+Replace+EntryString.substring(EntryString.indexOf(Find)+Find.length,EntryString.length); }; return EntryString}; function alertBox (vField, vMessage, vType ) { // ==================================== //this function replaces the spaces in a string with the provided character //if we pass a null message, we are doing a multiple validation test. return so we can check other conditions. if ( vMessage == "null" ) return; //otherwise, display the error message alert ( "Field Contains Incorrect Value:\n\n" + vMessage ) //and set focus (plus select the text if a text element) if ( vType == "text" ) { vField.focus(); vField.select(); } else { if ( vType != "checkbox" && vType != "radio") { vField.focus()}; } return; } function trimBlanks ( theString, repChar ) { // ==================================== //this function replaces the spaces in a string with the provided character trimString=""; for ( i = 0; i < theString.length; i++) { theChar=theString.substring ( i, i+1); if ( theChar == " ") { trimString += repChar } else { trimString+=theString.substring ( i, i+1); } } return (trimString); } function trimString(EntryString) //===================== // This function deletes leading and trailing spaces in the string EntryString { TrimmedEntryString=EntryString; while (TrimmedEntryString.substring(0,1)==' ' ) {TrimmedEntryString=TrimmedEntryString.substring(1,TrimmedEntryString.length)}; while (TrimmedEntryString.substring(TrimmedEntryString.length-1,TrimmedEntryString.length)==' ' ) {TrimmedEntryString=TrimmedEntryString.substring(0,TrimmedEntryString.length-1)}; return TrimmedEntryString; }; function failNull ( vField, vMessage, vType) { // ==================================== //this function will stop the submit if a field is null or contains all spaces //get the field value... theValue = getFieldValue (vField, vType); //if the field value is null, we fail and return true... if ( theValue == "" ) { alertBox ( vField, vMessage, vType ); return ( true ); } //remove any spaces from the value trimField = trimBlanks( theValue ); //if the field value is all spaces, fail and return true... if ( trimField =="" ) { alertBox ( vField, vMessage, vType ); return ( true ); } //otherwise continue... return ( false ); } function failContains( vField, vValue, vMessage, vType ) { // ==================================== //this function will stop the submit if a field contains a specified value (or value list) //get the field value... theValue = getFieldValue (vField, vType); //check argument list to see if we are testing multiple characters... var count = ( failContains.arguments.length == 6 ) ? vValue.length-1 : 0; var value = ( failContains.arguments.length == 6 ) ? vValue.substring(0,1) : vValue; //fail the submit if the field contains the value(s)... for ( i = 0; i <= count; i++) { if ( theValue.indexOf(value) > -1) { alertBox ( vField, vMessage, vType ); return (true); } value = ( count > 0 ) ? vValue.substring(i+1,i+2) : vValue; } //otherwise continue... return (false) } function failNotContains( vField, vValue, vMessage, vType ) { // ==================================== //this function will stop the submit if a field does not contain a specified value (or value list) //get the field value... theValue = getFieldValue (vField, vType); //check argument list to see if we are testing multiple characters... var count = ( failNotContains.arguments.length == 6 ) ? vValue.length-1 : 0; var value = ( failNotContains.arguments.length == 6 ) ? vValue.substring(0,1) : vValue; //fail the submit if the field contains the value(s)... for ( i = 0; i <= count; i++) { if ( theValue.indexOf(value) == -1) { alertBox ( vField, vMessage, vType ); return (true); } value = ( count > 0 ) ? vValue.substring(i+1,i+2) : vValue; } //otherwise continue... return (false) } function getFieldValue ( theField, vType ) { // ==================================== //this function will return the field value (or value list) based on the element type theValue = ""; sep = ""; hits = 0; //text is the user-entered value as a string if ( vType == "text" ) return ( theField.value ); //textarea is the user-entered value as a string array of one element // if ( vType == "textarea" ) return ( theField[0].value ); if ( vType == "textarea" ) return ( theField.value ); //select is an array of selection pointers to an array of strings representing the choices if ( vType == "select" ) { for ( i = 0; i < theField.options.length; i++ ) { if ( theField.options[i].selected ) theValue += theField.options[i].text } return ( theValue ); } //checkboxes & radio buttons are not so simple if ( vType == "checkbox" || vType == "radio" ) { if ( theField.value == null ) { //if we're here, we are validating a radio button or a nn multi-element checkbox for ( i = 0; i < theField.length; i++ ) { if ( theField[i].checked ) { hits++; if ( hits > 1 ) { sep = "; "; } theValue += sep + theField[i].value; } } } return ( theValue ); } else { //if we are here, must be an ie checkbox, or nn with a one-element checkbox") if ( navigator.appName == "Microsoft Internet Explorer" ) { //ie. return some data so we can validate on the server; return ("can't validate on client") } //nn one-element checkbox, see if its checked ... if (theField.checked ) { return ( theField.value ); } else { return ( "" ); } } } function setFieldValue ( theField, vType , theValue) { // ==================================== //this function will set the field value (or value list) based on the element type //theValue = ""; sep = ""; hits = 0; //text is the user-entered value as a string if ( vType == "text" ) return ( theField.value = theValue); //textarea is the user-entered value as a string array of one element // if ( vType == "textarea" ) {} //select is an array of selection pointers to an array of strings representing the choices if ( vType == "select" ) { for ( i = 0; i < theField.options.length; i++ ) { if ( theField.options[i].text == theValue ) { theField.options[i].selected = true return (true) } else { theField.options[i].selected = false } } return ( theValue ); } //checkboxes & radio buttons are not so simple if ( vType == "checkbox" || vType == "radio" ) { } else { }} function showSection(snb){ //===================== var tpLayer = document.all("section" + snb); if (tpLayer!=null) {tpLayer.style.display = ""}; var tpLayer = document.all("hideSection" + snb); if (tpLayer!=null) {tpLayer.style.display = ""}; var tpLayer = document.all("showSection" + snb); if (tpLayer!=null) {tpLayer.style.display = "none"}; } //===================== function hideSection(snb){ //===================== var tpLayer = document.all("section" + snb); if (tpLayer==null){ alert("section" + snb + " not found");} else { tpLayer.style.display = "none"; var tpLayer = document.all("hideSection" + snb); tpLayer.style.display = "none"; var tpLayer = document.all("showSection" + snb); tpLayer.style.display = ""; } } function goBack() { //===================== history.go(-1); } //===================== function wip() //===================== { alert("Feature not available."); } var eC_Remote; function SessionCookie() { this.set_cookie=set_cookie; this.delete_cookie=delete_cookie; this.get_cookie=get_cookie; } /** * Sets a Cookie with the given name and value. * name Name of the cookie * value Value of the cookie * [expires] Expiration date of the cookie (default: end of current session) * [path] Path where the cookie is valid (default: path of calling document) * [domain] Domain where the cookie is valid (default: domain of calling document) * [secure] Boolean value indicating if the cookie transmission requires a secure transmission * @return void */ function set_cookie ( name, value, exp_y, exp_m, exp_d, path, domain, secure ) { var cookie_string = name + "=" + escape ( value ); if ( exp_y ) { var expires = new Date ( exp_y, exp_m, exp_d ); cookie_string += "; expires=" + expires.toGMTString(); } if ( path ) cookie_string += "; path=" + escape ( path ); if ( domain ) cookie_string += "; domain=" + escape ( domain ); if ( secure ) cookie_string += "; secure"; document.cookie = cookie_string; //alert("METHOD WORKING"); } /* * Deletes a cookie with the name specified * @return void */ function delete_cookie ( cookie_name ) { var cookie_date = new Date ( ); // current date & time cookie_date.setTime ( cookie_date.getTime() - 1 ); document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString(); } /* * Retrieves cookie value with the name specified * @return void */ function get_cookie ( cookie_name ) { var results = document.cookie.match ( cookie_name + '=(.*?)(;|$)' ); if ( results ) return ( unescape ( results[1] ) ); else return null; }