var SMIOS = {}; //Create a global object to hook things onto so that they don't interfere with local variables /*=-=-=-=-=-=-[Constants]-=-=-=-=-=-=*/ // In ASP.NET 2.0 prefix is ctl100_centralContent_, changed to centralContent_ in ASP.NET 4.0 // This behaviour can be overriden by changing to in Web.config // or by adding AutoID to Page or controls in a page var asp = "ctl00_centralContent_"; ///var asp = "centralContent_"; var d = String.fromCharCode(6); //delimitter used for arrays - this seemed smart at the time but then I learned a lot and now this seems silly var server_error_message = 'There was an error connecting to the server. Please wait a while and try again. If the error persists, please contact the administrator.'; //this message will be used in the error function of jquery ajax calls /*=-=-=-=-=-=-[End Constants]-=-=-=-=-=-=*/ /*=-=-=-=-=-=-[Compatibility]-=-=-=-=-=-=*/ var compat_id = false; var compat_all = false; var compat_layer = false; var isMSIE = /*@cc_on!@*/false;//Test for IE /*@cc_on if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x; var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number if (ieversion>=8) ieversion = 8; else if (ieversion>=7) ieversion = 7; else if (ieversion>=6) ieversion = 6; else if (ieversion>=5) ieversion = 5; else ieversion = 4; } @*/ //Verify that getElementById exists and can be used. if (typeof document.getElementById == 'function' || (typeof document.getElementById === 'object' && isMSIE)) { compat_id = true; } else { //If not check for document.all if (document.all) { compat_all = true; } else { //If not, see if "layers" are valid var browserVersion = parseInt(navigator.appVersion, 10); if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion >= 4)) { compat_layer = true; } } } function dom(objectID, aspname) { /* This function is used to return an element from the XHTML * markup and is meant to be cross-browser compatible. */ if (typeof aspname == 'boolean') { objectID = asp + objectID; } //Ensure a valid string was passed to the function if (typeof objectID == 'string') { if (compat_id == true) { //If document.getElementById() is a valid function return (document.getElementById(objectID)); } else { //If document.all is a valid collection if (compat_all) { return (document.all[objectID]); } else { //If document.layers is a valid collection if (compat_layer) { return (document.layers[objectID]); } } } } //If no valid string or no valid objects, return nothing return; } function GetWindowHeight() { /* This function returns the height of the user's * browser window. */ var height = 0; if (typeof (window.innerHeight) == 'number') { //Non-IE height = window.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) { //IE 6+ in 'standards compliant mode' height = document.documentElement.clientHeight; } else if (document.body && (document.body.clientHeight)) { //IE 4 compatible height = document.body.clientHeight; } return height; } function GetWindowWidth() { /* This function returns the width of the user's * browser window. */ var width = 0; if (typeof (window.innerWidth) == 'number') { //Non-IE width = window.innerWidth; } else if (document.documentElement && document.documentElement.clientWidth) { //IE 6+ in 'standards compliant mode' width = document.documentElement.clientWidth; } else if (document.body && document.body.clientWidth) { //IE 4 compatible width = document.body.clientWidth; } return width; } function GetScrollLeft() { /* This function returns the offset of the user's * horizontal scroll bar. */ var scrollleft = 0; if (window.pageXOffset) { scrollleft = window.pageXOffset; } else if (document.documentElement && document.documentElement.scrollLeft) { scrollleft = document.documentElement.scrollLeft; } else if (document.body && document.body.scrollLeft) { scrollleft = document.body.scrollLeft; } return scrollleft; } function GetScrollTop() { /* This function returns the offset of the user's * vertical scroll bar. */ var scrolltop = 0; if (window.pageYOffset) { scrolltop = window.pageYOffset; } else if (document.documentElement && document.documentElement.scrollTop) { scrolltop = document.documentElement.scrollTop; } else if (document.body && document.body.scrollTop) { scrolltop = document.body.scrollTop; } return scrolltop; } /*=-=-=-=-=-=-[End Compatibility]-=-=-=-=-=-=*/ /*=-=-=-=-=-=-[General HTML/DOM Functions]-=-=-=-=-=-=*/ function AppendSelectOption(text,value, selectID) { //Creates a new option object and adds it to the end of a select element var option = document.createElement('option'); option.text = text; option.value = value var ddl = dom(selectID); try { ddl.add(option, null); // standards compliant; doesn't work in IE } catch(ex) { ddl.add(option); // IE only } } function ClearAllComponents(arrayContainer, arrayType) { ///description: takes an array of container IDs and an array of types; clearing all components] if (arrayContainer.length != arrayType.length) { //Array lengths do not match alert('Error: jsCommon.aspx/ClearAllComponents'); return; } for (var s = 0; s < arrayContainer.length; s++) { var container = arrayContainer[s]; var control = dom(container); if (control != null) { switch (arrayType[s]) { case "textbox": control.value = "";break; case "hidden": control.value = "";break; case "radio": control.checked = "";break; case "checkbox": control.checked = "";break; case "select": control.selectedIndex = 0;break; case "div": control.innerHTML = "";break; default: alert('Error: jsCommon.aspx/ClearAllComponents');break; } } } } function SortRowsInTable(int_StartIndex, tbody) { //Sorts all rows in a table after the selected index. Only sorts by date if date is in the first column var rows = tbody.getElementsByTagName("tr"); for (var s = int_StartIndex; s < rows.length; s++) { for (var d = s; d > rows.length; d++) { if (new Date(rows[s].getElementsByTagName("td")[0].firstChild.nodeValue) < new Date(rows[d].getElementsByID("td")[0].firstChild.nodeValue)) { var temp = rows[s]; rows[s] = rows[d]; rows[d] = temp; } } } } function AddRowsToTable(input, tbl_id, funct) { ///description: Takes a delimitted input string; char 4 between rows adn char 6 between cells; tbl or tbody id (it will find object) and optional funct for when mouse is down on var tbody = dom(tbl_id); var rows = input.split(String.fromCharCode(4)); for (var j = 0; j < rows.length; j++) { var row = tbody.insertRow(j); var cells = rows[j].split(String.fromCharCode(6)); row.setAttribute("id", cells[0]); row.onmousedown = funct; row.className = 'selector'; for (var h = 0; h < cells.length; h++) { var cell = row.insertCell(h); cell.innerHTML = cells[h]; } } } function RemoveAllChildElements(element) { //Removes all child elements from a container object (if it has any) if (typeof element == 'object' && element != null && element.hasChildNodes) { while (element.hasChildNodes()) { element.removeChild(element.childNodes[0]); } } } function AddRowToTable(tablebody, arycolvals) { if (typeof tablebody != 'object' || tablebody == null) { return null; } if (typeof arycolvals.constructor == 'function' || (typeof arycolvals.constructor === 'object' && isMSIE)) { //Check if arycolvals is an array if (arycolvals.constructor.toString().replace(/^\s*|\s*$/g, '').substr(8, 8) === ' Array()') { //arycolvals is an array var row = tablebody.insertRow(-1); //Add new row for (var i = 0; i < arycolvals.length; i++) { var cell = row.insertCell(i); //Add the cell cell.innerHTML = arycolvals[i]; //Set the text } return row; } } return null; } function AddHoverHighlight(objecttoaddto, changecursor) { /* This function is used to add highlighting to an element. It will maintain any original * functionality within the onmouseover and onmouseout events and also has the option to * change the cursor. */ if (typeof objecttoaddto != 'object' || objecttoaddto == null) { return; } if (typeof changecursor != 'boolean' || changecursor == null) { changecursor = false; } var oldonmouseover = null; var oldonmouseout = null; if (typeof objecttoaddto.onmouseover == 'function' || (typeof objecttoaddto.onmouseover === 'object' && isMSIE)) { oldonmouseover = objecttoaddto.onmouseover; } if (typeof objecttoaddto.onmouseout == 'function' || (typeof objecttoaddto.onmouseout === 'object' && isMSIE)) { oldonmouseout = objecttoaddto.onmouseout; } if (changecursor) { objecttoaddto.style.cursor = 'pointer'; } objecttoaddto.onmouseover = function() { objecttoaddto.style.background = '#5cbfe9'; objecttoaddto.style.color = '#ffffff'; if (oldonmouseover != null) { oldonmouseover(); } } objecttoaddto.onmouseout = function() { objecttoaddto.style.background = ''; objecttoaddto.style.color = ''; if (oldonmouseout != null) { oldonmouseout(); } } } function GetSelectedValue(selectelement, boolText) { /* Gets the selected text or value from a drop down list. Returns blank * if nothing is selected or an error occurred. */ if (typeof selectelement != 'object' || selectelement == null) {alert('bad select get: ' + typeof selectelement); return ''; } //FIXX: Remove bad select get when done testing var retval = ''; if (typeof boolText != 'boolean') { //Return the text of the selected element try { retval = selectelement.options[selectelement.selectedIndex].text; } catch (ex) { } } else { //Return the value of the selected element try { retval = selectelement.options[selectelement.selectedIndex].value; } catch (ex) { } } return retval; } function GrayOut(vis, options) { // Pass true to gray out screen, false to ungray // options are optional. This is a JSON object with the following (optional) properties // opacity:0-100 // Lower number = less grayout higher = more of a blackout // zindex: # // HTML elements with a higher zindex appear on top of the gray out // bgcolor: (#xxxxxx) // Standard RGB Hex color code // grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'}); // Because options is JSON opacity/zindex/bgcolor are all optional and can appear // in any order. Pass only the properties you need to set. var options = options || {}; var zindex = options.zindex || 50; var opacity = options.opacity || 70; var opaque = (opacity / 100); var bgcolor = options.bgcolor || '#000000'; var dark=document.getElementById('darkenScreenObject'); if (!dark) { // The dark layer doesn't exist, it's never been created. So we'll // create it here and apply some basic styles. // If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917 var tbody = document.getElementsByTagName("body")[0]; var tnode = document.createElement('div'); // Create the layer. tnode.style.position='absolute'; // Position absolutely tnode.style.top='0'; // In the top tnode.style.left='0'; // Left corner of the page tnode.style.overflow='hidden'; // Try to avoid making scroll bars tnode.style.display='none'; // Start out Hidden tnode.setAttribute('id','darkenScreenObject');// Name it so we can find it later tbody.appendChild(tnode); // Add it to the web page dark=document.getElementById('darkenScreenObject'); // Get the object. } if (vis) { // Calculate the page width and height if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) { if (GetWindowWidth() > document.body.scrollWidth) { var pageWidth = GetWindowWidth()+'px'; } else { var pageWidth = document.body.scrollWidth+'px'; } if (GetWindowHeight() > document.body.scrollHeight) { var pageHeight = GetWindowHeight()+'px'; } else { var pageHeight = document.body.scrollHeight+'px'; } } else if( document.body.offsetWidth ) { if (GetWindowWidth() > document.body.offsetWidth) { var pageWidth = GetWindowWidth()+'px'; } else { var pageWidth = document.body.offsetWidth+'px'; } if (GetWindowHeight() > document.body.offsetHeight) { var pageHeight = GetWindowHeight()+'px'; } else { var pageHeight = document.body.offsetHeight+'px'; } } else { var pageWidth='100%'; var pageHeight='100%'; } //set the shader to cover the entire page and make it visible. dark.style.opacity=opaque; dark.style.MozOpacity=opaque; dark.style.filter='alpha(opacity='+opacity+')'; dark.style.zIndex=zindex; dark.style.backgroundColor=bgcolor; dark.style.width= pageWidth; dark.style.height= pageHeight; dark.style.display='block'; } else { dark.style.display='none'; } } function CreateCentredDiv(width,content,id,cssclass) { /* This function will create a centred DIV tag with the specified * width, height, content, ID and css class. */ if (isNaN(width) || typeof(content) != 'string') { return; } //Check for valid arguments if (!dom(id)) { /*var newdiv1 = document.createElement('div'); //Create the back div newdiv1.style.background = 'url(\'/Resources/Images/grayback.gif\')'; newdiv1.style.backgroundRepeat = 'repeat'; newdiv1.style.zIndex = '9998'; newdiv1.style.position = 'absolute'; newdiv1.style.top = 0; newdiv1.style.left = 0; newdiv1.style.width = '100%'; newdiv1.style.height = '100%'; // Add the div tag to the document try { document.body.appendChild(newdiv1); } catch (er) { } */ var newdiv = document.createElement('div'); //Create the div //Set the ID so that it can be referenced later if (id && typeof(id) == 'string' ) { newdiv.setAttribute('id', id); } if (cssclass && typeof(cssclass) == 'string' ) { newdiv.className = cssclass; } newdiv.innerHTML = content; //Set the content for the tag var divstyle = newdiv.style; //Prevent extra dom look-ups divstyle.width = width + 'px'; //Set the width divstyle.height = 'auto'; //Set the height divstyle.position = 'absolute'; //Position it absolutely in the document divstyle.zIndex = '9999'; //Make sure it gets displayed higher than everything divstyle.backgroundColor = "#fff"; document.body.appendChild(newdiv); //Add the div so we can get the offset values divstyle.top = (GetScrollTop() + (GetWindowHeight() / 2) - (newdiv.offsetHeight / 2)) + 'px'; //Centre the tag vertically divstyle.left = (GetScrollLeft() + (GetWindowWidth() / 2) - (newdiv.offsetWidth / 2)) + 'px'; //Centre the tag horizontally var frm = document.createElement('iframe'); var frmstyle = frm.style; frmstyle.left = divstyle.left; frmstyle.top = divstyle.top; frmstyle.height = newdiv.offsetHeight; frmstyle.width = newdiv.offsetWidth; frmstyle.zIndex = '9998'; frmstyle.display = 'block'; frmstyle.position = 'absolute'; frmstyle.border = '0'; frm.setAttribute('id', id + '-frm'); // Add the div tag to the document document.body.appendChild(frm); } } /*=-=-=-=-=-=-[End General HTML/DOM Functions]-=-=-=-=-=-=*/ /*=-=-=-=-=-=-[Showing/Hiding Objects]-=-=-=-=-=-=*/ function ToggleShowHide(objid, disptype) { /* This function is used to toggle an XHTML element between * display:none and display:block|other (as defined by disptype) */ //Ensure object ID is a string if (typeof objid != 'string') { return; } //Set default display type if not set if (typeof disptype != 'string') { disptype = 'block'; } //Get the object to work with var obj = dom(objid); //Verify that the object is valid if (typeof obj === 'object' && obj != null) { //If it is currently not displayed, show it, else hide it if (obj.style.display == 'none') { obj.style.display = disptype; } else { obj.style.display = 'none' } } } function ShowObj(objid, disptype) { /* This function is used to set an XHTML element's display style * property. */ //Ensure object ID is a string if (typeof objid != 'string') { return; } //Set default display type if not set if (typeof disptype != 'string' || disptype == '') { disptype = 'block'; } //Verify that the object is valid if (typeof dom(objid) === 'object' && dom(objid) != null) { //Show the object dom(objid).style.display = disptype; } } function HideObj(objid) { /* This function is used to set an XHTML element's display style * property to 'none'. */ //Ensure object ID is a string if (typeof objid != 'string') { return; } //Verify that the object is valid if (typeof dom(objid) === 'object') { //Hide the object dom(objid).style.display = 'none'; } } function EnableObj (objid) { /* This function is used to set an XHTML element's display style * property to 'none'. */ //Ensure object ID is a string if (typeof objid != 'string') { return; } //Verify that the object is valid if (typeof dom(objid) === 'object') { //Hide the object dom(objid).disabled = false; } } function DisableObj (objid) { /* This function is used to set an XHTML element's display style * property to 'none'. */ //Ensure object ID is a string if (typeof objid != 'string') { return; } //Verify that the object is valid if (typeof dom(objid) === 'object') { //Hide the object dom(objid).disabled = true; } } /*=-=-=-=-=-=-[End Showing/Hiding Objects]-=-=-=-=-=-=*/ /*=-=-=-=-=-=-[Help Pop-ups]-=-=-=-=-=-=*/ function HelpPopUp(owner, tagname, title, desc, event) { /* The HelpPopUp function is used for displaying help information in the bottom corner * of the screen. It sets up a div tag that will appear on the bottom right side of the * screen. It also defines the function for the onmouseout event so that the user does * not have to add this. */ // Validate parameters to ensure that they are all valid types. if (typeof owner !== 'object' || typeof tagname != 'string' || typeof title != 'string' || typeof desc != 'string') { return; } // Get the object if it exists. var obj = dom('helpobj-' + tagname); // Check if the div already exists if (!obj) { // If it doesn't exist, create a new div tag var helpobj = document.createElement('div'); //Set the ID so that it can be referenced later helpobj.setAttribute('id', 'helpobj-' + tagname); //Set the inline positioning based on the offset of the owner var offset = $(owner).offset(); helpobj.setAttribute('style', "top:"+offset.top+"px;left:"+offset.left+"px"); //Add the CSS class information to the new div helpobj.className = 'helppopup'; //Remove the old mouseover owner.onmouseover = null; //Set the inner HTML code helpobj.innerHTML = '
' + title + '
' + desc + '
'; //Set up the hover functions to make the pop-up hide when the mouse leaves var $owner = $(owner), $helpobj = $(helpobj); $owner.hover(function(evt) { $helpobj.show(); }, function(evt) { $helpobj.hide(); }); $helpobj.hover(function(evt) { $helpobj.show(); }, function(evt) { $helpobj.hide(); }); // Add the div tag to the document document.body.appendChild(helpobj); } } /*=-=-=-=-=-[End Help Pop-ups]-=-=-=-=-=*/ /*=-=-=-=-=-[AJAX/XML HTTP Request Object]-=-=-=-=-=*/ function GetXmlHttpObject() { var xmlhttpfound = false; //boolean var to tell if XMLHTTPRequest has been loaded. var xmlhttp; // Set the xmlhttp variable to false //Turn on compiler conditions and execute only if javascript is a certain version /*@cc_on@*/ /*@if (@_jscript_version >= 5) // JScript gives us Conditional compilation, we can cope with old IE versions. // and security blocked creation of the objects. // Try to create objects (IE only) try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); xmlhttpfound = true; } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); xmlhttpfound = true; } catch (E) { xmlhttpfound = false; } } @end@*/ //If the objects couldn't be created, create for most other browsers. if (!xmlhttpfound && typeof XMLHttpRequest != 'undefined') { try { xmlhttp = new XMLHttpRequest(); xmlhttpfound = true; } catch (e) { xmlhttpfound = false; } } //If that didn't work try it for IceBrowser if (!xmlhttpfound && window.createRequest) { try { xmlhttp = window.createRequest(); xmlhttpfound = true; } catch (e) { xmlhttpfound = false; } } return xmlhttp; } function AJAXWrapper(postTo, postString, onLoadedFunc) { /* This method is meant to simplify sending ajax requests. * It supports the passing of a two-dimensional array (first dimension=names, second=values) * or the post string directly. It also supports running a function when * the request completed by passing a function as the third argument. */ var poststr = ''; //Check if postString has a constructor function if (typeof postString.constructor == 'function' || (typeof postString.constructor === 'object' && isMSIE && postString.constructor != null)) { //Check if postString is an array if (postString.constructor.toString().replace(/^\s*|\s*$/g,'').substr(8,8) === ' Array()') { //postString is an array //Check if its first dimension has a length of two (names and values) if (postString.length == 2) { //Make sure the name dimension has the same length as the value dimension if (postString[0].length == postString[1].length) { //Loop through the arrays and add them to the post string, also encode the values for (var i = 0; i < postString[0].length; i++) { poststr += (i != 0 ? '&' : '') + postString[0][i] + '=' + encodeURIComponent(postString[1][i]); } } else { //Array lengths don't match alert('Post string inner array lengths don\'t match!'); return; } } else { //The first dimension of the array doesn't have exactly two items alert('Invalid post string array!'); return; } } } //If postString is not an array if (poststr == '') { //Make sure it is of type string if (typeof postString != 'string') { //Not of type string alert('Invalid post string.'); return; } else { //Is of type string poststr = postString; } } //Validate the page we're posting to if (typeof postTo != 'string') { alert('Invalid post to string.'); return; } //Get the XML HTTP Object var xmlHttp = GetXmlHttpObject(); //Ensure it was created if (xmlHttp == null) { alert('Browser does not support HTTP Request'); return; } //Set up the result set variable var resultset; try { //Create a 'POST' session xmlHttp.open('POST', postTo, false); //Set it to encoded form xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); //Add ajax=1 (tells the page that it's an ajax request) and a random number (to prevent caching) to the post string poststr = poststr + (poststr.lastIndexOf("&") == (poststr.length - 1) ? '' : '&') + 'ajax=1&randomnum=' + Math.random(); //Send the request xmlHttp.send(poststr); //Read the response resultset = (xmlHttp.responseText); if (xmlHttp.readyState == 4) { //If onLoadedFunc is a function, run it try { if (typeof onLoadedFunc == 'function' || (typeof onLoadedFunc === 'object' && isMSIE && onLoadedFunc != null)) { onLoadedFunc(); } } catch (ex) { } } } catch (ex) { //Something went wrong, reset the response. resultset = ''; alert('There was a problem with the request. If this persists, please contact the Service Metrics Help Desk.'); } //Return the response. return resultset; } function AJAXHandler(postTo,postString,onLoadedFunc,onErrorFunc) { /* This method is meant to simplify sending ajax requests. * It supports the passing of a two-dimensional array (first dimension=names, second=values) * or the post string directly. It also supports running a function when * the request completed by passing a function as the third argument. */ var poststr = ''; if (ValidateArray(postString, 2, true)) { //'postString' is Valid Array Loop through the arrays and add them to the post string, also encode the values for (var i = 0; i < postString[0].length; i++) { poststr += (i != 0 ? '&' : '') + postString[0][i] + '=' + encodeURIComponent(postString[1][i]); } } else if (postString != null && typeof(postString) == "string") { //'postString' is a string poststr = postString; } else { //Invalid 'postString' object alert('There was a problem making the request (Invalid Post String).'); return null; } //Validate the page we're posting to if (typeof postTo != 'string') { alert('Invalid post to string.'); return; } //Get the XML HTTP Object var xmlHttp = GetXmlHttpObject(); //Ensure it was created if (xmlHttp == null) { alert('Browser does not support HTTP Request'); return; } //Set up the result set variable var resultset; try { //Create a 'POST' session xmlHttp.open('POST', postTo, false); //Set it to encoded form xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); //Add ajax=1 (tells the page that it's an ajax request) and a random number (to prevent caching) to the post string poststr = poststr + (poststr.lastIndexOf("&") == (poststr.length - 1) ? '' : '&') + 'ajax=1&randomnum=' + Math.random(); //Send the request xmlHttp.send(poststr); //Read the response resultset = (xmlHttp.responseText); resultset = ValidateResultSet(resultset,onErrorFunc); if (xmlHttp.readyState == 4) { //If onLoadedFunc is a function, run it if (typeof onLoadedFunc == 'function' || (typeof onLoadedFunc === 'object' && isMSIE && onLoadedFunc != null)) { onLoadedFunc(); } } } catch (ex) { //Something went wrong, reset the response. alert(ex.description); resultset = null; } //Return the response. return resultset; } function ValidateResultSet(resultSet,onErrorFunc) { //Validates AJAXWrapper 'resultSet' responses switch (resultSet.substring(0,1)) { case "0": //On success return resultSet.substr(1); case "1": alert(resultSet.substr(1)); return null; case "2": return null; case "3": //Used in situations where a control should be changed with no error message present if (onErrorFunc != null && typeof(onErrorFunc) == 'function' || (typeof onErrorFunc === 'object' && isMSIE && onErrorFunc != null)) { //If onErrorFunc is a function, run it onErrorFunc(resultSet.substr(1)); } return null; default: // alert(resultSet); this alert was for testing alert('There was no response from the server, please try again. If the problem persists please contact the administrator.'); return null; } } function update(xmlobject) { var root = xmlobject.getElementsByTagName('ResultSet')[0]; var filters = root.getElementsByTagName('Field'); for (var i = 0; i < filters.length; i++) { var filter = filters[i]; var loc = ""; try { loc = filter.getElementsByTagName('Location')[0].firstChild.nodeValue; dom(loc).value = filter.getElementsByTagName('Value')[0].firstChild.nodeValue; } catch (Exception) { dom(loc).value = ""; } finally { } } } function PopulateControls(arraySet) { //Requires a three dimensioned arraySet: 1D - ids of controls; 2D - content for controls; 3D - type of control //Populates control with content, initialising based on type of control if (ValidateArray(arraySet, 3, true)) { for (var s = 0; s < arraySet[0].length; s++) { var control = dom(arraySet[0][s]); var content = arraySet[1][s]; var type = arraySet[2][s]; if (control != null && type != null && content != null) { if (type == 'textbox' || type == 'hidden') { control.value = content; } else if (type == 'checkbox' || type=='radio') { UpdateCheckBox(control, content); } else if (type == 'select') { searchList(content, control); } else if (type == 'div') { control.innerHTML = content; } else { alert('dev: Error in PopulateControls'); } } } } else { alert('dev: ValidateArray failed'); console.log(arraySet); } } function DelimitControls(arraySet) { //Creates a delimitted string from 2D arraySet - 1D is ControlID; 2D is Type if (ValidateArray(arraySet, 2, true)) { var strDel = ""; for (var h = 0; h < arraySet[0].length; h++) { if (h > 0) { strDel += String.fromCharCode(6); } var control = dom(arraySet[0][h]); var type = arraySet[1][h]; if (control != null && type != null) { if (type == 'textbox' || type == 'hidden') { strDel += control.value; } else if (type == 'checkbox') { strDel += UpdateCheckBox(control, '', true); } else if (type == 'select') { strDel += ddlValue(control); } else { alert('dev: DelimitControls type unrecognised'); } } } if (strDel.length > 1) return strDel; } else { alert('dev: ValidateArray failed'); } } function PopulateSelect(object, delString, fillIndex0,optStrFirstText, optStrFirstValue) { ///description: Takes a delimitted string, breaks it into an array and loads the elements into an HTML select object ///param 'object': Variable container for HTML Select Object ///param 'delString': Delimitted string using char 6 as a delimitter, must be ordered by {value, text, value, text} ///param 'fillIndex0': Optional; If true the first index of select element gets populated by an empty space, or by following optional parameters ///param 'optStrFirstText': Initial value for first elements text ///param 'optStrFirstValue': Initial value for first elements value if (object != null && typeof(object) == "object" && delString.length > 4) { RemoveAllChildElements(object); var arraySet = new Array(); if (typeof(fillIndex0) == 'boolean' && fillIndex0) { if (optStrFirstText == null) optStrFirstText = ""; if (optStrFirstValue == null) optStrFirstValue = ""; arraySet = arraySet.concat([optStrFirstValue,optStrFirstText],delString.split(String.fromCharCode(6))); } else { arraySet = delString.split(String.fromCharCode(6)); } if (arraySet.length % 2 == 1 && arraySet[arraySet.length-1].length <= 0) { arraySet = arraySet.slice(0, arraySet.length-1); } if (arraySet.length % 2 == 0) { for(var s = 0; s < arraySet.length; s+=2) { object.options[s/2] = new Option(arraySet[s+1], arraySet[s]); } } } } function PopulateTable(table, delString, colCount, optInitHeader) { //(object, string, int, bool) //takes a delimitted string (char 6) and a number of columns and adds the rows and cells to a table or tbody; optional first row is header if (table != null) RemoveAllChildElements(table); if (table != null && delString != null && colCount != null) { if (optInitHeader == null) optInitHeader = false; var elements = delString.split(String.fromCharCode(6)); for (var q = 0; q < ((elements.length - 1) / colCount); q++) { //This should be each row var row = table.insertRow(q); if (q > 0 || (!optInitHeader)) { for (var p = 0; p < colCount; p++) { var cell = row.insertCell(p); cell.innerHTML = elements[p + colCount * q]; } } else if (q == 0 && optInitHeader) { for (var p = 0; p < colCount; p++) { var cell = row.insertCell(p); cell.innerHTML = "" + elements[p + colCount * q] + ""; } } } } } /*=-=-=-=-=-[End AJAX/XML HTTP Request Object]-=-=-=-=-=*/ /*=-=-=-=-=-=-[Loading Pop-up]-=-=-=-=-=-=*/ function ShowLoader(runFunc) { /* This method is used to display a "Please Wait" screen for the * user for things like when AJAX is loading/querying. */ var longTimeLength = 3; //Seconds until longTime expires var longCancelLength = 7; //Seconds until longCancel expires // Get the object if it exists. var obj = dom('common-loader'); if (typeof obj === 'object' && obj != null) { //Exists, make it visible //Gray out the background GrayOut(true); //Reset the loader object ResetLoader(); //Recentre the tag obj.style.top = (GetScrollTop() + (GetWindowHeight() / 2) - 125) + 'px'; //Centre the tag vertically obj.style.left = (GetScrollLeft() + (GetWindowWidth() / 2) - 25) + 'px'; //Centre the tag horizontally var ldrfrm = (dom('common-loader-frm') ? dom('common-loader-frm').style : null); if (ldrfrm) { ldrfrm.top = obj.style.top; ldrfrm.left = obj.style.top; } //Set the timeout timers obj.longTimeTimer = setTimeout("ResizeLoader(450,100);ShowObj('loader-longtime');", longTimeLength * 1000); obj.longCancelTimer = setTimeout("HideObj('loader-longtime');ResizeLoader(450,120);ShowObj('loader-longcancel');", longCancelLength * 1000); //Show it obj.style.display = 'block'; if (ldrfrm) { ldrfrm.display = 'block'; } } else { //Gray out the background GrayOut(true); //Doesn't exist, create it. CreateCentredDiv(250,'
Please wait...
Loading...
','common-loader','sessionwarning'); var loader = dom('common-loader'); //Show the long time text/long time loader cancel after x/y number of seconds. loader.longTimeTimer = setTimeout("ResizeLoader(450,100);ShowObj('loader-longtime');", longTimeLength * 1000); loader.longCancelTimer = setTimeout("HideObj('loader-longtime');ResizeLoader(450,120);ShowObj('loader-longcancel');", longCancelLength * 1000); } if (typeof runFunc == 'function' || (typeof runFunc === 'object' && isMSIE && runFunc != null) || typeof runFunc == 'string') { //This allows IE to process hiding the other sections // and show the "Please wait" div. setTimeout(runFunc, 10); } } function ResizeLoader(width, height) { /* This method is used to resize the loader object. */ if (!width && !height) { return; } var loaderstyle = (dom('common-loader') ? dom('common-loader').style : null); var loaderfrmstyle = (dom('common-loader-frm') ? dom('common-loader-frm').style : null); //The IFrame used to block IE from displaying drop-downs through the div tag var div = dom('common-loader'); if (loaderstyle) { if (height) { var oldheight = parseInt(div.offsetHeight); var oldtop = parseInt(loaderstyle.top.replace(/px/,'')); loaderstyle.height = height + 'px'; loaderstyle.top = (oldtop + (oldheight / 2) - (height / 2)) + 'px'; if (loaderfrmstyle) { loaderfrmstyle.height = loaderstyle.height; loaderfrmstyle.top = loaderstyle.top; } } if (width) { var oldwidth = parseInt(loaderstyle.width.replace(/px/,'')); var oldleft = parseInt(loaderstyle.left.replace(/px/,'')); loaderstyle.width = width + 'px'; loaderstyle.left = oldleft + (oldwidth / 2) - (width / 2); if (loaderfrmstyle) { loaderfrmstyle.width = loaderstyle.width; loaderfrmstyle.left = loaderstyle.left; } } } } function HideLoader() { /* This method is used to hide the "Please Wait" screen for the * user. */ //Reset the loader ResetLoader(); //Show the content again GrayOut(false); } function ResetLoader(recentre) { /* This method is used to reset the "Please Wait" screen for the * user. It clears the timeouts and hides the object. */ //Get the loader object var obj = dom('common-loader'); //Validate loader object if (typeof obj !== 'object' || obj == null) { return; } //Hide the loader object obj.style.display = 'none'; //Check if the longTime timeout exists if (obj.longTimeTimer !== null) { //Clear it if it does. clearTimeout(obj.longTimeTimer); obj.longTimeTimer = null; } //Check if the longCancel timeout exists if (obj.longCancelTimer !== null) { //Clear it if it does. clearTimeout(obj.longCancelTimer); obj.longCancelTimer = null; } //Optimize for IE, prevents extra DOM look-up var Hide = HideObj; //Hide the longTime and longCancel texts for re-use. Hide('loader-longtime'); Hide('loader-longcancel'); Hide('common-loader-frm'); ResizeLoader(250,50); } function SetContentDisplay(dispType) { //Ensure the dispType is valid. Default to show (block). if (typeof dispType != 'string' || dispType == null) {dispType = 'block'; } try { //Change the display for each section of the main layout if (dom('master_header') != null) { dom('master_header').style.display = dispType; } if (dom('master_topmenu') != null) { dom('master_topmenu').style.display = dispType; } if (dom('master_banner') != null) { dom('master_banner').style.display = dispType; } if (dom('master_powerbar') != null) { dom('master_powerbar').style.display = 'none'; } if (dom('master_powerbar_js') != null) { dom('master_powerbar_js').style.display = dispType; } if (dom('master_content_holder') != null) { dom('master_content_holder').style.display = dispType; } if (dom('master_footer') != null) { dom('master_footer').style.display = dispType; } } catch (er) { } } /*=-=-=-=-=-=-[End Loading Pop-up]-=-=-=-=-=-=*/ /*=-=-=-=-=-=-[HTML Encoding/Decoding]-=-=-=-=-=-=*/ function HTMLEntityDecode(item) { if (typeof item != 'string') { return item; } item = item.replace(/\&/g, '&'); item = item.replace(/\</g, '<'); item = item.replace(/\"/g, '"'); item = item.replace(/\©/g, '©'); item = item.replace(/\®/g, '®'); item = item.replace(/\«/g, '«'); item = item.replace(/\&raqou;/g, '»'); item = item.replace(/\'/g, "'"); return item; } function HTMLEntityEncode(item) { if (typeof item != 'string') { return item; } item = item.replace(/\&/g, '&'); item = item.replace(/\ */ var keynum; //Create local scoped variable to hold key number if (window.event) { // IE keynum = evnt.keyCode; } else if (evnt.which) { // Netscape/Firefox/Opera keynum = evnt.which; } //Check if it was the return key if (keynum == 13) { //Call the function if so return false; } else { return true; } } function ValidateArray(array, arrayLength, multiDim) { //Tests 'array' to check if it is an array. If a length should be defined 'arrayLength' should be included. If a multiDim array should have components that are all teh same length make this true //Check if 'array' has a constructor function if (typeof array.constructor == 'function') { //Check if 'array' is an array if (array.constructor.toString().replace(/^\s*|\s*$/g, '').substr(8, 8) === ' Array()') { //'array' is an array //Check to see if arrayLength is initialised and is a number if (arrayLength != null && !isNaN(arrayLength) && arrayLength > 0) { //Check if the first dimension has defined length if (array.length == arrayLength) { if (typeof(multiDim) == 'boolean' && multiDim) { for (var f = 1; f < arrayLength; f++) { //Checks that each dimension is the same length as the first dimension 'array[0]' if (array[0].length != array[f].length) { return false; } } return true; } return true; } } else if (arrayLength == null) { return true; } } } return false; } /*=-=-=-=-=-=-[End Validation]-=-=-=-=-=-=*/ ///description: convert 1's or True's to yes ///parameter 'input': string, taken right from database from a small int or bit field ///returns 'output': string formatted as 'Yes' or 'No' for display purposes //FIXX: Doesn't use LANG. Not sure if this is appropriate to be changed function yesIt(input) { var output = 'No'; switch (input) { case '1': output = 'Yes'; break; case '0': output = 'No'; break; case 'True': output = 'Yes'; break; case 'False': output = 'No'; break; default: break; } return output; } //FIXX: Same as above but goes the other way function reverseIt(input) { var output = '0'; switch (input) { case 'Yes': output = '1'; break; case 'No': output = '0'; break; case 'True': output = '1'; break; case 'False': output = '0'; break; default: break; } return output; } function searchList(text, ddl, optBoolSearchByText){ var regEx = new RegExp(text, 'i'); if (typeof(optBoolSearchByText) == 'boolean'){ for (var i=0; i= 0 || option.innerHTML.indexOf(text) >= 0) { return f; } } } return -1; } function UpdateCheckBox(control, value, optBoolReverse) { if (typeof (optBoolReverse) == 'boolean') { if (value.length > 3) { switch (control.checked) { case true: return 'True'; default: return 'False'; } } else { switch (control.checked) { case true: return '1'; default: return '0'; } } } switch (value) { case '1': control.checked = true; break; case 'True': control.checked = true; break; default: control.checked = false; } } /*=-=-=-=-=-=-[Font Size]-=-=-=-=-=-=*/ function IncreaseFontSize() { /* Increases the font size in the main content area */ var contentstyle = dom('master_content').style; var sz = 10; if (contentstyle.fontSize) { sz = parseInt(contentstyle.fontSize.replace('px', '')); } if (sz < 16) { sz += 1; } SetFontSizeCookie(sz); contentstyle.fontSize = sz + 'px'; } function DecreaseFontSize() { /* Decreases the font size in the main content area */ var contentstyle = dom('master_content').style; var sz = 10; if (contentstyle.fontSize) { sz = parseInt(contentstyle.fontSize.replace('px', '')); } if (sz > 10) { sz -= 1; } SetFontSizeCookie(sz); contentstyle.fontSize = sz + 'px'; } function CheckFontSize() { if (document.cookie.length > 0) { //Check that cookies exists c_start = document.cookie.indexOf("FontSize="); //Check for the font size cookie if (c_start != -1) { //Make sure it's there c_start += 9; //Add the length of "FontSize=" to the start c_end = document.cookie.indexOf(";",c_start); //Find the end of the cookie value if (c_end == -1) { c_end = document.cookie.length; } //Check if it's the end of the cookie string var size = unescape(document.cookie.substring(c_start,c_end)); //Get the size if (size && !isNaN(size) && dom('master_content')) { //Check the size dom('master_content').style.fontSize = size + 'px'; //Set the size of the central content. } } } } function SetFontSizeCookie(fontsize) { /*This function sets the FontSize cookie*/ var exdate = new Date(); exdate.setTime(exdate.getTime() + (10 * 365 * 24 * 60 * 60 * 1000)); document.cookie="FontSize=" + escape(fontsize) + "; expires=" + exdate.toGMTString() + "; path=/"; } /*=-=-=-=-=-=-[End Font Size]-=-=-=-=-=-=*/ /*=-=-=-=-=-=-[Change Language]-=-=-=-=-=-=*/ function ChangePageLanguage(langid) { if (confirm('This will refresh the page and any unsaved changes will be lost. Are you sure that you want to continue?\n\nCeci va rafraichir la page et toutes information modifiées et non sauvegardées seront perdus. Etes-vous sur de vouloir continuer?')) { var exdate = new Date(); exdate.setTime(exdate.getTime() + (10 * 365 * 24 * 60 * 60 * 1000)); document.cookie = "lang=" + escape(langid) + "; expires=" + exdate.toGMTString() + "; path=/"; var path = window.location.href; if (path.indexOf('?') > -1) { if (path.indexOf('lang=') > -1) { path = path.replace(/lang=[0-9]/gi, 'lang=' + encodeURIComponent(langid)); } else { path = path + '&lang=' + encodeURIComponent(langid); } } else { path = path + '?lang=' + encodeURIComponent(langid); } window.location = path; } else { var langdropdown = dom('master_ddllang'); if (langdropdown) { if (langid == 1) { langdropdown.selectedIndex = 1; } else { langdropdown.selectedIndex = 0; } } } } /*=-=-=-=-=-=-[End Change Language]-=-=-=-=-=-=*/ /*=-=-=-=-=-=-=[Form Control]=-=-=-=-=-=-==-*/ function ReturnHandler(functionToCall, evnt) { /* Usage: */ //Ensure that we were passed a function] if (typeof functionToCall != 'function' && typeof functionToCall != 'object') { return; } var keynum; //Create local scoped variable to hold key number if (window.event) { // IE keynum = evnt.keyCode; } else if (evnt.which) { // Netscape/Firefox/Opera keynum = evnt.which; } //Check if it was the return key if (keynum == 13) { //Call the function if so functionToCall(); } } /*=-=-=-=-=-=-=[Form Control]=-=-=-=-=-=-==-*/ /*=-=-=-=-=-=-[Load Functions]-=-=-=-=-=-=*/ function BodyLoad() { //Hide the non-js power bar and show the js version var jspowerbar = dom('master_powerbar_js'); var powerbar = dom('master_powerbar'); if (powerbar) { powerbar.style.display = 'none'; } if (jspowerbar) { jspowerbar.style.display = 'block'; } //Update the font size when the page is loaded CheckFontSize(); } addLoadEvent(BodyLoad);//Add the body load function to the onload event /*=-=-=-=-=-[End Load Functions]-=-=-=-=-=*/ /*=-=-=-=-=-=[Dialog Functions]=-=-=-=-=-=*/ SMIOS.showMsgBox = function(msg, title, modal, callback, buttons) { SiteBase.SharedFunctions.ShowMsgBox(msg, title, modal, callback, buttons); }; /*=-=-=-=-=[End Dialog Functions]=-=-=-=-=*/