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