/** Function to find an element by its ID. @argument objectId String containing id of the element */ function findDOM(objectId) { // general check for DOM support var DOMsupported = 0; var standardDOMsupported = 0; var ieDOMsupported = 0; var netscapeDOMsupported = 0; if (document.getElementById) {standardDOMsupported = 1; DOMsupported = 1;} else { if (document.all) {ieDOMsupported = 1; DOMsupported = 1;} else if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion ==4)) {netscapeDOMsupported = 1; DOMsupported = 1;} } if (standardDOMsupported) {return (document.getElementById(objectId));} if (ieDOMsupported) {return (document.all[objectId]);} if (netscapeDOMsupported) {return (document.layers[objectId]);} } /** Function to display a confirm DHTML popup containing 2 buttons with text. First buttonpress (Yes button) calls confirmationPressYes() function. Second buttonpress (No button) calls confirmationPressNo. These functions need to be implemented in the pages that call this function. @argument confirmationText String containing the text of the confirmation. @argument yesButtonText String containing the text of the Yes button. @argument noButtonText String containing the text of the No button. */ function confirmYesNo( confirmationText, yesButtonText, noButtonText ) { var div = findDOM("spiderConfirmation"); if (!div) { // since this layer can overlap with form elements, namely select element we make sure they don't by specifying absolute position var nWidth = 100; var nHeight = 20; div = document.createElement("div"); div.setAttribute("id","spiderConfirmation"); var headerColourFilter=""; if(document.all){ headerColourFilter=" filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=1, StartColorStr='#FF102468', EndColorStr='#FFa5cbf7');"; } var cnt='\ \
 Spider Confirm Alert
\

' + confirmationText + '

\ \
\ \ \ \ \ \ \
\
\
\ '; div.innerHTML=cnt; div.style.position = 'absolute'; document.body.appendChild(div); div.style.left = nWidth+'px'; div.style.top = nHeight+'px'; return true; } } /** Function to create a centered popup window @argument myUrl String containing popup url @argument myHeight String containing url height @argument myWidth String containing url width */ function popUpWindow(myUrl, myHeight, myWidth) { popUpWindowPos(myUrl, myHeight, myWidth, "center"); } /** Function to create a popup window, with the additional capability to specify the position of the window. @argument myUrl String containing popup url @argument myHeight String containing url height @argument myWidth String containing url width @argument myPosition "center" - center of screen "left", "right" - fully left or right of screen, vertically centered "top" or "bottom" - fully top or bottom of screen, vertically centered "rightheight" - full right of screen, over entire height */ function popUpWindowPos(myUrl, myHeight, myWidth, myPosition) { var winName = 'popUpSpider'; var toolbar = 0; var location = 0; var directories = 0; var status = 0; var menubar = 0; var scrollbars = 1; var resizable = 1; var top; var left; if(myPosition=="center") { top = (screen.height/2)-(myHeight/2); left = (screen.width/2)-(myWidth/2); } else if(myPosition=="left") { top = (screen.availHeight/2)-(myHeight/2); left = 0; } else if(myPosition=="right") { top = (screen.availHeight/2)-(myHeight/2); left = screen.availWidth-myWidth-10; // 10=guessed size of windowborder } else if(myPosition=="rightheight") { top = 0; myHeight = screen.availHeight - 30; // 30=guessed size of windowborder left = screen.availWidth-myWidth-10; // 10=guessed size of windowborder } else if(myPosition=="top") { top = 0; left = (screen.width/2)-(myWidth/2); } else if(myPosition=="bottom") { top = screen.availHeight-myHeight - 30; // 30=guessed size of windowborder left = (screen.width/2)-(myWidth/2); } else { top=0; left=0; } var param = "width=" + myWidth + ",height=" + myHeight + ",toolbar=" + toolbar + ",location=" + location + ",directories=" + directories + ",status=" + status + ",menubar=" + menubar + ",scrollbars=" + scrollbars + ",resizable=" + resizable + ",top=" + top + ",left=" + left; var popUp = window.open(myUrl, winName, param); popUp.focus(); } /** Function to create a popup window that passes form parameters from opener to popup window using append string To be used as: popUpParams('url', 400, 600, 'formName', new Array('field1Name','field2Name',..), true) @argument myUrl String containing popup url @argument myHeight String containing url height @argument myWidth String containing url width @argument formObject Form object @argument fieldObjectArray Array containing strings of field names @argument hasAppendString Boolean, use true for hasAppendString if myUrl already has an append string, otherwise false */ function popUpParams(myUrl, myHeight, myWidth, formObject, fieldObjectArray, hasAppendString) { // build up append string var appendString = ""; var appendStartToken = "?"; var appendToken = "&"; if (hasAppendString == true) { appendStartToken = "&"; } var loops = fieldObjectArray.length; var firstValue = true; for (var i = 0; i < loops; i++) { var obj = eval('document.' + formObject + '.' + fieldObjectArray[i]); var value = getGeneralSingleInputValue(obj, false); if (value) { // if it exists add name value pair if (firstValue == true) { appendString += appendStartToken + fieldObjectArray[i] + "=" + value; firstValue = false; } else { appendString += appendToken + fieldObjectArray[i] + "=" + value; } } } // call popup with the right url var myAppendedUrl = myUrl + appendString; popUpWindow(myAppendedUrl, myHeight, myWidth); } /** Function to create a confirmation window @argument yesUrl String containing yes action url @argument noUrl String containing no action url */ function confirmAction(yesUrl, noUrl) { var conf = confirm(warningMessage); if (conf) { self.location = yesUrl; } else { self.location = noUrl; } } /** Function to create a decision tree made of confirmation windows Example call: confirmTree(new Array('message1','message2','message3'), 'redirect.html') You progress through the tree by positive actions (yes button) A negative actions (cancel button) stops the function @argument messageArray Array containing a string of messages @argument yesUrl String containing yes action url @argument noUrl String containing no action url */ function confirmTree(messageArray, yesUrl, noUrl) { var loops = messageArray.length; for (var i = 0; i < loops; i++) { var conf = confirm(messageArray[i]); if (conf) { if (i == (messageArray.length - 1)) { window.location.href = yesUrl; return; } } else { // negative action if (i == (messageArray.length - 1)) { window.location.href = noUrl; return; } } } return; } /** Function to change the url of pop-up opener page, close pop-up window In a link used as: @argument newOpenerUrl String containing url to be opened */ function changeUrlOpenerCloseSelf(newOpenerUrl) { window.opener.location.href = newOpenerUrl; self.close(); } /** Function to close window */ function exit() { window.close(); } /** Functions to pass values from a popup window to its opener and close the popup window @argument formField String @argument codeField String @argument textField String @argument codeText String @argument nameText String */ function selectAndExit(formField, codeField, textField, codeText, nameText) { opener.document.forms[formField].elements[textField].value = nameText; opener.document.forms[formField].elements[codeField].value = codeText; window.close(); } /** Functions to pass default values from a popup window to its opener and close the popup window @argument formField String @argument textField String @argument codeField String @argument defaultText String */ function clearAndExit(formField, textField, codeField, defaultText) { opener.document.forms[formField].elements[textField].value = defaultText; opener.document.forms[formField].elements[codeField].value = ''; window.close(); } /** Functions sort form fields and submit form @argument formField String @argument sortColumnField String @argument sortAscendingField String @argument columnName String */ function sort(formField, sortColumnField, sortAscendingField, columnName) { if (document.forms[formField].elements[sortColumnField].value == columnName) { if (document.forms[formField].elements[sortAscendingField].value == 'true') { document.forms[formField].elements[sortAscendingField].value = 'false'; } else { document.forms[formField].elements[sortAscendingField].value = 'true'; } } else { document.forms[formField].elements[sortAscendingField].value = 'true'; } document.forms[formField].elements[sortColumnField].value=columnName; document.forms[formField].submit(); } /** Function to clear all text, password, textarea, radio & checkbox element values of a form Select (one & multiple) element values are set to first value available Called by: onclick="clearForm('myFormName')" @argument formName String with name of form */ function clearForm(formName) { var formArrayLength = eval('window.document.' + formName + '.elements.length'); var formTypes = new Array(formArrayLength); for (var i = 0; i < formArrayLength; i++) { formTypes[i] = eval('window.document.' + formName + '.elements['+ i +'].type'); if ((formTypes[i] == 'text') || (formTypes[i] == 'password') || (formTypes[i] == 'textarea')) { eval('window.document.' + formName + '.elements['+ i +'].value = ""'); } else if ((formTypes[i] == 'radio') || (formTypes[i] == 'checkbox')) { eval('window.document.' + formName + '.elements['+ i +'].checked = false'); } else if ((formTypes[i] == 'select-one')) { eval('window.document.' + formName + '.elements['+ i +'].options[0].selected = true'); } else if ((formTypes[i] == 'select-multiple')) { var optionSize = eval('window.document.' + formName + '.elements['+ i +'].length'); for (j = 0; j < optionSize; j++) { eval('window.document.' + formName + '.elements['+ i +'].options[' + j + '].selected = false'); } eval('window.document.' + formName + '.elements['+ i +'].options[0].selected = true'); } } } /** Function to expand/collapse the