var ALIB_ROOT = "/lib/aereus.lib.js";/*====================================================================================== Module: CAjax Purpose: Handle remote XML documents Author: Sky Stebnicki, sky.stebnicki@aereus.com Copyright (c) 2006 Aereus Corporation. All rights reserved. Usage: // Create ajax object ajax = new CAjax(); // Set callback once xml is loaded ajax.onload = function() { // Get first node var root = this.m_firstNode; var num = root.getNumChildren(); for (i = 0; i < num; i++) { // Get child nodes var model = root.getChildNode(i); if (model.m_name == "mynode") { document.write(model.m_name); document.write(model.m_text); } } }; // Get xml file ajax.exec("/path/to/xml.xml"); ======================================================================================*/ // Define constants // ----------------------------------------------------------- var AJAX_POST = 1; var AJAX_GET = 2; // Node Types var AJAX_NODE_TEXT = 3; var AJAX_NODE_HTML = 1; /*********************************************************************************** * * Class: CAjax * * Purpose: Encapsulate AJAX functionality * ***********************************************************************************/ function CAjax() { this.m_xmlLocal = null; this.m_response = null; this.m_firstNode = null; this.m_method = AJAX_GET; if (window.XMLHttpRequest) { this.m_xmlLocal = new XMLHttpRequest(); } else { var msxmlhttp = new Array('Msxml2.XMLHTTP.5.0', 'Msxml2.XMLHTTP.4.0', 'Msxml2.XMLHTTP.3.0', 'Msxml2.XMLHTTP', 'Microsoft.XMLHTTP'); for (var i = 0; i < msxmlhttp.length; i++) { try { this.m_xmlLocal = new ActiveXObject(msxmlhttp[i]); } catch (e) { this.m_xmlLocal = null; } } } } /*********************************************************************************** * * Function: exec * * Purpose: Send request to server using http get * * Arguements: url - string: path to xml document * async - bool: defaults to true. Be careful if set to false, it can * hang the browser until the xml doc is loaded. Users generally * don't like that too much. * ***********************************************************************************/ CAjax.prototype.exec = function (url, args, async) { var is_async = (async != null) ? async : true; var post_data = null; var xmlLocal = this.m_xmlLocal; var objref = this; // If this is a syncronus request we don't need callback if (is_async == true) { function inlineLoaded() { if (xmlLocal && xmlLocal.readyState == 4) { if (xmlLocal.status == 200) { // Get the parent node objref.m_response = xmlLocal.responseXML.documentElement; objref.m_firstNode = new CAjaxNode("root", ""); objref.m_firstNode.m_xmlcld = objref.m_response; // Parse tree objref.parseNodes(objref.m_firstNode, objref.m_response); // Call user defined loaded objref.onload(); // Clear reference objref = null; } } } this.m_xmlLocal.onreadystatechange = inlineLoaded; } if (this.m_method == AJAX_GET) { this.m_xmlLocal.open("GET", url, is_async); } else if (this.m_method == AJAX_POST) { // Get arguments var numargs = 0; if (typeof args != "undefined" && args) { numargs = args.length; if (numargs) { // Arguments are pass as {name, value} for (i = 0; i < numargs; i++) { if (post_data) post_data += "&"; else post_data = ""; post_data += args[i][0] + "=" + escape_utf8(args[i][1]); } } } this.m_xmlLocal.open("POST", url, is_async); //Send the proper header information along with the request this.m_xmlLocal.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); this.m_xmlLocal.setRequestHeader("Content-length", numargs); this.m_xmlLocal.setRequestHeader("Connection", "close"); } // If this is a syncronus request we don't need callback if (is_async == false) { this.parseXml(); } this.m_xmlLocal.send(post_data); } /*********************************************************************************** * * Function: readyStateChange * * Purpose: Private function that handles readystate change for request. * ***********************************************************************************/ CAjax.prototype.readyStateChange = function () { var xmlLocal = this.m_xmlLocal; if (xmlLocal && xmlLocal.readyState == 4) { if (xmlLocal.status == 200) { // Get the parent node this.m_response = xmlLocal.responseXML.documentElement; this.m_firstNode = new CAjaxNode(this.m_firstNode.nodeName, ""); this.m_firstNode.m_type = AJAX_NODE_HTML; // Parse tree this.parseNodes(this.m_firstNode, m_response); // Call user defined loaded this.onload(); } } } /*********************************************************************************** * * Function: parseXml * * Purpose: Private function that parses the xml document once it is loaded * ***********************************************************************************/ CAjax.prototype.parseXml = function () { var xmlLocal = this.m_xmlLocal; alert(xmlLocal); alert(xmlLocal.status); if (xmlLocal.status == 200) { // Get the parent node this.m_response = xmlLocal.responseXML.documentElement; this.m_firstNode = new CAjaxNode("root", ""); // Parse tree this.parseNodes(this.m_firstNode, this.m_response); } } /*********************************************************************************** * * Function: parseNodes * * Purpose: Private function that parses each xml node * * Arguements: ajax_node - CAjaxNode: Branch to parse * xml_child - xml_node: xml object node to copy in CAjaxNode * ***********************************************************************************/ CAjax.prototype.parseNodes = function (ajax_node, xml_child) { if (!ajax_node || !xml_child) return 0; var iNumSubNodes = ajax_node.m_children.length; var children = xml_child.childNodes; var iNewIndex = 0; if (children) { var num = children.length; for(var i = 0; i < num; i++) { var child = children[i]; // Element Node if (child.nodeType == AJAX_NODE_HTML) { ajax_node.m_children[iNumSubNodes + iNewIndex] = new CAjaxNode(child.nodeName, ""); ajax_node.m_children[iNumSubNodes + iNewIndex].m_xmlcld = child; if (child.childNodes && child.childNodes.length) this.parseNodes(ajax_node.m_children[iNumSubNodes + iNewIndex], child); iNewIndex++; } // Text Node if (child.nodeType == AJAX_NODE_TEXT) { ajax_node.m_text += child.nodeValue; } } } } /*********************************************************************************** * * Function: onload * * Purpose: This function should be redefined by the public calling procedure. * ***********************************************************************************/ CAjax.prototype.onload = function () { } /*********************************************************************************** * * Class: CAjaxNode * * Purpose: This is the node linked list * * Arguements: name - string: the name of the node * text - string: the value of the node * ***********************************************************************************/ function CAjaxNode(name, text) { this.m_name = name; this.m_text = text; this.m_attributes = new Array(); this.m_children = new Array(); } /*********************************************************************************** * * Function: getNumChildren * * Purpose: Get number of children (try not to access vars directly) * ***********************************************************************************/ CAjaxNode.prototype.getNumChildren = function () { if (this.m_children) return this.m_children.length; else return 0; } /*********************************************************************************** * * Function: getChildNode * * Purpose: Retrieve a node at a specific index * * Arguements: iIndex - integer: index of node to retrieve * ***********************************************************************************/ CAjaxNode.prototype.getChildNode = function (iIndex) { return this.m_children[iIndex]; } /*********************************************************************************** * * Function: getChildNodesByName * * Purpose: Retrieve nodes by name * * Arguements: name - string: name of nodes to retrieve * ***********************************************************************************/ CAjaxNode.prototype.getChildNodesByName = function (name) { if (this.m_query_res && this.m_query_res.length) delete this.m_query_res; // mres is used as a temporary storage array of node references this.m_query_res = new Array(); // Loop through children looking for 'name' var num = this.getNumChildren(); var iFound = 0; for (i = 0; i < num; i++) { if (this.getChildNode(i).m_name == name) { this.m_query_res[iFound] = this.getChildNode(i); iFound++; } } return this.m_query_res; } /*********************************************************************************** * * Function: getChildNodesValByName * * Purpose: Retrieve node value by name. If more than one node with that name * is found it will return the first value. This is best used where * you know for sure there will only be one child node with that name. * * Arguements: name - string: name of nodes to retrieve * ***********************************************************************************/ CAjaxNode.prototype.getChildNodeValByName = function(name) { var val = null; // Loop through children looking for 'name' for (var p = 0; p < this.getNumChildren(); p++) { if (this.getChildNode(p).m_name == name) { val = this.getChildNode(p).m_text; break; } } return val; } /*********************************************************************************** * * Function: getAttribute * * Purpose: Get node attribute by name * * Arguements: name - string: name of attribute to retrieve * ***********************************************************************************/ CAjaxNode.prototype.getAttribute = function(name) { return unescape(this.m_xmlcld.getAttribute(name)); } /*====================================================================================== Module: CAjaxRpc Purpose: Execute remote procedures and return value via ajax Author: Sky Stebnicki, sky.stebnicki@aereus.com Copyright (c) 2006 Aereus Corporation. All rights reserved. Usage: // Create ajaxrpc object var rpc = new CAjaxRpc("/path/to/xml.xml", "function_name", [["argument_name", "value"]], callback_function, cb_args); ======================================================================================*/ // Define globals // ----------------------------------------------------------- var g_CAjaxRpc = new Array(); /*********************************************************************** * Class: CAjaxRpc * * Purpose: Create CAjaxRpc class * * Arguments: url - string: path to server file * f_name - string: name of function to process on server * args - array[][]: arguments to send to server. * Sent via get using name=value * finished_cb - string or function ref: function to call * with return value after server has processed * request. Define: function name(retval); * ************************************************************************/ function CAjaxRpc(url, f_name, args, finished_cb, cb_args, method) { var send_method = (method) ? method : AJAX_GET; // Get last index var ind = g_CAjaxRpc.length; g_CAjaxRpc[ind] = new CAjax(); g_CAjaxRpc[ind].m_method = send_method; if (typeof cb_args != "undefined") g_CAjaxRpc[ind].m_cb_args = cb_args; else g_CAjaxRpc[ind].m_cb_args = null; g_CAjaxRpc[ind].onload = function() { var retval = null; var root = this.m_firstNode; // The result will be held in a variable called 'retval' var num = root.getNumChildren(); if (num) { for (i = 0; i < num; i++) { var child = root.getChildNode(i); if (child.m_name == "retval") { if (child.m_text) retval = unescape(child.m_text); } } if (this.cb_function) { try { if (typeof this.cb_function == "string") { if (this.m_cb_args) { var passargs = "\"" + retval + "\""; for (var j = 0; j < m_cb_args.length; j++) { passargs += ", \"" + m_cb_args[j] + "\""; } eval(this.cb_function + "(" + passargs + ")"); } else { eval(this.cb_function + "(\"" + retval + "\")"); } } else { if (this.m_cb_args) { switch (this.m_cb_args.length) { case 1: this.cb_function(retval, this.m_cb_args[0]); break; case 2: this.cb_function(retval, this.m_cb_args[0], this.m_cb_args[1]); break; case 3: this.cb_function(retval, this.m_cb_args[0], this.m_cb_args[1], this.m_cb_args[2]); break; case 4: this.cb_function(retval, this.m_cb_args[0], this.m_cb_args[1], this.m_cb_args[2], this.m_cb_args[3]); break; case 5: this.cb_function(retval, this.m_cb_args[0], this.m_cb_args[1], this.m_cb_args[2], this.m_cb_args[3], this.m_cb_args[4]); break; case 6: this.cb_function(retval, this.m_cb_args[0], this.m_cb_args[1], this.m_cb_args[2], this.m_cb_args[3], this.m_cb_args[4], this.m_cb_args[5]); break; case 7: this.cb_function(retval, this.m_cb_args[0], this.m_cb_args[1], this.m_cb_args[2], this.m_cb_args[3], this.m_cb_args[4], this.m_cb_args[5], this.m_cb_args[6]); break; case 8: this.cb_function(retval, this.m_cb_args[0], this.m_cb_args[1], this.m_cb_args[2], this.m_cb_args[3], this.m_cb_args[4], this.m_cb_args[5], this.m_cb_args[6], this.m_cb_args[7]); break; case 9: this.cb_function(retval, this.m_cb_args[0], this.m_cb_args[1], this.m_cb_args[2], this.m_cb_args[3], this.m_cb_args[4], this.m_cb_args[5], this.m_cb_args[6], this.m_cb_args[7], this.m_cb_args[8]); break; case 10: this.cb_function(retval, this.m_cb_args[0], this.m_cb_args[1], this.m_cb_args[2], this.m_cb_args[3], this.m_cb_args[4], this.m_cb_args[5], this.m_cb_args[6], this.m_cb_args[7], this.m_cb_args[8], this.m_cb_args[9]); break; } } else { this.cb_function(retval); } } } catch (e) {} } } CAjaxRpcCleanup(this); }; var exec_url = url; exec_url += "?function=" + f_name; // Get callback (optional) if (finished_cb) g_CAjaxRpc[ind].cb_function = finished_cb; if (send_method == AJAX_POST && typeof args != "undefined") { g_CAjaxRpc[ind].exec(exec_url, args); } else { if (typeof args != "undefined" && args) { var numargs = args.length; if (numargs) { // Arguments are pass as {name, value} for (i = 0; i < numargs; i++) { exec_url += "&" + args[i][0] + "=" + escape_utf8(args[i][1]); } } } g_CAjaxRpc[ind].exec(exec_url); } } /*********************************************************************** * Function: CAjaxRpcCleanup * * Purpose: Removes reference to ajax from global array * ************************************************************************/ function CAjaxRpcCleanup(ref) { var num = g_CAjaxRpc.length; for (i = 0; i < num; i++) { if (g_CAjaxRpc[i] == ref) { g_CAjaxRpc[i] = null; } } } /*====================================================================================== Module: CBrowserInfo Purpose: Gather and make available info about the user's browser Author: Sky Stebnicki, sky.stebnicki@aereus.com Copyright (c) 2006 Aereus Corporation. All rights reserved. Usage: var bi = new CBrowserInfo(); (1) Get vendor bi.nav, bi.ie, bi.opera, bi.hotjava, bi.webtv, bi.TVNavigator, bi.AOLTV (2) Get version number bi.major (integer indicating major version number: 2, 3, 4 ...) bi.minor (float indicating full version number: 2.02, 3.01, 4.04 ...) (3) Version AND vendor bi.nav2, bi.nav3, bi.nav4, bi.nav4up, bi.nav6, bi.nav6up, bi.gecko, bi.ie3, bi.ie4, bi.ie4up, bi.ie5, bi.ie5up, bi.ie5_5, bi.ie5_5up, bi.ie6, bi.ie6up, bi.ie7up, bi.hotjava3, bi.hotjava3up (4) JavaScript version bi.js (float indicating full JavaScript version number: 1, 1.1, 1.2 ...) (5) OS platform and version bi.win, bi.win16, bi.win32, bi.win31, bi.win95, bi.winnt, bi.win98, bi.winme, bi.win2k, bi.winxp, bi.winvista, bi.os2 bi.mac, bi.mac68k, bi.macppc bi.unix bi.sun, bi.sun4, bi.sun5, bi.suni86 bi.irix, bi.irix5, bi.irix6 bi.hpux, bi.hpux9, bi.hpux10 bi.aix, bi.aix1, bi.aix2, bi.aix3, bi.aix4 bi.linux, bi.sco, bi.unixware, bi.mpras, bi.reliant bi.dec, bi.sinix, bi.freebsd, bi.bsd bi.vms ======================================================================================*/ function CBrowserInfo () { // convert all characters to lowercase to simplify testing var agt=navigator.userAgent.toLowerCase(); // *** BROWSER VERSION *** // Note: On IE5, these return 4, so use is.ie5up to detect IE5. this.major = parseInt(navigator.appVersion); this.minor = parseFloat(navigator.appVersion); // Note: Opera and WebTV spoof Navigator. We do strict client detection. // If you want to allow spoofing, take out the tests for opera and webtv. this.nav = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)); this.nav2 = (this.nav && (this.major == 2)); this.nav3 = (this.nav && (this.major == 3)); this.nav4 = (this.nav && (this.major == 4)); this.nav4up = (this.nav && (this.major >= 4)); this.navonly = (this.nav && ((agt.indexOf(";nav") != -1) || (agt.indexOf("; nav") != -1)) ); this.nav6 = (this.nav && (this.major == 5)); this.nav6up = (this.nav && (this.major >= 5)); this.gecko = (agt.indexOf('gecko') != -1); this.ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1)); this.ie3 = (this.ie && (this.major < 4)); this.ie4 = (this.ie && (this.major == 4) && (agt.indexOf("msie 4")!=-1) ); this.ie4up = (this.ie && (this.major >= 4)); this.ie5 = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.0")!=-1) ); this.ie5_5 = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.5") !=-1)); this.ie5up = (this.ie && !this.ie3 && !this.ie4); this.ie5_5up =(this.ie && !this.ie3 && !this.ie4 && !this.ie5); this.ie6 = (this.ie && (this.major == 4) && (agt.indexOf("msie 6.")!=-1) ); this.ie6up = (this.ie && !this.ie3 && !this.ie4 && !this.ie5 && !this.ie5_5 && !this.ie6); this.ie7 = (this.ie && (this.major == 4) && (agt.indexOf("msie 7.")!=-1) ); this.ie7up = (this.ie && !this.ie3 && !this.ie4 && !this.ie5 && !this.ie5_5 && !this.ie6); // KNOWN BUG: On AOL4, returns false if IE3 is embedded browser // or if this is the first browser window opened. Thus the // variables is.aol, is.aol3, and is.aol4 aren't 100% reliable. this.aol = (agt.indexOf("aol") != -1); this.aol3 = (this.aol && this.ie3); this.aol4 = (this.aol && this.ie4); this.aol5 = (agt.indexOf("aol 5") != -1); this.aol6 = (agt.indexOf("aol 6") != -1); this.opera = (agt.indexOf("opera") != -1); this.opera2 = (agt.indexOf("opera 2") != -1 || agt.indexOf("opera/2") != -1); this.opera3 = (agt.indexOf("opera 3") != -1 || agt.indexOf("opera/3") != -1); this.opera4 = (agt.indexOf("opera 4") != -1 || agt.indexOf("opera/4") != -1); this.opera5 = (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1); this.opera5up = (this.opera && !this.opera2 && !this.opera3 && !this.opera4); this.webtv = (agt.indexOf("webtv") != -1); this.TVNavigator = ((agt.indexOf("navio") != -1) || (agt.indexOf("navio_aoltv") != -1)); this.AOLTV = this.TVNavigator; this.hotjava = (agt.indexOf("hotjava") != -1); this.hotjava3 = (this.hotjava && (this.major == 3)); this.hotjava3up = (this.hotjava && (this.major >= 3)); // *** JAVASCRIPT VERSION CHECK *** if (this.nav2 || this.ie3) this.js = 1.0; else if (this.nav3) this.js = 1.1; else if (this.opera5up) this.js = 1.3; else if (this.opera) this.js = 1.1; else if ((this.nav4 && (this.minor <= 4.05)) || this.ie4) this.js = 1.2; else if ((this.nav4 && (this.minor > 4.05)) || this.ie5) this.js = 1.3; else if (this.hotjava3up) this.js = 1.4; else if (this.nav6 || this.gecko) this.js = 1.5; // NOTE: In the future, update this code when newer versions of JS // are released. For now, we try to provide some upward compatibility // so that future versions of Nav and IE will show they are at // *least* JS 1.x capable. Always check for JS version compatibility // with > or >=. else if (this.nav6up) this.js = 1.5; // note ie5up on mac is 1.4 else if (this.ie5up) this.js = 1.3 // HACK: no idea for other browsers; always check for JS version with > or >= else this.js = 0.0; // *** PLATFORM *** this.win = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) ); // NOTE: On Opera 3.0, the userAgent string includes "Windows 95/NT4" on all // Win32, so you can't distinguish between Win95 and WinNT. this.win95 = ((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1)); // is this a 16 bit compiled version? this.win16 = ((agt.indexOf("win16")!=-1) || (agt.indexOf("16bit")!=-1) || (agt.indexOf("windows 3.1")!=-1) || (agt.indexOf("windows 16-bit")!=-1) ); this.win31 = ((agt.indexOf("windows 3.1")!=-1) || (agt.indexOf("win16")!=-1) || (agt.indexOf("windows 16-bit")!=-1)); // NOTE: Reliable detection of Win98 may not be possible. It appears that: // - On Nav 4.x and before you'll get plain "Windows" in userAgent. // - On Mercury client, the 32-bit version will return "Win98", but // the 16-bit version running on Win98 will still return "Win95". this.win98 = ((agt.indexOf("win98")!=-1) || (agt.indexOf("windows 98")!=-1)); this.winnt = ((agt.indexOf("winnt")!=-1) || (agt.indexOf("windows nt")!=-1)); this.win32 = (this.win95 || this.winnt || this.win98 || ((this.major >= 4) && (navigator.platform == "Win32")) || (agt.indexOf("win32")!=-1) || (agt.indexOf("32bit")!=-1)); this.winme = ((agt.indexOf("win 9x 4.90")!=-1)); this.win2k = ((agt.indexOf("windows nt 5.0")!=-1)); this.winxp = ((agt.indexOf("windows nt 5.1")!=-1)); this.winvista = ((agt.indexOf("windows nt 6.0")!=-1)); this.os2 = ((agt.indexOf("os/2")!=-1) || (navigator.appVersion.indexOf("OS/2")!=-1) || (agt.indexOf("ibm-webexplorer")!=-1)); this.mac = (agt.indexOf("mac")!=-1); // hack ie5 js version for mac if (this.mac && this.ie5up) this.js = 1.4; this.mac68k = (this.mac && ((agt.indexOf("68k")!=-1) || (agt.indexOf("68000")!=-1))); this.macppc = (this.mac && ((agt.indexOf("ppc")!=-1) || (agt.indexOf("powerpc")!=-1))); this.sun = (agt.indexOf("sunos")!=-1); this.sun4 = (agt.indexOf("sunos 4")!=-1); this.sun5 = (agt.indexOf("sunos 5")!=-1); this.suni86= (this.sun && (agt.indexOf("i86")!=-1)); this.irix = (agt.indexOf("irix") !=-1); // SGI this.irix5 = (agt.indexOf("irix 5") !=-1); this.irix6 = ((agt.indexOf("irix 6") !=-1) || (agt.indexOf("irix6") !=-1)); this.hpux = (agt.indexOf("hp-ux")!=-1); this.hpux9 = (this.hpux && (agt.indexOf("09.")!=-1)); this.hpux10= (this.hpux && (agt.indexOf("10.")!=-1)); this.aix = (agt.indexOf("aix") !=-1); // IBM this.aix1 = (agt.indexOf("aix 1") !=-1); this.aix2 = (agt.indexOf("aix 2") !=-1); this.aix3 = (agt.indexOf("aix 3") !=-1); this.aix4 = (agt.indexOf("aix 4") !=-1); this.linux = (agt.indexOf("inux")!=-1); this.sco = (agt.indexOf("sco")!=-1) || (agt.indexOf("unix_sv")!=-1); this.unixware = (agt.indexOf("unix_system_v")!=-1); this.mpras = (agt.indexOf("ncr")!=-1); this.reliant = (agt.indexOf("reliantunix")!=-1); this.dec = ((agt.indexOf("dec")!=-1) || (agt.indexOf("osf1")!=-1) || (agt.indexOf("dec_alpha")!=-1) || (agt.indexOf("alphaserver")!=-1) || (agt.indexOf("ultrix")!=-1) || (agt.indexOf("alphastation")!=-1)); this.sinix = (agt.indexOf("sinix")!=-1); this.freebsd = (agt.indexOf("freebsd")!=-1); this.bsd = (agt.indexOf("bsd")!=-1); this.unix = ((agt.indexOf("x11")!=-1) || this.sun || this.irix || this.hpux || this.sco ||this.unixware || this.mpras || this.reliant || this.dec || this.sinix || this.aix || this.linux || this.bsd || this.freebsd); this.vms = ((agt.indexOf("vax")!=-1) || (agt.indexOf("openvms")!=-1)); } function CButton(title, funct, args, scheme, width, mouseover, mouseout) { scheme = (scheme) ? scheme : 'b1'; this.m_scheme = scheme; this.m_main = ALib.m_document.createElement("div"); ALib.Dom.styleSet(this.m_main, "float", "left"); /* this.m_main = ALib.m_document.createElement("button"); ALib.Dom.styleSet(this.m_main, "padding", "0px"); ALib.Dom.styleSet(this.m_main, "margin", "0px"); ALib.Dom.styleSet(this.m_main, "background-color", "transparent"); ALib.Dom.styleSet(this.m_main, "border-style", "none"); /* this.m_main = ALib.m_document.createElement("span"); if (ALib.Dom.m_binfo.nav) ALib.Dom.styleSet(this.m_main, "display", "-moz-inline-stack"); else ALib.Dom.styleSet(this.m_main, "display", "inline-block"); */ /* this.m_main = ALib.m_document.createElement("div"); ALib.Dom.styleSet(this.m_main, "float", "left"); */ var table = ALib.m_document.createElement("table"); this.m_main.appendChild(table); //ALib.Dom.styleSet(table, "display", "inline"); ALib.Dom.styleSetClass(table, "CButton_" + scheme); table.setAttribute("cellpadding","0"); table.cellPadding = "0"; table.setAttribute("cellspacing","0"); table.cellSpacing = "0"; var tbody = ALib.m_document.createElement("tbody"); table.appendChild(tbody); // Top of button var tr = ALib.m_document.createElement("tr"); this.m_tl = ALib.m_document.createElement("td"); tr.appendChild(this.m_tl); this.m_tc = ALib.m_document.createElement("td"); tr.appendChild(this.m_tc); this.m_tr = ALib.m_document.createElement("td"); tr.appendChild(this.m_tr); tbody.appendChild(tr); // Button Body var tr = ALib.m_document.createElement("tr"); this.m_l = ALib.m_document.createElement("td"); tr.appendChild(this.m_l); this.m_c = ALib.m_document.createElement("td"); this.m_c.m_btnh = this; this.m_c.innerHTML = title; this.m_c.style.whiteSpace = "nowrap"; tr.appendChild(this.m_c); this.m_r = ALib.m_document.createElement("td"); tr.appendChild(this.m_r); tbody.appendChild(tr); // Bottom Row var tr = ALib.m_document.createElement("tr"); this.m_bl = ALib.m_document.createElement("td"); tr.appendChild(this.m_bl); this.m_bc = ALib.m_document.createElement("td"); tr.appendChild(this.m_bc); this.m_br = ALib.m_document.createElement("td"); tr.appendChild(this.m_br); tbody.appendChild(tr); // Set actions /* this.m_main.m_btnh = this; this.m_main.onmouseover = function () { this.m_btnh.changeState("over"); } this.m_main.onmouseout = function () { this.m_btnh.changeState("out"); } this.m_main.m_funct = funct; this.m_main.m_args = args; this.m_main.onclick = function () { if (typeof this.m_funct == "string") eval(this.m_funct); else { if (this.m_args) { switch(this.m_args.length) { case 1: this.m_funct(this.m_args[0]); break; case 2: this.m_funct(this.m_args[0], this.m_args[1]); break; case 3: this.m_funct(this.m_args[0], this.m_args[1], this.m_args[2]); break; case 4: this.m_funct(this.m_args[0], this.m_args[1], this.m_args[2], this.m_args[3]); break; } } else this.m_funct(); } } */ this.m_c.onmouseover = function () { this.m_btnh.changeState("over"); } this.m_c.onmouseout = function () { this.m_btnh.changeState("out"); } this.m_c.m_funct = funct; this.m_c.m_args = args; this.m_c.onclick = function () { if (typeof this.m_funct == "string") eval(this.m_funct); else { if (this.m_args) { switch(this.m_args.length) { case 1: this.m_funct(this.m_args[0]); break; case 2: this.m_funct(this.m_args[0], this.m_args[1]); break; case 3: this.m_funct(this.m_args[0], this.m_args[1], this.m_args[2]); break; case 4: this.m_funct(this.m_args[0], this.m_args[1], this.m_args[2], this.m_args[3]); break; } } else this.m_funct(); } } this.m_table = table; this.changeState("out"); } CButton.prototype.changeState = function (state) { switch (state) { case 'over': ALib.Dom.styleSetClass(this.m_tl, "CButtonTopLeft_"+this.m_scheme+"Over"); ALib.Dom.styleSetClass(this.m_tc, "CButtonTopCenter_"+this.m_scheme+"Over"); ALib.Dom.styleSetClass(this.m_tr, "CButtonTopRight_"+this.m_scheme+"Over"); ALib.Dom.styleSetClass(this.m_l, "CButtonBodyLeft_"+this.m_scheme+"Over"); ALib.Dom.styleSetClass(this.m_c, "CButtonBody_"+this.m_scheme+"Over"); ALib.Dom.styleSetClass(this.m_r, "CButtonBodyRight_"+this.m_scheme+"Over"); ALib.Dom.styleSetClass(this.m_bl, "CButtonBottomLeft_"+this.m_scheme+"Over"); ALib.Dom.styleSetClass(this.m_bc, "CButtonBottomCenter_"+this.m_scheme+"Over"); ALib.Dom.styleSetClass(this.m_br, "CButtonBottomRight_"+this.m_scheme+"Over"); break; case 'out': ALib.Dom.styleSetClass(this.m_tl, "CButtonTopLeft_"+this.m_scheme); ALib.Dom.styleSetClass(this.m_tc, "CButtonTopCenter_"+this.m_scheme); ALib.Dom.styleSetClass(this.m_tr, "CButtonTopRight_"+this.m_scheme); ALib.Dom.styleSetClass(this.m_l, "CButtonBodyLeft_"+this.m_scheme); ALib.Dom.styleSetClass(this.m_c, "CButtonBody_"+this.m_scheme); ALib.Dom.styleSetClass(this.m_r, "CButtonBodyRight_"+this.m_scheme); ALib.Dom.styleSetClass(this.m_bl, "CButtonBottomLeft_"+this.m_scheme); ALib.Dom.styleSetClass(this.m_bc, "CButtonBottomCenter_"+this.m_scheme); ALib.Dom.styleSetClass(this.m_br, "CButtonBottomRight_"+this.m_scheme); break; } } CButton.prototype.getButton = function () { return this.m_main; } CButton.prototype.print = function(con) { con.appendChild(this.m_main); } CButton.prototype.getTable = function () { return this.m_table; } /*====================================================================================== Module: CContentTable Purpose: Kind of like a window but embedded in the document Author: Sky Stebnicki, sky.stebnicki@aereus.com Copyright (c) 2006 Aereus Corporation. All rights reserved. Usage: var ccTble = new CContentTable("My Window Name", "100px", "100px"); ccTble.print(parent_div); // If no parent div then just doc.write ======================================================================================*/ /*********************************************************************************** * * Class: CContentTable * * Purpose: Create new content table class * * Arguements: title - string: the default title for this window. Can be changed later. * width - (optional) string: width in px * height - (optional) string: height in px * ***********************************************************************************/ function CContentTable(title, width, height) { /* return reference to inner div for div.innerHTML or div.createDiv */ // Create main table var table = ALib.m_document.createElement("table"); this.m_table = table; table.className = "ContentTable"; table.setAttribute("cellpadding","0"); table.cellSpacing = "0"; table.setAttribute("cellspacing","0"); table.cellPadding = "0"; table.setAttribute("border","0"); table.border = "0"; if (width) { this.m_width = width; ALib.Dom.styleSet(table, "width", width); } if (height) table.style.height = height; var tbl_body = ALib.m_document.createElement("TBODY") // Create title bar row var row = ALib.m_document.createElement("tr"); var td_left = ALib.m_document.createElement("td"); td_left.className = "ContentTableTitleLeftCorn"; row.appendChild(td_left); var td_middle = ALib.m_document.createElement("td"); td_middle.className = "ContentTableTitleCenter"; this.m_spTitle = ALib.m_document.createElement("div"); this.m_spTitle.className = "ContentTableTitleLabel"; ALib.Dom.styleSet(this.m_spTitle, "float", "left"); this.m_spTitle.innerHTML = title; td_middle.appendChild(this.m_spTitle); this.m_context = ALib.m_document.createElement("div"); ALib.Dom.styleSet(this.m_context, "float", "right"); //ALib.Dom.styleSet(this.m_context, "padding-right", "3px"); this.m_context.className = 'ContentTableTitleContext'; td_middle.appendChild(this.m_context); row.appendChild(td_middle); var td_right = ALib.m_document.createElement("td"); td_right.className = "ContentTableTitleRightCorn"; row.appendChild(td_right); tbl_body.appendChild(row); // Create content row and div var row = ALib.m_document.createElement("tr"); row.vAlign = "top"; row.setAttribute("valign", "top"); var td_left = ALib.m_document.createElement("td"); td_left.className = "ContentTableBodyLeft"; row.appendChild(td_left); var divContent = ALib.m_document.createElement("td"); divContent.className = "ContentTableBody"; row.appendChild(divContent); /* var divContent = ALib.m_document.createElement("div"); divContent.style.height = "100%"; td_middle.appendChild(divContent); */ var td_right = ALib.m_document.createElement("td"); td_right.className = "ContentTableBodyRight"; row.appendChild(td_right); tbl_body.appendChild(row); // Create footer row var row = ALib.m_document.createElement("tr"); row.className = "ContentTableFooterRow"; var td_left = ALib.m_document.createElement("td"); td_left.className = "ContentTableFooterLeftCorn"; row.appendChild(td_left); var td_middle = ALib.m_document.createElement("td"); td_middle.className = "ContentTableFooterCenter"; row.appendChild(td_middle); var td_right = ALib.m_document.createElement("td"); td_right.className = "ContentTableFooterRightCorn"; row.appendChild(td_right); tbl_body.appendChild(row); table.appendChild(tbl_body); /* Initiate local class variables */ this.m_table = table; this.m_contentdiv = divContent; } /*********************************************************************************** * * Function: print * * Purpose: Append the content table to parent or print using document.write * * Arguements: div_parent - (optional) The parent container that will hold the * table. If none is specified, use document.write() * ***********************************************************************************/ CContentTable.prototype.print = function(div_parent) { try { if (div_parent) { this.m_parentdiv = div_parent; div_parent.appendChild(this.m_table); } else document.write(this.m_table.outerHTML); } catch (e) {} } /*********************************************************************************** * * Function: write * * Purpose: Add html to the body of the content table * * Arguments: htm - any html markup or text to append to the body. Must be string * ***********************************************************************************/ CContentTable.prototype.write = function (htm) { this.m_contentdiv.innerHTML += htm; } /*********************************************************************************** * * Function: get_cdiv (depreciated) * * Purpose: Get the body/content container. Please use getCon instead. * ***********************************************************************************/ CContentTable.prototype.get_cdiv = function () { return this.m_contentdiv; } /*********************************************************************************** * * Function: getCon * * Purpose: Get the body/content container. * ***********************************************************************************/ CContentTable.prototype.getCon = function () { return this.m_contentdiv; } /*********************************************************************************** * * Function: getTitleCon * * Purpose: Get the container that holds the title of the window/table * ***********************************************************************************/ CContentTable.prototype.getTitleCon = function() { return this.m_spTitle; } /*********************************************************************************** * * Function: setTitle * * Purpose: Set the title (html) * * Arguements: title - string * ***********************************************************************************/ CContentTable.prototype.setTitle = function (title) { this.m_spTitle.innerHTML = title; } /*********************************************************************************** * * Function: getOuterCon * * Purpose: Get entire table * ***********************************************************************************/ CContentTable.prototype.getOuterCon = function() { return this.m_table; } /*********************************************************************************** * * Function: get_ctitle (depreciated) * * Purpose: Get context container. Usually in the upper right for close, max, min. * This function has been depreciated, please use getContextCon * ***********************************************************************************/ CContentTable.prototype.get_ctitle = function () { return this.m_context; } /*********************************************************************************** * * Function: getContextCon * * Purpose: Get context container. Usually in the upper right for close, max, min. * ***********************************************************************************/ CContentTable.prototype.getContextCon = function () { return this.m_context; } /*********************************************************************************** * * Function: hide * * Purpose: Hides the entire table. * ***********************************************************************************/ CContentTable.prototype.hide = function () { this.m_table.style.display = "none"; } /*********************************************************************************** * * Function: show * * Purpose: Displays the entire table. * ***********************************************************************************/ CContentTable.prototype.show = function () { this.m_table.style.display = "block"; if (this.m_width) ALib.Dom.styleSet(this.m_table, "width", this.m_width); } /*********************************************************************************** * * Function: unload * * Purpose: Delete this table * ***********************************************************************************/ CContentTable.prototype.unload = function () { if (this.m_parentdiv) { this.m_parentdiv.removeChild(this.m_table); } } /**************************************************************************** * * Class: CDatasheet * * Purpose: Editable spreadsheet table * * Author: Sky Stebnicki, sky.stebnicki@aereus.com * Copyright (c) 2006 Aereus Corporation. All rights reserved. * *****************************************************************************/ var g_cdt_tind = 0; var g_cdt_tables = new Array(); function CDatasheet(width, height, show_headers, show_rowtitle) { // Set options this.show_rowtitles = (show_rowtitle) ? show_rowtitle : true; this.clicksToEdit = "double"; // This can either be double or single and will determine clicks for edit // Create main table var table = ALib.m_document.createElement("table"); table.className = "CDatasheetMainTable"; table.setAttribute("cellpadding","0"); table.cellPadding = "0"; table.setAttribute("cellspacing","0"); table.cellSpacing = "0"; table.setAttribute("border","0"); table.border = "0"; if (width) table.style.width = width; if (height) table.style.height = height; var tbl_body = ALib.m_document.createElement("TBODY") table.appendChild(tbl_body); // Initiate local class variables this.m_table = table; this.m_table_body = tbl_body; this.m_numrows = 0; this.m_rows = new Array(); this.m_cols = new Array(); this.m_rowBody = null; this.m_headersrow = null; // Set callback functions this.onCellChange = new Function(); // Editing of cell is finished this.onCellUpdate = new Function(); // Any change (keypress) to the cell // Set table unique id this.m_uni_id = "alib_cdt_" + g_cdt_tind; g_cdt_tables[g_cdt_tind] = this; g_cdt_tind++; } CDatasheet.prototype.addHeader = function (title, align, width, height, idname) { // Initial indefined variables if (!align) var align = "left"; //if (typeof showspacer == "undefined") // var showspacer = true; if (!this.m_headersrow) { this.m_headersrow = ALib.m_document.createElement("tr"); this.m_table_body.appendChild(this.m_headersrow); // Check for row titles if (this.show_rowtitles) { var td_body = ALib.m_document.createElement("td"); ALib.Dom.styleSetClass(td_body, "CDatasheetRowTitle"); this.m_headersrow.appendChild(td_body); } } var td = ALib.m_document.createElement("td"); // Content td.innerHTML = title; // Class ALib.Dom.styleSetClass(td, "CDatasheetHeaderCell"); // Alignment td.align = align; td.setAttribute("align",align); // Width and Height if (width) td.style.width = width; if (height) td.style.height = height; // Add cell to headers row this.m_headersrow.appendChild(td); // Add to headers array this.m_cols[this.m_cols.length] = td; return td; } CDatasheet.prototype.addRow = function(idname, title) { // Get unique id name var name = (idname) ? idname : this.m_numrows; this.m_lastRow = name; this.m_rows[name] = new CDatasheetRow(); this.m_rows[name].m_hinst = this; this.m_rows[name].m_name = name; this.m_rows[name].m_uni_id = this.m_uni_id + "_row_" + name; this.m_rowBody = ALib.m_document.createElement("tr"); ALib.Dom.styleSetClass(this.m_rowBody, "CDatasheetRow"); this.m_rowBody.valign = "top"; this.m_rowBody.setAttribute("valign", "top"); this.m_table_body.appendChild(this.m_rowBody); this.m_rows[name].m_row = this.m_rowBody; this.m_numrows++; // Create row title if (this.show_rowtitles) { var td_body = ALib.m_document.createElement("td"); ALib.Dom.styleSetClass(td_body, "CDatasheetRowTitle"); if (typeof title != "undefined") { if (typeof title == "string" || typeof title == "number") td_body.innerHTML = title; else { try { td_body.appendChild(title); } catch (e) {} } } this.m_rows[name].m_titlecell = td_body; this.m_rows[name].m_row.appendChild(td_body); } return this.m_rows[name]; } CDatasheet.prototype.numRows = function() { return this.m_numrows; } CDatasheet.prototype.rows = function(name) { return this.m_rows[name]; } CDatasheet.prototype.removeRow = function(indx) { this.m_table_body.removeChild(this.m_rows[indx].m_row); this.m_numrows = this.m_numrows - 1; } CDatasheet.prototype.addCell = function(content, align, width, height, readonly, colind, row) { // Get unique id name var name = (row) ? row.m_name : this.m_lastRow; var f_readonly = (readonly) ? readonly : false; // Create body cell var td_body = ALib.m_document.createElement("td"); td_body.m_row = row; td_body.m_colind = colind; td_body.f_readonly = f_readonly; td_body.m_tblcls = this; ALib.Dom.styleSetClass(td_body, "CDatasheetCell"); td_body.align = (align) ? align : "left"; if (width) td_body.style.width = width; if (height) td_body.style.width = height; if (typeof content == "string") td_body.innerHTML = content; else { try { td_body.appendChild(content); } catch (e) {} } if (this.clicksToEdit == "double") { var clkfctn = function() { if (this.m_tblcls.m_lastCellSelected) ALib.Dom.styleSetClass(this.m_tblcls.m_lastCellSelected, "CDatasheetCell"); ALib.Dom.styleSetClass(this, "CDatasheetCellSelected"); this.m_tblcls.m_lastCellSelected = this; } td_body.onclick = clkfctn; if (!f_readonly) { var dblclkfctn = function() { var buf = this.innerHTML; ALib.Dom.styleSetClass(this, "CDatasheetCellEdit"); this.onclick = function() {}; this.innerHTML = ""; var inp = ALib.m_document.createElement("input"); ALib.Dom.styleSet(inp, "width", "99%"); ALib.Dom.styleSet(inp, "height", "100%"); inp.value = buf; inp.m_td = this; inp.onkeydown = function(e) { this.m_td.m_tblcls.onCellUpdate(this.m_td.m_row.m_name, this.m_td.m_colind); } inp.onblur = function () { inp.m_td.innerHTML = this.value; ALib.Dom.styleSetClass(inp.m_td, "CDatasheetCell"); inp.m_td.m_tblcls.onCellChange(this.m_td.m_row.m_name, this.m_td.m_colind); inp.m_td.onclick = clkfctn; inp.m_td.ondblclick = dblclkfctn; } this.appendChild(inp); this.ondblclick = function() {}; inp.select(); inp.focus(); }; td_body.ondblclick = dblclkfctn; } } else // Single click will edit { if (!f_readonly) { var clkfctn = function() { this.m_origbuf = this.innerHTML; ALib.Dom.styleSetClass(this, "CDatasheetCellEdit"); this.onclick = function() {}; this.innerHTML = ""; var inp = ALib.m_document.createElement("input"); ALib.Dom.styleSet(inp, "width", "100%"); ALib.Dom.styleSet(inp, "height", "100%"); inp.value = this.m_origbuf; inp.m_td = this; inp.onkeyup = function(e) { this.m_td.m_tblcls.onCellUpdate(this.m_td.m_row.m_name, this.m_td.m_colind); } inp.onblur = function () { inp.m_td.innerHTML = this.value; ALib.Dom.styleSetClass(inp.m_td, "CDatasheetCell"); inp.m_td.onclick = clkfctn; if (this.value != inp.m_td.m_origbuf) inp.m_td.m_tblcls.onCellChange(this.m_td.m_row.m_name, this.m_td.m_colind); } this.appendChild(inp); this.onclick = function() {}; inp.select(); inp.focus(); }; td_body.onclick = clkfctn; } } this.m_rows[name].m_row.appendChild(td_body); return td_body; } CDatasheet.prototype.print = function (div_parent) { if (div_parent) div_parent.appendChild(this.m_table); else document.write(this.m_table.outerHTML); this.fixColSize(); } CDatasheet.prototype.getValue = function(row, col) { if (this.m_rows[row].m_cols[col]) return this.m_rows[row].m_cols[col].m_td.innerHTML; } // Give auto cols a width so they do not resize on edit CDatasheet.prototype.fixColSize = function() { for (var i = 0; i < this.m_cols.length; i++) { var width = ALib.Dom.styleGet(this.m_cols[i], "width"); ALib.Dom.styleSet(this.m_cols[i], "width", width); } } function CDatasheetRow() { this.m_row; this.m_hinst; this.m_name; this.m_titlecell = null; this.m_uni_id = null; this.m_colind = 0; this.m_cols = new Array(); } CDatasheetRow.prototype.setName = function(name) { this.m_hinst.m_rows[name] = this.m_hinst.m_rows[this.m_name]; this.m_hinst.m_rows[this.m_name] = null; this.m_name = name; } CDatasheetRow.prototype.setTitle = function(title) { if (this.m_titlecell) { if (typeof title == "string" || typeof title == "number") this.m_titlecell.innerHTML = title; else { try { this.m_titlecell.appendChild(title); } catch (e) {} } } } CDatasheetRow.prototype.addCell = function (content, align, width, height, readonly) { // Create defaults if (!content) var content = null; if (!align) var align = null; if (!width) var width = null; if (!height) var height = null; if (!readonly) var readonly = null; this.m_cols[this.m_colind] = new CDatasheetCell(content, this); this.m_cols[this.m_colind].m_td = this.m_hinst.addCell(content, align, width, height, readonly, this.m_colind, this); this.m_colind++; } CDatasheetRow.prototype.deleteRow = function() { this.m_hinst.removeRow(this.m_name); } CDatasheetRow.prototype.getId = function() { return this.m_uni_id; } CDatasheetRow.prototype.cols = function(colname) { return this.m_cols[colname]; } function CDatasheetCell(title, row) { this.m_name = row; this.m_title = null; this.m_td = null; } CDatasheetCell.prototype.setTitle = function(title) { if (typeof title == "string" || typeof title == "number") this.m_td.innerHTML = title; else { try { this.m_td.innerHTML = ""; this.m_td.appendChild(title); } catch (e) {} } } /**************************************************************************** * * Class: CDom * * Purpose: Excapsulates the Document Object Model * * Author: Sky Stebnicki, sky.stebnicki@aereus.com * Copyright (c) 2006 Aereus Corporation. All rights reserved. * *****************************************************************************/ function CDom() { this.m_binfo = null; // Browser Information this.m_stylecache = {}; this.m_document = document; } /*********************************************************************************** * * Function: setCurrentDoc * * Purpose: (pubic) Change local document variable to work within frames * * Arguements: doc - element: the document elment to use * ***********************************************************************************/ CDom.prototype.setCurrentDoc = function(doc) { this.m_document = doc; // Reset mouse move var cls = this; if (this.m_binfo.ie) { this.m_document.detachEvent('mousemove', cls.setMouseCoords); this.m_document.attachEvent('mousemove', cls.setMouseCoords); } else { try { this.m_document.removeEventListener('mousemove', cls.setMouseCoords, false); this.m_document.addEventListener('mousemove', cls.setMouseCoords, false); } catch (e) {} } } /*********************************************************************************** * * Function: createElement * * Purpose: (pubic) Create any elment withing the local document varialbe * * Arguements: type - string: the type of element to create * appendto - element: append to container * ***********************************************************************************/ CDom.prototype.createElement = function(type, appendto) { var dv = this.m_document.createElement(type); if (appendto) appendto.appendChild(dv); return dv; } /*********************************************************************************** * * Function: getElementById * * Purpose: (pubic) Abstract document.getElementById * * Arguements: id - string: id of element to get * ***********************************************************************************/ CDom.prototype.getElementById = function(id) { var ele = this.m_document.getElementById(id); return ele; } /*********************************************************************************** * * Function: styleToCamel * * Purpose: (private) Change a hyphenated style to Camel * * Arguements: property - string: propertry to convert * ***********************************************************************************/ CDom.prototype.styleToCamel = function(property) { var change = function(prop) { var test = /(-[a-z])/i.exec(prop); var ret = prop.replace(RegExp.$1, RegExp.$1.substr(1).toUpperCase()); return ret; }; while(property.indexOf('-') > -1) property = change(property); return property; } /*********************************************************************************** * * Function: styleToHyphen * * Purpose: (private) Change a Camle (nameName) hyphenated (name-name) * * Arguements: property - string: propertry to convert * ***********************************************************************************/ CDom.prototype.styleToHyphen = function(property) { if (property.indexOf('-') > -1) return property; var converted = ''; for (var i = 0, len = property.length;i < len; ++i) { if (property.charAt(i) == property.charAt(i).toUpperCase()) { converted = converted + '-' + property.charAt(i).toLowerCase(); } else { converted = converted + property.charAt(i); } } return converted; } /*********************************************************************************** * * Function: styleMakeCache * * Purpose: (private) cache converted styles * * Arguements: property - string: propertry to cache * ***********************************************************************************/ CDom.prototype.styleMakeCache = function(property) { this.m_stylecache[property] = { camel: this.styleToCamel(property), hyphen: this.styleToHyphen(property) }; }; /*********************************************************************************** * * Function: styleGet * * Purpose: (public) get style of element * * Arguements: element - element: element to reference * property - string: style property to get * ***********************************************************************************/ CDom.prototype.styleGet = function(element, property) { var val = null; var dv = this.m_document.defaultView; if (!element) return null; if (!this.m_stylecache[property]) this.styleMakeCache(property); var camel = this.m_stylecache[property]['camel']; var hyphen = this.m_stylecache[property]['hyphen']; // Check for IE opacity if (property == 'opacity' && element.filters) { val = 1; try { val = element.filters.item('DXImageTransform.Microsoft.Alpha').opacity / 100; } catch(e) { try { val = element.filters.item('alpha').opacity / 100; } catch(e) {} } } else if (element.style[camel]) // get camelCase { val = element.style[camel]; } else if (this.m_binfo.ie && element.currentStyle && element.currentStyle[camel]) // Opera 9 "currentStyle" is broken { // camelCase for currentStyle; isIE to workaround broken Opera 9 currentStyle val = element.currentStyle[camel]; } else if (dv && dv.getComputedStyle ) // hyphen-case for computedStyle { var computed = dv.getComputedStyle(element, ''); if (computed && computed.getPropertyValue(hyphen)) { val = computed.getPropertyValue(hyphen); } } return val; } /*********************************************************************************** * * Function: styleSet * * Purpose: (public) set style of element * * Arguements: element - element: element to reference * property - string: style property to set * value - string: value to apply to property * ***********************************************************************************/ CDom.prototype.styleSet = function(element, property, value) { if (!this.m_stylecache[property]) this.styleMakeCache(property); var camel = this.m_stylecache[property]['camel']; switch(property) { case 'opacity': if (this.m_binfo.ie && typeof element.style.filter == 'string') { // not appended element.style.filter = 'alpha(opacity=' + value * 100 + ')'; if (!element.currentStyle || !element.currentStyle.hasLayout) { // no layout or cant tell element.style.zoom = 1; } } else { element.style.opacity = value; element.style['-moz-opacity'] = value; element.style['-khtml-opacity'] = value; } break; case 'float': if (this.m_binfo.ie) element.style['styleFloat'] = value; else element.style['cssFloat'] = value; break; default: element.style[camel] = value; } } /*********************************************************************************** * * Function: getClientHeight * * Purpose: (public) get the height of the client (window) * * Arguements: * ***********************************************************************************/ CDom.prototype.getClientHeight = function() { /* return ALib.m_evwnd.innerHeight != null? ALib.m_evwnd.innerHeight: ALib.m_document.documentElement && ALib.m_document.documentElement.clientHeight ? ALib.m_document.documentElement.clientHeight:ALib.m_document.body != null? ALib.m_document.body.clientHeight:null; */ var height = -1; var mode = this.m_document.compatMode; if ( (mode || this.m_binfo.ie) && !this.m_binfo.opera ) { // IE - Gecko switch (mode) { case 'CSS1Compat': // Standards mode height = this.m_document.documentElement.clientHeight; break; default: // Quirks height = this.m_document.body.clientHeight; } } else // Safari - Opera { height = self.innerHeight; } return height; } CDom.prototype.GetClientHeight = function() { return this.getClientHeight(); } /*********************************************************************************** * * Function: getClientWidth * * Purpose: (public) get the width of the client (window) * * Arguements: * ***********************************************************************************/ CDom.prototype.getClientWidth = function() { /* return ALib.m_evwnd.innerWidth != null? ALib.m_evwnd.innerWidth: ALib.m_document.documentElement && ALib.m_document.documentElement.clientWidth ? ALib.m_document.documentElement.clientWidth:ALib.m_document.body != null? ALib.m_document.body.clientWidth:null; */ var width = -1; var mode = this.m_document.compatMode; // IE, Gecko, Opera if (mode || this.m_binfo.ie) { switch (mode) { case 'CSS1Compat': // Standards mode width = this.m_document.documentElement.clientWidth; break; default: // Quirks width = this.m_document.body.clientWidth; } } else // Safari { width = self.innerWidth; } return width; } CDom.prototype.GetClientWidth = function() { this.getClientWidth(); } /*********************************************************************************** * * Function: getDocumentHeight * * Purpose: (public) get the height of the entire document * * Arguements: * ***********************************************************************************/ CDom.prototype.getDocumentHeight = function() { /* return ALib.m_evwnd.innerHeight != null? ALib.m_evwnd.innerHeight: ALib.m_document.documentElement && ALib.m_document.documentElement.clientHeight ? ALib.m_document.documentElement.clientHeight:ALib.m_document.body != null? ALib.m_document.body.clientHeight:null; */ var scrollHeight=-1; ALib.m_evwnd.eight=-1; var bodyHeight=-1; var marginTop = parseInt(this.styleGet(this.m_document.body, 'marginTop'), 10); var marginBottom = parseInt(this.styleGet(this.m_document.body, 'marginBottom'), 10); var mode = this.m_document.compatMode; if ((mode || this.m_binfo.ie) && !this.m_binfo.opera) // IE - Gecko { switch (mode) { case 'CSS1Compat': // Standards mode scrollHeight = ((ALib.m_evwnd.innerHeight && ALib.m_evwnd.scrollMaxY) ? ALib.m_evwnd.innerHeight+ALib.m_evwnd.scrollMaxY : -1); ALib.m_evwnd.eight = [this.m_document.documentElement.clientHeight, self.innerHeight||-1].sort(function(a, b){return(a-b);})[1]; bodyHeight = this.m_document.body.offsetHeight + marginTop + marginBottom; break; default: // Quirks scrollHeight = this.m_document.body.scrollHeight; bodyHeight = this.m_document.body.clientHeight; } } else // Safari - Opera { scrollHeight = this.m_document.documentElement.scrollHeight; ALib.m_evwnd.eight = self.innerHeight; bodyHeight = this.m_document.documentElement.clientHeight; } var h = [scrollHeight,ALib.m_evwnd.eight,bodyHeight].sort(function(a, b){return(a-b);}); return h[2]; } CDom.prototype.GetDocumentHeight = function() { return this.getDocumentHeight(); } /*********************************************************************************** * * Function: getDocumentWidth * * Purpose: (public) get the width of the entire document * * Arguements: * ***********************************************************************************/ CDom.prototype.getDocumentWidth = function() { /* return ALib.m_evwnd.innerWidth != null? ALib.m_evwnd.innerWidth: ALib.m_document.documentElement && ALib.m_document.documentElement.clientWidth ? ALib.m_document.documentElement.clientWidth:ALib.m_document.body != null? ALib.m_document.body.clientWidth:null; */ var docWidth=-1,bodyWidth=-1,winWidth=-1; var marginRight = parseInt(this.styleGet(this.m_document.body, 'marginRight'), 10); var marginLeft = parseInt(this.styleGet(this.m_document.body, 'marginLeft'), 10); var mode = this.m_document.compatMode; // (IE, Gecko, Opera) if (mode || isIE) { switch (mode) { case 'CSS1Compat': // Standards docWidth = this.m_document.documentElement.clientWidth; bodyWidth = this.m_document.body.offsetWidth + marginLeft + marginRight; winWidth = self.innerWidth || -1; break; default: // Quirks bodyWidth = this.m_document.body.clientWidth; winWidth = this.m_document.body.scrollWidth; break; } } else // safari { docWidth = this.m_document.documentElement.clientWidth; bodyWidth = this.m_document.body.offsetWidth + marginLeft + marginRight; winWidth = self.innerWidth; } var w = [docWidth,bodyWidth,winWidth].sort(function(a, b){return(a-b);}); return w[2]; } CDom.prototype.GetDocumentWidth = function() { return this.getDocumentWidth(); } /*********************************************************************************** * * Function: getScrollPosLeft * * Purpose: (public) get the current position (scrolled) on the document - left * * Arguements: * ***********************************************************************************/ CDom.prototype.getScrollPosLeft = function() { return typeof ALib.m_evwnd.pageXOffset != 'undefined' ? ALib.m_evwnd.pageXOffset : ALib.m_document.documentElement && ALib.m_document.documentElement.scrollLeft ? ALib.m_document.documentElement.scrollLeft : ALib.m_document.body.scrollLeft ? ALib.m_document.body.scrollLeft:0; } /*********************************************************************************** * * Function: getScrollPosTop * * Purpose: (public) get the current position (scrolled) on the document - top * * Arguements: * ***********************************************************************************/ CDom.prototype.getScrollPosTop = function() { return typeof ALib.m_evwnd.pageYOffset != 'undefined' ? ALib.m_evwnd.pageYOffset : ALib.m_document.documentElement && ALib.m_document.documentElement.scrollTop ? ALib.m_document.documentElement.scrollTop : ALib.m_document.body.scrollTop?ALib.m_document.body.scrollTop:0; } /*********************************************************************************** * * Function: styleAddClass * * Purpose: (public) append a class to an element * * Arguements: element - element: element to modify * className - string: class to add * ***********************************************************************************/ CDom.prototype.styleAddClass = function(element, className) { element['className'] = [element['className'], className].join(' '); } CDom.prototype.StyleAddClass = function(element, className) { this.styleAddClass(element, className); } /*********************************************************************************** * * Function: styleSetClass * * Purpose: (public) change class of element. This will replace current class * * Arguements: element - element: element to modify * className - string: class to add * ***********************************************************************************/ CDom.prototype.styleSetClass = function(element, className) { element['className'] = className; } CDom.prototype.setClass = function(element, className) { this.styleSetClass(element, className); } /*********************************************************************************** * * Function: getElementPosition * * Purpose: (public) get the position of an emelment in relation to doc * * Arguements: element - element: element to locate * ***********************************************************************************/ CDom.prototype.getElementPosition = function(o) { var left = 0; var top = 0; var right = o.offsetWidth; var bottom = o.offsetHeight; while (o.offsetParent) { left += o.offsetLeft; top += o.offsetTop; o = o.offsetParent; } left += o.offsetLeft; top += o.offsetTop; right += left; bottom += top; return {x:left, y:top, r:right, b:bottom}; } /*********************************************************************************** * * Function: setMouseCoords * * Purpose: (private) set the current position of the mouse (for tracking clicks) * * Arguements: ev - event: event to process * ***********************************************************************************/ CDom.prototype.setMouseCoords = function (ev) { ev = CDomFixEvent(ev); if(ev.pageX || ev.pageY) { ALib.Dom.mouse_x = ev.pageX; ALib.Dom.mouse_y = ev.pageY; } else { ALib.Dom.mouse_x = ev.clientX + ALib.m_document.body.scrollLeft - ALib.m_document.body.clientLeft; ALib.Dom.mouse_y = ev.clientY + ALib.m_document.body.scrollTop - ALib.m_document.body.clientTop; } } /*********************************************************************************** * * Function: getMouseCoords * * Purpose: (public) return x and y of current mouse position * * Arguements: * ***********************************************************************************/ CDom.prototype.getMouseCoords = function () { return { x:ALib.Dom.mouse_x, y:ALib.Dom.mouse_y }; } /*********************************************************************************** * * Function: changeFontSize * * Purpose: (public) change the size of font inside any container * * Arguements: e - string/element : the id of the container or the container * type - string : + or - * ***********************************************************************************/ CDom.prototype.changeFontSize = function(e, type, min, max) { if (typeof e == "string") e = this.getElementById(e); if (!min) var min = 8; if (!max) var max = 18; if(e.style.fontSize) { var s = parseInt(e.style.fontSize.replace("px","")); } else { var s = 12; } if (type == "-") { if(s!=min) { s -= 1; } } else { if(s!=max) { s += 1; } } e.style.fontSize = s+"px" } /*********************************************************************************** * * Function: setInputBlurText * * Purpose: (public) Put text inside input until user clicks on it * * Arguements: e - string/input : the id of the container or the container * type - string : + or - * ***********************************************************************************/ CDom.prototype.setInputBlurText = function(e, text, blurclass, onclass, overclass) { if (typeof e == "string") e = this.getElementById(e); e.Dom = this; e.blurtext = text; if (onclass) e.onclass = onclass; if (blurclass) e.blurclass = blurclass; if (overclass) e.overclass = overclass; e.onfocus = function() { if (this.overclass) { this.onmouseover = function() { this.Dom.styleSetClass(this, this.overclass); } this.onmouseout = function() { if (this.onclass) this.Dom.styleSetClass(this, this.onclass); else this.Dom.styleSetClass(this, ""); } } this.value = ""; if (this.onclass) this.Dom.styleSetClass(this, this.onclass); else if (this.blurclass) this.Dom.styleSetClass(this, ""); }; e.onblur = function() { if (this.overclass) { this.onmouseover = function() { this.Dom.styleSetClass(this, this.overclass); } this.onmouseout = function() { if (this.blurclass) this.Dom.styleSetClass(this, this.blurclass); else this.Dom.styleSetClass(this, ""); } } if (this.blurclass) this.Dom.styleSetClass(this, this.blurclass); if (this.value == "") { this.value = this.blurtext; } } e.value = text; if (blurclass) this.styleSetClass(e, blurclass); if (overclass) { e.onmouseover = function() { this.Dom.styleSetClass(this, this.overclass); } e.onmouseout = function() { if (this.blurclass) this.Dom.styleSetClass(this, this.blurclass); else this.Dom.styleSetClass(this, ""); } } } /*********************************************************************************** * * Function: CDomFixEvent * * Purpose: (private) process and return standard event * * Arguements: e - event: event to process/translate * ***********************************************************************************/ function CDomFixEvent(e) { if (typeof e == 'undefined') { if (ALib.m_evwnd) e = ALib.m_evwnd.event; else e = ALib.m_evwnd.event; } if (e) { if (typeof e.layerX == 'undefined') e.layerX = e.offsetX; if (typeof e.layerY == 'undefined') e.layerY = e.offsetY; return e; } else return null; } /**************************************************************************** * * Class: CDragAndDrop * * Purpose: Add Drag&Drop functionality * * Author: Sky Stebnicki, sky.stebnicki@aereus.com * Copyright (c) 2006 Aereus Corporation. All rights reserved. * *****************************************************************************/ /* * Notes * * 1. If there is no drop zone defined then just drag the entire if (if absolute positioned) * Otherwise, if there are dropzones, create a dummy div(absoutle) with a copy of source to drag. * That way if the user does not drop into a drop zone then we can just return to our previous position. */ var DragAndDrop = { obj : null, dropzones : new Array, registerDragable : function (o, oRoot, dzgroup, minX, maxX, minY, maxY) { o.onmousedown = DragAndDrop.start; o.hmode = true ; o.vmode = true ; o.root = (oRoot && oRoot != null) ? oRoot : o ; // We can restrict this drag item to a groups of dropzones with dzgroup if (dzgroup) o.m_groupName = dzgroup; // Create new element that will hold copy of orig o.m_dragCon = ALib.m_document.createElement("div"); ALib.m_document.body.appendChild(o.m_dragCon); o.m_dragCon.style.position = "absolute"; o.m_dragCon.style.top = "0px"; o.m_dragCon.style.left = "0px"; o.m_dragCon.style.display = "none"; o.minX = typeof minX != 'undefined' ? minX : null; o.minY = typeof minY != 'undefined' ? minY : null; o.maxX = typeof maxX != 'undefined' ? maxX : null; o.maxY = typeof maxY != 'undefined' ? maxY : null; o.root.onDragStart = new Function(); o.root.onDragEnd = new Function(); o.root.onDrag = new Function(); }, start : function(e) { var o = DragAndDrop.obj = this; e = DragAndDrop.fixE(e); var pos = ALib.Dom.getElementPosition(DragAndDrop.obj.root); var y = pos.y; var x = pos.x; o.root.onDragStart(x, y); // Now create a default setDragGuiCon if not already called if (typeof o.m_dragConSet == "undefined") { var icon = ALib.m_document.createElement("div"); ALib.Dom.styleSet(icon, "border", o.style.border); ALib.Dom.styleSet(icon, "width", (pos.r - pos.x) + "px"); ALib.Dom.styleSet(icon, "height", (pos.b - pos.y) + "px"); icon.innerHTML = o.root.innerHTML; DragAndDrop.setDragGuiCon(o, icon); } o.m_dragCon.style.display = "block"; o.m_dragCon.style.top = y + "px"; o.m_dragCon.style.left = x+ "px"; o.lastMouseX = e.clientX; o.lastMouseY = e.clientY; if (o.minX != null) o.minMouseX = e.clientX - x + o.minX; if (o.maxX != null) o.maxMouseX = o.minMouseX + o.maxX - o.minX; if (o.minY != null) o.minMouseY = e.clientY - y + o.minY; if (o.maxY != null) o.maxMouseY = o.minMouseY + o.maxY - o.minY; ALib.m_document.onmousemove = DragAndDrop.drag; ALib.m_document.onmouseup = DragAndDrop.end; return false; }, drag : function(e) { e = DragAndDrop.fixE(e); var o = DragAndDrop.obj; var ey = e.clientY; var ex = e.clientX; var y = parseInt(o.m_dragCon.style.top); var x = parseInt(o.m_dragCon.style.left); var nx, ny; if (o.minX != null) ex = Math.max(ex, o.minMouseX); if (o.maxX != null) ex = Math.min(ex, o.maxMouseX); if (o.minY != null) ey = Math.max(ey, o.minMouseY); if (o.maxY != null) ey = Math.min(ey, o.maxMouseY); nx = x + (ex - o.lastMouseX); ny = y + (ey - o.lastMouseY); // Check if we are over a drop zone var dz = DragAndDrop.inDropZone(o, ex, ey); if (o.m_dz) { if (dz) { if (dz != o.m_dz) { DragAndDrop.dzDragExit(o.m_dz, o); o.m_dz = dz; DragAndDrop.dzDragEnter(dz, o); } } else { DragAndDrop.dzDragExit(o.m_dz, o); o.m_dz = null; } } else { if (dz) { o.m_dz = dz; DragAndDrop.dzDragEnter(dz, o); } } if (DragAndDrop.obj.m_dragOffsetX) DragAndDrop.obj.m_dragCon.style["left"] = (ex + DragAndDrop.obj.m_dragOffsetX) + "px"; else DragAndDrop.obj.m_dragCon.style["left"] = nx + "px"; if (DragAndDrop.obj.m_dragOffsetY) DragAndDrop.obj.m_dragCon.style["top"] = (ey + DragAndDrop.obj.m_dragOffsetY) + "px"; else DragAndDrop.obj.m_dragCon.style["top"] = ny + "px"; DragAndDrop.obj.lastMouseX = ex; DragAndDrop.obj.lastMouseY = ey; // If we are offsetting the container then report mouse pos if (DragAndDrop.obj.m_dragOffsetX) nx = ex; if (DragAndDrop.obj.m_dragOffsetY) ny = ey; DragAndDrop.obj.root.onDrag(nx, ny); return false; }, end : function() { ALib.m_document.onmousemove = null; ALib.m_document.onmouseup = null; var x = DragAndDrop.obj.lastMouseX; var y = DragAndDrop.obj.lastMouseY; var pos = ALib.Dom.getElementPosition(DragAndDrop.obj.m_dragCon); var reportX = pos.x; var reportY = pos.y; // If we are offsetting the container then report mouse pos if (DragAndDrop.obj.m_dragOffsetX) reportX = x; if (DragAndDrop.obj.m_dragOffsetY) reportY = y; if (!DragAndDrop.dropzones.length || (DragAndDrop.dropzones.length && DragAndDrop.obj.m_dz) || !DragAndDrop.obj.m_groupName) { DragAndDrop.obj.root.onDragEnd(reportX, reportY); } // Move original object DragAndDrop.obj.m_dragCon.style.display = "none"; if(DragAndDrop.obj.m_dz) { DragAndDrop.dzDragDrop(DragAndDrop.obj.m_dz, DragAndDrop.obj); } DragAndDrop.obj = null; }, fixE : function(e) { if (typeof e == 'undefined') { if (ALib.m_evwnd) e = ALib.m_evwnd.event; else e = window.event; } if (typeof e.layerX == 'undefined') e.layerX = e.offsetX; if (typeof e.layerY == 'undefined') e.layerY = e.offsetY; return e; }, // The below function will set the icon/container under the cursor when dragged (can be object) setDragGuiCon : function(obj, con, offsetX, offsetY) { DragAndDrop.clearDragGuiCon(obj.m_dragCon); obj.m_dragCon.appendChild(con); obj.m_dragConSet = true; // offsetX and offsetY are used to position div relative to mouse obj.m_dragOffsetX = null; obj.m_dragOffsetY = null; if (offsetX) obj.m_dragOffsetX = offsetX; if (offsetY) obj.m_dragOffsetY = offsetY; }, clearDragGuiCon : function(con) { con.innerHTML = ""; }, inDropZone : function(e, x, y) { var objPos = []; for (var i = 0; i < this.dropzones.length; i++) { objPos = ALib.Dom.getElementPosition(this.dropzones[i], true); // test to see if x and y are in object region if (x >= objPos.x && y >= objPos.y && y <= objPos.b && x <= objPos.r) { if (e.m_groupName) { if (e.m_groupName == this.dropzones[i].m_groupName) return this.dropzones[i]; } //else // return this.dropzones[i]; } } return null; }, getElementPosition : function(o) { var left = 0; var top = 0; var right = o.offsetWidth; var bottom = o.offsetHeight; while (o.offsetParent) { left += o.offsetLeft; top += o.offsetTop; o = o.offsetParent; } left += o.offsetLeft; top += o.offsetTop; right += left; bottom += top; return {x:left, y:top, r:right, b:bottom}; }, mouseCoords : function(ev) { if(ev.pageX || ev.pageY) return {x:ev.pageX, y:ev.pageY}; return { x:ev.clientX + ALib.m_document.body.scrollLeft - ALib.m_document.body.clientLeft, y:ev.clientY + ALib.m_document.body.scrollTop - ALib.m_document.body.clientTop }; }, /* Dropzone functions */ registerDropzone : function (o, groupname) { var ind = this.dropzones.length; this.dropzones[ind] = o; // set group name o.m_groupName = groupname; o.onDragEnter = new Function; o.onDragExit = new Function; o.onDragDrop = new Function; }, dzDragEnter : function(dz, e) { // Call in dropzone when item is dragged over it dz.onDragEnter(e); }, dzDragExit : function(dz, e) { // Call in dropzone when item leaves drop zone dz.onDragExit(e); }, dzDragDrop : function(dz, e) { // Call in dropzone when item leaves drop zone dz.onDragDrop(e); } }; /*====================================================================================== Module: CDropdownMenu Purpose: Kind of like a window but embedded in the document Author: Sky Stebnicki, sky.stebnicki@aereus.com Copyright (c) 2006 Aereus Corporation. All rights reserved. Usage: var ccTble = new CContentTable("My Window Name", "100px", "100px"); ccTble.print(parent_div); // If no parent div then just doc.write ======================================================================================*/ // Define globals // ----------------------------------------------------------- var g_mRootDiv = null; var g_mClearTimer = null; var g_mClearObj = new Object(); var mDivMClicked = null; var mDivRootMenu = null; var GTIMERCLEAR = null; var mRootBtn = null; var mChildActive = null; var g_CDMenues = new Array(); var g_CDMenCount = 0; function CDropAddHandler(doc) { doc.onclick = function() { if (g_mRootDiv) { if ((g_mRootDiv.m_HaveMouseFocus == false || !g_mRootDiv.m_HaveMouseFocus)) { g_mRootDiv.unloadMe(); g_mRootDiv = null; } } } } function CDropdownMenuDocClick() { try { if (g_mRootDiv) { if ((g_mRootDiv.m_HaveMouseFocus == false || !g_mRootDiv.m_HaveMouseFocus)) { if (g_mRootDiv.m_button.onclickold) g_mRootDiv.m_button.onclick = g_mRootDiv.m_button.onclickold; g_mRootDiv.unloadMe(); g_mRootDiv = null; } } } catch (e) {} } function CDropdownMenu(pnt) { if (pnt) this.m_parent = pnt; // Create an absolutely positioned invisible (for now) div this.m_div = ALib.m_document.createElement("div"); this.m_div.style.position = "absolute"; this.m_div.style.top = "0px"; this.m_div.style.left = "0px"; this.m_div.style.zIndex = g_CDMenCount; this.m_div.menuref = this; this.m_div.onmouseover = function () { this.menuref.handleMouseOver(); } this.m_div.onmouseout = function () { this.menuref.handleMouseOut(); } this.m_div.style.visibility = "hidden"; // Put table inside of div this.m_table = ALib.m_document.createElement("table"); this.m_table.setAttribute("border","0"); this.m_table.border = "0"; this.m_table.setAttribute("cellpadding","0"); this.m_table.cellPadding = "0"; this.m_table.setAttribute("cellspacing","0"); this.m_table.cellSpacing = "0"; this.m_table.className = "CDropdownMenuContainer"; this.m_tbody = ALib.m_document.createElement("tbody"); // Add table body this.m_table.appendChild(this.m_tbody); this.m_div.appendChild(this.m_table); this.m_fulldiv = ALib.m_document.createElement("div"); this.m_id = g_CDMenCount; // Set type (rght, down, left, up) if (pnt) this.m_droptype = 'right'; else this.m_droptype = 'down'; // This is used for ANT if (typeof Ant != 'undefined') this.m_themename = Ant.m_theme; else this.m_themename = 'default'; g_CDMenues[g_CDMenCount] = this; g_CDMenCount++; } CDropdownMenu.prototype.destroyMenu = function (title) { if(this.m_parent) { g_mRootDiv.destroyMenu(); } else { //g_CDMenues.splice(index, howMany this.unloadMe(); delete g_CDMenues[this.m_id]; } } CDropdownMenu.prototype.createLinkMenu = function (title) { var div = ALib.m_document.createElement("span"); div.menuref = this; div.onclick = function() { this.menuref.toggleMenu(); } div.onmouseover = function () { this.menuref.handleMouseOver(); } div.onmouseout = function () { this.menuref.handleMouseOut(); } div.style.cursor = "pointer"; div.innerHTML = title; this.m_button = div; this.m_fulldiv.appendChild(div); this.m_fulldiv.appendChild(this.m_div); return this.m_fulldiv; } // Create a right-click context menu CDropdownMenu.prototype.createContextMenu = function(e, cls_out, cls_over, cls_on) { // You can pass the id of an element if (typeof e == "string") e = ALib.getElementById(e); // Create a test button if (cls_out) this.m_clsOut = cls_out; if (cls_over) this.m_clsOver = cls_over; if (cls_on) this.m_clsOn = cls_on; e.menuref = this; e.m_cls = this; e.oncontextmenu= function() { // Temporarily disable the onclick event (store in onclickold) this.onclickold = this.onclick; this.onclick = null; var cls = this.m_cls; cls.toggleMenu(); // Resture onclick event this.onclick = function() { this.onclick = this.onclickold; }; //this.onclick = onclickold; return false; }; var funover = function() { this.m_cls.handleMouseOver(); if (this.menuref.m_clsOver && this.menuref.m_div.style.visibility == "hidden") ALib.Dom.styleSetClass(this, this.menuref.m_clsOver); } var funout = function() { this.m_cls.handleMouseOut(); if (this.menuref.m_clsOut && this.menuref.m_div.style.visibility == "hidden") ALib.Dom.styleSetClass(this, this.menuref.m_clsOut); } if (ALib.Dom.m_binfo.ie) { e.attachEvent('mouseover', funover); e.attachEvent('mouseout', funout); } else { e.addEventListener('mouseover', funover, false); e.addEventListener('mouseout', funout, false); } this.m_button = e; this.m_fulldiv.appendChild(this.m_div); e.appendChild(this.m_fulldiv); //return this.m_fulldiv; } CDropdownMenu.prototype.createImageMenu = function (img_out, img_over, img_on) { if (img_out) this.m_imageOut = img_out; else if (Ant) this.m_imageOut = "/images/themes/" + Ant.m_theme + "/buttons/dropdownOut.gif"; if (img_over) this.m_imageOver = img_over; else if (Ant) this.m_imageOver = "/images/themes/" + Ant.m_theme + "/buttons/dropdownOver.gif"; if (img_on) this.m_imageOn = img_on; else if (Ant) this.m_imageOn = "/images/themes/" + Ant.m_theme + "/buttons/dropdownOn.gif"; var div = ALib.m_document.createElement("span"); div.menuref = this; div.style.cursor = "pointer"; div.m_image = ALib.m_document.createElement("img"); div.m_image.border = "0"; div.m_image.src = this.m_imageOut; div.appendChild(div.m_image); //div.innerHTML = ""; div.m_imageOut = this.m_imageOut; div.m_imageOver = this.m_imageOver; div.onclick = function() { this.menuref.toggleMenu(); } div.onmouseover = function () { this.menuref.handleMouseOver(); if (this.menuref.m_div.style.visibility == "hidden") div.m_image.src = this.m_imageOver; } div.onmouseout = function () { this.menuref.handleMouseOut(); if (this.menuref.m_div.style.visibility == "hidden") div.m_image.src = this.m_imageOut; } this.m_button = div; this.m_fulldiv.appendChild(div); this.m_fulldiv.appendChild(this.m_div); return this.m_fulldiv; } CDropdownMenu.prototype.createButtonMenu = function (title) { var full_title = "
"; full_title += (title) ? title : ''; full_title += "
"; // Create a test button var btn = new CButton(full_title, "g_CDMenues["+this.m_id+"].toggleMenu()", null, "b1"); var button_con = btn.getButton(); var button_tbl = btn.getTable(); button_tbl.menuref = this; button_tbl.onmouseover = function () { this.menuref.handleMouseOver(); } button_tbl.onmouseout = function () { this.menuref.handleMouseOut(); } this.m_button = button_con; this.m_fulldiv.appendChild(button_con); this.m_fulldiv.appendChild(this.m_div); return this.m_fulldiv; } CDropdownMenu.prototype.createCustomnMenu = function(element, cls_out, cls_over, cls_on) { // Create a test button if (cls_out) this.m_clsOut = cls_out; if (cls_over) this.m_clsOver = cls_over; if (cls_on) this.m_clsOn = cls_on; element.menuref = this; element.onclick = function() { this.menuref.toggleMenu(); } element.onmouseover = function () { this.menuref.handleMouseOver(); if (this.menuref.m_clsOver && this.menuref.m_div.style.visibility == "hidden") ALib.Dom.styleSetClass(this, this.menuref.m_clsOver); } element.onmouseout = function () { this.menuref.handleMouseOut(); if (this.menuref.m_clsOut && this.menuref.m_div.style.visibility == "hidden") ALib.Dom.styleSetClass(this, this.menuref.m_clsOut); } this.m_button = element; this.m_fulldiv.appendChild(element); this.m_fulldiv.appendChild(this.m_div); return this.m_fulldiv; } CDropdownMenu.prototype.addEntry = function (title, funct, icon, icon_text, fargs) { var row = ALib.m_document.createElement("tr"); row.menuref = this; // Create icon cell var cell_icon = ALib.m_document.createElement("td"); cell_icon.className = "CDropdownMenuIcon"; cell_icon.style.whiteSpace = "nowrap"; if (icon) { cell_icon.innerHTML = ""; } else { cell_icon.innerHTML = "
"+((icon_text) ? icon_text : '')+"
"; } row.appendChild(cell_icon); // Create link cell var cell_link = ALib.m_document.createElement("td"); cell_link.className = "CDropdownMenuLink"; cell_link.nowrap = true; cell_link.style.whiteSpace = "nowrap"; cell_link.innerHTML = title; row.appendChild(cell_link); // Create right arrow cell var cell_right = ALib.m_document.createElement("td"); cell_right.className = "CDropdownMenuRight"; cell_right.nowrap = true; cell_right.style.whiteSpace = "nowrap"; cell_right.innerHTML = " "; row.appendChild(cell_right); if (funct) { row.style.cursor = "pointer"; row.functname = funct; row.onclick = function () { if (typeof this.functname != "string") { if (typeof fargs != "undefined" && fargs) { switch (fargs.length) { case 1: this.functname(fargs[0]); break; case 2: this.functname(fargs[0], fargs[1]); break; case 3: this.functname(fargs[0], fargs[1], fargs[2]); break; case 4: this.functname(fargs[0], fargs[1], fargs[2], fargs[3]); break; case 5: this.functname(fargs[0], fargs[1], fargs[2], fargs[3], fargs[4]); break; case 6: this.functname(fargs[0], fargs[1], fargs[2], fargs[3], fargs[4], fargs[5]); break; case 7: this.functname(fargs[0], fargs[1], fargs[2], fargs[3], fargs[4], fargs[5], fargs[6]); break; } } else this.functname(); } else eval(this.functname); g_mRootDiv.unloadMe(); g_mRootDiv = null; } } row.onmouseover = function () { if (this.menuref.m_activechild) { this.menuref.m_activechild.unloadMe(); this.menuref.m_activechild = null; } CDMenuSetRowHighligh(true, this); } row.onmouseout = function () { CDMenuSetRowHighligh(false, this); } this.m_tbody.appendChild(row); } CDropdownMenu.prototype.addSubmenu = function (title, icon, funct, fargs) { var dlmenu = new CDropdownMenu(this); var row = ALib.m_document.createElement("tr"); row.style.cursor = "pointer"; // Create icon cell var cell_icon = ALib.m_document.createElement("td"); cell_icon.className = "CDropdownMenuIcon"; cell_icon.style.width = '15px'; cell_icon.style.whiteSpace = "nowrap"; if (icon) cell_icon.innerHTML = "
"; else cell_icon.innerHTML = "
"; row.appendChild(cell_icon); // Create link cell var cell_link = ALib.m_document.createElement("td"); cell_link.className = "CDropdownMenuLink"; cell_link.innerHTML = title; cell_link.nowrap = true; cell_link.style.whiteSpace = "nowrap"; row.appendChild(cell_link); // Create right arrow cell var cell_right = ALib.m_document.createElement("td"); cell_right.className = "CDropdownMenuRight"; cell_right.nowrap = true; cell_right.style.whiteSpace = "nowrap"; // "+this.m_themename+" cell_right.innerHTML = "
"; row.appendChild(cell_right); if (funct) { row.style.cursor = "pointer"; row.functname = funct; row.onclick = function () { if (typeof this.functname != "string") { if (typeof fargs != "undefined" && fargs) { switch (fargs.length) { case 1: this.functname(fargs[0]); break; case 2: this.functname(fargs[0], fargs[1]); break; case 3: this.functname(fargs[0], fargs[1], fargs[2]); break; case 4: this.functname(fargs[0], fargs[1], fargs[2], fargs[3]); break; case 5: this.functname(fargs[0], fargs[1], fargs[2], fargs[3], fargs[4]); break; case 6: this.functname(fargs[0], fargs[1], fargs[2], fargs[3], fargs[4], fargs[5]); break; case 7: this.functname(fargs[0], fargs[1], fargs[2], fargs[3], fargs[4], fargs[5], fargs[6]); break; } } else this.functname(); } else eval(this.functname); g_mRootDiv.unloadMe(); g_mRootDiv = null; } } row.menuref = dlmenu; dlmenu.m_button = row; row.onmouseover = function () { this.menuref.handleMouseOver(); if (this.menuref.m_div.style.visibility == "hidden") this.menuref.toggleMenu(); window.clearTimeout(g_mClearObj.timer); g_mClearObj.m_id = null; CDMenuSetRowHighligh(true, this); } row.onmouseout = function () { this.menuref.handleMouseOut(); g_mClearObj.m_id = this.menuref.m_id; g_mClearObj.timer = setTimeout('CDMenuClearMenu()', 2000); CDMenuSetRowHighligh(false, this); } this.m_tbody.appendChild(row); dlmenu.m_fulldiv.appendChild(dlmenu.m_div); this.m_fulldiv.appendChild(dlmenu.m_fulldiv); return dlmenu; } CDropdownMenu.prototype.unloadMe = function () { if (this.m_activechild) { this.m_activechild.unloadMe(); } this.m_activechild = null; if (this.m_parent) CDMenuSetRowHighligh(false, this.m_button); else { if (this.m_imageOut) { if (this.m_button && this.m_button.m_image) this.m_button.m_image.src = this.m_imageOut; } if (this.m_clsOut) { if (this.m_button) ALib.Dom.styleSetClass(this.m_button, this.m_clsOut); } } this.m_div.style.visibility = "hidden"; } CDropdownMenu.prototype.handleMouseOver = function () { this.setFocus(true); /* this.m_HaveMouseFocus=true if (this.m_parent) { this.m_parent.m_HaveMouseFocus=true CDMenuSetRowHighligh(true, this.m_button); } */ // Cancel clear if set to current object if (g_mClearObj.m_id == this.m_id) { window.clearTimeout(g_mClearObj.timer); g_mClearObj.m_id = null; } // Open if another dropdown is already open if (g_mRootDiv) { if ((g_mRootDiv.m_HaveMouseFocus == false)) { g_mRootDiv.unloadMe(); g_mRootDiv = null; /* if (this.m_button && this.m_button.onclick) this.m_button.onclick(); */ } } } CDropdownMenu.prototype.handleMouseOut = function () { this.m_HaveMouseFocus=false if (this.m_parent) this.m_parent.m_HaveMouseFocus=false } CDropdownMenu.prototype.setFocus = function(focused) { if (focused == true) this.m_HaveMouseFocus=true; if (this.m_parent) { CDMenuSetRowHighligh(true, this.m_button); this.m_parent.setFocus(true); } } CDropdownMenu.prototype.toggleMenu = function() { if (this.m_parent) { tmpx=this.m_parent.m_div.offsetLeft; tmpy=this.m_parent.m_div.offsetTop + this.m_button.offsetTop; tmpParent=this.m_parent.m_div.offsetParent; } else { tmpx=this.m_button.offsetLeft; tmpy=this.m_button.offsetTop; tmpParent=this.m_button.offsetParent; } tmpheight=this.m_button.offsetHeight; while(tmpParent !=null) { tmpy+=tmpParent.offsetTop; tmpx+=tmpParent.offsetLeft; tmpParent=tmpParent.offsetParent; } // Get document width if (ALib.m_document) { var doc_width = ALib.m_document.body.clientWidth; } else { var doc_width = document.body.clientWidth; } if (this.m_div.style.visibility == "visible") { this.m_div.onfaded = function() { this.style.visibility = 'hidden'; } ALib.Effect.fade(this.m_div, 200); if (this.m_parent) { if (this.m_parent.m_activechild != this) { this.m_parent.m_activechild.unloadMe() this.m_parent.m_activechild = null; } } else { this.unloadMe(); g_mRootDiv = null; // Unloaded root, detach event if (ALib.Dom.m_binfo.ie) { ALib.m_document.detachEvent('click', CDropdownMenuDocClick); } else { ALib.m_document.removeEventListener('click', CDropdownMenuDocClick, false); } } } else { // Find out of we are out of space if ('right' == this.m_droptype) { //alert(tmpx + this.m_div.offsetWidth + " " + doc_width); if ((tmpx + this.m_button.offsetWidth + this.m_div.offsetWidth) >= doc_width) this.m_droptype = 'left'; } switch (this.m_droptype) { case 'up': this.m_div.style.top = tmpy - this.m_div.offsetHeight + 'px'; if ((tmpy - this.m_div.offsetHeight) < 10) { this.m_div.style.top = tmpy + tmpheight + 'px'; } this.m_div.style.left = tmpx + 'px'; break; case 'down': this.m_div.style.top = tmpy + tmpheight + 'px'; if ((tmpx + this.m_div.offsetWidth) >= doc_width) this.m_div.style.left = doc_width - this.m_div.offsetWidth - 1 + 'px'; else this.m_div.style.left = tmpx + 'px'; break; case 'right': this.m_div.style.top = tmpy + 'px'; this.m_div.style.left = tmpx + this.m_button.offsetWidth - 1 + 'px'; break; case 'left': this.m_div.style.top = tmpy + 'px'; this.m_div.style.left = tmpx - this.m_div.offsetWidth + 1 + 'px'; break; } // clear existing menu if (g_mRootDiv && !this.m_parent) { g_mRootDiv.unloadMe(); } ALib.Effect.fadein(this.m_div, 200); this.m_div.style.visibility = "visible"; if (this.m_parent) { if (this.m_parent.m_activechild && this.m_parent.m_activechild != this) this.m_parent.m_activechild.unloadMe(); this.m_parent.m_activechild = this; } else { g_mRootDiv = this; if (this.m_imageOn) this.m_button.m_image.src = this.m_imageOn; if (this.m_clsOn) { ALib.Dom.styleSetClass(this.m_button, this.m_clsOn); } } if (ALib.Dom.m_binfo.ie) { ALib.m_document.attachEvent('onclick', CDropdownMenuDocClick); } else { ALib.m_document.addEventListener('click', CDropdownMenuDocClick, false); } } } function CDMenuClearMenu() { g_CDMenues[g_mClearObj.m_id].unloadMe(); } function CDMenuSetRowHighligh(setRow, row) { if (setRow == true) { try { row.childNodes.item(0).className = "CDropdownMenuIconOver"; row.childNodes.item(1).className = "CDropdownMenuLinkOver"; row.childNodes.item(2).className = "CDropdownMenuRightOver"; row.childNodes.item(2).childNodes.item(0).className = "CDropdownMenuRightIconOver"; } catch (e) {} } else { try { row.childNodes.item(0).className = "CDropdownMenuIcon"; row.childNodes.item(1).className = "CDropdownMenuLink"; row.childNodes.item(2).className = "CDropdownMenuRight"; row.childNodes.item(2).childNodes.item(0).className = "CDropdownMenuRightIcon"; } catch (e) {} } } /**************************************************************************** * * Class: CMenubar * * Purpose: Create menu bar like the file menu in windows * * Author: Sky Stebnicki, sky.stebnicki@aereus.com * Copyright (c) 2006 Aereus Corporation. All rights reserved. * *****************************************************************************/ function CMenubar() { this.m_document = ALib.m_document; var doc = this.m_document; this.m_outerdv = doc.createElement("div"); var tbl = doc.createElement("table"); ALib.Dom.styleSetClass(tbl, "CMenubar"); ALib.Dom.styleSet(tbl, "width", "100%"); tbl.setAttribute("cellpadding","0"); tbl.cellPadding = "0"; tbl.setAttribute("cellspacing","0"); tbl.cellSpacing = "0"; var tbl_bdy = doc.createElement("tbody"); tbl.appendChild(tbl_bdy); var row = doc.createElement("tr"); tbl_bdy.appendChild(row); var td = doc.createElement("td"); row.appendChild(td); this.m_con = td; this.m_outerdv.appendChild(tbl); } /****************************************************************************** * Function: AddItem * Purpose: Add any item to the toolbar *******************************************************************************/ CMenubar.prototype.AddItem = function (title, align) { var dv = this.m_document.createElement("div"); if (align == "right") { ALib.Dom.styleSet(dv, "float", "right"); ALib.Dom.styleSet(dv, "padding-right", "2px"); } else { ALib.Dom.styleSet(dv, "float", "left"); ALib.Dom.styleSet(dv, "padding-left", "2px"); } dv.innerHTML = title; // Create dropdown menu var dm = new CDropdownMenu(); this.m_con.appendChild(dm.createCustomnMenu(dv, "CMenuBarLink", "CMenuBarLinkOver", "CMenuBarLinkOn")); return dm; } /****************************************************************************** * Function: print * Purpose: Append toolbar to container passed in dv (write if no container) *******************************************************************************/ CMenubar.prototype.print = function (dv) { if (dv) dv.appendChild(this.m_outerdv); else document.write(this.m_outerdv.outerHTML); } /****************************************************************************** * Function: getContainer * Purpose: Get content container for toolbar *******************************************************************************/ CMenubar.prototype.getContainer = function () { return this.m_con; } /**************************************************************************** * * Class: CNavBar * * Purpose: Create standard navigation bar * * Author: Sky Stebnicki, sky.stebnicki@aereus.com * Copyright (c) 2006 Aereus Corporation. All rights reserved. * *****************************************************************************/ function CNavBar(width) { this.m_con = ALib.m_document.createElement("div"); if (!width) var width = "100%"; ALib.Dom.styleSet(this.m_con, "width", width); this.m_items = new Array(); this.m_itemcounter = 0; this.m_sections = new Array(); this.m_sectioncounter = 0; this.m_lasesection = null; this.m_appclass = null; } CNavBar.prototype.addSectionItem = function(label, icon, action, args, idname, sectionid, depth, parent_node) { // Get unique id name var name = (idname) ? idname: this.getNextItemId(); var sect_id = (sectionid) ? sectionid : this.m_lasesection; // Create item/node this.m_items[name] = new CNavBarItem(this); var item = this.m_items[name]; item.m_secname = sect_id; item.m_idname = name; if (typeof(depth) == "undefined") item.m_depth = 0; else item.m_depth = depth; var tr = ALib.m_document.createElement("tr"); item.m_tr = tr; if (typeof(parent_node) != "undefined") insertAfter(this.m_sections[sect_id].m_tblbdy, tr, parent_node.m_tr); else this.m_sections[sect_id].m_tblbdy.appendChild(tr); var td = ALib.m_document.createElement("td"); ALib.Dom.styleSet(td, "width", "100%"); tr.appendChild(td); // Make header table var tbl = ALib.m_document.createElement("table"); ALib.Dom.styleSet(tbl, "border", "0px"); ALib.Dom.styleSet(tbl, "width", "100%"); tbl.cellPadding = 0; tbl.cellSpacing = 0; td.appendChild(tbl); var tbody = ALib.m_document.createElement("tbody"); tbl.appendChild(tbody); // Add Item var tr = ALib.m_document.createElement("tr"); tbody.appendChild(tr); var td = ALib.m_document.createElement("td"); ALib.Dom.StyleAddClass(td, "CTMLeftBorder"); tr.appendChild(td); var td = ALib.m_document.createElement("td"); ALib.Dom.StyleAddClass(td, "CNavBarItem"); ALib.Dom.styleSet(td, "cursor", "pointer"); item.m_itemcon = td; // if depth add spacers for (var i = 0; i < item.m_depth; i++) { var dv = ALib.m_document.createElement("div"); ALib.Dom.styleSet(dv, "float", "left"); ALib.Dom.styleSetClass(dv, "CTreeViewSpaceLine"); td.appendChild(dv); } // icon var dv = ALib.m_document.createElement("div"); ALib.Dom.styleSetClass(dv, "CNavBarItemIcon"); item.m_icon = dv; ALib.Dom.styleSet(dv, "float", "left"); if (icon) { if (typeof(icon) == "string") dv.innerHTML = ""; else dv.appendChild(icon); } td.appendChild(dv); // label var dv = ALib.m_document.createElement("div"); ALib.Dom.styleSetClass(dv, "CNavBarItemLink"); ALib.Dom.styleSet(dv, "float", "left"); item.m_link = dv; dv.innerHTML = label; td.appendChild(dv); //this.m_items[name] = td; item.m_linktd = dv; td.m_name = name; td.m_nav = this; td.onmouseover = function () { if (this.className != "CNavBarItemOn") this.m_nav.itemChangeState(this.m_name, "over"); }; td.onmouseout = function () { if (this.className != "CNavBarItemOn") this.m_nav.itemChangeState(this.m_name, "out"); }; // Set link action item.m_linktd.m_action = action; item.m_linktd.m_nav = this; item.m_linktd.m_name = name; item.m_linktd.m_idname = (typeof idname != "undefined") ? idname : name; if (args) item.m_linktd.m_args = args; item.m_linktd.onclick = function () { if (this.m_idname != -1) this.m_nav.itemChangeState(this.m_name, "on"); if (this.m_action) { if (typeof this.m_action == "string") eval(this.m_action); else { try { if (this.m_args && this.m_args.length) { switch (this.m_args.length) { case 3: this.m_action(this.m_args[0], this.m_args[1], this.m_args[2]); break; case 2: this.m_action(this.m_args[0], this.m_args[1]); break; case 1: this.m_action(this.m_args[0]); break; } } else this.m_action(); } catch (e) {} } } }; var dv = ALib.Dom.createElement("div"); dv.style.clear = "both"; td.appendChild(dv); tr.appendChild(td); var td = ALib.m_document.createElement("td"); ALib.Dom.StyleAddClass(td, "CTMRightBorder"); tr.appendChild(td); return item; } CNavBar.prototype.itemChangeState = function(name, state) { switch (state) { case 'out': this.m_items[name].m_itemcon.className = "CNavBarItem"; break; case 'over': this.m_items[name].m_itemcon.className = "CNavBarItemOver"; break; case 'on': this.m_items[name].m_itemcon.className = "CNavBarItemOn"; if (this.m_laston && this.m_laston != name) this.itemChangeState(this.m_laston, "out"); this.m_laston = name; break; } } CNavBar.prototype.itemClearOnStates = function() { for (item in this.m_items) { this.itemChangeState(item, 'out'); } } CNavBar.prototype.addSectionDiv = function() { } CNavBar.prototype.getNavBar = function() { // Add closing HR var div = ALib.m_document.createElement("div"); this.m_con.appendChild(div); var tbl = ALib.m_document.createElement("table"); div.appendChild(tbl); ALib.Dom.styleSet(tbl, "border", "0px"); ALib.Dom.styleSet(tbl, "width", "100%"); tbl.cellPadding = '0'; tbl.cellSpacing = '0'; var tblbdy = ALib.m_document.createElement("tbody"); tbl.appendChild(tblbdy); var tr = ALib.m_document.createElement("tr"); tblbdy.appendChild(tr); var td = ALib.m_document.createElement("td"); ALib.Dom.StyleAddClass(td, "CTMBorderBottom"); tr.appendChild(td); return this.m_con; } CNavBar.prototype.print = function(con) { con.appendChild(this.getNavBar()); } CNavBar.prototype.getNextItemId = function() { this.m_itemcounter++; var name = "item_" + this.m_itemcounter; return name; } CNavBar.prototype.getNextSectionId = function() { this.m_sectioncounter++; var name = "section_" + this.m_sectioncounter; return name; } CNavBar.prototype.addSection = function(label, idname) { // Get unique id name var name = (idname) ? idname: this.getNextSectionId(); this.m_lasesection = name; this.m_sections[name] = new CNavBarSection(this); var section = this.m_sections[name]; section.m_idname = idname; // Create containing div section.m_div = ALib.m_document.createElement("div"); this.m_con.appendChild(section.m_div); section.m_tbl = ALib.m_document.createElement("table"); ALib.Dom.styleSet(section.m_tbl, "border", "0px"); ALib.Dom.styleSet(section.m_tbl, "width", "100%"); section.m_tbl.cellPadding = '0'; section.m_tbl.cellSpacing = '0'; section.m_tblbdy = ALib.m_document.createElement("tbody"); section.m_tbl.appendChild(section.m_tblbdy); section.m_div.appendChild(section.m_tbl); var tr = ALib.m_document.createElement("tr"); section.m_tblbdy.appendChild(tr); var td = ALib.m_document.createElement("td"); tr.appendChild(td); // Make header table var tbl = ALib.m_document.createElement("table"); ALib.Dom.styleSet(tbl, "border", "0px"); ALib.Dom.styleSet(tbl, "width", "100%"); tbl.cellPadding = 0; tbl.cellSpacing = 0; td.appendChild(tbl); var tbody = ALib.m_document.createElement("tbody"); tbl.appendChild(tbody); // Add HR var tr = ALib.m_document.createElement("tr"); tbody.appendChild(tr); var td = ALib.m_document.createElement("td"); td.colSpan = "3"; ALib.Dom.StyleAddClass(td, "CTMHeaderTopHr"); tr.appendChild(td); // Add Label if (label) { var tr = ALib.m_document.createElement("tr"); tbody.appendChild(tr); var td = ALib.m_document.createElement("td"); ALib.Dom.StyleAddClass(td, "CTMLeftBorder"); tr.appendChild(td); var td = ALib.m_document.createElement("td"); ALib.Dom.StyleAddClass(td, "CTMHeaderBody"); ALib.Dom.styleSet(td, "font-weight", "bold"); td.innerHTML = label; tr.appendChild(td); var td = ALib.m_document.createElement("td"); ALib.Dom.StyleAddClass(td, "CTMRightBorder"); tr.appendChild(td); } return this.m_sections[name]; } // This function should be defined by client application // and called whenever content is changed CNavBar.prototype.onExit = function() { } CNavBar.prototype.deleteItem = function(idname) { var row = this.m_items[idname].m_linktd.parentNode; var tbl = row.parentNode; tbl.removeChild(row); } CNavBar.prototype.setItemLabel = function(idname, label) { // Get label div var dv = this.m_items[idname].m_linktd.childNodes.item(1); if (dv) dv.innerHTML = label; } /*********************************************************************************** * * Function: CNavBarSection * * Purpose: Create CNavBarSection * * Arguements: nbobj - (object): Navbar object * ***********************************************************************************/ function CNavBarSection(nbobj) { this.m_div = null; this.m_tbl = null; this.m_tblbdy = null; this.m_idname = null; this.m_nb = nbobj; } CNavBarSection.prototype.addItem = function(label, icon, action, args, idname) { return this.m_nb.addSectionItem(label, icon, action, args, idname, this.m_idname); } /*********************************************************************************** * * Function: CNavBarItem * * Purpose: Creates node that handles each item. * * Arguements: nbobj - (object): Navbar object * ***********************************************************************************/ function CNavBarItem(nbobj) { this.m_secname = null; this.m_tr = null; this.tilde_dv = null; this.icon_dv = null; this.link_dv = null; this.m_linktd = null; this.m_nb = nbobj; this.m_expanded = false; this.m_depth = 0; this.m_parent = null; this.m_children = new Array(); } CNavBarItem.prototype.addItem = function(label, icon, action, args, idname) { var item = this.m_nb.addSectionItem(label, icon, action, args, idname, this.m_secname, (this.m_depth + 1), this); item.m_parent = this; item.setHasChildren(false); this.m_children[this.m_children.length] = item; this.setHasChildren(true); return item; } CNavBarItem.prototype.getOptionCon = function() { var dv = ALib.Dom.createElement("div"); ALib.Dom.styleSet(dv, "float", "right"); insertAfter(this.m_itemcon, dv, this.m_linktd); return dv; } CNavBarItem.prototype.getLabelCon = function() { return this.m_link; } CNavBarItem.prototype.hide = function() { ALib.Dom.styleSet(this.m_tr, "display", "none"); } CNavBarItem.prototype.show = function() { if (ALib.m_browser.ie) ALib.Dom.styleSet(this.m_tr, "display", "block"); else ALib.Dom.styleSet(this.m_tr, "display", "table-row"); } /*********************************************************************************** * * Function: setHasChildren * * Purpose: Change node the style of one with children * * Arguements: haschildren - bool = does this have children * ***********************************************************************************/ CNavBarItem.prototype.setHasChildren = function(haschildren) { if (!this.tilde_dv) { this.tilde_dv = ALib.Dom.createElement("div"); this.tilde_dv.m_node = this; this.tilde_dv.onclick = function() { if (this.m_node.m_expanded) this.m_node.collapse(); else this.m_node.expand(); } ALib.Dom.styleSet(this.tilde_dv, "float", "left"); this.m_itemcon.insertBefore(this.tilde_dv, this.m_icon); } if (haschildren) { if (this.m_expanded) ALib.Dom.styleSetClass(this.tilde_dv, "CTreeViewTildeWithSubOpen"); else ALib.Dom.styleSetClass(this.tilde_dv, "CTreeViewTildeWithSubClosed"); } else { ALib.Dom.styleSetClass(this.tilde_dv, "CTreeViewTildeNoSub"); } } /*********************************************************************************** * * Function: expand * * Purpose: Expand this node (display children if they exist) * ***********************************************************************************/ CNavBarItem.prototype.expand = function() { if (this.m_children.length) { for (var i = 0; i < this.m_children.length; i++) this.m_children[i].show(); this.m_expanded = true; ALib.Dom.styleSetClass(this.tilde_dv, "CTreeViewTildeWithSubOpen"); } } /*********************************************************************************** * * Function: collapse * * Purpose: Collapse this node (collapse children if they exist) * ***********************************************************************************/ CNavBarItem.prototype.collapse = function() { if (this.m_children.length) { for (var i = 0; i < this.m_children.length; i++) { this.m_children[i].collapse(); this.m_children[i].hide(); } this.m_expanded = false; ALib.Dom.styleSetClass(this.tilde_dv, "CTreeViewTildeWithSubClosed"); } } /*********************************************************************************** * * Function: deleteItem * * Purpose: Deletes this item * ***********************************************************************************/ CNavBarItem.prototype.deleteItem = function() { if (this.m_children.length); { for (var i = 0; i < this.m_children.length; i++) this.m_children[i].deleteItem(); } this.m_nb.deleteItem(this.m_idname); if (this.m_parent) { if (this.m_parent.m_children.length < 2) this.m_parent.haschildren(false); } } /*********************************************************************** * Class: CAdcClient * * Copyright 2006, Aereus Corporation. All rights reserved. * * Purpose: Act as JS clinet of ANT Datacenter Database * * Security: For security reasons, this script cannot pass user name * and password. There is a PHP Class called CAdcJsClient * that can accept quieries from this file (stored locally) * and it will handle authentication securely. * ************************************************************************/ var g_CAdcClient = new Array(); function CAdcClient(url, dbid) { // Set Database ID this.m_dbid = dbid; // Set URL this.m_url = url; // Set cols array this.m_cols = new Array(); // Get last index this.m_ind = g_CAdcClient.length; //g_CAdcClient[this.m_ind] = new CAjax(); } /*********************************************************************** * Function: query * * Purpose: Execute a query * ************************************************************************/ CAdcClient.prototype.query = function(query) { g_CAdcClient[this.m_ind] = null; g_CAdcClient[this.m_ind] = new CAjax(); this.m_cols = null; this.m_cols = new Array(); g_CAdcClient[this.m_ind].m_dbh = this; g_CAdcClient[this.m_ind].onload = function() { var retval = null; var root = this.m_firstNode; var num = root.getNumChildren(); for (i = 0; i < num; i++) { var child = root.getChildNode(i); if (child.m_name == "retval") { if (child.m_text) { this.m_dbh.retval = unescape(child.m_text); } } if (child.m_name == "collist") { var num_cols = child.getNumChildren(); for (j = 0; j < num_cols; j++) { var cols = child.getChildNode(j); if (cols.m_name == "column") { var num_vars = cols.getNumChildren(); var name = null; var type_name = null; var type = null; var notes = null; for (m = 0; m < num_vars; m++) { var colattr = cols.getChildNode(m); switch (colattr.m_name) { case "name": name = (colattr.m_text) ? unescape(colattr.m_text) : ""; break; case "type_name": type_name = (colattr.m_text) ? unescape(colattr.m_text) : ""; break; case "type": type = (colattr.m_text) ? unescape(colattr.m_text) : ""; break; case "notes": notes = (colattr.m_text) ? unescape(colattr.m_text) : ""; break; } } if (name) { var ind = this.m_dbh.m_cols.length; this.m_dbh.m_cols[ind] = new Object(); this.m_dbh.m_cols[ind].name = name; this.m_dbh.m_cols[ind].notes = notes; this.m_dbh.m_cols[ind].data_type = type_name; this.m_dbh.m_cols[ind].type = type; } } } } if (child.m_name == "dataset") { // Populate dataset and numrows if (child.getNumChildren()) this.m_dbh.m_dataset = child; } } this.m_dbh.onload(); }; /* var dv = document.createElement("div"); document.body.appendChild(dv); dv.innerHTML = this.m_url + "?dbid=" + this.m_dbid + "&query=" + escape(query); */ g_CAdcClient[this.m_ind].exec(this.m_url + "?dbid=" + this.m_dbid + "&query=" + escape(query)); } /*********************************************************************** * Function: getNumRows * * Purpose: Get number of rows returned in XML document (not collis) * ************************************************************************/ CAdcClient.prototype.getNumRows = function() { if (this.m_dataset) return this.m_dataset.getNumChildren(); else return 0; } /*********************************************************************** * Function: onload * * Purpose: Will be overloaded by client * ************************************************************************/ CAdcClient.prototype.onload = function() { } /*********************************************************************** * Function: getValue * * Purpose: Retrieve result at row,col_id * ************************************************************************/ CAdcClient.prototype.getValue = function(row, col) { if (this.getNumRows() > row && this.getNumCols() > col) { try { if (this.m_dataset.getChildNode(row)) return this.m_dataset.getChildNode(row).getChildNode(col).m_text; } catch (e) {} } } /*********************************************************************** * Function: getNamedValue * * Purpose: Retrieve result at row,namedcol * ************************************************************************/ CAdcClient.prototype.getNamedValue = function(row, colname) { if (this.getNumRows() > row) { try { if (this.m_dataset.getChildNode(row)) { var num = this.m_cols.length; //[ind].name for (var i = 0; i < num; i++) { if (this.m_cols[i].name == colname) return this.m_dataset.getChildNode(row).getChildNode(i).m_text; } } } catch (e) {} } return ""; } CAdcClient.prototype.getNumCols = function() { return this.m_cols.length; } CAdcClient.prototype.getColName = function(colind) { return this.m_cols[colind].name; } CAdcClient.prototype.getCol = function(colind) { return this.m_cols[colind]; } CAdcClient.prototype.getColIndex = function(colname) { } CAdcClient.prototype.escape = function(text) { if (text) { var myRegExp = /[']/g; return text.replace(myRegExp, "\\'") ; } else return text; } /**************************************************************************** * * Class: CSplitContainer * * Purpose: Create a div-based frame set similar to html frames but using divs * * Author: Sky Stebnicki, sky.stebnicki@aereus.com * Copyright (c) 2006 Aereus Corporation. All rights reserved. * *****************************************************************************/ function CSplitContainer(orientation, width, height) { // Types can be "verticle" or "horizontal" this.m_orientation = (orientation) ? orientation : "verticle"; this.m_document = ALib.m_document; this.m_con = this.m_document.createElement("div"); this.m_tbl = this.m_document.createElement("table"); if (width) ALib.Dom.styleSet(this.m_tbl, "width", width); else ALib.Dom.styleSet(this.m_tbl, "width", "100%"); if (height) ALib.Dom.styleSet(this.m_tbl, "height", height); this.m_tbl.setAttribute("cellpadding","0"); this.m_tbl.cellPadding = "0"; this.m_tbl.setAttribute("cellspacing","0"); this.m_tbl.cellSpacing = "0"; this.m_con.appendChild(this.m_tbl); this.m_tbody = this.m_document.createElement("tbody"); this.m_tbl.appendChild(this.m_tbody); if (height) ALib.Dom.styleSet(this.m_tbody, "height", height); if (this.m_orientation == "verticle") { this.m_row = this.m_document.createElement("tr"); this.m_tbody.appendChild(this.m_row); } this.resizable = false; this.m_columns = new Array(); this.onPanelResize = new Function(); this.onPanelResizeStart = new Function(); } CSplitContainer.prototype.addPanel = function(size, overflow) { // if this is not the first panel and this.resizable == true if (this.m_columns.length >= 1 && this.resizable) { var res_dv = this.m_document.createElement("td"); // Add a column for resize bar if (this.m_orientation == "verticle") { ALib.Dom.styleSetClass(res_dv, "CSplitContainerVertResizeBar"); res_dv.onmouseover = function () { ALib.Dom.styleSetClass(this, "CSplitContainerVertResizeBarOver"); }; res_dv.onmouseout = function () { ALib.Dom.styleSetClass(this, "CSplitContainerVertResizeBar"); }; this.m_row.appendChild(res_dv); } else { ALib.Dom.styleSetClass(res_dv, "CSplitContainerHorizResizeBar"); res_dv.onmouseover = function () { ALib.Dom.styleSetClass(this, "CSplitContainerHorizResizeBarOver"); }; res_dv.onmouseout = function () { ALib.Dom.styleSetClass(this, "CSplitContainerHorizResizeBar"); }; this.m_row = this.m_document.createElement("tr"); this.m_row.appendChild(res_dv); this.m_tbody.appendChild(this.m_row); } } var col_dv = this.m_document.createElement("td"); ALib.Dom.styleSet(col_dv, "vertical-align", "top"); if (overflow) ALib.Dom.styleSet(col_dv, "overflow", overflow); if (this.m_orientation == "verticle") { if (size != "*" && size != "") { ALib.Dom.styleSet(col_dv, "width", size); } this.m_row.appendChild(col_dv); } else { if (size != "*" && size != "") { ALib.Dom.styleSet(col_dv, "height", size); } this.m_row = this.m_document.createElement("tr"); this.m_row.appendChild(col_dv); this.m_tbody.appendChild(this.m_row); } this.m_columns[this.m_columns.length] = col_dv; // Make resize bar dragable (if exists) if (res_dv) { // Add a column for resize bar if (this.m_orientation == "verticle") { DragAndDrop.registerDragable(res_dv); res_dv.m_cls = this; res_dv.m_leftcon = this.m_columns[this.m_columns.length - 2]; res_dv.m_rightcon = this.m_columns[this.m_columns.length - 1]; res_dv.onDragStart = function (x, y) { this.minY = y; this.maxY = y; this.startX = x; // maxX should be set to bounds of container var l_pos = ALib.Dom.getElementPosition(this.m_leftcon); var r_pos = ALib.Dom.getElementPosition(this.m_rightcon); this.minX = l_pos.x; this.maxX = r_pos.r - this.offsetWidth; this.m_leftConWidth = this.m_leftcon.offsetWidth; this.m_rightConWidth = this.m_rightcon.offsetWidth; ALib.Dom.styleSetClass(this.m_dragCon, "CSplitContainerVertResizeBarOver"); this.m_cls.onPanelResizeStart(); }; res_dv.onDrag = function(x, y) { var change = x - this.startX; var l = (this.m_leftConWidth + change); var r = (this.m_rightConWidth + (change*-1)); ALib.Dom.styleSet(this.m_leftcon, "width", l + "px"); ALib.Dom.styleSet(this.m_rightcon, "width", r + "px"); //this.m_leftcon.innerHTML = this.m_leftcon.style.width; //this.m_rightcon.innerHTML = this.m_rightcon.style.width; }; res_dv.onDragEnd = function(x, y) { this.m_cls.onPanelResize(); }; } else { DragAndDrop.registerDragable(res_dv); res_dv.m_cls = this; res_dv.m_topcon = this.m_columns[this.m_columns.length - 2]; res_dv.m_bottomcon = this.m_columns[this.m_columns.length - 1]; res_dv.onDragStart = function (x, y) { this.minX = x; this.maxX = x; this.startY = y; // maxY should be set to bounds of container var t_pos = ALib.Dom.getElementPosition(this.m_topcon); var b_pos = ALib.Dom.getElementPosition(this.m_bottomcon); this.minY = t_pos.y; this.maxY = b_pos.b - this.offsetHeight; this.m_topConHeight = this.m_topcon.offsetHeight; this.m_bottomConHeight = this.m_bottomcon.offsetHeight; ALib.Dom.styleSetClass(this.m_dragCon, "CSplitContainerHorizResizeBarOver"); this.m_cls.onPanelResizeStart(); }; res_dv.onDrag = function(x, y) { var change = y - this.startY; var t = (this.m_topConHeight + change); var b = (this.m_bottomConHeight + (change * -1)); ALib.Dom.styleSet(this.m_topcon, "height", t + "px"); ALib.Dom.styleSet(this.m_bottomcon, "height", b + "px"); //this.m_leftcon.innerHTML = this.m_leftcon.style.width; //this.m_rightcon.innerHTML = this.m_rightcon.style.width; }; res_dv.onDragEnd = function(x, y) { this.m_cls.onPanelResize(); }; } } return col_dv; } CSplitContainer.prototype.getPanelCon = function(indx) { return this.m_columns[indx]; } CSplitContainer.prototype.print = function(con) { con.appendChild(this.m_con); } /**************************************************************************** * * Class: CTabs * * Purpose: Build tab navigation * * Author: Sky Stebnicki, sky.stebnicki@aereus.com * Copyright (c) 2006 Aereus Corporation. All rights reserved. * *****************************************************************************/ function CTabs() { this.m_document = ALib.m_document; var doc = this.m_document; this.m_outerdv = doc.createElement("div"); // Create nav row this.m_navrow = doc.createElement("div"); this.m_outerdv.appendChild(this.m_navrow); var tbl = doc.createElement("table"); this.m_navrow.appendChild(tbl); tbl.setAttribute("cellpadding","0"); tbl.cellPadding = "0"; tbl.setAttribute("cellspacing","0"); tbl.cellSpacing = "0"; var tbl_bdy = doc.createElement("tbody"); tbl.appendChild(tbl_bdy); // Create tab row this.m_tabrow = doc.createElement("tr"); tbl_bdy.appendChild(this.m_tabrow); // Create hr row var dv = this.m_document.createElement("div"); ALib.Dom.styleSetClass(dv, "CTTabHr"); this.m_outerdv.appendChild(dv); // Create content div this.m_con = this.m_document.createElement("div"); //ALib.Dom.styleSet(this.m_con, "padding", "1px"); this.m_outerdv.appendChild(this.m_con); this.m_pages = new Array(); this.m_next_index = 0; this.m_default_index = 0; } CTabs.prototype.addTab = function(label, clk_act) { // Create tab object this.m_pages[this.m_next_index] = new Object(); this.m_pages[this.m_next_index].label = label; this.m_pages[this.m_next_index].ind = this.m_next_index; if (clk_act) this.m_pages[this.m_next_index].clk_act = clk_act; this.m_pages[this.m_next_index].container = this.m_document.createElement("div"); // Add tab to tabrow this.m_pages[this.m_next_index].td_l = this.m_document.createElement("td"); this.m_tabrow.appendChild(this.m_pages[this.m_next_index].td_l); this.m_pages[this.m_next_index].td_b = this.m_document.createElement("td"); this.m_pages[this.m_next_index].td_b.innerHTML = label; this.m_tabrow.appendChild(this.m_pages[this.m_next_index].td_b); var me = this; this.m_pages[this.m_next_index].td_b.m_cls = me; this.m_pages[this.m_next_index].td_b.m_ind = this.m_next_index; this.m_pages[this.m_next_index].td_b.onclick = function () { this.m_cls.selectTab(this.m_ind); } this.m_pages[this.m_next_index].td_r = this.m_document.createElement("td"); this.m_tabrow.appendChild(this.m_pages[this.m_next_index].td_r); // Check for display of current tab if (this.m_next_index != this.m_default_index) { ALib.Dom.styleSet(this.m_pages[this.m_next_index].container, "display", "none"); this.setTabState(this.m_next_index, "off"); } else { this.setTabState(this.m_next_index, "on"); } this.m_con.appendChild(this.m_pages[this.m_next_index].container); ALib.Dom.styleSetClass(this.m_pages[this.m_next_index].container, "CTTabBody"); var lastind = this.m_next_index; this.m_next_index++; return this.m_pages[lastind].container; } CTabs.prototype.selectTab = function(indx) { if (this.m_lasttab) this.setTabState(this.m_lasttab, "off"); else this.setTabState(this.m_default_index, "off"); this.setTabState(indx, "on"); this.m_lasttab = indx; } CTabs.prototype.setTabState = function(tabind, state) { switch (state) { case 'on': ALib.Dom.styleSetClass(this.m_pages[tabind].td_l, "CTTabLeftOn"); ALib.Dom.styleSetClass(this.m_pages[tabind].td_b, "CTTabCenterOn"); ALib.Dom.styleSetClass(this.m_pages[tabind].td_r, "CTTabRightOn"); ALib.Dom.styleSet(this.m_pages[tabind].container, "display", "block"); break; case 'off': ALib.Dom.styleSetClass(this.m_pages[tabind].td_l, "CTTabLeftOff"); ALib.Dom.styleSetClass(this.m_pages[tabind].td_b, "CTTabCenterOff"); ALib.Dom.styleSetClass(this.m_pages[tabind].td_r, "CTTabRightOff"); ALib.Dom.styleSet(this.m_pages[tabind].container, "display", "none"); break; } } CTabs.prototype.getPageCon = function(ind) { return this.m_pages[ind].container; } CTabs.prototype.print = function (container) { if (container) container.appendChild(this.m_outerdv); else document.write(this.m_table.outerHTML); } CTabs.prototype.getTabHeight = function() { return this.m_navrow.offsetHeight; } /**************************************************************************** * * Class: CToolbar * * Purpose: Create toolbar frame * * Author: Sky Stebnicki, sky.stebnicki@aereus.com * Copyright (c) 2006 Aereus Corporation. All rights reserved. * *****************************************************************************/ function CToolbar() { this.m_document = ALib.m_document; var doc = this.m_document; this.m_outerdv = doc.createElement("div"); var tbl = doc.createElement("table"); this.m_table = tbl; ALib.Dom.styleSetClass(tbl, "CToolbar"); ALib.Dom.styleSet(tbl, "width", "100%"); tbl.setAttribute("cellpadding","0"); tbl.cellPadding = "0"; tbl.setAttribute("cellspacing","0"); tbl.cellSpacing = "0"; var tbl_bdy = doc.createElement("tbody"); tbl.appendChild(tbl_bdy); var row = doc.createElement("tr"); tbl_bdy.appendChild(row); var td = doc.createElement("td"); row.appendChild(td); this.m_con = td; this.m_outerdv.appendChild(tbl); } /****************************************************************************** * Function: AddItem * Purpose: Add any item to the toolbar *******************************************************************************/ CToolbar.prototype.AddItem = function(element, align) { var dv = this.m_document.createElement("div"); if (align == "right") { ALib.Dom.styleSet(dv, "float", "right"); ALib.Dom.styleSet(dv, "padding-right", "2px"); } else { ALib.Dom.styleSet(dv, "float", "left"); ALib.Dom.styleSet(dv, "padding-left", "2px"); } dv.appendChild(element); this.m_con.appendChild(dv); } /****************************************************************************** * Function: addSpacer * Purpose: Add a spacer to the tooblar *******************************************************************************/ CToolbar.prototype.addSpacer = function(align) { var dv = this.m_document.createElement("div"); if (align == "right") { ALib.Dom.styleSet(dv, "float", "right"); } else { ALib.Dom.styleSet(dv, "float", "left"); } ALib.Dom.styl