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; // Debugging var AJAX_TRACE_RESPONSE = false; /*********************************************************************************** * * 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) { // If a valid xml document has not been loaded then exit gracefully if (xmlLocal.responseXML == null) { if (ALib.m_debug == true) { ALib.trace("XML Failed: " + xmlLocal.responseText); } } else if (xmlLocal.responseXML.documentElement == null) { if (ALib.m_debug == true) { ALib.trace("XML Failed: " + xmlLocal.responseText); } } else { if (AJAX_TRACE_RESPONSE) ALib.trace("Response: " + xmlLocal.responseText); // 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); } // Populate text objref.responseText = xmlLocal.responseText; //ALib.m_debug = true; //ALib.trace(objref.responseText); // 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] + "="; if (typeof args[i][1] != "undefined" && args[i][1] != null) post_data += 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", post_data.length); //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: getChildNodeByName * * Purpose: Retrieve a single node by name * * Arguements: name - string: name of nodes to retrieve * ***********************************************************************************/ CAjaxNode.prototype.getChildNodeByName = 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); break; } } return val; } /*********************************************************************************** * * 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); // Safari & Chrome this.webkit = (agt.indexOf("webkit") != -1); 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'; switch (scheme) { case 'b1-pill-l': this.m_scheme = "b1"; this.m_subscheme = scheme; break; case 'b1-pill-c': this.m_scheme = "b1"; this.m_subscheme = scheme; break; case 'b1-pill-r': this.m_scheme = "b1"; this.m_subscheme = scheme; break; default: this.m_scheme = scheme; } /* this.m_main = ALib.m_document.createElement("div"); ALib.Dom.styleSet(this.m_main, "display", "inline-block"); */ /* this.m_main = ALib.m_document.createElement("div"); ALib.Dom.styleSet(this.m_main, "display", "inline-block"); */ /* 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("button"); this.m_main.setAttribute("type","button"); ALib.Dom.styleSetClass(this.m_main, "CButton-".this.m_scheme); ALib.Dom.styleSet(this.m_main, "padding", "0"); if (ALib.Dom.m_binfo.gecko) ALib.Dom.styleSet(this.m_main, "margin", "0 -3px -5px -3px"); else ALib.Dom.styleSet(this.m_main, "margin", "0"); ALib.Dom.styleSet(this.m_main, "background-color", "transparent"); ALib.Dom.styleSet(this.m_main, "border-width", "0"); ALib.Dom.styleSet(this.m_main, "overflow", "visible"); ALib.Dom.styleSet(this.m_main, "text-decoration", "none"); ALib.Dom.styleSet(this.m_main, "display", "inline-block"); */ /* var table = ALib.m_document.createElement("table"); ALib.Dom.styleSet(table, "display", "inline-table"); this.m_main.appendChild(table); 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.innerHTML = title; 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); */ this.m_main = ALib.m_document.createElement("button"); this.m_main.setAttribute("type","button"); ALib.Dom.styleSetClass(this.m_main, "CButton"); ALib.Dom.styleAddClass(this.m_main, this.m_scheme); if (this.m_subscheme) ALib.Dom.styleAddClass(this.m_main, this.m_subscheme); /* Immediately below is a temporary hack to serve the following margin values only to Gecko browsers Gecko browsers add an extra 3px of left/right padding to button elements which can't be overriden. Thus, we use -3px of left/right margin to overcome this. */ //if (ALib.Dom.m_binfo.gecko) //ALib.Dom.styleSet(this.m_main, "margin", "0 -3px"); var table = ALib.Dom.createElement("span", this.m_main); var lbl = ALib.Dom.createElement("span", table); lbl.innerHTML = title; // Set actions for button 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(); } } /* Set actions for div 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('onmousemove', cls.setMouseCoords); this.m_document.attachEvent('onmousemove', 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 { try { 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; } catch (e) {} } } /*********************************************************************************** * * 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: textAreaAutoResize * * Purpose: (public) Make a textarea autoresize * * Arguements: e - string/input : the id of the container or the container * type - string : + or - * min - minimum height * max - maximum height * ***********************************************************************************/ CDom.prototype.textAreaAutoResizeHeight = function(e, min_height, max_heigh) { var minHeight = (typeof min_height != "undefined") ? min_height : null; var maxHeight = (typeof max_height != "undefined") ? max_height : null; if (typeof e == "string") e = this.getElementById(e); e.minHeight = minHeight; e.maxHeight = maxHeight; e.autoResizeHeight = function() { if (!ALib.m_browser.ie) this.style.height = 0; if (this.minHeight) { if (this.scrollHeight < this.minHeight) { if (!ALib.m_browser.ie) this.style.height = this.minHeight + "px"; return true; } } if (this.maxHeight) { if (this.scrollHeight > this.maxHeight) return true; } this.style.height = this.scrollHeight + 5 + "px"; } var funct = function(e) { if (ALib.m_browser.ie) var ta = ALib.m_evwnd.event.srcElement; else var ta = this; ta.autoResizeHeight(); } if (this.m_binfo.ie) { e.attachEvent('onkeyup', funct); } else { try { e.addEventListener('keyup', funct, false); } catch (e) {} } } /*********************************************************************************** * * 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 += "
"; */ var 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_con.menuref = this; button_con.onmouseover = function () { this.menuref.handleMouseOver(); } button_con.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); // 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; } } } 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(); } this.m_div.style.visibility = "visible"; //ALib.Effect.fadein(this.m_div, 2000); 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 = "left"; 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.getSectionHeight = function(idname) { var section = this.m_sections[idname]; return section.m_div.offsetHeight; } CNavBar.prototype.setSectionHeight = function(idname, height, overflow) { var section = this.m_sections[idname]; if (typeof overflow == "undefined") var overflow = "auto"; var set_height = height - section.m_headerhr.offsetHeight; if (section.m_headerlbl) set_height -= section.m_headerlbl.offsetHeight; ALib.Dom.styleSet(section.m_condiv, "height", set_height+"px"); ALib.Dom.styleSet(section.m_condiv, "overflow", overflow); } CNavBar.prototype.addSection = function(label, idname, manual_height) { // Get unique id name var name = (idname) ? idname: this.getNextSectionId(); this.m_lasesection = name; // Get height var height = (manual_height) ? manual_height : null; this.m_sections[name] = new CNavBarSection(this); var section = this.m_sections[name]; section.m_idname = name; // Create containing div section.m_div = ALib.Dom.createElement("div", this.m_con); // Create content table section.m_outertbl = ALib.Dom.createElement("table", section.m_div); ALib.Dom.styleSet(section.m_outertbl, "border", "0px"); ALib.Dom.styleSet(section.m_outertbl, "width", "100%"); section.m_outertbl.cellPadding = '0'; section.m_outertbl.cellSpacing = '0'; section.m_outertblbdy = ALib.Dom.createElement("tbody", section.m_outertbl); //section.m_tblbdy = ALib.Dom.createElement("tbody"); // Make header table //--------------------------------------------------------------- // Add HR var tr = ALib.Dom.createElement("tr", section.m_outertblbdy); section.m_headerhr = tr; var td = ALib.Dom.createElement("td", tr); td.colSpan = "3"; ALib.Dom.StyleAddClass(td, "CTMHeaderTopHr"); // Add Label if (label) { var tr = ALib.Dom.createElement("tr", section.m_outertblbdy); var td = ALib.Dom.createElement("td", tr); ALib.Dom.StyleAddClass(td, "CTMLeftBorder"); var td = ALib.Dom.createElement("td", tr); ALib.Dom.StyleAddClass(td, "CTMHeaderBody"); ALib.Dom.styleSet(td, "font-weight", "bold"); td.innerHTML = label; var td = ALib.Dom.createElement("td", tr); ALib.Dom.StyleAddClass(td, "CTMRightBorder"); section.m_headerlbl = tr; } // Make content table var tr = ALib.Dom.createElement("tr", section.m_outertblbdy); var td = ALib.Dom.createElement("td", tr); ALib.Dom.StyleAddClass(td, "CTMLeftBorder"); var td = ALib.Dom.createElement("td", tr); section.m_condiv = ALib.Dom.createElement("div", td); ALib.Dom.StyleAddClass(td, "CTMBody"); if (height) { ALib.Dom.styleSet(section.m_condiv, "height", height); ALib.Dom.styleSet(section.m_condiv, "overflow", "auto"); } section.m_tbl = ALib.Dom.createElement("table", section.m_condiv); 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.Dom.createElement("tbody", section.m_tbl); var td = ALib.Dom.createElement("td", tr); ALib.Dom.StyleAddClass(td, "CTMRightBorder"); /* // Create containing div section.m_div = ALib.m_document.createElement("div"); ALib.Dom.styleSet(section.m_div, "height", "100px"); ALib.Dom.styleSet(section.m_div, "overflow", "auto"); this.m_con.appendChild(section.m_div); // Create content table 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); // Make header table var tr = ALib.m_document.createElement("tr"); section.m_tblbdy.appendChild(tr); var td = ALib.m_document.createElement("td"); tr.appendChild(td); 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; section.m_div.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); } // Make content table var tr = ALib.m_document.createElement("tr"); section.m_tblbdy.appendChild(tr); var td = ALib.m_document.createElement("td"); tr.appendChild(td); 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; section.m_div.appendChild(tbl); var tbody = ALib.m_document.createElement("tbody"); tbl.appendChild(tbody); */ 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); } // Get the actual height of the whole section CNavBarSection.prototype.getHeight = function() { return this.m_nb.getSectionHeight(this.m_idname); } // Set the height of the section CNavBarSection.prototype.setHeight = function(height, overflow) { if (typeof overflow == "undefined") var overflow = "auto"; this.m_nb.setSectionHeight(this.m_idname, height, overflow) } /*********************************************************************************** * * 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(); this.m_height = (height) ? height : null; } CSplitContainer.prototype.addPanel = function(size, overflow) { if (typeof overflow == "undefined") var overflow = "auto"; // 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"); var col_inner_dv = this.m_document.createElement("div"); // Used to place content so we can use overflow attribute (won't work with td) col_dv.appendChild(col_inner_dv); ALib.Dom.styleSet(col_inner_dv, "overflow", overflow); if (this.m_orientation == "verticle" && this.m_height) { ALib.Dom.styleSet(col_inner_dv, "height", this.m_height); } 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_inner_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.styleSetClass(dv, "CToolbarSpacer"); this.m_con.appendChild(dv); } /****************************************************************************** * Function: addIcon * Purpose: Add any item to the toolbar *******************************************************************************/ CToolbar.prototype.addIcon = function(src, align, funct, fargs) { var dv = this.m_document.createElement("div"); ALib.Dom.styleSetClass(dv, "CToolbarIcon"); if (align == "right") { ALib.Dom.styleSet(dv, "float", "right"); } else { ALib.Dom.styleSet(dv, "float", "left"); } dv.innerHTML = ""; dv.functname = funct; dv.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(); } } this.m_con.appendChild(dv); } /****************************************************************************** * Function: print * Purpose: Append toolbar to container passed in dv (write if no container) *******************************************************************************/ CToolbar.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 *******************************************************************************/ CToolbar.prototype.getContainer = function () { return this.m_con; } /****************************************************************************** * Function: setClass * Purpose: Set container class *******************************************************************************/ CToolbar.prototype.setClass = function(cls) { ALib.Dom.styleSetClass(this.m_table, cls); } /**************************************************************************** * * Class: CToolTable * * Purpose: Table encapsulation for simplified usage of html tables * * Author: Sky Stebnicki, sky.stebnicki@aereus.com * Copyright (c) 2006 Aereus Corporation. All rights reserved. * *****************************************************************************/ var g_ctt_tind = 0; var g_ctt_tables = new Array(); function CToolTable(width, height, custom_class) { /* return reference to inner div for div.innerHTML or div.createDiv */ // Create main table var table = ALib.m_document.createElement("table"); if (custom_class) table.className = custom_class; else table.className = "CTTMainTable"; 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_rowBody = null; this.m_rowSpacer = null; this.m_headersrow = null; // Set table unique id this.m_uni_id = "alib_ctt_" + g_ctt_tind; g_ctt_tables[g_ctt_tind] = this; g_ctt_tind++; } CToolTable.prototype.addHeader = function (name, align, width, height, custom_class, custom_padding) { // Initial indefined variables if (!align) var align = "left"; if (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); } var td = ALib.m_document.createElement("td"); // Content td.innerHTML = name; // Class td.className = (custom_class) ? custom_class : "CTTHeaderCell"; // Alignment td.align = align; td.setAttribute("align",align); // Width and Height if (width) td.style.width = width; if (height) td.style.height = height; td.style.padding = (custom_padding) ? custom_padding : "3px 5px 3px 5px"; // top, right, bottom, left // Add cell to headers row this.m_headersrow.appendChild(td); return td; } CToolTable.prototype.addRow = function(idname) { // Get unique id name var name = (idname) ? idname : this.m_numrows; this.m_lastRow = name; this.m_rows[name] = new CToolTableRow(); 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; // Spacer row goes above body row this.m_rowSpacer = ALib.m_document.createElement("tr"); this.m_rowBody = ALib.m_document.createElement("tr"); this.m_rowBody.valign = "top"; this.m_rowBody.setAttribute("valign", "top"); // Spacer row goes above body row this.m_table_body.appendChild(this.m_rowSpacer); this.m_table_body.appendChild(this.m_rowBody); this.m_rows[name].m_rowSpacer = this.m_rowSpacer; this.m_rows[name].m_row = this.m_rowBody; this.m_numrows++; return this.m_rows[name]; } CToolTable.prototype.numRows = function() { return this.m_numrows; } CToolTable.prototype.startRow = function() { this.addRow(); } CToolTable.prototype.endRow = function() { } // Empty the table CToolTable.prototype.clear = function() { for (var row in this.m_rows) { this.removeRow(row); } } CToolTable.prototype.removeRow = function(indx) { try { this.m_table_body.removeChild(this.m_rows[indx].m_rowSpacer); this.m_table_body.removeChild(this.m_rows[indx].m_row); this.m_numrows = this.m_numrows - 1; } catch (e) {} } CToolTable.prototype.addCell = function(content, bold, align, width, height, custom_class, custom_padding, indx) { // Get unique id name var name = (indx) ? indx : this.m_lastRow; // Rows alternate, set class var cellclass = ""; if (this.m_numrows % 2) cellclass = (bold) ? "CTTRowOneBold" : "CTTRowOne"; else cellclass = (bold) ? "CTTRowTwoBold" : "CTTRowTwo"; // Create spacer cell var td_spacer = ALib.m_document.createElement("td"); td_spacer.className = "CTTRowSpacer"; this.m_rows[name].m_rowSpacer.appendChild(td_spacer); // Create body cell var td_body = ALib.m_document.createElement("td"); td_body.className = (custom_class) ? custom_class : cellclass; td_body.align = (align) ? align : "left"; td_body.style.padding = (custom_padding) ? custom_padding : "3px 5px 3px 5px"; // top, right, bottom, 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) {} } this.m_rows[name].m_row.appendChild(td_body); return td_body; } CToolTable.prototype.print = function (div_parent) { if (div_parent) { this.m_parentdiv = div_parent; div_parent.appendChild(this.m_table); } else document.write(this.m_table.outerHTML); } function CToolTableRow() { this.m_row; this.m_rowSpacer; this.m_hinst; this.m_name; this.m_uni_id = null; } CToolTableRow.prototype.addCell = function (content, bold, align, width, height, custom_class, custom_padding) { // Create defaults if (!content) var content = null; if (!bold) var bold = null; if (!align) var align = null; if (!width) var width = null; if (!height) var height = null; if (!custom_class) var custom_class = null; if (!custom_padding) var custom_padding = null; this.m_hinst.addCell(content, bold, align, width, height, custom_class, custom_padding, this.m_name); } CToolTableRow.prototype.deleteRow = function() { this.m_hinst.removeRow(this.m_name); } CToolTableRow.prototype.getId = function() { return this.m_uni_id; } /**************************************************************************** * * Class: CWindowFrame * * Purpose: Window Frame * * Author: Sky Stebnicki, sky.stebnicki@aereus.com * Copyright (c) 2006 Aereus Corporation. All rights reserved. * *****************************************************************************/ function CWindowFrame(label, width, padding) { // WFOuter this.m_div = ALib.m_document.createElement("div"); ALib.Dom.styleSetClass(this.m_div, "CWindowFrameOuter"); if (width) ALib.Dom.styleSet(this.m_div, "width", width); if (label) { // WFLabel var lbl_div = ALib.m_document.createElement("div"); ALib.Dom.styleSetClass(lbl_div, "CWindowFrameLabel"); lbl_div.innerHTML = label; this.m_div.appendChild(lbl_div); } // Content var cell_pad = (padding) ? padding : '3px'; this.m_con_div = ALib.m_document.createElement("div"); ALib.Dom.styleSetClass(this.m_con_div, "CWindowFrameContent"); ALib.Dom.styleSet(this.m_con_div, "padding", cell_pad); this.m_div.appendChild(this.m_con_div); } CWindowFrame.prototype.getCon = function () { return this.m_con_div; } CWindowFrame.prototype.getFrame = function() { return this.m_div; } CWindowFrame.prototype.print = function(div_parent) { if (div_parent) div_parent.appendChild(this.getFrame()); else document.write(this.m_div.outerHTML); } /**************************************************************************** * * Class: Ant * * Purpose: Base Ant class for Aereus Network Tools * * Author: Sky Stebnicki, sky.stebnicki@aereus.com * Copyright (c) 2006 Aereus Corporation. All rights reserved. * *****************************************************************************/ function CAlib() { this.m_appcontainer = null; this.m_browser = new CBrowserInfo(); this.Dom = new CDom(); this.Effect = new CEffect(); this.Dlg = new CDialog(); this.setDocument(); this.m_evwnd = window; this.m_debug = false; // Used for tracing output } /*********************************************************************** * Function: setDocument * * Purpose: Used to set working ducument if different from 'document' * ************************************************************************/ CAlib.prototype.setDocument = function(doc) { this.Dom.m_binfo = this.m_browser; this.Dom.m_browser = this.m_browser; this.Effect.m_browser = this.m_browser; if (doc) { this.m_document = doc; this.Dom.setCurrentDoc(doc); } else { this.m_document = document; this.Dom.setCurrentDoc(document); } } /*********************************************************************** * Function: statusShowAlert * * Arguments: 1. content - either an element or text to display * 2. timeout - number of mili-seconds to display * 3. valign - top, middle, bottom (default=middle) * 4. halign - left, center, right (default=center) * * Purpose: Show status messages on document (absolute positioned) * ************************************************************************/ CAlib.prototype.statusShowAlert = function(content, timeout, valign, halign) { var vert_align = (valign) ? valign : 'middle'; var horiz_align = (halign) ? halign : 'center'; if (!this.m_alert_id) this.m_alert_id = 0; try { this.m_alert_id++; // Create status div var dv_status = this.m_document.createElement('div'); dv_status.id = "alib_statusalert_"+this.m_alert_id; this.Dom.styleSet(dv_status, "position", "absolute"); this.Dom.styleSet(dv_status, "top", "150px"); this.Dom.styleSet(dv_status, "visibility", "hidden"); if (typeof content == "string" || typeof content == "number") dv_status.innerHTML = content; else dv_status.appendChild(content); this.m_document.body.appendChild(dv_status); // Center and display the loading div var ht = dv_status.offsetHeight; var wd = dv_status.offsetWidth; var sptop = this.Dom.getScrollPosTop(); var spleft = this.Dom.getScrollPosLeft(); // Set aligned position switch (vert_align) { case "top": var tp= sptop + 3; break; case "middle": var tp= sptop +((this.Dom.getClientHeight()-ht)/2)-12; break; case "bottom": var tp= sptop +(this.Dom.getClientHeight()-ht)-12; break; } switch (horiz_align) { case "left": var lt= spleft + 3; break; case "center": var lt= spleft +((this.Dom.getClientWidth()-wd)/2)-12; break; case "right": var lt= spleft +(this.Dom.getClientWidth()-wd)-12; break; } this.Dom.styleSet(dv_status, "left", lt + "px"); this.Dom.styleSet(dv_status, "top", tp + "px"); this.Effect.fadein(dv_status, 200); this.Dom.styleSet(dv_status, "visibility", "visible"); if (timeout) { var fctn = function() { dv_status.onfaded = function() { ALib.Dom.styleSet(this, "visibility", "hidden"); } ALib.Effect.fade(dv_status, 200); }; window.setTimeout(fctn, timeout); } } catch (e) {} return dv_status; } /*********************************************************************** * Function: statusHideAlert * * Arguments: 1. Status alert container * * Purpose: Show status messages on document (absolute positioned) * ************************************************************************/ CAlib.prototype.statusHideAlert = function(dv_status) { try { ALib.Dom.styleSet(dv_status, "visibility", "hidden"); } catch (e) {} } /*********************************************************************** * Function: trace * * Purpose: Create popup and send debug info * ************************************************************************/ CAlib.prototype.trace = function (txt) { // Right now this only works in firefox and opera try { if (!this.m_debug) return; if (!this.m_debug_wnd || !this.m_debug_wnd.document) { var attribs = 'top=200,left=100,width=450,height=350,toolbar=no,menubar=no,scrollbars=yes,' + 'location=no,directories=no,status=no,resizable=yes'; this.m_debug_wnd = window.open('about:blank', 'ALIB Debuger', attribs); var frameHtml = ""; frameHtml += "\n"; frameHtml += "\n"; frameHtml += "\n"; frameHtml += "ALib Debugger\n"; frameHtml += "\n"; frameHtml += "\n"; frameHtml += "\n"; frameHtml += ""; this.m_debug_wnd.document.open(); this.m_debug_wnd.document.write(frameHtml); this.m_debug_wnd.document.close(); } var dv = this.m_debug_wnd.document.createElement("div"); dv.innerHTML = txt; this.m_debug_wnd.document.body.appendChild(dv); } catch (e) {} } // Initialize AntMain(); var ALib = new CAlib(); /**************************************************************************** * * Section: Global Functions * * Author: Sky Stebnicki, sky.stebnicki@aereus.com * Copyright (c) 2007 Aereus Corporation. All rights reserved. * *****************************************************************************/ if (typeof insertAfter == "undefined") { function insertAfter(parent, node, referenceNode) { if (referenceNode.nextSibling) parent.insertBefore(node, referenceNode.nextSibling); else parent.appendChild(node); } } if (typeof(Math.sqr) == "undefined") { Math.sqr = function (x) { return x*x; }; } function rgb2hex(value) { var x = 255; var hex = ''; var i; var regexp=/([0-9]+)[, ]+([0-9]+)[, ]+([0-9]+)/; var array=regexp.exec(value); for(i=1;i<4;i++) hex += ('0'+parseInt(array[i]).toString(16)).slice(-2); return '#'+hex; } function encode_utf8( s ) { return unescape(encodeURIComponent(s)); } function escape_utf8( s ) { return encodeURIComponent(s); } function decode_utf8(s) { return decodeURIComponent(escape(s)); } function unescape_utf8(s) { return decodeURIComponent(s); } /**************************************************************************** * * Class: CUsageTracking * * Purpose: Editable spreadsheet table * * Author: Sky Stebnicki, sky.stebnicki@aereus.com * Copyright (c) 2006 Aereus Corporation. All rights reserved. * * Usage: Include the following anywhere on the page (make sure all ALIB * or CUsageTracking.js is included) * * * *****************************************************************************/ function CUsageTracking(server, dbid, page) { var send_vars = new Array(); var path = "http://" + server + "/datacenter/svr_logwebusage.awp"; try { var doc = (typeof ALib != "undefined") ? ALib.m_document : document; } catch (e) { var doc = document; } // Get page name if (!page) { var page = doc.location.href; var i = page.indexOf("://"); if (i) { page=page.substring(i+3, page.length); i=page.indexOf("/"); if (i) page=page.substring(i+1, page.length); if ("index.htm" == page || "index.html" == page || "index.php" == page || "index.awp" == page || "" == page) { page = "/"; } send_vars[send_vars.length] = ["page", page]; } } else { send_vars[send_vars.length] = ["page", page]; } var referrer = doc.referrer; if (referrer) { send_vars[send_vars.length] = ["referrer", referrer]; } // Set logvisit 1 = log a new visit (don't log for each page view) var ses = CUTReadCookie("ant_cut_ses"); // Get session cookie var ret = CUTReadCookie("ant_cut_ret"); // Get feturning cookie if (!ses) { send_vars[send_vars.length] = ["logvisit", '1']; // Type: 1 = new visit, 2 = returning var visit_type = (ret) ? 2 : 1; send_vars[send_vars.length] = ["visit_type", visit_type]; // Create retunring and session cookie CUTCreateCookie("ant_cut_ses", "1", null); CUTCreateCookie("ant_cut_ret", "1", 90); } // Set database id send_vars[send_vars.length] = ["dbid", dbid]; path += "?"; var tmpVars = "function=log"; for (var i = 0; i < send_vars.length; i++) { tmpVars += "&" + send_vars[i][0] + "=" + escape(send_vars[i][1]); } var img = new Image(1, 1); img.src = path + tmpVars; img.onload = function() {}; } function CUTCreateCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; } function CUTReadCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } function CUTEraseCookie(name) { createCookie(name,"",-1); } /*====================================================================================== Module: CTreeView Purpose: Build TreeView GUI component Author: Sky Stebnicki, sky.stebnicki@aereus.com Copyright (c) 2007 Aereus Corporation. All rights reserved. Depends: CDragAndDrop.js Usage: var tv = new CTreeView(); var n1 = tv.addNode("Test Node 1", null, "alert('Clicked');"); var su1 = n1.addNode("Test Sub 1"); var susu1 = su1.addNode("Sub Sub 1"); var susu2 = su1.addNode("Sub Sub 2"); var susu3 = su1.addNode("Sub Sub 3"); var sususu1 = susu3.addNode("Sub Sub 1"); var sususu2 = susu3.addNode("Sub Sub 2", null, function() {alert("Hi"); }); var sususu3 = susu3.addNode("Sub Sub 3"); var su2 = n1.addNode("Test Sub 2"); var su3 = n1.addNode("Test Sub 3"); tv.print(con); ======================================================================================*/ function CTreeView() { this.m_nodes = new Array(); this.m_outercon = ALib.m_document.createElement("div"); ALib.Dom.styleSetClass(this.m_outercon, "CTreeViewCon"); } /*********************************************************************************** * * Function: addNode * * Purpose: Creates root node. There can be more than one first level node. * * Arguements: title - String||Element = what to put in the title * icon - (optional) string = path to icon * action - (optional) string||function = what do do on click * ***********************************************************************************/ CTreeView.prototype.addNode = function(title, icon, action) { if (typeof icon == "undefined") var icon = null; if (typeof action == "undefined") var action = null; this.m_nodes[this.m_nodes.length] = new CTreeViewNode(this.m_outercon, 1, title, icon, action); // Root = 1 return this.m_nodes[this.m_nodes.length - 1]; } /*********************************************************************************** * * Function: getTvNodeById * * Purpose: Find and return a node by unique id * * Arguements: id - string : the unique id of the specified node * ***********************************************************************************/ CTreeView.prototype.getTvNodeById = function(id, pnt) { var parent_node = (pnt) ? pnt : this; for (var i = 0; i < parent_node.m_nodes.length; i++) { ALib.trace("CTreeView: getTvNodeById - checking " + id + " against " + parent_node.m_nodes[i].id); if (parent_node.m_nodes[i].id == id) return parent_node.m_nodes[i]; var tmpnd = this.getTvNodeById(id, parent_node.m_nodes[i]); if (tmpnd) return tmpnd; } // Not found return null; } /*********************************************************************************** * * Function: print * * Purpose: Append or write TreeView html * * Arguements: container - (optional) element = Will append as child * ***********************************************************************************/ CTreeView.prototype.print = function(container) { if (typeof container != "undefined" && container) container.appendChild(this.m_outercon); else document.write(this.m_outercon.outerHTML); } /*********************************************************************************** * * Class: CTreeViewNode * * Purpose: Node object - linked list of nodes * * Arguements: con - element = container for tree * depth - integet = depth of current object for reference * title - string||element = what to put in the title * icon - (optional) string = path to icon * action - (optional) string||function = what do do on click * ***********************************************************************************/ function CTreeViewNode(con, depth, title, icon, action, args, parent_node) { this.m_expanded = false; this.id = null; this.m_title =(typeof title != "undefined") ? title : ""; // Title to display - can be string this.m_icon = (typeof icon != "undefined") ? icon : ""; // Node Icon this.m_depth = depth; this.m_outercon = con; if (parent_node) this.m_parent = parent_node; else this.m_parent = null; //this.onclick = (typeof action != "undefined") ? action : null; // Onclick action //this.ondoubleclick = null; // Onclick action // Used for drag and drop this.registerDropzone = null; this.onDragEnter = null; this.onDragExit = null; this.onDragDrop = null; // Subnodes (if any) this.m_nodes = new Array(); // Now create div this.m_row = ALib.m_document.createElement("div"); ALib.Dom.styleSetClass(this.m_row, "CTreeViewRow"); if (this.m_parent) { var after = null; // Check if we are the first child if (this.m_parent.m_nodes.length) { insertAfter(con, this.m_row, this.m_parent.getLastChildNode().m_row); } else { // Look like this is the first child node - put it after the parent insertAfter(con, this.m_row, this.m_parent.m_row); } this.m_nodes[this.m_nodes.length] } else con.appendChild(this.m_row); for (var i = 1; i < depth; i++) { var dv = ALib.m_document.createElement("div"); ALib.Dom.styleSet(dv, "float", "left"); ALib.Dom.styleSetClass(dv, "CTreeViewSpaceLine"); this.m_row.appendChild(dv); } // Add tilde this.tilde_dv = ALib.m_document.createElement("div"); ALib.Dom.styleSetClass(this.tilde_dv, "CTreeViewTildeNoSub"); ALib.Dom.styleSet(this.tilde_dv, "float", "left"); 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(); } this.m_row.appendChild(this.tilde_dv); // Add icon (if any) var dv = ALib.m_document.createElement("div"); ALib.Dom.styleSetClass(dv, "CTreeViewIcon"); ALib.Dom.styleSet(dv, "float", "left"); this.m_row.appendChild(dv); if (this.m_icon) dv.innerHTML = ""; // Add body this.m_bodydv = ALib.m_document.createElement("div"); ALib.Dom.styleSet(this.m_bodydv, "display", "inline"); ALib.Dom.styleSetClass(this.m_bodydv, "CTreeViewBodyOut"); this.m_row.appendChild(this.m_bodydv); this.m_bodydv.innerHTML = "" + this.m_title + ""; // Clear floats var cdiv = ALib.m_document.createElement("div"); ALib.Dom.styleSet(cdiv, "clear", "both"); this.m_row.appendChild(cdiv); // Set action if (action) { if (args) this.setAction(action, args); else this.setAction(action); } // Set mouse states this.setMouseHandlers(true); // Set default display status if (depth > 1) { if (parent_node && parent_node.m_expanded) { this.show(); } else this.hide(); } } /*********************************************************************************** * * Function: setAction * * Purpose: Set onclick action for this node * * Arguements: function, args * ***********************************************************************************/ CTreeViewNode.prototype.setAction = function(action, args) { if (action) { ALib.Dom.styleSet(this.m_bodydv, "cursor", "pointer"); if (typeof action == "string") { this.m_bodydv.m_actstr = action; this.m_bodydv.onclick = function() { eval(this.m_actstr); }; } else { this.m_bodydv.cb_function = action; this.m_bodydv.m_cb_args = args; this.m_bodydv.onclick = function() { if (this.m_cb_args) { switch (this.m_cb_args.length) { case 1: this.cb_function(this.m_cb_args[0]); break; case 2: this.cb_function(this.m_cb_args[0], this.m_cb_args[1]); break; case 3: this.cb_function(this.m_cb_args[0], this.m_cb_args[1], this.m_cb_args[2]); break; case 4: this.cb_function(this.m_cb_args[0], this.m_cb_args[1], this.m_cb_args[2], this.m_cb_args[3]); case 5: this.cb_function(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]); case 6: this.cb_function(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]); case 7: this.cb_function(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]); case 8: this.cb_function(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(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]); case 10: this.cb_function(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(); } } } } } /*********************************************************************************** * * Function: addNode * * Purpose: Creates sub node * * Arguements: title - String||Element = what to put in the title * icon - (optional) string = path to icon * action - (optional) string||function = what do do on click * ***********************************************************************************/ CTreeViewNode.prototype.addNode = function(title, icon, action, args) { if (typeof icon == "undefined") var icon = null; if (typeof action == "undefined") var action = null; if (typeof args == "undefined") var args = null; this.m_nodes[this.m_nodes.length] = new CTreeViewNode(this.m_outercon, this.m_depth + 1, title, icon, action, args, this); this.setHasChildren(true); return this.m_nodes[this.m_nodes.length - 1]; } /*********************************************************************************** * * Function: editBody * * Purpose: Allow user to change the text in the body (only recommended for text) * ***********************************************************************************/ CTreeViewNode.prototype.editBody = function() { var bdy = this.m_bodydv.childNodes.item(0); var buf = bdy.innerHTML; bdy.innerHTML = ""; var inp = ALib.m_document.createElement("input"); ALib.Dom.styleSet(inp, "height", "100%"); inp.value = buf; inp.m_node = this; inp.onblur = function() { var val = this.value; this.m_node.m_bodydv.childNodes.item(0).innerHTML = val; this.m_node.onBodyEdit(val); } bdy.appendChild(inp); inp.select(); inp.focus(); } /*********************************************************************************** * * Function: onBodyEdit * * Purpose: Callback will be fired when node has been edited * ***********************************************************************************/ CTreeViewNode.prototype.onBodyEdit = function(val) { } /*********************************************************************************** * * Function: setBody * * Purpose: Change the text in the body of the node * ***********************************************************************************/ CTreeViewNode.prototype.setBody = function(val) { this.m_bodydv.childNodes.item(0).innerHTML = val; } /*********************************************************************************** * * Function: createContextMenu * * Purpose: Creates a dm menu when user right-clicks this node * * Arguements: N/A * ***********************************************************************************/ CTreeViewNode.prototype.createContextMenu = function() { this.setMouseHandlers(false); // Allow dropdown to handle classes var dm = new CDropdownMenu(); dm.createContextMenu(this.m_bodydv, "CTreeViewBodyOut", "CTreeViewBodyOver", "CTreeViewBodyOn"); return dm; } /*********************************************************************************** * * Function: setHasChildren * * Purpose: Change node the style of one with children * * Arguements: haschildren - bool = does this have children * ***********************************************************************************/ CTreeViewNode.prototype.setHasChildren = function(haschildren) { 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: getLastChildNode * * Purpose: Traverse the nodes to get the last child node for inserting before/after * ***********************************************************************************/ CTreeViewNode.prototype.getLastChildNode = function() { var last = null; if (this.m_nodes.length) last = this.m_nodes[this.m_nodes.length - 1].getLastChildNode(); else last = this; return last; } /*********************************************************************************** * * Function: hide * * Purpose: Hide this and child nodes * ***********************************************************************************/ CTreeViewNode.prototype.hide = function() { ALib.Dom.styleSet(this.m_row, "display", "none"); } /*********************************************************************************** * * Function: show * * Purpose: Display this node * ***********************************************************************************/ CTreeViewNode.prototype.show = function() { ALib.Dom.styleSet(this.m_row, "display", "block"); } /*********************************************************************************** * * Function: expand * * Purpose: Expand this node (display children if they exist) * ***********************************************************************************/ CTreeViewNode.prototype.expand = function() { if (this.m_nodes.length) { for (var i = 0; i < this.m_nodes.length; i++) this.m_nodes[i].show(); this.m_expanded = true; ALib.Dom.styleSetClass(this.tilde_dv, "CTreeViewTildeWithSubOpen"); } } /*********************************************************************************** * * Function: collapse * * Purpose: Collapse this node (collapse children if they exist) * ***********************************************************************************/ CTreeViewNode.prototype.collapse = function() { if (this.m_nodes.length) { for (var i = 0; i < this.m_nodes.length; i++) { this.m_nodes[i].collapse(); this.m_nodes[i].hide(); } this.m_expanded = false; ALib.Dom.styleSetClass(this.tilde_dv, "CTreeViewTildeWithSubClosed"); } } /*********************************************************************************** * * Function: deleteNode * * Purpose: Remove node child nodes * ***********************************************************************************/ CTreeViewNode.prototype.deleteNode = function(node) { if (this.m_nodes.length) { for (var i = 0; i < this.m_nodes.length; i++) { if (this.m_nodes[i] == node) { this.m_nodes[i] = null; this.m_nodes.splice(i, 1); break; } } if (!this.m_nodes.length) this.setHasChildren(false); } } /*********************************************************************************** * * Function: remove * * Purpose: Remove this node (remove children if they exist) * ***********************************************************************************/ CTreeViewNode.prototype.remove = function() { if (this.m_nodes.length) { for (var i = 0; i < this.m_nodes.length; i++) this.m_nodes[i].remove(); } this.m_outercon.removeChild(this.m_row); this.m_parent.deleteNode(this); } /*********************************************************************************** * * Function: setMouseHandlers * * Purpose: Add and remove event listners for setting on/over/out states * ***********************************************************************************/ CTreeViewNode.prototype.setMouseHandlers = function(set) { var funover = function() { ALib.Dom.styleSetClass(this, "CTreeViewBodyOver"); } var funout = function() { ALib.Dom.styleSetClass(this, "CTreeViewBodyOut"); } if (set) { if (ALib.Dom.m_binfo.ie) { this.m_bodydv.attachEvent('mouseover', funover); this.m_bodydv.attachEvent('mouseout', funout); } else { this.m_bodydv.addEventListener('mouseover', funover, false); this.m_bodydv.addEventListener('mouseout', funout, false); } } else { if (ALib.Dom.m_binfo.ie) { this.m_bodydv.detachEvent('mouseover', funover); this.m_bodydv.detachEvent('mouseout', funout); } else { this.m_bodydv.removeEventListener('mouseover', funover, false); this.m_bodydv.removeEventListener('mouseout', funout, false); } } } /*====================================================================================== Module: CDialog Purpose: Create custom dialog box Author: Sky Stebnicki, sky.stebnicki@aereus.com Copyright (c) 2007 Aereus Corporation. All rights reserved. Usage: ======================================================================================*/ /*********************************************************************************** * * Class: CDialog * * Purpose: Encapsulate custom dialog functionality * ***********************************************************************************/ function CDialog(title) { if (title) this.m_title = title; else this.m_title = null; this.m_initialized = false; //this.initdlg(); } CDialog.prototype.fixSizeAndScroll = function() { ALib.m_evwnd.onscroll = this.scrollFix; ALib.m_evwnd.onresize = this.sizeFix; } CDialog.prototype.posLeft = 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; } CDialog.prototype.posTop = 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; } CDialog.prototype.gete= function(x) { return ALib.m_document.getElementById(x); } CDialog.prototype.scrollFix = function() { var obol=this.overlay; if (obol) { obol.style.top=ALib.Dom.getScrollPosTop()+'px'; obol.style.left=ALib.Dom.getScrollPosLeft()+'px'; } } CDialog.prototype.sizeFix = function() { var obol=this.overlay; if (obol) { obol.style.height=ALib.Dom.GetDocumentHeight()+'px'; obol.style.width=ALib.Dom.getDocumentWidth()+'px'; } } CDialog.prototype.kp = function(e) { ky=e?e.which:event.keyCode; if(ky==88||ky==120) this.hm(); return false } CDialog.prototype.inf = function(h) { tag=ALib.m_document.getElementsByTagName('select'); for(i=tag.length-1;i>=0;i--) tag[i].style.visibility=h; tag=ALib.m_document.getElementsByTagName('iframe'); for(i=tag.length-1;i>=0;i--) tag[i].style.visibility=h; tag=ALib.m_document.getElementsByTagName('object'); for(i=tag.length-1;i>=0;i--) tag[i].style.visibility=h; } CDialog.prototype.show = function(wd, ht) { this.sm(wd, ht); } CDialog.prototype.sm = function(wd, ht) { var h = 'hidden'; var b = 'block'; var p = 'px'; // Display overlay this.overlay.style.height = ALib.Dom.getDocumentHeight()+p; this.overlay.style.width = ALib.Dom.getDocumentWidth()+p; this.overlay.style.top = "0px"; //ALib.Dom.getScrollPosTop()+p; this.overlay.style.left = "0px"; //ALib.Dom.getScrollPosLeft()+p; this.overlay.style.display = b; var sptop = ALib.Dom.getScrollPosTop(); var spleft = ALib.Dom.getScrollPosLeft(); var tp= sptop +((ALib.Dom.getClientHeight()-ht)/2)-12; var lt= spleft +((ALib.Dom.getClientWidth()-wd)/2)-12; this.m_dcon.style.top=(tp<0?0:tp)+p; this.m_dcon.style.left=(lt<0?0:lt)+p; this.m_dcon.style.width=wd +p; //this.m_dcon.style.height=ht +p; this.inf(h); this.m_dcon.style.display=b; return false; } CDialog.prototype.hide = function() { this.hm(); } CDialog.prototype.hm = function() { var v = 'visible'; var n = 'none'; this.overlay.style.display=n; this.m_dcon.style.display=n; this.inf(v); if (this.m_cleardv) { try { this.m_bodycon.removeChild(this.m_cleardv); } catch (e) {} this.m_cleardv = null; } if (this.m_titlecon) { this.m_titlecon.style.display=n; } //ALib.m_document.onkeypress='' } CDialog.prototype.initdlg = function() { var ab='absolute'; var n='none'; var obody=ALib.m_document.getElementsByTagName('body')[0]; var frag=ALib.m_document.createDocumentFragment(); // Create document overlay - this should only exist once this.overlay = ALib.Dom.getElementById('CDialogOverlay'); if (!this.overlay) { this.overlay = ALib.Dom.createElement('div'); this.overlay.setAttribute('id','CDialogOverlay'); ALib.Dom.styleSet(this.overlay, "display", "none"); ALib.Dom.styleSet(this.overlay, "position", "absolute"); ALib.Dom.styleSet(this.overlay, "top", "0"); ALib.Dom.styleSet(this.overlay, "left", "0"); this.overlay.style.zIndex = "998"; ALib.Dom.styleSet(this.overlay, "width", "100%"); obody.appendChild(this.overlay); } // Create dialog container - there can be many dialogs in a document this.m_dcon = ALib.Dom.createElement('div'); ALib.Dom.setClass(this.m_dcon, "CDialogCon"); ALib.Dom.styleSet(this.m_dcon, "display", "none"); ALib.Dom.styleSet(this.m_dcon, "position", "absolute"); this.m_dcon.style.zIndex = "999"; // Add title if (!this.m_titlecon) { this.m_titlecon = ALib.Dom.createElement("div"); this.m_dcon.appendChild(this.m_titlecon); ALib.Dom.setClass(this.m_titlecon, "CDialogTitle"); this.m_titlecon.style.display=n; } if (this.m_title) { this.m_titlecon.innerHTML = this.m_title; this.m_titlecon.style.display="block"; } // Add body this.m_bodycon = ALib.Dom.createElement("div"); this.m_dcon.appendChild(this.m_bodycon); ALib.Dom.setClass(this.m_bodycon, "CDialogBody"); obody.appendChild(this.m_dcon); this.m_initialized = true; /* var obl=ALib.Dom.createElement('span'); obbx.appendChild(obl); var obbxd=ALib.Dom.createElement('div'); obbxd.setAttribute('id','mbd'); obl.appendChild(obbxd); frag.insertBefore(obbx,obol.nextSibling); obody.insertBefore(frag,obody.firstChild); */ } CDialog.prototype.messageBox = function(msg) { if (!this.m_initialized) this.initdlg(); var dlg = this; var dv = ALib.Dom.createElement("div"); this.m_bodycon.appendChild(dv); var dv_inner = ALib.Dom.createElement("div"); ALib.Dom.styleSet(dv_inner, "text-align", "center"); dv.appendChild(dv_inner); var sp = ALib.Dom.createElement("div"); dv_inner.appendChild(sp); sp.innerHTML = msg; var bdv = ALib.Dom.createElement("div"); bdv.setAttribute("align", "center"); dv_inner.appendChild(bdv); var dlg_btn = new CButton("OK", function(dlg) { dlg.hm(); }, [dlg], "b1"); dlg_btn.print(bdv); var len = msg.length * 10; this.sm(len, 50); this.m_cleardv = dv; } CDialog.prototype.confirmBox = function(msg, title, args) { if (!this.m_initialized) this.initdlg(); if (title) { this.m_titlecon.innerHTML = title; this.m_titlecon.style.display="block"; } var dlg = this; var dv = ALib.Dom.createElement("div"); this.m_bodycon.appendChild(dv); var dv_inner = ALib.Dom.createElement("div"); ALib.Dom.styleSet(dv_inner, "text-align", "center"); dv.appendChild(dv_inner); var sp = ALib.Dom.createElement("div"); dv_inner.appendChild(sp); sp.innerHTML = msg; var bdv = ALib.Dom.createElement("div"); bdv.setAttribute("align", "center"); dv_inner.appendChild(bdv); function yesClicked() { dlg.hide(); if (args) { switch (args.length) { case 1: dlg.onConfirmOk(args[0]); break; case 2: dlg.onConfirmOk(args[0], args[1]); break; case 3: dlg.onConfirmOk(args[0], args[1], args[2]); break; case 4: dlg.onConfirmOk(args[0], args[1], args[2], args[3]); break; case 5: dlg.onConfirmOk(args[0], args[1], args[2], args[3], args[4]); break; case 6: dlg.onConfirmOk(args[0], args[1], args[2], args[3], args[4], args[5]); break; } } else dlg.onConfirmOk(); dlg.onConfirmOk = new Function(); } var dlg_btn = new CButton("Yes", yesClicked, null, "b1"); dlg_btn.print(bdv); function noClicked() { dlg.hide(); if (args) { switch (args.length) { case 1: dlg.onConfirmCancel(args[0]); break; case 2: dlg.onConfirmCancel(args[0], args[1]); break; case 3: dlg.onConfirmCancel(args[0], args[1], args[2]); break; case 4: dlg.onConfirmCancel(args[0], args[1], args[2], args[3]); break; case 5: dlg.onConfirmCancel(args[0], args[1], args[2], args[3], args[4]); break; case 6: dlg.onConfirmCancel(args[0], args[1], args[2], args[3], args[4], args[5]); break; } } else dlg.onConfirmCancel(); dlg.onConfirmCancel = new Function(); } var dlg_btn = new CButton("No", noClicked, null, "b1"); dlg_btn.print(bdv); var len = msg.length * 10; this.sm(len, 50); this.m_cleardv = dv; } CDialog.prototype.onConfirmOk = function() { } CDialog.prototype.onConfirmCancel = function() { } CDialog.prototype.promptBox = function(msg, title, def_value, args) { if (!this.m_initialized) this.initdlg(); if (title) { this.m_titlecon.innerHTML = title; this.m_titlecon.style.display="block"; } var dlg = this; var dv = ALib.Dom.createElement("div"); this.m_bodycon.appendChild(dv); var dv_inner = ALib.Dom.createElement("div"); ALib.Dom.styleSet(dv_inner, "text-align", "center"); dv.appendChild(dv_inner); var sp = ALib.Dom.createElement("div"); dv_inner.appendChild(sp); sp.innerHTML = msg; var bdv = ALib.Dom.createElement("div"); bdv.setAttribute("align", "center"); dv_inner.appendChild(bdv); var inpdv = ALib.Dom.createElement("div", bdv); this.m_input = ALib.Dom.createElement("input", inpdv); ALib.Dom.styleSet(this.m_input, "width", "95%"); this.m_input.value = def_value; function okClicked() { dlg.hide(); if (args) { switch (args.length) { case 1: dlg.onPromptOk(dlg.m_input.value, args[0]); break; case 2: dlg.onPromptOk(dlg.m_input.value, args[0], args[1]); break; case 3: dlg.onPromptOk(dlg.m_input.value, args[0], args[1], args[2]); break; case 4: dlg.onPromptOk(dlg.m_input.value, args[0], args[1], args[2], args[3]); break; case 5: dlg.onPromptOk(dlg.m_input.value, args[0], args[1], args[2], args[3], args[4]); break; case 6: dlg.onPromptOk(dlg.m_input.value, args[0], args[1], args[2], args[3], args[4], args[5]); break; } } else dlg.onPromptOk(dlg.m_input.value); dlg.onPromptOk = new Function(); } var dlg_btn = new CButton("Ok", okClicked, null, "b1"); dlg_btn.print(bdv); function cancelClicked() { dlg.hide(); if (args) { switch (args.length) { case 1: dlg.onPromptCancel(args[0]); break; case 2: dlg.onPromptCancel(args[0], args[1]); break; case 3: dlg.onPromptCancel(args[0], args[1], args[2]); break; case 4: dlg.onPromptCancel(args[0], args[1], args[2], args[3]); break; case 5: dlg.onPromptCancel(args[0], args[1], args[2], args[3], args[4]); break; case 6: dlg.onPromptCancel(args[0], args[1], args[2], args[3], args[4], args[5]); break; } } else dlg.onPromptCancel(); dlg.onPromptCancel = new Function(); } var dlg_btn = new CButton("Cancel", cancelClicked, null, "b1"); dlg_btn.print(bdv); if (typeof title != "undefined") var len = (msg.length > title.length) ? msg.length * 10 : title.length * 10; else var len = msg.length * 10; this.sm(len, 50); this.m_cleardv = dv; } CDialog.prototype.onPromptOk = function() { } CDialog.prototype.onPromptCancel = function() { } CDialog.prototype.customDialog = function(con, width, height) { if (!this.m_initialized) this.initdlg(); if (this.m_title) { this.m_titlecon.innerHTML = this.m_title; this.m_titlecon.style.display="block"; } var dlg = this; con.m_dialog = dlg; this.m_bodycon.appendChild(con); this.m_cleardv = con; this.sm(width, height); } CDialog.prototype.statusDialog = function(con, width, height) { if (!this.m_initialized) this.initdlg(); ALib.Dom.setClass(this.m_bodycon, ""); ALib.Dom.setClass(this.m_dcon, ""); var dlg = this; con.m_dialog = dlg; this.m_bodycon.appendChild(con); this.m_cleardv = con; this.sm(width, height); } /*====================================================================================== Module: CRte Purpose: Create RTE input textarea Author: Sky Stebnicki, sky.stebnicki@aereus.com Copyright (c) 2007 Aereus Corporation. All rights reserved. Usage: // Create rte ======================================================================================*/ /*********************************************************************************** * * Class: CRte * * Purpose: Rich text class * ***********************************************************************************/ function CRte() { this.ifrm = ALib.Dom.createElement("iframe"); this.ifrm.border = '0'; this.ifrm.frameBorder = '0'; ALib.Dom.styleSetClass(this.ifrm, "CRteIframe"); this.hdntxt = ALib.Dom.createElement("input"); this.hdntxt.type = "hidden"; this.idoc = null; this.f_src = false; this.rte_id = '1'; } /*********************************************************************************** * * Function: setDocument * * Purpose: Set document * ***********************************************************************************/ CRte.prototype.setDocument = function() { this.iwnd = this.ifrm.contentWindow || this.ifrm.contentDocument; if (this.iwnd.document) { this.idoc = this.iwnd.document; } } /*********************************************************************************** * * Function: updateText * * Purpose: Update value in hidden text field * ***********************************************************************************/ CRte.prototype.updateText = function(html) { //this.hdntxt.value = this.idoc.body.innerHTML; if (this.f_src) { if (ALib.Dom.m_binfo.ie) { //fix for IE var output = escape(this.idoc.body.innerText); output = output.replace("%3CP%3E%0D%0A%3CHR%3E", "%3CHR%3E"); output = output.replace("%3CHR%3E%0D%0A%3C/P%3E", "%3CHR%3E"); this.hdntxt.value = unescape(output); } else { var htmlSrc = this.idoc.body.ownerDocument.createRange(); htmlSrc.selectNodeContents(this.idoc.body); this.hdntxt.value = htmlSrc.toString(); } } else { this.hdntxt.value = this.idoc.body.innerHTML; } } /*********************************************************************************** * * Function: getValue * * Purpose: Get text value of rte * ***********************************************************************************/ CRte.prototype.getValue = function(html) { this.updateText(); return this.hdntxt.value; } /*********************************************************************************** * * Function: setHeight * * Purpose: Set the height of iframe * ***********************************************************************************/ CRte.prototype.setHeight = function(height) { this.ifrm.style.height = height; } /*********************************************************************************** * * Function: insertHtml * * Purpose: Update value in hidden text field * ***********************************************************************************/ CRte.prototype.insertHtml = function(html) { if (ALib.Dom.m_binfo.ie) { //retrieve selected range var sel = this.idoc.selection; if (sel != null) { var newRng = sel.createRange(); newRng = rng; newRng.select(); } this.rteCommand('paste', html); } else { this.rteCommand('insertHtml', html); } } /*********************************************************************************** * * Function: enableDesign * * Purpose: Enable design mode in iframe * ***********************************************************************************/ CRte.prototype.enableDesign = function(html) { this.setDocument(); var frameHtml = "'; frameHtml += "\n"; frameHtml = "\n"; frameHtml += "\n"; frameHtml += "\n"; frameHtml += "\n"; frameHtml += "\n"; frameHtml += "\n"; if (html) frameHtml += html + "\n"; frameHtml += "\n"; frameHtml += ""; if (ALib.Dom.m_binfo.ie) { this.idoc.open(); this.idoc.write(frameHtml); this.idoc.close(); this.idoc.designMode = "On"; } else { this.ifrm.contentDocument.designMode = "on"; var oRTE = this.ifrm.contentWindow.document; oRTE.open(); oRTE.write(frameHtml); oRTE.close(); if (ALib.Dom.m_binfo.gecko) { //attach a keyboard handler for gecko browsers to make keyboard shortcuts work //oRTE.addEventListener("keypress", kb_handler, true); oRTE.body.spellcheck = true; } } } /*********************************************************************************** * * Function: createToolbar * * Purpose: Create toolbar * ***********************************************************************************/ CRte.prototype.createToolbar = function(container) { var me = this; var imgroot = (typeof ALIB_ROOT == "string") ? ALIB_ROOT : "."; // Add toolbar var tb = new CToolbar(); tb.setClass(""); tb.addIcon(imgroot + "/images/bold.gif", "left", function(cls) {cls.rteCommand('bold', ''); }, [me]); tb.addIcon(imgroot + "/images/italic.gif", "left", function(cls) {cls.rteCommand('italic', ''); }, [me]); tb.addIcon(imgroot + "/images/underline.gif", "left", function(cls) {cls.rteCommand('underline', ''); }, [me]); tb.addSpacer(); tb.addIcon(imgroot + "/images/left_just.gif", "left", function(cls) {cls.rteCommand('justifyleft', ''); }, [me]); tb.addIcon(imgroot + "/images/centre.gif", "left", function(cls) {cls.rteCommand('justifycenter', ''); }, [me]); tb.addIcon(imgroot + "/images/right_just.gif", "left", function(cls) {cls.rteCommand('justifyright', ''); }, [me]); tb.addIcon(imgroot + "/images/justifyfull.gif", "left", function(cls) {cls.rteCommand('justifyfull', ''); }, [me]); tb.addSpacer(); tb.addIcon(imgroot + "/images/hr.gif", "left", function(cls) {cls.rteCommand('inserthorizontalrule', ''); }, [me]); tb.addSpacer(); tb.addIcon(imgroot + "/images/numbered_list.gif", "left", function(cls) {cls.rteCommand('insertorderedlist', ''); }, [me]); tb.addIcon(imgroot + "/images/list.gif", "left", function(cls) {cls.rteCommand('insertunorderedlist', ''); }, [me]); tb.addSpacer(); tb.addIcon(imgroot + "/images/src.gif", "left", function(cls) {cls.toggleHtmlSrc(); }, [me]); tb.print(container); } /*********************************************************************************** * * Function: rteCommand * * Purpose: Issue commands to the iframe window * * Arguments: 1. command:string - name of command to run * 2. option:string - value to pass with command * ***********************************************************************************/ CRte.prototype.rteCommand = function(command, option) { var oRTE; if (ALib.Dom.m_binfo.ie) { oRTE = this.ifrm; } else { oRTE = this.ifrm.contentWindow; } try { oRTE.focus(); this.idoc.execCommand(command, false, option); oRTE.focus(); } catch (e) { alert(e); } } /*********************************************************************************** * * Function: toggleHtmlSrc * * Purpose: Toggle HTML Source * ***********************************************************************************/ CRte.prototype.toggleHtmlSrc = function() { if (this.f_src) { if (ALib.Dom.m_binfo.ie) { //fix for IE var output = escape(this.idoc.body.innerText); output = output.replace("%3CP%3E%0D%0A%3CHR%3E", "%3CHR%3E"); output = output.replace("%3CHR%3E%0D%0A%3C/P%3E", "%3CHR%3E"); this.idoc.body.innerHTML = unescape(output); } else { var htmlSrc = this.idoc.body.ownerDocument.createRange(); htmlSrc.selectNodeContents(this.idoc.body); this.idoc.body.innerHTML = htmlSrc.toString(); } this.f_src = false; } else { if (ALib.Dom.m_binfo.ie) { this.idoc.body.innerText = this.idoc.body.innerHTML; } else { var htmlSrc = this.idoc.createTextNode(this.idoc.body.innerHTML); this.idoc.body.innerHTML = ""; this.idoc.body.appendChild(htmlSrc); } this.f_src = true; } } /*********************************************************************************** * * Function: print * * Purpose: Print rte * ***********************************************************************************/ CRte.prototype.print = function(container, width, height, html) { if (container) { this.createToolbar(container); container.appendChild(this.ifrm); if (width) this.ifrm.style.width = width; if (height) this.ifrm.style.height = height; var htm = (typeof html != 'undefined') ? html : ''; this.enableDesign(htm); var me = this; var bcb = function() { me.updateText(); } if(ALib.Dom.m_binfo.ie) this.ifrm.attachEvent("onblur", bcb); else this.ifrm.contentDocument.addEventListener("blur",bcb,false); var br = ALib.Dom.createElement("br"); container.appendChild(br); container.appendChild(this.hdntxt); } } /*====================================================================================== Module: CEffect Purpose: Handle visual effects Author: Sky Stebnicki, sky.stebnicki@aereus.com Copyright (c) 2008 Aereus Corporation. All rights reserved. Usage: ======================================================================================*/ function CEffect() { this.m_browser = null; // Browser Information } CEffect.prototype.round = function(element, sizex, sizey, sizex_b, sizex_y) { if (typeof(element) == "string") element = ALib.Dom.getElementById(element); if (typeof(sizey) == 'undefined') sizey = sizex; if (typeof(sizex_b) == 'undefined') sizex_b = sizex; if (typeof(sizex_y) == 'undefined') sizex_y = sizey; var settings = { tl: { radius: sizex }, tr: { radius: sizey }, bl: { radius: sizex_b }, br: { radius: sizex_y }, antiAlias: true, autoPad: true, validTags: ["div"] } /* Usage: newCornersObj = new curvyCorners(settingsObj, classNameStr); newCornersObj = new curvyCorners(settingsObj, divObj1[, divObj2[, divObj3[, . . . [, divObjN]]]]); */ var myBoxObject = new curvyCorners(settings, element); myBoxObject.applyCornersToAll(); } CEffect.prototype.fadein = function(element, time_ms, max, min) { if (typeof(element) == "string") element = ALib.Dom.getElementById(element); if (typeof(max) == "undefined") var max = 100; if (typeof(min) == "undefined") var min = 0; element.style.opacity = '0'; element.style.filter = 'alpha(opacity = ' + '0' + ')'; element.FadeState = -2; this.fade(element, time_ms, max, min); } CEffect.prototype.fadeout = function(element, time_ms, max, min) { if (typeof(element) == "string") element = ALib.Dom.getElementById(element); if (typeof(max) == "undefined") var max = 100; if (typeof(min) == "undefined") var min = 0; element.FadeState = 2; this.fade(element, time_ms, max, min); } CEffect.prototype.fade = function(element, time_ms, max, min) { if (typeof(element) == "string") element = ALib.Dom.getElementById(element); if (typeof(max) == "undefined") var max = 1; if (typeof(min) == "undefined") var min = 0; if(element == null) return; if(element.FadeState == null) { if(element.style.opacity == null || element.style.opacity == '' || element.style.opacity == '1') { element.FadeState = 2; } else { element.FadeState = -2; } } element.animateFade = function(lastTick) { var curTick = new Date().getTime(); var elapsedTicks = curTick - lastTick; var element = this; if(element.FadeTimeLeft <= elapsedTicks) { element.style.opacity = element.FadeState == 1 ? max : min; element.style.filter = 'alpha(opacity = ' + (element.FadeState == 1 ? max : min) + ')'; element.FadeState = element.FadeState == 1 ? 2 : -2; return; } element.FadeTimeLeft -= elapsedTicks; var newOpVal = element.FadeTimeLeft/time_ms; if(element.FadeState == 1) newOpVal = max - newOpVal; element.style.opacity = newOpVal; element.style.filter = 'alpha(opacity = ' + (newOpVal*100) + ')'; setTimeout(function() { element.animateFade(curTick); }, 33); } if(element.FadeState == 1 || element.FadeState == -1) { element.FadeState = element.FadeState == 1 ? -1 : 1; element.FadeTimeLeft = time_ms - element.FadeTimeLeft; } else { element.FadeState = element.FadeState == 2 ? -1 : 1; element.FadeTimeLeft = time_ms; setTimeout(function() { element.animateFade(new Date().getTime()); }, 33); } } /* CEffect.prototype.round = function(element, sizex, sizey, sizex_b, sizex_y) { if (typeof(element) == "string") element = ALib.Dom.getElementById(element); if (typeof(sizex_b) == 'undefined') var sizex_b = sizex; if (typeof(sizey_b) == 'undefined') var sizey_b = sizey; /* var pdiv = ALib.Dom.createElement("div"); if (element.parentNode) { for (var i = 0; i < element.style.length; i++) { //ALib.trace(element.style[i] + ": " + ALib.Dom.styleGet(element, element.style[i])); if (element.style[i] != 'background-color' && element.style[i] != 'height') { ALib.Dom.styleSet(pdiv, element.style[i], ALib.Dom.styleGet(element, element.style[i])); ALib.Dom.styleSet(element, element.style[i], ''); } } insertAfter(element.parentNode, pdiv, element); var color = ALib.Dom.styleGet(element,"background-color"); element.parentNode.removeChild(element); pdiv.appendChild(element); this.addRoundCorner(pdiv, "transparent", color, sizex, sizey, true); this.addRoundCorner(pdiv, "transparent", color, sizex_b, sizey_b, false); } * / var bdiv = ALib.Dom.createElement("div"); // Copy child nodes to body div ALib.trace("GEtting Children = " + element.childNodes.length); for (var i = 0; i < element.childNodes.length; i++) { ALib.trace(element.childNodes.item(i)); bdiv.appendChild(element.childNodes.item(i)); } // Remove child nodes for (var i = element.childNodes.length - 1; i >= 0; i--) { element.removeChild(element.childNodes.item(i)); } ALib.trace("Copied Children"); var color = ALib.Dom.styleGet(element,"background-color"); var bk = ALib.Dom.styleGet(element.parentNode,"background-color"); this.addRoundCorner(element, bk, color, sizex, sizey, true); element.appendChild(bdiv); this.addRoundCorner(element, bk, color, sizex_b, sizey_b, false); // Copy styles ALib.Dom.styleSet(bdiv, "background-color", color); ALib.Dom.styleSet(element, "background-color", "transparent"); var height = ALib.Dom.styleGet(element,"height"); if (height) { ALib.Dom.styleSet(bdiv, "height", height); ALib.Dom.styleSet(element, "height", ""); } } CEffect.prototype.addRoundCorner = function(el, bk, color, sizex, sizey, top) { if (!sizex && !sizey) return; var i, j; var d = ALib.Dom.createElement("div"); d.style.backgroundColor = bk; var lastarc = 0; for (i = 1; i <= sizey; i++) { var coverage, arc2, arc3; // Find intersection of arc with bottom of pixel row arc = Math.sqrt(1.0 - Math.sqr(1.0 - i / sizey)) * sizex; // Calculate how many pixels are bg, fg and blended. var n_bg = sizex - Math.ceil(arc); var n_fg = Math.floor(lastarc); var n_aa = sizex - n_bg - n_fg; // Create pixel row wrapper var x = ALib.Dom.createElement("div"); var y = d; x.style.margin = "0px " + n_bg + "px"; x.style.height='1px'; x.style.overflow='hidden'; // Make a wrapper per anti-aliased pixel (at least one) for (j = 1; j <= n_aa; j++) { // Calculate coverage per pixel // (approximates circle by a line within the pixel) if (j == 1) { if (j == n_aa) { // Single pixel coverage = ((arc + lastarc) * .5) - n_fg; } else { // First in a run arc2 = Math.sqrt(1.0 - Math.sqr((sizex - n_bg - j + 1) / sizex)) * sizey; coverage = (arc2 - (sizey - i)) * (arc - n_fg - n_aa + 1) * .5; // Coverage is incorrect. Why? coverage = 0; } } else if (j == n_aa) { // Last in a run arc2 = Math.sqrt(1.0 - Math.sqr((sizex - n_bg - j + 1) / sizex)) * sizey; coverage = 1.0 - (1.0 - (arc2 - (sizey - i))) * (1.0 - (lastarc - n_fg)) * .5; } else { // Middle of a run arc3 = Math.sqrt(1.0 - Math.sqr((sizex - n_bg - j) / sizex)) * sizey; arc2 = Math.sqrt(1.0 - Math.sqr((sizex - n_bg - j + 1) / sizex)) * sizey; coverage = ((arc2 + arc3) * .5) - (sizey - i); } x.style.backgroundColor = this.blend(bk, color, coverage); if (top) y.appendChild(x); else y.insertBefore(x, y.firstChild); y = x; var x = ALib.Dom.createElement("div"); x.style.height='1px'; x.style.overflow='hidden'; x.style.margin = "0px 1px"; } x.style.backgroundColor = color; if (top) y.appendChild(x); else y.insertBefore(x, y.firstChild); lastarc = arc; } if (top) el.insertBefore(d, el.firstChild); else el.appendChild(d); } CEffect.prototype.blend = function(a, b, alpha) { var ca = Array( parseInt('0x' + a.substring(1, 3)), parseInt('0x' + a.substring(3, 5)), parseInt('0x' + a.substring(5, 7)) ); var cb = Array( parseInt('0x' + b.substring(1, 3)), parseInt('0x' + b.substring(3, 5)), parseInt('0x' + b.substring(5, 7)) ); return '#' + ('0'+Math.round(ca[0] + (cb[0] - ca[0])*alpha).toString(16)).slice(-2).toString(16) + ('0'+Math.round(ca[1] + (cb[1] - ca[1])*alpha).toString(16)).slice(-2).toString(16) + ('0'+Math.round(ca[2] + (cb[2] - ca[2])*alpha).toString(16)).slice(-2).toString(16); return '#' + ('0'+Math.round(ca[0] + (cb[0] - ca[0])*alpha).toString(16)).slice(-2).toString(16) + ('0'+Math.round(ca[1] + (cb[1] - ca[1])*alpha).toString(16)).slice(-2).toString(16) + ('0'+Math.round(ca[2] + (cb[2] - ca[2])*alpha).toString(16)).slice(-2).toString(16); } */ /**************************************************************** * * * curvyCorners * * ------------ * * * * This script generates rounded corners for your divs. * * * * Version 1.2.9 * * Copyright (c) 2006 Cameron Cooke * * By: Cameron Cooke and Tim Hutchison. * * * * * * Website: http://www.curvycorners.net * * Email: info@totalinfinity.com * * Forum: http://www.curvycorners.net/forum/ * * * * * * This library is free software; you can redistribute * * it and/or modify it under the terms of the GNU * * Lesser General Public License as published by the * * Free Software Foundation; either version 2.1 of the * * License, or (at your option) any later version. * * * * This library is distributed in the hope that it will * * be useful, but WITHOUT ANY WARRANTY; without even the * * implied warranty of MERCHANTABILITY or FITNESS FOR A * * PARTICULAR PURPOSE. See the GNU Lesser General Public * * License for more details. * * * * You should have received a copy of the GNU Lesser * * General Public License along with this library; * * Inc., 59 Temple Place, Suite 330, Boston, * * MA 02111-1307 USA * * * ****************************************************************/ // Browser detection var isIE = navigator.userAgent.toLowerCase().indexOf("msie") > -1; var isMoz = document.implementation && document.implementation.createDocument; var isSafari = ((navigator.userAgent.toLowerCase().indexOf('safari')!=-1)&&(navigator.userAgent.toLowerCase().indexOf('mac')!=-1))?true:false; /* Usage: newCornersObj = new curvyCorners(settingsObj, "classNameStr"); newCornersObj = new curvyCorners(settingsObj, divObj1[, divObj2[, divObj3[, . . . [, divObjN]]]]); */ function curvyCorners() { // Check parameters if(typeof(arguments[0]) != "object") throw newCurvyError("First parameter of curvyCorners() must be an object."); if(typeof(arguments[1]) != "object" && typeof(arguments[1]) != "string") throw newCurvyError("Second parameter of curvyCorners() must be an object or a class name."); // Get object(s) if(typeof(arguments[1]) == "string") { // Get elements by class name var startIndex = 0; var boxCol = getElementsByClass(arguments[1]); } else { // Get objects var startIndex = 1; var boxCol = arguments; } // Create return collection/object var curvyCornersCol = new Array(); // Create array of html elements that can have rounded corners if(arguments[0].validTags) var validElements = arguments[0].validTags; else var validElements = ["div"]; // Default // Loop through each argument for(var i = startIndex, j = boxCol.length; i < j; i++) { // Current element tag name var currentTag = boxCol[i].tagName.toLowerCase(); if(inArray(validElements, currentTag) !== false) { curvyCornersCol[curvyCornersCol.length] = new curvyObject(arguments[0], boxCol[i]); } } this.objects = curvyCornersCol; // Applys the curvyCorners to all objects this.applyCornersToAll = function() { for(var x = 0, k = this.objects.length; x < k; x++) { this.objects[x].applyCorners(); } } } // curvyCorners object (can be called directly) function curvyObject() { // Setup Globals this.box = arguments[1]; this.settings = arguments[0]; this.topContainer = null; this.bottomContainer = null; this.masterCorners = new Array(); this.contentDIV = null; // Get box formatting details var boxHeight = get_style(this.box, "height", "height"); var boxWidth = get_style(this.box, "width", "width"); var borderWidth = get_style(this.box, "borderTopWidth", "border-top-width"); var borderColour = get_style(this.box, "borderTopColor", "border-top-color"); var boxColour = get_style(this.box, "backgroundColor", "background-color"); var backgroundImage = get_style(this.box, "backgroundImage", "background-image"); var boxPosition = get_style(this.box, "position", "position"); var boxPadding = get_style(this.box, "paddingTop", "padding-top"); // Set formatting propertes this.boxHeight = parseInt(((boxHeight && boxHeight != "" && boxHeight != "auto" && boxHeight.indexOf("%") == -1)? boxHeight.substring(0, boxHeight.indexOf("px")) : this.box.scrollHeight)); this.boxWidth = parseInt(((boxWidth != "" && boxWidth != "auto" && boxWidth.indexOf("%") == -1)? boxWidth.substring(0, boxWidth.indexOf("px")) : this.box.scrollWidth)); this.borderWidth = parseInt(((borderWidth && borderWidth != "" && borderWidth.indexOf("px") !== -1)? borderWidth.slice(0, borderWidth.indexOf("px")) : 0)); this.boxColour = format_colour(boxColour); this.boxPadding = parseInt(((boxPadding && boxPadding != "" && boxPadding.indexOf("px") !== -1)? boxPadding.slice(0, boxPadding.indexOf("px")) : 0)); this.borderColour = format_colour(borderColour); this.borderString = this.borderWidth + "px" + " solid " + this.borderColour; this.backgroundImage = ((backgroundImage != "none")? backgroundImage : ""); this.boxContent = this.box.innerHTML; // Make box relative if not already absolute and remove any padding if(boxPosition != "absolute") this.box.style.position = "relative"; this.box.style.padding = "0px"; // If IE and height and width are not set, we need to set width so that we get positioning if(isIE && boxWidth == "auto" && boxHeight == "auto") this.box.style.width = "100%"; // Resize box so that it stays to the orignal height // Remove content if box is using autoPad if(this.settings.autoPad == true && this.boxPadding > 0) this.box.innerHTML = ""; /* This method creates the corners and applies them to the div element. */ this.applyCorners = function() { /* Create top and bottom containers. These will be used as a parent for the corners and bars. */ for(var t = 0; t < 2; t++) { switch(t) { // Top case 0: // Only build top bar if a top corner is to be draw if(this.settings.tl || this.settings.tr) { var newMainContainer = ALib.Dom.createElement("DIV"); newMainContainer.style.width = "100%"; newMainContainer.style.fontSize = "1px"; newMainContainer.style.overflow = "hidden"; newMainContainer.style.position = "absolute"; newMainContainer.style.paddingLeft = this.borderWidth + "px"; newMainContainer.style.paddingRight = this.borderWidth + "px"; var topMaxRadius = Math.max(this.settings.tl ? this.settings.tl.radius : 0, this.settings.tr ? this.settings.tr.radius : 0); newMainContainer.style.height = topMaxRadius + "px"; newMainContainer.style.top = 0 - topMaxRadius + "px"; newMainContainer.style.left = 0 - this.borderWidth + "px"; this.topContainer = this.box.appendChild(newMainContainer); } break; // Bottom case 1: // Only build bottom bar if a top corner is to be draw if(this.settings.bl || this.settings.br) { var newMainContainer = ALib.Dom.createElement("DIV"); newMainContainer.style.width = "100%"; newMainContainer.style.fontSize = "1px"; newMainContainer.style.overflow = "hidden"; newMainContainer.style.position = "absolute"; newMainContainer.style.paddingLeft = this.borderWidth + "px"; newMainContainer.style.paddingRight = this.borderWidth + "px"; var botMaxRadius = Math.max(this.settings.bl ? this.settings.bl.radius : 0, this.settings.br ? this.settings.br.radius : 0); newMainContainer.style.height = botMaxRadius + "px"; newMainContainer.style.bottom = 0 - botMaxRadius + "px"; newMainContainer.style.left = 0 - this.borderWidth + "px"; this.bottomContainer = this.box.appendChild(newMainContainer); } break; } } // Turn off current borders if(this.topContainer) this.box.style.borderTopWidth = "0px"; if(this.bottomContainer) this.box.style.borderBottomWidth = "0px"; // Create array of available corners var corners = ["tr", "tl", "br", "bl"]; /* Loop for each corner */ for(var i in corners) { // FIX for prototype lib if(i > -1 < 4) { // Get current corner type from array var cc = corners[i]; // Has the user requested the currentCorner be round? if(!this.settings[cc]) { // No if(((cc == "tr" || cc == "tl") && this.topContainer != null) || ((cc == "br" || cc == "bl") && this.bottomContainer != null)) { // We need to create a filler div to fill the space upto the next horzontal corner. var newCorner = ALib.Dom.createElement("DIV"); // Setup corners properties newCorner.style.position = "relative"; newCorner.style.fontSize = "1px"; newCorner.style.overflow = "hidden"; // Add background image? if(this.backgroundImage == "") newCorner.style.backgroundColor = this.boxColour; else newCorner.style.backgroundImage = this.backgroundImage; switch(cc) { case "tl": newCorner.style.height = topMaxRadius - this.borderWidth + "px"; newCorner.style.marginRight = this.settings.tr.radius - (this.borderWidth*2) + "px"; newCorner.style.borderLeft = this.borderString; newCorner.style.borderTop = this.borderString; newCorner.style.left = -this.borderWidth + "px"; break; case "tr": newCorner.style.height = topMaxRadius - this.borderWidth + "px"; newCorner.style.marginLeft = this.settings.tl.radius - (this.borderWidth*2) + "px"; newCorner.style.borderRight = this.borderString; newCorner.style.borderTop = this.borderString; newCorner.style.backgroundPosition = "-" + (topMaxRadius + this.borderWidth) + "px 0px"; newCorner.style.left = this.borderWidth + "px"; break; case "bl": newCorner.style.height = botMaxRadius - this.borderWidth + "px"; newCorner.style.marginRight = this.settings.br.radius - (this.borderWidth*2) + "px"; newCorner.style.borderLeft = this.borderString; newCorner.style.borderBottom = this.borderString; newCorner.style.left = -this.borderWidth + "px"; newCorner.style.backgroundPosition = "-" + (this.borderWidth) + "px -" + (this.boxHeight + (botMaxRadius + this.borderWidth)) + "px"; break; case "br": newCorner.style.height = botMaxRadius - this.borderWidth + "px"; newCorner.style.marginLeft = this.settings.bl.radius - (this.borderWidth*2) + "px"; newCorner.style.borderRight = this.borderString; newCorner.style.borderBottom = this.borderString; newCorner.style.left = this.borderWidth + "px" newCorner.style.backgroundPosition = "-" + (botMaxRadius + this.borderWidth) + "px -" + (this.boxHeight + (botMaxRadius + this.borderWidth)) + "px"; break; } } } else { /* PERFORMANCE NOTE: If more than one corner is requested and a corner has been already created for the same radius then that corner will be used as a master and cloned. The pixel bars will then be repositioned to form the new corner type. All new corners start as a bottom right corner. */ if(this.masterCorners[this.settings[cc].radius]) { // Create clone of the master corner var newCorner = this.masterCorners[this.settings[cc].radius].cloneNode(true); } else { // Yes, we need to create a new corner var newCorner = ALib.Dom.createElement("DIV"); newCorner.style.height = this.settings[cc].radius + "px"; newCorner.style.width = this.settings[cc].radius + "px"; newCorner.style.position = "absolute"; newCorner.style.fontSize = "1px"; newCorner.style.overflow = "hidden"; // THE FOLLOWING BLOCK OF CODE CREATES A ROUNDED CORNER // ---------------------------------------------------- TOP // Get border radius var borderRadius = parseInt(this.settings[cc].radius - this.borderWidth); // Cycle the x-axis for(var intx = 0, j = this.settings[cc].radius; intx < j; intx++) { // Calculate the value of y1 which identifies the pixels inside the border if((intx +1) >= borderRadius) var y1 = -1; else var y1 = (Math.floor(Math.sqrt(Math.pow(borderRadius, 2) - Math.pow((intx+1), 2))) - 1); // Only calculate y2 and y3 if there is a border defined if(borderRadius != j) { if((intx) >= borderRadius) var y2 = -1; else var y2 = Math.ceil(Math.sqrt(Math.pow(borderRadius,2) - Math.pow(intx, 2))); if((intx+1) >= j) var y3 = -1; else var y3 = (Math.floor(Math.sqrt(Math.pow(j ,2) - Math.pow((intx+1), 2))) - 1); } // Calculate y4 if((intx) >= j) var y4 = -1; else var y4 = Math.ceil(Math.sqrt(Math.pow(j ,2) - Math.pow(intx, 2))); // Draw bar on inside of the border with foreground colour if(y1 > -1) this.drawPixel(intx, 0, this.boxColour, 100, (y1+1), newCorner, -1, this.settings[cc].radius); // Only draw border/foreground antialiased pixels and border if there is a border defined if(borderRadius != j) { // Cycle the y-axis for(var inty = (y1 + 1); inty < y2; inty++) { // Draw anti-alias pixels if(this.settings.antiAlias) { // For each of the pixels that need anti aliasing between the foreground and border colour draw single pixel divs if(this.backgroundImage != "") { var borderFract = (pixelFraction(intx, inty, borderRadius) * 100); if(borderFract < 30) { this.drawPixel(intx, inty, this.borderColour, 100, 1, newCorner, 0, this.settings[cc].radius); } else { this.drawPixel(intx, inty, this.borderColour, 100, 1, newCorner, -1, this.settings[cc].radius); } } else { var pixelcolour = BlendColour(this.boxColour, this.borderColour, pixelFraction(intx, inty, borderRadius)); this.drawPixel(intx, inty, pixelcolour, 100, 1, newCorner, 0, this.settings[cc].radius, cc); } } } // Draw bar for the border if(this.settings.antiAlias) { if(y3 >= y2) { if (y2 == -1) y2 = 0; this.drawPixel(intx, y2, this.borderColour, 100, (y3 - y2 + 1), newCorner, 0, 0); } } else { if(y3 >= y1) { this.drawPixel(intx, (y1 + 1), this.borderColour, 100, (y3 - y1), newCorner, 0, 0); } } // Set the colour for the outside curve var outsideColour = this.borderColour; } else { // Set the coour for the outside curve var outsideColour = this.boxColour; var y3 = y1; } // Draw aa pixels? if(this.settings.antiAlias) { // Cycle the y-axis and draw the anti aliased pixels on the outside of the curve for(var inty = (y3 + 1); inty < y4; inty++) { // For each of the pixels that need anti aliasing between the foreground/border colour & background draw single pixel divs this.drawPixel(intx, inty, outsideColour, (pixelFraction(intx, inty , j) * 100), 1, newCorner, ((this.borderWidth > 0)? 0 : -1), this.settings[cc].radius); } } } // END OF CORNER CREATION // ---------------------------------------------------- END // We now need to store the current corner in the masterConers array this.masterCorners[this.settings[cc].radius] = newCorner.cloneNode(true); } /* Now we have a new corner we need to reposition all the pixels unless the current corner is the bottom right. */ if(cc != "br") { // Loop through all children (pixel bars) for(var t = 0, k = newCorner.childNodes.length; t < k; t++) { // Get current pixel bar var pixelBar = newCorner.childNodes[t]; // Get current top and left properties var pixelBarTop = parseInt(pixelBar.style.top.substring(0, pixelBar.style.top.indexOf("px"))); var pixelBarLeft = parseInt(pixelBar.style.left.substring(0, pixelBar.style.left.indexOf("px"))); var pixelBarHeight = parseInt(pixelBar.style.height.substring(0, pixelBar.style.height.indexOf("px"))); // Reposition pixels if(cc == "tl" || cc == "bl"){ pixelBar.style.left = this.settings[cc].radius -pixelBarLeft -1 + "px"; // Left } if(cc == "tr" || cc == "tl"){ pixelBar.style.top = this.settings[cc].radius -pixelBarHeight -pixelBarTop + "px"; // Top } switch(cc) { case "tr": pixelBar.style.backgroundPosition = "-" + Math.abs((this.boxWidth - this.settings[cc].radius + this.borderWidth) + pixelBarLeft) + "px -" + Math.abs(this.settings[cc].radius -pixelBarHeight -pixelBarTop - this.borderWidth) + "px"; break; case "tl": pixelBar.style.backgroundPosition = "-" + Math.abs((this.settings[cc].radius -pixelBarLeft -1) - this.borderWidth) + "px -" + Math.abs(this.settings[cc].radius -pixelBarHeight -pixelBarTop - this.borderWidth) + "px"; break; case "bl": pixelBar.style.backgroundPosition = "-" + Math.abs((this.settings[cc].radius -pixelBarLeft -1) - this.borderWidth) + "px -" + Math.abs((this.boxHeight + this.settings[cc].radius + pixelBarTop) -this.borderWidth) + "px"; break; } } } } if(newCorner) { // Position the container switch(cc) { case "tl": if(newCorner.style.position == "absolute") newCorner.style.top = "0px"; if(newCorner.style.position == "absolute") newCorner.style.left = "0px"; if(this.topContainer) this.topContainer.appendChild(newCorner); break; case "tr": if(newCorner.style.position == "absolute") newCorner.style.top = "0px"; if(newCorner.style.position == "absolute") newCorner.style.right = "0px"; if(this.topContainer) this.topContainer.appendChild(newCorner); break; case "bl": if(newCorner.style.position == "absolute") newCorner.style.bottom = "0px"; if(newCorner.style.position == "absolute") newCorner.style.left = "0px"; if(this.bottomContainer) this.bottomContainer.appendChild(newCorner); break; case "br": if(newCorner.style.position == "absolute") newCorner.style.bottom = "0px"; if(newCorner.style.position == "absolute") newCorner.style.right = "0px"; if(this.bottomContainer) this.bottomContainer.appendChild(newCorner); break; } } } } /* The last thing to do is draw the rest of the filler DIVs. We only need to create a filler DIVs when two corners have diffrent radiuses in either the top or bottom container. */ // Find out which corner has the biiger radius and get the difference amount var radiusDiff = new Array(); radiusDiff["t"] = Math.abs(this.settings.tl.radius - this.settings.tr.radius) radiusDiff["b"] = Math.abs(this.settings.bl.radius - this.settings.br.radius); for(z in radiusDiff) { // FIX for prototype lib if(z == "t" || z == "b") { if(radiusDiff[z]) { // Get the type of corner that is the smaller one var smallerCornerType = ((this.settings[z + "l"].radius < this.settings[z + "r"].radius)? z +"l" : z +"r"); // First we need to create a DIV for the space under the smaller corner var newFiller = ALib.Dom.createElement("DIV"); newFiller.style.height = radiusDiff[z] + "px"; newFiller.style.width = this.settings[smallerCornerType].radius+ "px" newFiller.style.position = "absolute"; newFiller.style.fontSize = "1px"; newFiller.style.overflow = "hidden"; newFiller.style.backgroundColor = this.boxColour; //newFiller.style.backgroundColor = get_random_color(); // Position filler switch(smallerCornerType) { case "tl": newFiller.style.bottom = "0px"; newFiller.style.left = "0px"; newFiller.style.borderLeft = this.borderString; this.topContainer.appendChild(newFiller); break; case "tr": newFiller.style.bottom = "0px"; newFiller.style.right = "0px"; newFiller.style.borderRight = this.borderString; this.topContainer.appendChild(newFiller); break; case "bl": newFiller.style.top = "0px"; newFiller.style.left = "0px"; newFiller.style.borderLeft = this.borderString; this.bottomContainer.appendChild(newFiller); break; case "br": newFiller.style.top = "0px"; newFiller.style.right = "0px"; newFiller.style.borderRight = this.borderString; this.bottomContainer.appendChild(newFiller); break; } } // Create the bar to fill the gap between each corner horizontally var newFillerBar = ALib.Dom.createElement("DIV"); newFillerBar.style.position = "relative"; newFillerBar.style.fontSize = "1px"; newFillerBar.style.overflow = "hidden"; newFillerBar.style.backgroundColor = this.boxColour; newFillerBar.style.backgroundImage = this.backgroundImage; switch(z) { case "t": // Top Bar if(this.topContainer) { // Edit by Asger Hallas: Check if settings.xx.radius is not false if(this.settings.tl.radius && this.settings.tr.radius) { newFillerBar.style.height = topMaxRadius - this.borderWidth + "px"; newFillerBar.style.marginLeft = this.settings.tl.radius - this.borderWidth + "px"; newFillerBar.style.marginRight = this.settings.tr.radius - this.borderWidth + "px"; newFillerBar.style.borderTop = this.borderString; if(this.backgroundImage != "") newFillerBar.style.backgroundPosition = "-" + (topMaxRadius + this.borderWidth) + "px 0px"; this.topContainer.appendChild(newFillerBar); } // Repos the boxes background image this.box.style.backgroundPosition = "0px -" + (topMaxRadius - this.borderWidth) + "px"; } break; case "b": if(this.bottomContainer) { // Edit by Asger Hallas: Check if settings.xx.radius is not false if(this.settings.bl.radius && this.settings.br.radius) { // Bottom Bar newFillerBar.style.height = botMaxRadius - this.borderWidth + "px"; newFillerBar.style.marginLeft = this.settings.bl.radius - this.borderWidth + "px"; newFillerBar.style.marginRight = this.settings.br.radius - this.borderWidth + "px"; newFillerBar.style.borderBottom = this.borderString; if(this.backgroundImage != "") newFillerBar.style.backgroundPosition = "-" + (botMaxRadius + this.borderWidth) + "px -" + (this.boxHeight + (topMaxRadius + this.borderWidth)) + "px"; this.bottomContainer.appendChild(newFillerBar); } } break; } } } /* AutoPad! apply padding if set. */ if(this.settings.autoPad == true && this.boxPadding > 0) { // Create content container var contentContainer = ALib.Dom.createElement("DIV"); // Set contentContainer's properties contentContainer.style.position = "relative"; contentContainer.innerHTML = this.boxContent; contentContainer.className = "autoPadDiv"; // Get padding amounts var topPadding = Math.abs(topMaxRadius - this.boxPadding); var botPadding = Math.abs(botMaxRadius - this.boxPadding); // Apply top padding if(topMaxRadius < this.boxPadding) contentContainer.style.paddingTop = topPadding + "px"; // Apply Bottom padding if(botMaxRadius < this.boxPadding) contentContainer.style.paddingBottom = botMaxRadius + "px"; // Apply left and right padding contentContainer.style.paddingLeft = this.boxPadding + "px"; contentContainer.style.paddingRight = this.boxPadding + "px"; // Append contentContainer this.contentDIV = this.box.appendChild(contentContainer); } } /* This function draws the pixles */ this.drawPixel = function(intx, inty, colour, transAmount, height, newCorner, image, cornerRadius) { // Create pixel var pixel = ALib.Dom.createElement("DIV"); pixel.style.height = height + "px"; pixel.style.width = "1px"; pixel.style.position = "absolute"; pixel.style.fontSize = "1px"; pixel.style.overflow = "hidden"; // Max Top Radius var topMaxRadius = Math.max(this.settings["tr"].radius, this.settings["tl"].radius); // Dont apply background image to border pixels if(image == -1 && this.backgroundImage != "") { pixel.style.backgroundImage = this.backgroundImage; pixel.style.backgroundPosition = "-" + (this.boxWidth - (cornerRadius - intx) + this.borderWidth) + "px -" + ((this.boxHeight + topMaxRadius + inty) -this.borderWidth) + "px"; } else { pixel.style.backgroundColor = colour; } // Set opacity if the transparency is anything other than 100 if (transAmount != 100) setOpacity(pixel, transAmount); // Set the pixels position pixel.style.top = inty + "px"; pixel.style.left = intx + "px"; newCorner.appendChild(pixel); } } // ------------- UTILITY FUNCTIONS /* Blends the two colours by the fraction returns the resulting colour as a string in the format "#FFFFFF" */ function BlendColour(Col1, Col2, Col1Fraction) { var red1 = parseInt(Col1.substr(1,2),16); var green1 = parseInt(Col1.substr(3,2),16); var blue1 = parseInt(Col1.substr(5,2),16); var red2 = parseInt(Col2.substr(1,2),16); var green2 = parseInt(Col2.substr(3,2),16); var blue2 = parseInt(Col2.substr(5,2),16); if(Col1Fraction > 1 || Col1Fraction < 0) Col1Fraction = 1; var endRed = Math.round((red1 * Col1Fraction) + (red2 * (1 - Col1Fraction))); if(endRed > 255) endRed = 255; if(endRed < 0) endRed = 0; var endGreen = Math.round((green1 * Col1Fraction) + (green2 * (1 - Col1Fraction))); if(endGreen > 255) endGreen = 255; if(endGreen < 0) endGreen = 0; var endBlue = Math.round((blue1 * Col1Fraction) + (blue2 * (1 - Col1Fraction))); if(endBlue > 255) endBlue = 255; if(endBlue < 0) endBlue = 0; return "#" + IntToHex(endRed)+ IntToHex(endGreen)+ IntToHex(endBlue); } /* Converts a number to hexadecimal format */ function IntToHex(strNum) { base = strNum / 16; rem = strNum % 16; base = base - (rem / 16); baseS = MakeHex(base); remS = MakeHex(rem); return baseS + '' + remS; } /* gets the hex bits of a number */ function MakeHex(x) { if((x >= 0) && (x <= 9)) { return x; } else { switch(x) { case 10: return "A"; case 11: return "B"; case 12: return "C"; case 13: return "D"; case 14: return "E"; case 15: return "F"; } } } /* For a pixel cut by the line determines the fraction of the pixel on the 'inside' of the line. Returns a number between 0 and 1 */ function pixelFraction(x, y, r) { var pixelfraction = 0; /* determine the co-ordinates of the two points on the perimeter of the pixel that the circle crosses */ var xvalues = new Array(1); var yvalues = new Array(1); var point = 0; var whatsides = ""; // x + 0 = Left var intersect = Math.sqrt((Math.pow(r,2) - Math.pow(x,2))); if ((intersect >= y) && (intersect < (y+1))) { whatsides = "Left"; xvalues[point] = 0; yvalues[point] = intersect - y; point = point + 1; } // y + 1 = Top var intersect = Math.sqrt((Math.pow(r,2) - Math.pow(y+1,2))); if ((intersect >= x) && (intersect < (x+1))) { whatsides = whatsides + "Top"; xvalues[point] = intersect - x; yvalues[point] = 1; point = point + 1; } // x + 1 = Right var intersect = Math.sqrt((Math.pow(r,2) - Math.pow(x+1,2))); if ((intersect >= y) && (intersect < (y+1))) { whatsides = whatsides + "Right"; xvalues[point] = 1; yvalues[point] = intersect - y; point = point + 1; } // y + 0 = Bottom var intersect = Math.sqrt((Math.pow(r,2) - Math.pow(y,2))); if ((intersect >= x) && (intersect < (x+1))) { whatsides = whatsides + "Bottom"; xvalues[point] = intersect - x; yvalues[point] = 0; } /* depending on which sides of the perimeter of the pixel the circle crosses calculate the fraction of the pixel inside the circle */ switch (whatsides) { case "LeftRight": pixelfraction = Math.min(yvalues[0],yvalues[1]) + ((Math.max(yvalues[0],yvalues[1]) - Math.min(yvalues[0],yvalues[1]))/2); break; case "TopRight": pixelfraction = 1-(((1-xvalues[0])*(1-yvalues[1]))/2); break; case "TopBottom": pixelfraction = Math.min(xvalues[0],xvalues[1]) + ((Math.max(xvalues[0],xvalues[1]) - Math.min(xvalues[0],xvalues[1]))/2); break; case "LeftBottom": pixelfraction = (yvalues[0]*xvalues[1])/2; break; default: pixelfraction = 1; } return pixelfraction; } // This function converts CSS rgb(x, x, x) to hexadecimal function rgb2Hex(rgbColour) { try{ // Get array of RGB values var rgbArray = rgb2Array(rgbColour); // Get RGB values var red = parseInt(rgbArray[0]); var green = parseInt(rgbArray[1]); var blue = parseInt(rgbArray[2]); // Build hex colour code var hexColour = "#" + IntToHex(red) + IntToHex(green) + IntToHex(blue); } catch(e){ alert("There was an error converting the RGB value to Hexadecimal in function rgb2Hex"); } return hexColour; } // Returns an array of rbg values function rgb2Array(rgbColour) { // Remove rgb() var rgbValues = rgbColour.substring(4, rgbColour.indexOf(")")); // Split RGB into array var rgbArray = rgbValues.split(", "); return rgbArray; } /* Function by Simon Willison from sitepoint.com Modified by Cameron Cooke adding Safari's rgba support */ function setOpacity(obj, opacity) { opacity = (opacity == 100)?99.999:opacity; if(isSafari && obj.tagName != "IFRAME") { // Get array of RGB values var rgbArray = rgb2Array(obj.style.backgroundColor); // Get RGB values var red = parseInt(rgbArray[0]); var green = parseInt(rgbArray[1]); var blue = parseInt(rgbArray[2]); // Safari using RGBA support obj.style.backgroundColor = "rgba(" + red + ", " + green + ", " + blue + ", " + opacity/100 + ")"; } else if(typeof(obj.style.opacity) != "undefined") { // W3C obj.style.opacity = opacity/100; } else if(typeof(obj.style.MozOpacity) != "undefined") { // Older Mozilla obj.style.MozOpacity = opacity/100; } else if(typeof(obj.style.filter) != "undefined") { // IE obj.style.filter = "alpha(opacity:" + opacity + ")"; } else if(typeof(obj.style.KHTMLOpacity) != "undefined") { // Older KHTML Based Browsers obj.style.KHTMLOpacity = opacity/100; } } /* Returns index if the passed value is found in the array otherwise returns false. */ function inArray(array, value) { for(var i = 0; i < array.length; i++){ // Matches identical (===), not just similar (==). if (array[i] === value) return i; } return false; } /* Returns true if the passed value is found as a key in the array otherwise returns false. */ function inArrayKey(array, value) { for(key in array){ // Matches identical (===), not just similar (==). if(key === value) return true; } return false; } // Cross browser add event wrapper function addEvent(elm, evType, fn, useCapture) { if (elm.addEventListener) { elm.addEventListener(evType, fn, useCapture); return true; } else if (elm.attachEvent) { var r = elm.attachEvent('on' + evType, fn); return r; } else { elm['on' + evType] = fn; } } // Cross browser remove event wrapper function removeEvent(obj, evType, fn, useCapture){ if (obj.removeEventListener){ obj.removeEventListener(evType, fn, useCapture); return true; } else if (obj.detachEvent){ var r = obj.detachEvent("on"+evType, fn); return r; } else { alert("Handler could not be removed"); } } // Formats colours function format_colour(colour) { var returnColour = "#ffffff"; // Make sure colour is set and not transparent if(colour != "" && colour != "transparent") { // RGB Value? if(colour.substr(0, 3) == "rgb") { // Get HEX aquiv. returnColour = rgb2Hex(colour); } else if(colour.length == 4) { // 3 chr colour code add remainder returnColour = "#" + colour.substring(1, 2) + colour.substring(1, 2) + colour.substring(2, 3) + colour.substring(2, 3) + colour.substring(3, 4) + colour.substring(3, 4); } else { // Normal valid hex colour returnColour = colour; } } return returnColour; } // Returns the style value for the property specfied function get_style(obj, property, propertyNS) { var ret = ALib.Dom.styleGet(obj, property); if (ret) return ret; else return ""; try { if(obj.currentStyle) { var returnVal = eval("obj.currentStyle." + property); } else { /* Safari does not expose any information for the object if display is set to none is set so we temporally enable it. */ if(isSafari && obj.style.display == "none") { obj.style.display = ""; var wasHidden = true; } var returnVal = ALib.m_document.defaultView.getComputedStyle(obj, '').getPropertyValue(propertyNS); // Rehide the object if(isSafari && wasHidden) { obj.style.display = "none"; } } } catch(e) { // Do nothing } return returnVal; } // Get elements by class by Dustin Diaz. function getElementsByClass(searchClass, node, tag) { var classElements = new Array(); if(node == null) node = ALib.m_document; if(tag == null) tag = '*'; var els = node.getElementsByTagName(tag); var elsLen = els.length; var pattern = new RegExp("(^|\s)"+searchClass+"(\s|$)"); for (i = 0, j = 0; i < elsLen; i++) { if(pattern.test(els[i].className)) { classElements[j] = els[i]; j++; } } return classElements; } // Displays error message function newCurvyError(errorMessage) { return new Error("curvyCorners Error:\n" + errorMessage) }