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!=null)
{
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 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'
if (root)
{
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!=null)
{
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);
this.ie7 = (this.ie && (this.major == 4) && (agt.indexOf("msie 8.")!=-1) );
this.ie7up = (this.ie && !this.ie3 && !this.ie4 && !this.ie5 && !this.ie5_5 && !this.ie6 && !this.ie7);
// 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;
case 5:
this.m_funct(this.m_args[0], this.m_args[1], this.m_args[2], this.m_args[3], this.m_args[4]);
break;
case 6:
this.m_funct(this.m_args[0], this.m_args[1], this.m_args[2], this.m_args[3], this.m_args[4], this.m_args[5]);
break;
default:
alert("Too many arguments");
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.disable = function()
{
this.m_main.disabled = true;
ALib.Dom.styleRemoveClass(this.m_main, this.m_scheme);
}
CButton.prototype.enable= function()
{
this.m_main.disabled = false;
}
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_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);
this.m_spTitle = ALib.m_document.createElement("div");
this.m_spTitle.className = "ContentTableTitleLabel";
//ALib.Dom.styleSet(this.m_spTitle, "float", "left");
ALib.Dom.styleSet(this.m_spTitle, "margin-right", (this.m_context.offsetWidth+3) + "px");
this.m_spTitle.innerHTML = title;
td_middle.appendChild(this.m_spTitle);
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.getRows = function(name)
{
return this.m_rows;
}
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, (f_readonly) ? "CDatasheetCellRO" : "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%");
ALib.Dom.styleSet(inp, "text-align", (align) ? align : "left");
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%");
ALib.Dom.styleSet(inp, "text-align", (align) ? align : "left");
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;
return this.m_rows[row].getValue(col);
}
}
CDatasheet.prototype.setValue = function(row, col, val)
{
if (this.m_rows[row].m_cols[col])
this.m_rows[row].m_cols[col].m_td.innerHTML = val;
}
// 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.getValue = function(col)
{
return this.m_cols[col].m_td.innerHTML;
}
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: addEvntListener
*
* Purpose: (pubic) Append an event listener to an object
*
* Arguements: e - element
* evnt - string: the event to capture
* funct - function: function to append
*
***********************************************************************************/
CDom.prototype.addEvntListener = function(e, evnt, funct)
{
if (this.m_binfo.ie)
{
//e.detachEvent(evnt, funct);
e.attachEvent("on"+evnt, funct);
}
else
{
try
{
//e.removeEventListener(evnt, funct, false);
e.addEventListener(evnt, funct, false);
}
catch (e) {}
}
}
/***********************************************************************************
*
* 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:
try
{
element.style[camel] = value;
}
catch (e) {}
}
}
/***********************************************************************************
*
* 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 = this.getDocumentHeights();
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: getDocumentHeights
*
* Purpose: (public) get the height of the entire document in scroll and more
*
* Arguements:
*
***********************************************************************************/
CDom.prototype.getDocumentHeights = function()
{
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);});
var h = [scrollHeight,ALib.m_evwnd.eight,bodyHeight];
return h;
}
/***********************************************************************************
*
* 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: styleRemoveClass
*
* Purpose: (public) remove a class from an element
*
* Arguements: element - element: element to modify
* className - string: class to remove
*
***********************************************************************************/
CDom.prototype.styleRemoveClass = function(element, strClass)
{
// if there is a class
if (element.className)
{
// the classes are just a space separated list, so first get the list
var arrList = element.className.split(' ');
// get uppercase class for comparison purposes
var strClassUpper = strClass.toUpperCase();
// find all instances and remove them
for ( var i = 0; i < arrList.length; i++ )
{
// if class found
if ( arrList[i].toUpperCase() == strClassUpper )
{
// remove array item
arrList.splice(i, 1);
// decrement loop counter as we have adjusted the array's contents
i--;
}
}
// assign modified class name attribute
element.className = arrList.join(' ');
}
}
/***********************************************************************************
*
* 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: o - element: element to locate
*
***********************************************************************************/
CDom.prototype.getElementPosition = function(o)
{
var left = 0;
var top = 0;
var right = o.offsetWidth;
var bottom = o.offsetHeight;
try
{
while (o.offsetParent)
{
left += o.offsetLeft;
top += o.offsetTop;
o = o.offsetParent;
}
}
catch(e) {}
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: getContentHeight
*
* Purpose: (public) get the content height of an element (minus px)
*
* Arguements: e = element
*
***********************************************************************************/
CDom.prototype.getContentHeight = function(e)
{
var height = -1;
var marginTop = parseInt(this.styleGet(this.m_document.body, 'marginTop'), 10);
var marginBottom = parseInt(this.styleGet(this.m_document.body, 'marginBottom'), 10);
var paddingTop = parseInt(this.styleGet(this.m_document.body, 'paddingTop'), 10);
var paddingBottom = parseInt(this.styleGet(this.m_document.body, 'paddingBottom'), 10);
height = e.offsetHeight-marginTop-marginBottom-paddingTop-paddingBottom;
/*
if (this.m_binfo.ie)
height = height - 20;
*/
return height;
}
/***********************************************************************************
*
* Function: getScrollBarWidth
*
* Purpose: (public) get the width of the system scrollbar
*
* Arguements: e = element
*
***********************************************************************************/
CDom.prototype.getScrollBarWidth = function(e)
{
var inner = this.createElement('p');
inner.style.width = "100%";
inner.style.height = "100px";
var outer = this.createElement('div');
outer.style.position = "absolute";
outer.style.top = "0px";
outer.style.left = "0px";
outer.style.visibility = "hidden";
outer.style.width = "50px";
outer.style.height = "50px";
outer.style.overflow = "hidden";
outer.appendChild (inner);
this.m_document.body.appendChild(outer);
var w1 = inner.offsetWidth;
outer.style.overflow = 'scroll';
var w2 = inner.offsetWidth;
if (w1 == w2) w2 = outer.clientWidth;
this.m_document.body.removeChild (outer);
return (w1 - w2);
}
/***********************************************************************************
*
* 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.onselectstart = function() { return false; } // Disable text selection
o.startdrag = 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();
},
init : function(e)
{
var o = DragAndDrop.obj = this;
//e = DragAndDrop.fixE(e);
DragAndDrop.startCoords = ALib.Dom.getMouseCoords();
ALib.m_document.onmousemove = function(e)
{
var cur_pos = ALib.Dom.getMouseCoords();
if (cur_pos.x >(DragAndDrop.startCoords.x+1) || cur_pos.x <(DragAndDrop.startCoords.x-1)
|| cur_pos.y >(DragAndDrop.startCoords.y+1) || cur_pos.y <(DragAndDrop.startCoords.y-1))
{
o.startdrag(e);
}
}
ALib.m_document.onmouseup = function(e)
{
ALib.m_document.onmousemove = function() {}
}
return false;
},
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++)
{
if (this.dropzones[i])
{
// IE never clears dropsozes if new pages are reloaded
// so we have to skip over null dropzones
// These should eventually be purged
try
{
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];
}
}
catch (e) { }
}
}
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 = 999;
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;
}
if (this.onmousedown)
div.onmousedown = function() { this.menuref.onmousedown(); };
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 : '';
if (ALib.Dom.m_binfo.ie)
full_title += "";
else
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();
}
if (this.onmousedown)
button_con.onmousedown = function() { this.menuref.onmousedown(); };
if (typeof this.tabIndex != "undefined")
{
button_con.tabIndex = this.tabIndex;
}
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.addCon = function()
{
var row = ALib.Dom.createElement("tr", this.m_tbody);
// Create icon cell
var cell = ALib.Dom.createElement("td", row);
cell.colSpan = 3;
cell.menuref = this;
return cell;
}
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, height)
{
this.m_con = ALib.m_document.createElement("div");
if (!width)
var width = "100%";
ALib.Dom.styleSet(this.m_con, "width", width);
if (height)
{
ALib.Dom.styleSet(this.m_con, "height", height);
}
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, selectable, sectionid, depth, parent_node)
{
// Get unique id name
var idname = (typeof idname == "undefined") ? null : idname;
var name = (idname && idname != -1) ? idname : this.getNextItemId();
var noOn = (selectable) ? false : true;
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;
item.m_noOn = noOn;
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_noOn = noOn;
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_noOn)
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(sectionid)
{
var sect_id = (sectionid) ? sectionid : this.m_lasesection;
var tr = ALib.m_document.createElement("tr");
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);
return td;
}
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, max)
{
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;
if (typeof max != "undefined" && max)
{
ALib.Dom.styleSet(section.m_condiv, "max-height", set_height+"px");
ALib.Dom.styleSet(section.m_condiv, "min-height", "15px");
}
else
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, selectable)
{
if (typeof selectable == "undefined")
{
var selectable = (idname=="-1") ? false : true;
}
return this.m_nb.addSectionItem(label, icon, action, args, idname, selectable, this.m_idname);
}
CNavBarSection.prototype.addCon = function()
{
return this.m_nb.addSectionDiv(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)
}
// Set the height of the section
CNavBarSection.prototype.setMaxHeight = function(height, overflow)
{
if (typeof overflow == "undefined")
var overflow = "auto";
this.m_nb.setSectionHeight(this.m_idname, height, overflow, true)
}
/***********************************************************************************
*
* 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, selectable)
{
if (typeof selectable == "undefined")
{
var selectable = (idname==-1) ? false : true;
}
var item = this.m_nb.addSectionItem(label, icon, action, args, idname, selectable, 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, act_args)
{
// 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;
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;
if (clk_act)
this.m_pages[this.m_next_index].td_b.clk_act = clk_act;
if (act_args)
this.m_pages[this.m_next_index].td_b.act_args = act_args;
this.m_pages[this.m_next_index].td_b.onclick = function ()
{
this.m_cls.selectTab(this.m_ind);
if (this.clk_act)
{
try
{
if (typeof this.clk_act == "string")
{
if (this.act_args)
{
var passargs = "";
for (var j = 0; j < act_args.length; j++)
{
if (passargs.length>0) passargs += ",";
passargs += "\"" + act_args[j] + "\"";
}
eval(this.clk_act + "(" + passargs + ")");
}
else
{
eval(this.clk_act + "()");
}
}
else
{
if (this.act_args)
{
switch (this.act_args.length)
{
case 1:
this.clk_act(this.act_args[0]);
break;
case 2:
this.clk_act(this.act_args[0], this.act_args[1]);
break;
case 3:
this.clk_act(this.act_args[0], this.act_args[1], this.act_args[2]);
break;
case 4:
this.clk_act(this.act_args[0], this.act_args[1],
this.act_args[2], this.act_args[3]);
break;
case 5:
this.clk_act(this.act_args[0], this.act_args[1],
this.act_args[2], this.act_args[3], this.act_args[4]);
break;
case 6:
this.clk_act(this.act_args[0], this.act_args[1],
this.act_args[2], this.act_args[3], this.act_args[4],
this.act_args[5]);
break;
case 7:
this.clk_act(this.act_args[0], this.act_args[1],
this.act_args[2], this.act_args[3], this.act_args[4],
this.act_args[5], this.act_args[6]);
break;
case 8:
this.clk_act(this.act_args[0], this.act_args[1],
this.act_args[2], this.act_args[3], this.act_args[4],
this.act_args[5], this.act_args[6], this.act_args[7]);
break;
case 9:
this.clk_act(this.act_args[0], this.act_args[1],
this.act_args[2], this.act_args[3], this.act_args[4],
this.act_args[5], this.act_args[6], this.act_args[7],
this.act_args[8]);
break;
case 10:
this.clk_act(this.act_args[0], this.act_args[1],
this.act_args[2], this.act_args[3], this.act_args[4],
this.act_args[5], this.act_args[6], this.act_args[7],
this.act_args[8], this.act_args[9]);
break;
}
}
else
{
this.clk_act();
}
}
}
catch (e) {}
}
}
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;
}
CTabs.prototype.getHeight = function()
{
return this.getTabHeight();
}
CTabs.prototype.setHeight = function(height)
{
// get Nav
var navheight = this.getTabHeight();
// outer
ALib.Dom.styleSet(this.m_outerdv, "height", height);
var fullheight = this.m_outerdv.offsetHeight;
ALib.Dom.styleSet(this.m_con, "height", (fullheight-navheight)+"px");
for (var i = 0; i < this.m_pages.length; i++)
{
ALib.Dom.styleSet(this.m_pages[i].container, "height", "100%");
}
}
/****************************************************************************
*
* 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: getHeight
* Purpose: Get the total height of the toolbar
*******************************************************************************/
CToolbar.prototype.getHeight= function ()
{
return this.m_con.offsetHeight;
}
/******************************************************************************
* 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, context)
{
// 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);
}
// Context content is displayed to the right of the label - commonly used for pagination
var con_div = ALib.m_document.createElement("div");
ALib.Dom.styleSetClass(con_div, "CWindowFrameContext");
this.m_context_div = con_div;
lbl_div.appendChild(con_div);
if (context && lbl_div)
{
// WFLabel
con_div.innerHTML = context;
}
// 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.getContextCon = function ()
{
return this.m_context_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: 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: // Modal
var dlg_d = new CDialog();
var dv = ALib.Dom.createElement("div");
dv.m_input = ALib.Dom.createElement("input", dv);
var dv_btn = ALib.Dom.createElement("div", dv);
var btn = new CButton("Alert", function(dv, dlg) { ALib.Dlg.messageBox("Say Something", dlg); }, [dv, dlg_d]); // Second param makes it modal
btn.print(dv_btn);
var btn = new CButton("Close", function(dlg) { dlg.hide(); }, [dlg_d]);
btn.print(dv_btn);
var btn = new CButton("Modal", function(dv, dlg) { dlg.customDialog(dv, 200, 200); }, [dv, dlg_d], "b1");
btn.print(con);
======================================================================================*/
/***********************************************************************************
*
* Class: CDialog
*
* Purpose: Encapsulate custom dialog functionality
*
***********************************************************************************/
function CDialog(title, parentDlg)
{
if (title)
this.m_title = title;
else
this.m_title = null;
this.zind = (parentDlg) ? parentDlg.zind+1 : 11;
this.m_initialized = false;
this.parentDlg = (parentDlg) ? parentDlg : null;
this.f_close = 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--)
{
if (!tag[i].dlgField)
tag[i].style.visibility=h;
}
tag=ALib.m_document.getElementsByTagName('iframe');
for(i=tag.length-1;i>=0;i--)
{
if (!tag[i].dlgField)
tag[i].style.visibility=h;
}
/*
* TODO: Correct this so that objects can work on dialogs but not on the background
tag=ALib.m_document.getElementsByTagName('object');
for(i=tag.length-1;i>=0;i--)
{
if (!tag[i].dlgField)
tag[i].style.visibility=h;
}
*/
}
CDialog.prototype.showOverlay = function(wd, ht)
{
if (!this.m_initialized)
this.initdlg();
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;
this.inf(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.showOverlay();
/*
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.hideOverlay = function()
{
var v = 'visible';
var n = 'none';
this.overlay.style.display=n;
this.inf(v);
}
CDialog.prototype.hide = function()
{
this.hm();
}
CDialog.prototype.hm = function()
{
var v = 'visible';
var n = 'none';
this.m_dcon.style.display=n;
if (!this.parentDlg)
this.hideOverlay();
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 = "10";
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 = this.zind;
// 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, parentdlg)
{
if (!this.m_initialized)
this.initdlg();
var old_parent = null;
if (parentdlg)
{
var old_parent = this.parentDlg;
this.parentDlg = parentdlg;
}
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, old_parent, cls) { dlg.hm(); cls.parentDlg = old_parent; }, [dlg, old_parent, this], "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);
// Add spacer
var spcr = ALib.Dom.createElement("span", bdv);
spcr.innerHTML = " ";
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);
// Add spacer
var spcr = ALib.Dom.createElement("span", bdv);
spcr.innerHTML = " ";
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 = "";
if (this.f_close)
{
var closedv = ALib.Dom.createElement("div", this.m_titlecon);
ALib.Dom.setClass(closedv, "CDialogTitleClose");
ALib.Dom.styleSet(closedv, "float", "right");
closedv.m_dlg = this;
closedv.onclick = function() { this.m_dlg.hide(); }
//closedv.innerHTML = "X";
}
var ttlsp = ALib.Dom.createElement("span", this.m_titlecon);
ttlsp.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';
this.ifrm.src = "about:blank";
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';
this.colors = [
"FFFFFF", "FFCCCC", "FFCC99", "FFFF99", "FFFFCC", "99FF99", "99FFFF", "CCFFFF",
"CCCCFF", "FFCCFF", "CCCCCC", "FF6666", "FF9966", "FFFF66", "FFFF33", "66FF99",
"33FFFF", "66FFFF", "9999FF", "FF99FF", "C0C0C0", "FF0000", "FF9900", "FFCC66",
"FFFF00", "33FF33", "66CCCC", "33CCFF", "6666CC", "CC66CC", "999999", "CC0000",
"FF6600", "FFCC33", "FFCC00", "33CC00", "00CCCC", "3366FF", "6633FF", "CC33CC",
"666666", "990000", "CC6600", "CC9933", "999900", "009900", "339999", "3333FF",
"6600CC", "993399", "333333", "660000", "993300", "996633", "666600", "006600",
"336666", "000099", "333399", "663366", "000000", "330000", "663300", "663333",
"333300", "003300", "003333", "000066", "330099", "330033"
];
}
/***********************************************************************************
*
* 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()
{
this.updateText();
return this.hdntxt.value;
}
/***********************************************************************************
*
* Function: setValue
*
* Purpose: Set text value of rte
*
***********************************************************************************/
CRte.prototype.setValue = function(html)
{
var frameHtml = "';
frameHtml += "\n";
frameHtml = "\n";
frameHtml += "\n";
frameHtml += "\n";
frameHtml += "\n";
frameHtml += "\n";
frameHtml += "\n";
if (html)
frameHtml += html + "\n";
frameHtml += "\n";
frameHtml += "";
this.idoc.open();
this.idoc.write(frameHtml);
this.idoc.close();
}
/***********************************************************************************
*
* Function: setHeight
*
* Purpose: Set the height of iframe
*
***********************************************************************************/
CRte.prototype.setHeight = function(height)
{
this.ifrm.style.height = height;
}
/***********************************************************************************
*
* Function: focus
*
* Purpose: Set the focus to the iframe
*
***********************************************************************************/
CRte.prototype.focus = function(height)
{
this.iwnd.focus();
}
/***********************************************************************************
*
* 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 = this.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();
this.setValue(html);
if (ALib.Dom.m_binfo.ie)
{
this.idoc.designMode = "On";
}
else
{
this.ifrm.contentDocument.designMode = "on";
if (ALib.Dom.m_binfo.gecko || ALib.Dom.m_binfo.webkit)
{
//attach a keyboard handler for gecko browsers to make keyboard shortcuts work
//oRTE.addEventListener("keypress", kb_handler, true);
this.idoc.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]);
// Image
if (typeof CFileOpen == "undefined") // Check for ANT CFileOpen
{
function imgdlg(cls)
{
cls.setRange();
var dlg_p = new CDialog();
dlg_p.m_rtfref = cls;
dlg_p.onPromptOk = function(val)
{
this.m_rtfref.insertImage(val);
}
dlg_p.promptBox("Enter the URL of your image", "Insert Image", "");
}
tb.addIcon(imgroot + "/images/image.gif", "left", imgdlg, [this]);
}
else // Use ANT file system
{
var cbrowser = new CFileOpen();
cbrowser.filterType = "jpg:jpeg:png:gif";
cbrowser.m_rtfref = this;
cbrowser.onSelect = function(fid, name, path)
{
this.m_rtfref.insertImage("/files/images/"+fid);
}
tb.addIcon(imgroot + "/images/image.gif", "left", function(cbrowser, cls) { cls.setRange(); cbrowser.showDialog(); }, [cbrowser, this]);
}
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();
var dmcon = new CDropdownMenu();
var dcon = dmcon.addCon();
this.createToolbarFntColor(dcon);
tb.AddItem(dmcon.createImageMenu(imgroot + "/images/textcolor.gif", imgroot + "/images/textcolor.gif", imgroot + "/images/textcolor.gif"));
var dmcon = new CDropdownMenu();
var dcon = dmcon.addCon();
this.createToolbarHlColor(dcon);
tb.AddItem(dmcon.createImageMenu(imgroot + "/images/bgcolor.gif", imgroot + "/images/bgcolor.gif", imgroot + "/images/bgcolor.gif"));
tb.addSpacer();
// Font
var dmfnt = new CDropdownMenu();
dmfnt.mRteCls = this;
dmfnt.onmousedown = function() { this.mRteCls.setRange(); }
dmfnt.tabIndex = -1;
var fonts = ["Arial", "Georgia", "Tahoma", "Courier New", "Times New Roman", "Verdana"];
for (var i = 0; i < fonts.length; i++)
dmfnt.addEntry(""+fonts[i]+"", function (cls, f) { cls.setFont("fontname", f); }, null, null, [this, fonts[i]]);
tb.AddItem(dmfnt.createButtonMenu("Font"));
// Size
var dmsz = new CDropdownMenu();
dmsz.mRteCls = this;
dmsz.onmousedown = function() { this.mRteCls.setRange(); }
dmsz.tabIndex = -1;
var sizes = [[1, "Smallest"], [2, "X-Small"], [3, "Small"], [4, "Normal"], [5, "Large"], [6, "X-Large"], [7, "Huge"]];
for (var i = 0; i < sizes.length; i++)
dmsz.addEntry(sizes[i][1], function (cls, f) { cls.setFont("fontsize", f); }, null, null, [this, sizes[i][0]]);
tb.AddItem(dmsz.createButtonMenu("Size"));
// Style
var dmst = new CDropdownMenu();
dmst.mRteCls = this;
dmst.onmousedown = function() { this.mRteCls.setRange(); }
dmst.tabIndex = -1;
var styles = [["Body", "formatblock", ""],
["Heading 1", "FormatBlock", "
"],
["Heading 2", "FormatBlock", ""],
["Heading 3", "FormatBlock", ""],
["Heading 4", "FormatBlock", ""],
["Heading 5", "FormatBlock", ""]];
for (var i = 0; i < styles.length; i++)
dmst.addEntry(styles[i][0], function (cls, func, val) { cls.setFont(func, val); }, null, null, [this, styles[i][1], styles[i][2]]);
tb.AddItem(dmst.createButtonMenu("Styles"));
tb.addSpacer();
tb.addIcon(imgroot + "/images/src.gif", "left", function(cls) {cls.toggleHtmlSrc(); }, [me]);
tb.print(container);
}
/***********************************************************************************
*
* Function: createToolbarFntColor
*
* Purpose: Create toolbar font color
*
***********************************************************************************/
CRte.prototype.createToolbarFntColor = function(container)
{
var me = this;
var tbl = ALib.Dom.createElement("table", container);
var tbody = ALib.Dom.createElement("tbody", tbl);
var cntr = 0;
var tr = ALib.Dom.createElement("tr", tbody);
for (var i = 0; i < this.colors.length; i++)
{
var td = ALib.Dom.createElement("td", tr);
td.menuref = container.menuref;
td.clsref = me;
td.clr = this.colors[i];
ALib.Dom.styleSet(td, "background-color", "#"+this.colors[i]);
ALib.Dom.styleSet(td, "width", "10px");
ALib.Dom.styleSet(td, "height", "10px");
ALib.Dom.styleSet(td, "border", "1px solid gray");
td.onmousedown = function() { this.clsref.setRange(); }
td.onmouseover = function() { this.style.border = '1px dotted white'; }
td.onmouseout = function() { this.style.border = '1px solid gray'; }
td.onclick = function() { this.clsref.setColor('forecolor', this.clr); this.menuref.unloadMe(); }
cntr++;
if (cntr >= 10)
{
var cntr = 0;
var tr = ALib.Dom.createElement("tr", tbody);
}
}
}
/***********************************************************************************
*
* Function: createToolbarHlColor
*
* Purpose: Create toolbar highlight color
*
***********************************************************************************/
CRte.prototype.createToolbarHlColor = function(container)
{
var me = this;
container.clsref = this;
var tbl = ALib.Dom.createElement("table", container);
var tbody = ALib.Dom.createElement("tbody", tbl);
var cntr = 0;
var tr = ALib.Dom.createElement("tr", tbody);
for (var i = 0; i < this.colors.length; i++)
{
var td = ALib.Dom.createElement("td", tr);
td.menuref = container.menuref;
td.clsref = me;
td.clr = this.colors[i];
ALib.Dom.styleSet(td, "background-color", "#"+this.colors[i]);
ALib.Dom.styleSet(td, "width", "10px");
ALib.Dom.styleSet(td, "height", "10px");
ALib.Dom.styleSet(td, "border", "1px solid gray");
td.onmousedown = function() { this.clsref.setRange(); }
td.onmouseover = function() { this.style.border = '1px dotted white'; }
td.onmouseout = function() { this.style.border = '1px solid gray'; }
td.onclick = function() { this.clsref.setColor('hilitecolor', this.clr); this.menuref.unloadMe(); }
cntr++;
if (cntr >= 10)
{
var cntr = 0;
var tr = ALib.Dom.createElement("tr", tbody);
}
}
}
/***********************************************************************************
*
* Function: setColor
*
* Purpose: Set hilight or foreground color
*
***********************************************************************************/
CRte.prototype.setColor = function(cmd, color)
{
if (ALib.Dom.m_binfo.ie)
{
this.iwnd.focus();
//retrieve selected range
var sel = this.idoc.selection;
if (sel != null)
{
var newRng = sel.createRange();
newRng = this.rng;
newRng.select();
}
cmd = (cmd == "hilitecolor") ? "backcolor" : cmd;
}
this.rteCommand(cmd, "#"+color);
}
/***********************************************************************************
*
* Function: setFont
*
* Purpose: Set Font Name
*
***********************************************************************************/
CRte.prototype.setFont = function(cmd, font)
{
if (ALib.Dom.m_binfo.ie)
{
this.iwnd.focus();
//retrieve selected range
var sel = this.idoc.selection;
if (sel != null)
{
var newRng = sel.createRange();
newRng = this.rng;
newRng.select();
}
}
this.rteCommand(cmd, font);
}
/***********************************************************************************
*
* Function: insertImage
*
* Purpose: Insert an image
*
***********************************************************************************/
CRte.prototype.insertImage = function(path)
{
if (ALib.Dom.m_binfo.ie)
{
this.iwnd.focus();
//retrieve selected range
var sel = this.idoc.selection;
if (sel != null)
{
var newRng = sel.createRange();
newRng = this.rng;
newRng.select();
}
}
this.rteCommand("InsertImage", path);
}
/***********************************************************************************
*
* Function: setRange
*
* Purpose: Set and store selection range
*
***********************************************************************************/
CRte.prototype.setRange = function()
{
//function to store range of current selection
if (ALib.Dom.m_binfo.ie)
{
var selection = this.idoc.selection;
if (selection != null) this.rng = selection.createRange();
}
else
{
var selection = this.iwnd.getSelection();
this.rng = selection.getRangeAt(selection.rangeCount - 1).cloneRange();
}
}
/***********************************************************************************
*
* 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)
{
try
{
this.iwnd.focus();
this.idoc.execCommand(command, false, option);
this.iwnd.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()
{
if (ALib.Dom.m_binfo.ie && !me.rng)
{
me.setRange();
//retrieve selected range
var sel = me.idoc.selection;
if (sel != null)
{
var newRng = sel.createRange();
newRng = me.rng;
newRng.select();
}
}
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)
}
function CAutoComplete(obj,ca)
{
/* ---- Public Variables ---- */
this.actb_timeOut = -1; // Autocomplete Timeout in ms (-1: autocomplete never time out)
this.actb_lim = 8; // Number of elements autocomplete can show (-1: no limit)
this.actb_firstText = false; // should the auto complete be limited to the beginning of keyword?
this.actb_mouse = true; // Enable Mouse Support
this.actb_delimiter = new Array(';',','); // Delimiter for multiple autocomplete. Set it to empty array for single autocomplete
this.actb_startcheck = 1; // Show widget only after this number of characters is typed in.
/* ---- Public Variables ---- */
/* --- Styles --- */
this.actb_bgColor = '#888888';
this.actb_textColor = '#FFFFFF';
this.actb_hColor = '#000000';
this.actb_fFamily = 'Arial';
this.actb_fSize = '12px';
this.actb_hStyle = 'text-decoration:underline;font-weight="bold"';
/* --- Styles --- */
/* ---- Private Variables ---- */
var actb_delimwords = new Array();
var actb_cdelimword = 0;
var actb_delimchar = new Array();
var actb_display = false;
var actb_pos = 0;
var actb_total = 0;
var actb_curr = null;
var actb_rangeu = 0;
var actb_ranged = 0;
var actb_bool = new Array();
var actb_pre = 0;
var actb_toid;
var actb_tomake = false;
var actb_getpre = "";
var actb_mouse_on_list = 1;
var actb_kwcount = 0;
var actb_caretmove = false;
this.actb_keywords = new Array();
/* ---- Private Variables---- */
this.actb_keywords = ca;
var actb_self = this;
actb_curr = obj;
// Set flag that ac is being displayed
actb_curr.m_inac = false;
addEvent(actb_curr,"focus",actb_setup);
function actb_setup()
{
addEvent(document,"keydown",actb_checkkey);
addEvent(actb_curr,"blur",actb_clear);
addEvent(document,"keypress",actb_keypress);
}
function actb_clear(evt)
{
if (!evt) evt = event;
removeEvent(document,"keydown",actb_checkkey);
removeEvent(actb_curr,"blur",actb_clear);
removeEvent(document,"keypress",actb_keypress);
actb_removedisp();
}
// Populate the HTML text
function actb_parse(n)
{
// Escape chars
n = n.replace(/[<]/g,'<');
n = n.replace(/[>]/g,'>');
if (actb_self.actb_delimiter.length > 0)
{
var t = actb_delimwords[actb_cdelimword].trim().addslashes();
var plen = actb_delimwords[actb_cdelimword].trim().length;
}
else
{
var t = actb_curr.value.addslashes();
var plen = actb_curr.value.length;
}
var tobuild = '';
var i;
if (actb_self.actb_firstText)
{
var re = new RegExp("^" + t, "i");
}
else
{
var re = new RegExp(t, "i");
}
var p = n.search(re);
for (i=0;i
"
for (i=p;i";
for (i=plen+p;i 1){
r = a.insertRow(-1);
r.style.backgroundColor = actb_self.actb_bgColor;
c = r.insertCell(-1);
c.style.color = actb_self.actb_textColor;
c.style.fontFamily = 'arial narrow';
c.style.fontSize = actb_self.actb_fSize;
c.align='center';
replaceHTML(c,'/\\');
if (actb_self.actb_mouse){
c.style.cursor = 'pointer';
c.onclick = actb_mouse_up;
}
}
for (i=0;i= actb_rangeu && j <= actb_ranged){
r = a.insertRow(-1);
r.style.backgroundColor = actb_self.actb_bgColor;
r.id = 'tat_tr'+(j);
c = r.insertCell(-1);
c.style.color = actb_self.actb_textColor;
c.style.fontFamily = actb_self.actb_fFamily;
c.style.fontSize = actb_self.actb_fSize;
c.innerHTML = actb_parse(actb_self.actb_keywords[i]);
c.id = 'tat_td'+(j);
c.setAttribute('pos',j);
if (actb_self.actb_mouse){
c.style.cursor = 'pointer';
c.onclick=actb_mouseclick;
c.onmouseover = actb_table_highlight;
}
j++;
}else{
j++;
}
}
if (j > actb_ranged) break;
}
if (j-1 < actb_total){
r = a.insertRow(-1);
r.style.backgroundColor = actb_self.actb_bgColor;
c = r.insertCell(-1);
c.style.color = actb_self.actb_textColor;
c.style.fontFamily = 'arial narrow';
c.style.fontSize = actb_self.actb_fSize;
c.align='center';
replaceHTML(c,'\\/');
if (actb_self.actb_mouse){
c.style.cursor = 'pointer';
c.onclick = actb_mouse_down;
}
}
// Set flag that ac is being displayed
actb_curr.m_inac = true;
}
function actb_goup()
{
if (!actb_display) return;
if (actb_pos == 1) return;
document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_bgColor;
actb_pos--;
if (actb_pos < actb_rangeu) actb_moveup();
document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_hColor;
if (actb_toid) clearTimeout(actb_toid);
if (actb_self.actb_timeOut > 0) actb_toid = setTimeout(function(){actb_mouse_on_list=0;actb_removedisp();},actb_self.actb_timeOut);
}
function actb_godown()
{
if (!actb_display) return;
if (actb_pos == actb_total) return;
document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_bgColor;
actb_pos++;
if (actb_pos > actb_ranged) actb_movedown();
document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_hColor;
if (actb_toid) clearTimeout(actb_toid);
if (actb_self.actb_timeOut > 0) actb_toid = setTimeout(function(){actb_mouse_on_list=0;actb_removedisp();},actb_self.actb_timeOut);
}
function actb_movedown()
{
actb_rangeu++;
actb_ranged++;
actb_remake();
}
function actb_moveup()
{
actb_rangeu--;
actb_ranged--;
actb_remake();
}
/* Mouse */
function actb_mouse_down()
{
document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_bgColor;
actb_pos++;
actb_movedown();
document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_hColor;
actb_curr.focus();
actb_mouse_on_list = 0;
if (actb_toid) clearTimeout(actb_toid);
if (actb_self.actb_timeOut > 0) actb_toid = setTimeout(function(){actb_mouse_on_list=0;actb_removedisp();},actb_self.actb_timeOut);
}
function actb_mouse_up(evt)
{
if (!evt) evt = event;
if (evt.stopPropagation){
evt.stopPropagation();
}else{
evt.cancelBubble = true;
}
document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_bgColor;
actb_pos--;
actb_moveup();
document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_hColor;
actb_curr.focus();
actb_mouse_on_list = 0;
if (actb_toid) clearTimeout(actb_toid);
if (actb_self.actb_timeOut > 0) actb_toid = setTimeout(function(){actb_mouse_on_list=0;actb_removedisp();},actb_self.actb_timeOut);
}
function actb_mouseclick(evt){
if (!evt) evt = event;
if (!actb_display) return;
actb_mouse_on_list = 0;
actb_pos = this.getAttribute('pos');
actb_penter();
}
function actb_table_focus()
{
actb_mouse_on_list = 1;
}
function actb_table_unfocus(){
actb_mouse_on_list = 0;
if (actb_toid) clearTimeout(actb_toid);
if (actb_self.actb_timeOut > 0) actb_toid = setTimeout(function(){actb_mouse_on_list = 0;actb_removedisp();},actb_self.actb_timeOut);
}
function actb_table_highlight(){
actb_mouse_on_list = 1;
document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_bgColor;
actb_pos = this.getAttribute('pos');
while (actb_pos < actb_rangeu) actb_moveup();
while (actb_pos > actb_ranged) actb_movedown();
document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_hColor;
if (actb_toid) clearTimeout(actb_toid);
if (actb_self.actb_timeOut > 0) actb_toid = setTimeout(function(){actb_mouse_on_list = 0;actb_removedisp();},actb_self.actb_timeOut);
}
/* ---- */
function actb_insertword(a){
if (actb_self.actb_delimiter.length > 0){
str = '';
l=0;
for (i=0;i=0;--j){
if (actb_delimwords[i].charAt(j) != ' ') break;
postspace += ' ';
}
str += prespace;
str += a;
l = str.length;
if (gotbreak) str += postspace;
}else{
str += actb_delimwords[i];
}
if (i != actb_delimwords.length - 1){
str += actb_delimchar[i];
}
}
actb_curr.value = str;
setCaret(actb_curr,l);
}else{
actb_curr.value = a;
}
actb_mouse_on_list = 0;
actb_removedisp();
try
{
actb_curr.onchange();
}
catch(e) {}
}
function actb_penter()
{
if (!actb_display) return;
actb_display = false;
var word = '';
var c = 0;
for (var i=0;i<=actb_self.actb_keywords.length;i++){
if (actb_bool[i]) c++;
if (c == actb_pos){
word = actb_self.actb_keywords[i];
break;
}
}
actb_insertword(word);
l = getCaretStart(actb_curr);
}
function actb_removedisp()
{
if (actb_mouse_on_list==0)
{
actb_display = 0;
if (document.getElementById('tat_table')){ document.body.removeChild(document.getElementById('tat_table')); }
if (actb_toid) clearTimeout(actb_toid);
actb_curr.m_inac = false;
}
}
function actb_keypress(e)
{
if (actb_caretmove) stopEvent(e);
return !actb_caretmove;
}
function actb_checkkey(evt){
if (!evt) evt = event;
a = evt.keyCode;
caret_pos_start = getCaretStart(actb_curr);
actb_caretmove = 0;
switch (a){
case 38:
actb_goup();
actb_caretmove = 1;
return false;
break;
case 40:
actb_godown();
actb_caretmove = 1;
return false;
break;
case 13: case 9:
if (actb_display)
{
actb_curr.m_inac = false;
actb_caretmove = 1;
actb_penter();
return false;
}
else
{
return true;
}
break;
default:
setTimeout(function(){actb_tocomplete(a)},50);
break;
}
}
function actb_tocomplete(kc){
if (kc == 38 || kc == 40 || kc == 13) return;
var i;
if (actb_display){
var word = 0;
var c = 0;
for (var i=0;i<=actb_self.actb_keywords.length;i++){
if (actb_bool[i]) c++;
if (c == actb_pos){
word = i;
break;
}
}
actb_pre = word;
}else{ actb_pre = -1};
if (actb_curr.value == ''){
actb_mouse_on_list = 0;
actb_removedisp();
return;
}
if (actb_self.actb_delimiter.length > 0){
caret_pos_start = getCaretStart(actb_curr);
caret_pos_end = getCaretEnd(actb_curr);
delim_split = '';
for (i=0;i= l && caret_pos_end <= l + actb_delimwords[i].length){
actb_cdelimword = i;
}
l+=actb_delimwords[i].length + 1;
}
var ot = actb_delimwords[actb_cdelimword].trim();
var t = actb_delimwords[actb_cdelimword].addslashes().trim();
}else{
var ot = actb_curr.value;
var t = actb_curr.value.addslashes();
}
if (ot.length == 0){
actb_mouse_on_list = 0;
actb_removedisp();
}
if (ot.length < actb_self.actb_startcheck) return this;
if (actb_self.actb_firstText){
var re = new RegExp("^" + t, "i");
}else{
var re = new RegExp(t, "i");
}
actb_total = 0;
actb_tomake = false;
actb_kwcount = 0;
for (i=0;i 0) actb_toid = setTimeout(function(){actb_mouse_on_list = 0;actb_removedisp();},actb_self.actb_timeOut);
actb_generate();
}
return this;
}
/*======================================================================================
Module: CAutoCompleteCal
Purpose: Provide in-page calendar popup for autocomplete of date input
Author: Sky Stebnicki, sky.stebnicki@aereus.com
Copyright (c) 2009 Aereus Corporation. All rights reserved.
Usage:
======================================================================================*/
// Define globals
// -----------------------------------------------------------
var g_CCalPopId = 1;
/***********************************************************************************
*
* Class: CAutoCompleteCal
*
* Purpose: Create Calendar Popup
*
* 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.
* divid - only used in ANT CAutoCompleteCal.awp because IE will not allow
* access to document.body before the doc is fully loaded.
*
***********************************************************************************/
function CAutoCompleteCal(inp, anchor, divid)
{
this.m_inp = inp;
this.m_id = g_CCalPopId++;
if (divid)
var dv = divid;
else
var dv= ALib.Dom.createElement("div");
ALib.Dom.styleSet(dv, "position", "absolute");
ALib.Dom.styleSet(dv, "visibility", "hidden");
ALib.Dom.styleSetClass(dv, "acCalContainer");
dv.style.zIndex = "991";
if (!divid)
{
ALib.Dom.m_document.body.appendChild(dv);
}
else
{
ALib.Dom.styleSet(dv, "display", "block");
}
dv.onmouseover = function() { this.haveFocus = true; }
dv.onmouseout = function() { this.haveFocus = false; }
this.m_div = dv;
this.m_cpop = new CalendarPopup(this.m_div);
if (inp && !anchor)
{
inp.onfocus = function()
{
}
inp.onblur = function()
{
}
}
if (anchor)
{
anchor.m_acc = this;
anchor.onclick = function()
{
var me = this;
this.m_acc.m_cpop.select(this.m_acc.m_inp, me, 'MM/dd/yyyy');
}
}
}
// Set the weekdays which should be disabled in the 'date' select popup. You can
// then allow someone to only select week end dates, or Tuedays, for example
CAutoCompleteCal.prototype.setDisabledWeekDays = function()
{
this.m_cpop.setDisabledWeekDays(0,1);
}
CAutoCompleteCal.prototype.addDisabledDate = function(strDate)
{
this.m_cpop.addDisabledDates(strDate);
}
// Selectively disable individual days or date ranges. Disabled days will not
// be clickable, and show as strike-through text on current browsers.
// Date format is any format recognized by parseDate() in date.js
// Pass a single date to disable:
//
// Pass null as the first parameter to mean "anything up to and including" the
// passed date:
// cal.addDisabledDates(null, "01/02/03")
//
// Pass null as the second parameter to mean "including the passed date and
// anything after it:
// cal.addDisabledDates("Jan 01, 2003", null);
//
// Pass two dates to disable all dates inbetween and including the two
// cal.addDisabledDates("January 01, 2003", "Dec 31, 2003");
CAutoCompleteCal.prototype.addDisabledDates = function(strDate1, strDate2)
{
this.m_cpop.addDisabledDates(strDate1, strDate2);
}
/*
$this->m_buf = "
".(($link) ? $link : "
")."
";
*/
/* SOURCE FILE: date.js */
// HISTORY
// ------------------------------------------------------------------
// May 17, 2003: Fixed bug in parseDate() for dates <1970
// March 11, 2003: Added parseDate() function
// March 11, 2003: Added "NNN" formatting option. Doesn't match up
// perfectly with SimpleDateFormat formats, but
// backwards-compatability was required.
// ------------------------------------------------------------------
// These functions use the same 'format' strings as the
// java.text.SimpleDateFormat class, with minor exceptions.
// The format string consists of the following abbreviations:
//
// Field | Full Form | Short Form
// -------------+--------------------+-----------------------
// Year | yyyy (4 digits) | yy (2 digits), y (2 or 4 digits)
// Month | MMM (name or abbr.)| MM (2 digits), M (1 or 2 digits)
// | NNN (abbr.) |
// Day of Month | dd (2 digits) | d (1 or 2 digits)
// Day of Week | EE (name) | E (abbr)
// Hour (1-12) | hh (2 digits) | h (1 or 2 digits)
// Hour (0-23) | HH (2 digits) | H (1 or 2 digits)
// Hour (0-11) | KK (2 digits) | K (1 or 2 digits)
// Hour (1-24) | kk (2 digits) | k (1 or 2 digits)
// Minute | mm (2 digits) | m (1 or 2 digits)
// Second | ss (2 digits) | s (1 or 2 digits)
// AM/PM | a |
//
// NOTE THE DIFFERENCE BETWEEN MM and mm! Month=MM, not mm!
// Examples:
// "MMM d, y" matches: January 01, 2000
// Dec 1, 1900
// Nov 20, 00
// "M/d/yy" matches: 01/20/00
// 9/2/00
// "MMM dd, yyyy hh:mm:ssa" matches: "January 01, 2000 12:30:45AM"
// ------------------------------------------------------------------
var MONTH_NAMES=new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var DAY_NAMES=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat');
function LZ(x) {return(x<0||x>9?"":"0")+x}
// ------------------------------------------------------------------
// isDate ( date_string, format_string )
// Returns true if date string matches format of format string and
// is a valid date. Else returns false.
// It is recommended that you trim whitespace around the value before
// passing it to this function, as whitespace is NOT ignored!
// ------------------------------------------------------------------
function isDate(val,format) {
var date=getDateFromFormat(val,format);
if (date==0) { return false; }
return true;
}
// -------------------------------------------------------------------
// compareDates(date1,date1format,date2,date2format)
// Compare two date strings to see which is greater.
// Returns:
// 1 if date1 is greater than date2
// 0 if date2 is greater than date1 of if they are the same
// -1 if either of the dates is in an invalid format
// -------------------------------------------------------------------
function compareDates(date1,dateformat1,date2,dateformat2) {
var d1=getDateFromFormat(date1,dateformat1);
var d2=getDateFromFormat(date2,dateformat2);
if (d1==0 || d2==0) {
return -1;
}
else if (d1 > d2) {
return 1;
}
return 0;
}
// ------------------------------------------------------------------
// formatDate (date_object, format)
// Returns a date in the output format specified.
// The format string uses the same abbreviations as in getDateFromFormat()
// ------------------------------------------------------------------
function formatDate(date,format) {
format=format+"";
var result="";
var i_format=0;
var c="";
var token="";
var y=date.getYear()+"";
var M=date.getMonth()+1;
var d=date.getDate();
var E=date.getDay();
var H=date.getHours();
var m=date.getMinutes();
var s=date.getSeconds();
var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;
// Convert real date parts into formatted versions
var value=new Object();
if (y.length < 4) {y=""+(y-0+1900);}
value["y"]=""+y;
value["yyyy"]=y;
value["yy"]=y.substring(2,4);
value["M"]=M;
value["MM"]=LZ(M);
value["MMM"]=MONTH_NAMES[M-1];
value["NNN"]=MONTH_NAMES[M+11];
value["d"]=d;
value["dd"]=LZ(d);
value["E"]=DAY_NAMES[E+7];
value["EE"]=DAY_NAMES[E];
value["H"]=H;
value["HH"]=LZ(H);
if (H==0){value["h"]=12;}
else if (H>12){value["h"]=H-12;}
else {value["h"]=H;}
value["hh"]=LZ(value["h"]);
if (H>11){value["K"]=H-12;} else {value["K"]=H;}
value["k"]=H+1;
value["KK"]=LZ(value["K"]);
value["kk"]=LZ(value["k"]);
if (H > 11) { value["a"]="PM"; }
else { value["a"]="AM"; }
value["m"]=m;
value["mm"]=LZ(m);
value["s"]=s;
value["ss"]=LZ(s);
while (i_format < format.length) {
c=format.charAt(i_format);
token="";
while ((format.charAt(i_format)==c) && (i_format < format.length)) {
token += format.charAt(i_format++);
}
if (value[token] != null) { result=result + value[token]; }
else { result=result + token; }
}
return result;
}
// ------------------------------------------------------------------
// Utility functions for parsing in getDateFromFormat()
// ------------------------------------------------------------------
function _isInteger(val) {
var digits="1234567890";
for (var i=0; i < val.length; i++) {
if (digits.indexOf(val.charAt(i))==-1) { return false; }
}
return true;
}
function _getInt(str,i,minlength,maxlength) {
for (var x=maxlength; x>=minlength; x--) {
var token=str.substring(i,i+x);
if (token.length < minlength) { return null; }
if (_isInteger(token)) { return token; }
}
return null;
}
// ------------------------------------------------------------------
// getDateFromFormat( date_string , format_string )
//
// This function takes a date string and a format string. It matches
// If the date string matches the format string, it returns the
// getTime() of the date. If it does not match, it returns 0.
// ------------------------------------------------------------------
function getDateFromFormat(val,format) {
val=val+"";
format=format+"";
var i_val=0;
var i_format=0;
var c="";
var token="";
var token2="";
var x,y;
var now=new Date();
var year=now.getYear();
var month=now.getMonth()+1;
var date=1;
var hh=now.getHours();
var mm=now.getMinutes();
var ss=now.getSeconds();
var ampm="";
while (i_format < format.length) {
// Get next token from format string
c=format.charAt(i_format);
token="";
while ((format.charAt(i_format)==c) && (i_format < format.length)) {
token += format.charAt(i_format++);
}
// Extract contents of value based on format token
if (token=="yyyy" || token=="yy" || token=="y") {
if (token=="yyyy") { x=4;y=4; }
if (token=="yy") { x=2;y=2; }
if (token=="y") { x=2;y=4; }
year=_getInt(val,i_val,x,y);
if (year==null) { return 0; }
i_val += year.length;
if (year.length==2) {
if (year > 70) { year=1900+(year-0); }
else { year=2000+(year-0); }
}
}
else if (token=="MMM"||token=="NNN"){
month=0;
for (var i=0; i11)) {
month=i+1;
if (month>12) { month -= 12; }
i_val += month_name.length;
break;
}
}
}
if ((month < 1)||(month>12)){return 0;}
}
else if (token=="EE"||token=="E"){
for (var i=0; i12)){return 0;}
i_val+=month.length;}
else if (token=="dd"||token=="d") {
date=_getInt(val,i_val,token.length,2);
if(date==null||(date<1)||(date>31)){return 0;}
i_val+=date.length;}
else if (token=="hh"||token=="h") {
hh=_getInt(val,i_val,token.length,2);
if(hh==null||(hh<1)||(hh>12)){return 0;}
i_val+=hh.length;}
else if (token=="HH"||token=="H") {
hh=_getInt(val,i_val,token.length,2);
if(hh==null||(hh<0)||(hh>23)){return 0;}
i_val+=hh.length;}
else if (token=="KK"||token=="K") {
hh=_getInt(val,i_val,token.length,2);
if(hh==null||(hh<0)||(hh>11)){return 0;}
i_val+=hh.length;}
else if (token=="kk"||token=="k") {
hh=_getInt(val,i_val,token.length,2);
if(hh==null||(hh<1)||(hh>24)){return 0;}
i_val+=hh.length;hh--;}
else if (token=="mm"||token=="m") {
mm=_getInt(val,i_val,token.length,2);
if(mm==null||(mm<0)||(mm>59)){return 0;}
i_val+=mm.length;}
else if (token=="ss"||token=="s") {
ss=_getInt(val,i_val,token.length,2);
if(ss==null||(ss<0)||(ss>59)){return 0;}
i_val+=ss.length;}
else if (token=="a") {
if (val.substring(i_val,i_val+2).toLowerCase()=="am") {ampm="AM";}
else if (val.substring(i_val,i_val+2).toLowerCase()=="pm") {ampm="PM";}
else {return 0;}
i_val+=2;}
else {
if (val.substring(i_val,i_val+token.length)!=token) {return 0;}
else {i_val+=token.length;}
}
}
// If there are any trailing characters left in the value, it doesn't match
if (i_val != val.length) { return 0; }
// Is date valid for month?
if (month==2) {
// Check for leap year
if ( ( (year%4==0)&&(year%100 != 0) ) || (year%400==0) ) { // leap year
if (date > 29){ return 0; }
}
else { if (date > 28) { return 0; } }
}
if ((month==4)||(month==6)||(month==9)||(month==11)) {
if (date > 30) { return 0; }
}
// Correct hours value
if (hh<12 && ampm=="PM") { hh=hh-0+12; }
else if (hh>11 && ampm=="AM") { hh-=12; }
var newdate=new Date(year,month-1,date,hh,mm,ss);
return newdate.getTime();
}
// ------------------------------------------------------------------
// parseDate( date_string [, prefer_euro_format] )
//
// This function takes a date string and tries to match it to a
// number of possible date formats to get the value. It will try to
// match against the following international formats, in this order:
// y-M-d MMM d, y MMM d,y y-MMM-d d-MMM-y MMM d
// M/d/y M-d-y M.d.y MMM-d M/d M-d
// d/M/y d-M-y d.M.y d-MMM d/M d-M
// A second argument may be passed to instruct the method to search
// for formats like d/M/y (european format) before M/d/y (American).
// Returns a Date object or null if no patterns match.
// ------------------------------------------------------------------
function parseDate(val) {
var preferEuro=(arguments.length==2)?arguments[1]:false;
generalFormats=new Array('y-M-d','MMM d, y','MMM d,y','y-MMM-d','d-MMM-y','MMM d');
monthFirst=new Array('M/d/y','M-d-y','M.d.y','MMM-d','M/d','M-d');
dateFirst =new Array('d/M/y','d-M-y','d.M.y','d-MMM','d/M','d-M');
var checkList=new Array('generalFormats',preferEuro?'dateFirst':'monthFirst',preferEuro?'monthFirst':'dateFirst');
var d=null;
for (var i=0; i tags may cause errors.
USAGE:
// Create an object for a WINDOW popup
var win = new PopupWindow();
// Create an object for a DIV window using the DIV named 'mydiv'
var win = new PopupWindow('mydiv');
// Set the window to automatically hide itself when the user clicks
// anywhere else on the page except the popup
win.autoHide();
// Show the window relative to the anchor name passed in
win.showPopup(anchorname);
// Hide the popup
win.hidePopup();
// Set the size of the popup window (only applies to WINDOW popups
win.setSize(width,height);
// Populate the contents of the popup window that will be shown. If you
// change the contents while it is displayed, you will need to refresh()
win.populate(string);
// set the URL of the window, rather than populating its contents
// manually
win.setUrl("http://www.site.com/");
// Refresh the contents of the popup
win.refresh();
// Specify how many pixels to the right of the anchor the popup will appear
win.offsetX = 50;
// Specify how many pixels below the anchor the popup will appear
win.offsetY = 100;
NOTES:
1) Requires the functions in AnchorPosition.js
2) Your anchor tag MUST contain both NAME and ID attributes which are the
same. For example:
3) There must be at least a space between for IE5.5 to see the
anchor tag correctly. Do not do with no space.
4) When a PopupWindow object is created, a handler for 'onmouseup' is
attached to any event handler you may have already defined. Do NOT define
an event handler for 'onmouseup' after you define a PopupWindow object or
the autoHide() will not work correctly.
*/
// Set the position of the popup window based on the anchor
function PopupWindow_getXYPosition(anchorobj)
{
var coordinates = ALib.Dom.getElementPosition(anchorobj);
this.x = coordinates.x;
this.y = coordinates.y;
}
// Set width/height of DIV/popup window
function PopupWindow_setSize(width,height)
{
this.width = width;
this.height = height;
}
// Fill the window with contents
function PopupWindow_populate(contents)
{
this.contents = contents;
this.populated = false;
}
// Set the URL to go to
function PopupWindow_setUrl(url)
{
this.url = url;
}
// Set the window popup properties
function PopupWindow_setWindowProperties(props)
{
this.windowProperties = props;
}
// Refresh the displayed contents of the popup
function PopupWindow_refresh()
{
if (this.divRef != null)
{
// refresh the DIV object
this.divRef.innerHTML = this.contents;
}
else
{
if (this.popupWindow != null && !this.popupWindow.closed)
{
if (this.url!="")
{
this.popupWindow.location.href=this.url;
}
else
{
this.popupWindow.document.open();
this.popupWindow.document.writeln(this.contents);
this.popupWindow.document.close();
}
this.popupWindow.focus();
}
}
}
// Position and show the popup, relative to an anchor object
function PopupWindow_showPopup(anchorname)
{
this.getXYPosition(anchorname);
this.x += this.offsetX;
this.y += this.offsetY;
if (!this.populated && (this.contents != ""))
{
this.populated = true;
this.refresh();
}
if (this.divRef != null)
{
// Show the DIV object
this.divRef.style.left = this.x + "px";
this.divRef.style.top = this.y + "px";
this.divRef.style.visibility = "visible";
}
else
{
if (this.popupWindow == null || this.popupWindow.closed)
{
// If the popup window will go off-screen, move it so it doesn't
if (this.x<0) { this.x=0; }
if (this.y<0) { this.y=0; }
if (screen && screen.availHeight)
{
if ((this.y + this.height) > screen.availHeight)
{
this.y = screen.availHeight - this.height;
}
}
if (screen && screen.availWidth)
{
if ((this.x + this.width) > screen.availWidth)
{
this.x = screen.availWidth - this.width;
}
}
var avoidAboutBlank = window.opera || ( document.layers && !navigator.mimeTypes['*'] ) || navigator.vendor == 'KDE' || ( document.childNodes && !document.all && !navigator.taintEnabled );
this.popupWindow = window.open(avoidAboutBlank?"":"about:blank","window_"+anchorname,this.windowProperties+",width="+this.width+",height="+this.height+",screenX="+this.x+",left="+this.x+",screenY="+this.y+",top="+this.y+"");
}
this.refresh();
}
}
// Hide the popup
function PopupWindow_hidePopup()
{
if (this.divRef != null)
{
this.divRef.style.visibility = "hidden";
}
else
{
if (this.popupWindow && !this.popupWindow.closed)
{
this.popupWindow.close();
this.popupWindow = null;
}
}
}
// Check an onMouseDown event to see if we should hide
function PopupWindow_hideIfNotClicked(e)
{
if (this.autoHideEnabled && !this.divRef.haveFocus)
{
this.hidePopup();
}
}
// Call this to make the DIV disable automatically when mouse is clicked outside it
function PopupWindow_autoHide()
{
this.autoHideEnabled = true;
}
// This global function checks all PopupWindow objects onmouseup to see if they should be hidden
function PopupWindow_hidePopupWindows(e)
{
for (var i=0; i0)
{
this.type="DIV";
this.divRef = arguments[0];
}
else
{
this.type="WINDOW";
}
this.use_gebi = false;
this.use_css = false;
this.use_layers = false;
if (document.getElementById) { this.use_gebi = true; }
else if (document.all) { this.use_css = true; }
else if (document.layers) { this.use_layers = true; }
else { this.type = "WINDOW"; }
this.offsetX = 0;
this.offsetY = 0;
// Method mappings
this.getXYPosition = PopupWindow_getXYPosition;
this.populate = PopupWindow_populate;
this.setUrl = PopupWindow_setUrl;
this.setWindowProperties = PopupWindow_setWindowProperties;
this.refresh = PopupWindow_refresh;
this.showPopup = PopupWindow_showPopup;
this.hidePopup = PopupWindow_hidePopup;
this.setSize = PopupWindow_setSize;
this.autoHide = PopupWindow_autoHide;
this.hideIfNotClicked = PopupWindow_hideIfNotClicked;
}
/* SOURCE FILE: CalendarPopup.js */
// HISTORY
// ------------------------------------------------------------------
// Feb 7, 2005: Fixed a CSS styles to use px unit
// March 29, 2004: Added check in select() method for the form field
// being disabled. If it is, just return and don't do anything.
// March 24, 2004: Fixed bug - when month name and abbreviations were
// changed, date format still used original values.
// January 26, 2004: Added support for drop-down month and year
// navigation (Thanks to Chris Reid for the idea)
// September 22, 2003: Fixed a minor problem in YEAR calendar with
// CSS prefix.
// August 19, 2003: Renamed the function to get styles, and made it
// work correctly without an object reference
// August 18, 2003: Changed showYearNavigation and
// showYearNavigationInput to optionally take an argument of
// true or false
// July 31, 2003: Added text input option for year navigation.
// Added a per-calendar CSS prefix option to optionally use
// different styles for different calendars.
// July 29, 2003: Fixed bug causing the Today link to be clickable
// even though today falls in a disabled date range.
// Changed formatting to use pure CSS, allowing greater control
// over look-and-feel options.
// June 11, 2003: Fixed bug causing the Today link to be unselectable
// under certain cases when some days of week are disabled
// March 14, 2003: Added ability to disable individual dates or date
// ranges, display as light gray and strike-through
// March 14, 2003: Removed dependency on graypixel.gif and instead
/// use table border coloring
// March 12, 2003: Modified showCalendar() function to allow optional
// start-date parameter
// March 11, 2003: Modified select() function to allow optional
// start-date parameter
/*
DESCRIPTION: This object implements a popup calendar to allow the user to
select a date, month, quarter, or year.
COMPATABILITY: Works with Netscape 4.x, 6.x, IE 5.x on Windows. Some small
positioning errors - usually with Window positioning - occur on the
Macintosh platform.
The calendar can be modified to work for any location in the world by
changing which weekday is displayed as the first column, changing the month
names, and changing the column headers for each day.
USAGE:
// Create a new CalendarPopup object of type WINDOW
var cal = new CalendarPopup();
// Create a new CalendarPopup object of type DIV using the DIV named 'mydiv'
var cal = new CalendarPopup('mydiv');
// Easy method to link the popup calendar with an input box.
cal.select(inputObject, anchorname, dateFormat);
// Same method, but passing a default date other than the field's current value
cal.select(inputObject, anchorname, dateFormat, '01/02/2000');
// This is an example call to the popup calendar from a link to populate an
// input box. Note that to use this, date.js must also be included!!
Select
// Set the type of date select to be used. By default it is 'date'.
cal.setDisplayType(type);
// When a date, month, quarter, or year is clicked, a function is called and
// passed the details. You must write this function, and tell the calendar
// popup what the function name is.
// Function to be called for 'date' select receives y, m, d
cal.setReturnFunction(functionname);
// Function to be called for 'month' select receives y, m
cal.setReturnMonthFunction(functionname);
// Function to be called for 'quarter' select receives y, q
cal.setReturnQuarterFunction(functionname);
// Function to be called for 'year' select receives y
cal.setReturnYearFunction(functionname);
// Show the calendar relative to a given anchor
cal.showCalendar(anchorname);
// Hide the calendar. The calendar is set to autoHide automatically
cal.hideCalendar();
// Set the month names to be used. Default are English month names
cal.setMonthNames("January","February","March",...);
// Set the month abbreviations to be used. Default are English month abbreviations
cal.setMonthAbbreviations("Jan","Feb","Mar",...);
// Show navigation for changing by the year, not just one month at a time
cal.showYearNavigation();
// Show month and year dropdowns, for quicker selection of month of dates
cal.showNavigationDropdowns();
// Set the text to be used above each day column. The days start with
// sunday regardless of the value of WeekStartDay
cal.setDayHeaders("S","M","T",...);
// Set the day for the first column in the calendar grid. By default this
// is Sunday (0) but it may be changed to fit the conventions of other
// countries.
cal.setWeekStartDay(1); // week is Monday - Sunday
// Set the weekdays which should be disabled in the 'date' select popup. You can
// then allow someone to only select week end dates, or Tuedays, for example
cal.setDisabledWeekDays(0,1); // To disable selecting the 1st or 2nd days of the week
// Selectively disable individual days or date ranges. Disabled days will not
// be clickable, and show as strike-through text on current browsers.
// Date format is any format recognized by parseDate() in date.js
// Pass a single date to disable:
cal.addDisabledDates("2003-01-01");
// Pass null as the first parameter to mean "anything up to and including" the
// passed date:
cal.addDisabledDates(null, "01/02/03");
// Pass null as the second parameter to mean "including the passed date and
// anything after it:
cal.addDisabledDates("Jan 01, 2003", null);
// Pass two dates to disable all dates inbetween and including the two
cal.addDisabledDates("January 01, 2003", "Dec 31, 2003");
// When the 'year' select is displayed, set the number of years back from the
// current year to start listing years. Default is 2.
// This is also used for year drop-down, to decide how many years +/- to display
cal.setYearSelectStartOffset(2);
// Text for the word "Today" appearing on the calendar
cal.setTodayText("Today");
// The calendar uses CSS classes for formatting. If you want your calendar to
// have unique styles, you can set the prefix that will be added to all the
// classes in the output.
// For example, normal output may have this:
// Today
// But if you set the prefix like this:
cal.setCssPrefix("Test");
// The output will then look like:
// Today
// And you can define that style somewhere in your page.
// When using Year navigation, you can make the year be an input box, so
// the user can manually change it and jump to any year
cal.showYearNavigationInput();
// Set the calendar offset to be different than the default. By default it
// will appear just below and to the right of the anchorname. So if you have
// a text box where the date will go and and anchor immediately after the
// text box, the calendar will display immediately under the text box.
cal.offsetX = 20;
cal.offsetY = 20;
NOTES:
1) Requires the functions in AnchorPosition.js and PopupWindow.js
2) Your anchor tag MUST contain both NAME and ID attributes which are the
same. For example:
3) There must be at least a space between for IE5.5 to see the
anchor tag correctly. Do not do with no space.
4) When a CalendarPopup object is created, a handler for 'onmouseup' is
attached to any event handler you may have already defined. Do NOT define
an event handler for 'onmouseup' after you define a CalendarPopup object
or the autoHide() will not work correctly.
5) The calendar popup display uses style sheets to make it look nice.
*/
// CONSTRUCTOR for the CalendarPopup Object
function CalendarPopup()
{
var c;
if (arguments.length>0)
{
c = new PopupWindow(arguments[0]);
}
else
{
c = new PopupWindow();
c.setSize(150,175);
}
c.offsetX = -152;
c.offsetY = 25;
c.autoHide();
// Calendar-specific properties
c.monthNames = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
c.monthAbbreviations = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
c.dayHeaders = new Array("S","M","T","W","T","F","S");
c.returnFunction = "CP_tmpReturnFunction";
c.returnMonthFunction = "CP_tmpReturnMonthFunction";
c.returnQuarterFunction = "CP_tmpReturnQuarterFunction";
c.returnYearFunction = "CP_tmpReturnYearFunction";
c.weekStartDay = 0;
c.isShowYearNavigation = false;
c.displayType = "date";
c.disabledWeekDays = new Object();
c.disabledDatesExpression = "";
c.yearSelectStartOffset = 2;
c.currentDate = null;
c.todayText="Today";
c.cssPrefix="";
c.isShowNavigationDropdowns=false;
c.isShowYearNavigationInput=false;
window.CP_calendarObject = null;
window.CP_targetInput = null;
window.CP_dateFormat = "MM/dd/yyyy";
// Method mappings
c.copyMonthNamesToWindow = CP_copyMonthNamesToWindow;
c.setReturnFunction = CP_setReturnFunction;
c.setReturnMonthFunction = CP_setReturnMonthFunction;
c.setReturnQuarterFunction = CP_setReturnQuarterFunction;
c.setReturnYearFunction = CP_setReturnYearFunction;
c.setMonthNames = CP_setMonthNames;
c.setMonthAbbreviations = CP_setMonthAbbreviations;
c.setDayHeaders = CP_setDayHeaders;
c.setWeekStartDay = CP_setWeekStartDay;
c.setDisplayType = CP_setDisplayType;
c.setDisabledWeekDays = CP_setDisabledWeekDays;
c.addDisabledDates = CP_addDisabledDates;
c.setYearSelectStartOffset = CP_setYearSelectStartOffset;
c.setTodayText = CP_setTodayText;
c.showYearNavigation = CP_showYearNavigation;
c.showCalendar = CP_showCalendar;
c.hideCalendar = CP_hideCalendar;
c.getStyles = getCalendarStyles;
c.refreshCalendar = CP_refreshCalendar;
c.getCalendar = CP_getCalendar;
c.select = CP_select;
c.setCssPrefix = CP_setCssPrefix;
c.showNavigationDropdowns = CP_showNavigationDropdowns;
c.showYearNavigationInput = CP_showYearNavigationInput;
c.copyMonthNamesToWindow();
// Return the object
return c;
}
function CP_copyMonthNamesToWindow() {
// Copy these values over to the date.js
if (typeof(window.MONTH_NAMES)!="undefined" && window.MONTH_NAMES!=null) {
window.MONTH_NAMES = new Array();
for (var i=0; i\n";
result += "."+p+"acCalYearNavigation,."+p+"acCalMonthNavigation { background-color:#C0C0C0; text-align:center; vertical-align:center; text-decoration:none; color:#000000; font-weight:bold; }\n";
result += "."+p+"acCalDayColumnHeader, ."+p+"acCalYearNavigation,."+p+"acCalMonthNavigation,."+p+"acCalCurrentMonthDate,."+p+"acCalCurrentMonthDateDisabled,."+p+"acCalOtherMonthDate,."+p+"acCalOtherMonthDateDisabled,."+p+"acCalCurrentDate,."+p+"acCurrentDateDisabled,."+p+"acCalTodayText,."+p+"acCalTodayTextDisabled,."+p+"cpText { font-family:arial; font-size:8pt; }\n";
result += "TD."+p+"acCalDayColumnHeader { text-align:right; border:solid thin #C0C0C0;border-width:0px 0px 1px 0px; }\n";
result += "."+p+"acCalCurrentMonthDate, ."+p+"acCalOtherMonthDate, ."+p+"acCalCurrentDate { text-align:right; text-decoration:none; }\n";
result += "."+p+"acCalCurrentMonthDateDisabled, ."+p+"acCalOtherMonthDateDisabled, ."+p+"acCurrentDateDisabled { color:#D0D0D0; text-align:right; text-decoration:line-through; }\n";
result += "."+p+"acCalCurrentMonthDate, .acCalCurrentDate { color:#000000; }\n";
result += "."+p+"acCalOtherMonthDate { color:#808080; }\n";
result += "TD."+p+"acCalCurrentDate { color:white; background-color: #C0C0C0; border-width:1px; border:solid thin #800000; }\n";
result += "TD."+p+"acCurrentDateDisabled { border-width:1px; border:solid thin #FFAAAA; }\n";
result += "TD."+p+"acCalTodayText, TD."+p+"acCalTodayTextDisabled { border:solid thin #C0C0C0; border-width:1px 0px 0px 0px;}\n";
result += "A."+p+"acCalTodayText, SPAN."+p+"acCalTodayTextDisabled { height:20px; }\n";
result += "A."+p+"acCalTodayText { color:black; }\n";
result += "."+p+"acCalTodayTextDisabled { color:#D0D0D0; }\n";
result += "."+p+"cpBorder { border:solid thin #808080; }\n";
result += "\n";
return result;
}
// Return a string containing all the calendar code to be displayed
function CP_getCalendar() {
var now = new Date();
// Reference to window
if (this.type == "WINDOW") { var windowref = "window.opener."; }
else { var windowref = ""; }
var result = "";
// If POPUP, write entire HTML document
if (this.type == "WINDOW")
{
result += "Calendar"+this.getStyles()+"\n";
result += '\n';
}
// Code for DATE display (default)
// -------------------------------
if (this.displayType=="date" || this.displayType=="week-end") {
if (this.currentDate==null) { this.currentDate = now; }
if (arguments.length > 0) { var month = arguments[0]; }
else { var month = this.currentDate.getMonth()+1; }
if (arguments.length > 1 && arguments[1]>0 && arguments[1]-0==arguments[1]) { var year = arguments[1]; }
else { var year = this.currentDate.getFullYear(); }
var daysinmonth= new Array(0,31,28,31,30,31,30,31,31,30,31,30,31);
if ( ( (year%4 == 0)&&(year%100 != 0) ) || (year%400 == 0) ) {
daysinmonth[2] = 29;
}
var current_month = new Date(year,month-1,1);
var display_year = year;
var display_month = month;
var display_date = 1;
var weekday= current_month.getDay();
var offset = 0;
offset = (weekday >= this.weekStartDay) ? weekday-this.weekStartDay : 7-this.weekStartDay+weekday ;
if (offset > 0) {
display_month--;
if (display_month < 1) { display_month = 12; display_year--; }
display_date = daysinmonth[display_month]-offset+1;
}
var next_month = month+1;
var next_month_year = year;
if (next_month > 12) { next_month=1; next_month_year++; }
var last_month = month-1;
var last_month_year = year;
if (last_month < 1) { last_month=12; last_month_year--; }
var date_class;
if (this.type!="WINDOW") {
result += "\n';
result += '\n';
result += '\n';
for (var j=0; j<7; j++) {
result += '| '+this.dayHeaders[(this.weekStartDay+j)%7]+' | \n';
}
result += '
\n';
for (var row=1; row<=6; row++) {
result += '\n';
for (var col=1; col<=7; col++) {
var disabled=false;
if (this.disabledDatesExpression!="") {
var ds=""+display_year+LZ(display_month)+LZ(display_date);
eval("disabled=("+this.disabledDatesExpression+")");
}
var dateClass = "";
if ((display_month == this.currentDate.getMonth()+1) && (display_date==this.currentDate.getDate()) && (display_year==this.currentDate.getFullYear())) {
dateClass = "acCalCurrentDate";
}
else if (display_month == month) {
dateClass = "acCalCurrentMonthDate";
}
else {
dateClass = "acCalOtherMonthDate";
}
if (disabled || this.disabledWeekDays[col-1]) {
result += ' | '+display_date+' | \n';
}
else {
var selected_date = display_date;
var selected_month = display_month;
var selected_year = display_year;
if (this.displayType=="week-end") {
var d = new Date(selected_year,selected_month-1,selected_date,0,0,0,0);
d.setDate(d.getDate() + (7-col));
selected_year = d.getYear();
if (selected_year < 1000) { selected_year += 1900; }
selected_month = d.getMonth()+1;
selected_date = d.getDate();
}
result += ' '+display_date+' | \n';
}
display_date++;
if (display_date > daysinmonth[display_month]) {
display_date=1;
display_month++;
}
if (display_month > 12) {
display_month=1;
display_year++;
}
}
result += '
';
}
var current_weekday = now.getDay() - this.weekStartDay;
if (current_weekday < 0) {
current_weekday += 7;
}
result += '\n';
result += ' \n';
if (this.disabledDatesExpression!="") {
var ds=""+now.getFullYear()+LZ(now.getMonth()+1)+LZ(now.getDate());
eval("disabled=("+this.disabledDatesExpression+")");
}
if (disabled || this.disabledWeekDays[current_weekday+1]) {
result += ' '+this.todayText+'\n';
}
else {
result += ' '+this.todayText+'\n';
}
result += ' \n';
result += ' |
\n';
}
// Code common for MONTH, QUARTER, YEAR
// ------------------------------------
if (this.displayType=="month" || this.displayType=="quarter" || this.displayType=="year") {
if (arguments.length > 0) { var year = arguments[0]; }
else {
if (this.displayType=="year") { var year = now.getFullYear()-this.yearSelectStartOffset; }
else { var year = now.getFullYear(); }
}
if (this.displayType!="year" && this.isShowYearNavigation) {
result += "";
result += '\n';
result += ' | << | \n';
result += ' '+year+' | \n';
result += ' >> | \n';
result += '
\n';
}
}
// Code for MONTH display
// ----------------------
if (this.displayType=="month") {
// If POPUP, write entire HTML document
result += '\n';
}
// Code for QUARTER display
// ------------------------
if (this.displayType=="quarter") {
result += '
\n';
for (var i=0; i<2; i++) {
result += '';
for (var j=0; j<2; j++) {
var quarter = ((i*2)+j+1);
result += ' Q'+quarter+'
| ';
}
result += '
';
}
result += '
\n';
}
// Code for YEAR display
// ---------------------
if (this.displayType=="year") {
var yearColumnSize = 4;
result += "";
result += '\n';
result += ' | << | \n';
result += ' >> | \n';
result += '
\n';
result += '\n';
}
// Common
if (this.type == "WINDOW") {
result += "\n";
}
return result;
}
function CAutoCompleteTime(inp, inc)
{
var incre = (inc) ? inc : 15;
this.m_inp = inp;
var timearr = new Array('12:00 AM', '12:15 AM', '12:30 AM', '12:45 AM',
'1:00 AM', '1:15 AM', '1:30 AM', '1:45 AM',
'2:00 AM', '2:15 AM', '2:30 AM', '2:45 AM',
'3:00 AM', '3:15 AM', '3:30 AM', '3:45 AM',
'4:00 AM', '4:15 AM', '4:30 AM', '4:45 AM',
'5:00 AM', '5:15 AM', '5:30 AM', '5:45 AM',
'6:00 AM', '6:15 AM', '6:30 AM', '6:45 AM',
'7:00 AM', '7:15 AM', '7:30 AM', '7:45 AM',
'8:00 AM', '8:15 AM', '8:30 AM', '8:45 AM',
'9:00 AM', '9:15 AM', '9:30 AM', '9:45 AM',
'10:00 AM', '10:15 AM', '10:30 AM', '10:45 AM',
'11:00 AM', '11:15 AM', '11:30 AM', '11:45 AM',
'12:00 PM', '12:15 PM', '12:30 PM', '12:45 PM',
'1:00 PM', '1:15 PM', '1:30 PM', '1:45 PM',
'2:00 PM', '2:15 PM', '2:30 PM', '2:45 PM',
'3:00 PM', '3:15 PM', '3:30 PM', '3:45 PM',
'4:00 PM', '4:15 PM', '4:30 PM', '4:45 PM',
'5:00 PM', '5:15 PM', '5:30 PM', '5:45 PM',
'6:00 PM', '6:15 PM', '6:30 PM', '6:45 PM',
'7:00 PM', '7:15 PM', '7:30 PM', '7:45 PM',
'8:00 PM', '8:15 PM', '8:30 PM', '8:45 PM',
'9:00 PM', '9:15 PM', '9:30 PM', '9:45 PM',
'10:00 PM', '10:15 PM', '10:30 PM', '10:45 PM',
'11:00 PM', '11:15 PM', '11:30 PM', '11:45 PM');
var cls = this;
ALib.Dom.addEvntListener(inp, "change", cls.validateInput);
ALib.Dom.addEvntListener(inp, "focus", cls.saveVal);
var tobj = new CAutoComplete(inp,timearr);
}
CAutoCompleteTime.prototype.validateInput = function()
{
//regular expression to match required time format
//var re = /^\d{1,2}:\d{2}([ap]m)?$/; Should have $ for end of string but fails with autocomplete
var re = /^\d{1,2}:\d{2}([ap]m)?/;
if(this.value != '' && !this.value.match(re) && !this.m_inac)
{
this.value = this.m_backupval;
this.focus();
}
}
CAutoCompleteTime.prototype.saveVal = function()
{
this.m_backupval = this.value;
}
/****************************************************************************
*
* Class: CAlib
*
* Purpose: Base aereus lib class
*
* Author: Sky Stebnicki, sky.stebnicki@aereus.com
* Copyright (c) 2009 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, exclusive)
{
var vert_align = (valign) ? valign : 'middle';
var horiz_align = (halign) ? halign : 'center';
var modal = (exclusive) ? exclusive : false;
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.styleSetClass(dv_status, "statusAlert");
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");
if (modal)
this.Dlg.showOverlay();
else
this.Effect.fadein(dv_status, 200);
dv_status.style.zIndex = "999";
this.Dom.styleSet(dv_status, "visibility", "visible");
if (timeout)
{
var fctn = function()
{
if (modal)
{
ALib.Dom.styleSet(dv_status, "visibility", "hidden");
ALib.Dlg.hideOverlay();
}
else
{
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(parnt, node, referenceNode)
{
if (referenceNode.nextSibling)
parnt.insertBefore(node, referenceNode.nextSibling);
else
parnt.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);
}
function rawurlencode(str)
{
// http://kevin.vanzonneveld.net
// + original by: Brett Zamir (http://brett-zamir.me)
// + input by: travc
// + input by: Brett Zamir (http://brett-zamir.me)
// + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + input by: Michael Grier
// + bugfixed by: Brett Zamir (http://brett-zamir.me)
// * example 1: rawurlencode('Kevin van Zonneveld!');
// * returns 1: 'Kevin%20van%20Zonneveld%21'
// * example 2: rawurlencode('http://kevin.vanzonneveld.net/');
// * returns 2: 'http%3A%2F%2Fkevin.vanzonneveld.net%2F'
// * example 3: rawurlencode('http://www.google.nl/search?q=php.js&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:unofficial&client=firefox-a');
// * returns 3: 'http%3A%2F%2Fwww.google.nl%2Fsearch%3Fq%3Dphp.js%26ie%3Dutf-8%26oe%3Dutf-8%26aq%3Dt%26rls%3Dcom.ubuntu%3Aen-US%3Aunofficial%26client%3Dfirefox-a'
var histogram = {}, unicodeStr='', hexEscStr='';
var ret = str.toString();
var replacer = function(search, replace, str) {
var tmp_arr = [];
tmp_arr = str.split(search);
return tmp_arr.join(replace);
};
// The histogram is identical to the one in urldecode.
histogram["'"] = '%27';
histogram['('] = '%28';
histogram[')'] = '%29';
histogram['*'] = '%2A';
histogram['~'] = '%7E';
histogram['!'] = '%21';
histogram['\u20AC'] = '%80';
histogram['\u0081'] = '%81';
histogram['\u201A'] = '%82';
histogram['\u0192'] = '%83';
histogram['\u201E'] = '%84';
histogram['\u2026'] = '%85';
histogram['\u2020'] = '%86';
histogram['\u2021'] = '%87';
histogram['\u02C6'] = '%88';
histogram['\u2030'] = '%89';
histogram['\u0160'] = '%8A';
histogram['\u2039'] = '%8B';
histogram['\u0152'] = '%8C';
histogram['\u008D'] = '%8D';
histogram['\u017D'] = '%8E';
histogram['\u008F'] = '%8F';
histogram['\u0090'] = '%90';
histogram['\u2018'] = '%91';
histogram['\u2019'] = '%92';
histogram['\u201C'] = '%93';
histogram['\u201D'] = '%94';
histogram['\u2022'] = '%95';
histogram['\u2013'] = '%96';
histogram['\u2014'] = '%97';
histogram['\u02DC'] = '%98';
histogram['\u2122'] = '%99';
histogram['\u0161'] = '%9A';
histogram['\u203A'] = '%9B';
histogram['\u0153'] = '%9C';
histogram['\u009D'] = '%9D';
histogram['\u017E'] = '%9E';
histogram['\u0178'] = '%9F';
// Begin with encodeURIComponent, which most resembles PHP's encoding functions
ret = encodeURIComponent(ret);
for (unicodeStr in histogram) {
hexEscStr = histogram[unicodeStr];
ret = replacer(unicodeStr, hexEscStr, ret); // Custom replace. No regexing
}
// Uppercase for full PHP compatibility
return ret.replace(/(\%([a-z0-9]{2}))/g, function(full, m1, m2) {
return "%"+m2.toUpperCase();
});
}
function rawurldecode( str )
{
// http://kevin.vanzonneveld.net
// + original by: Brett Zamir (http://brett-zamir.me)
// + input by: travc
// + input by: Brett Zamir (http://brett-zamir.me)
// + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// * example 1: rawurldecode('Kevin+van+Zonneveld%21');
// * returns 1: 'Kevin+van+Zonneveld!'
// * example 2: rawurldecode('http%3A%2F%2Fkevin.vanzonneveld.net%2F');
// * returns 2: 'http://kevin.vanzonneveld.net/'
// * example 3: rawurldecode('http%3A%2F%2Fwww.google.nl%2Fsearch%3Fq%3Dphp.js%26ie%3Dutf-8%26oe%3Dutf-8%26aq%3Dt%26rls%3Dcom.ubuntu%3Aen-US%3Aunofficial%26client%3Dfirefox-a');
// * returns 3: 'http://www.google.nl/search?q=php.js&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:unofficial&client=firefox-a'
// * example 4: rawurldecode('-22%97bc%2Fbc');
// * returns 4: '-22—bc/bc'
var histogram = {}, ret = str.toString(), unicodeStr='', hexEscStr='';
var replacer = function(search, replace, str) {
var tmp_arr = [];
tmp_arr = str.split(search);
return tmp_arr.join(replace);
};
// The histogram is identical to the one in urlencode.
histogram["'"] = '%27';
histogram['('] = '%28';
histogram[')'] = '%29';
histogram['*'] = '%2A';
histogram['~'] = '%7E';
histogram['!'] = '%21';
for (unicodeStr in histogram) {
hexEscStr = histogram[unicodeStr]; // Switch order when decoding
ret = replacer(hexEscStr, unicodeStr, ret); // Custom replace. No regexing
}
// End with decodeURIComponent, which most resembles PHP's encoding functions
ret = ret.replace(/%([a-fA-F][0-9a-fA-F])/g, function (all, hex) {return String.fromCharCode('0x'+hex);}); // These Latin-B have the same values in Unicode, so we can convert them like this
ret = decodeURIComponent(ret);
return ret;
}
String.prototype.trim = function()
{
return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function()
{
return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function()
{
return this.replace(/\s+$/,"");
}
// Base64
var Base64 = {
// private property
_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
// public method for encoding
encode : function (input) {
var output = "";
var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
var i = 0;
input = Base64._utf8_encode(input);
while (i < input.length) {
chr1 = input.charCodeAt(i++);
chr2 = input.charCodeAt(i++);
chr3 = input.charCodeAt(i++);
enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63;
if (isNaN(chr2)) {
enc3 = enc4 = 64;
} else if (isNaN(chr3)) {
enc4 = 64;
}
output = output +
this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
}
return output;
},
// public method for decoding
decode : function (input) {
var output = "";
var chr1, chr2, chr3;
var enc1, enc2, enc3, enc4;
var i = 0;
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
while (i < input.length) {
enc1 = this._keyStr.indexOf(input.charAt(i++));
enc2 = this._keyStr.indexOf(input.charAt(i++));
enc3 = this._keyStr.indexOf(input.charAt(i++));
enc4 = this._keyStr.indexOf(input.charAt(i++));
chr1 = (enc1 << 2) | (enc2 >> 4);
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
chr3 = ((enc3 & 3) << 6) | enc4;
output = output + String.fromCharCode(chr1);
if (enc3 != 64) {
output = output + String.fromCharCode(chr2);
}
if (enc4 != 64) {
output = output + String.fromCharCode(chr3);
}
}
output = Base64._utf8_decode(output);
return output;
},
// private method for UTF-8 encoding
_utf8_encode : function (string) {
string = string.replace(/\r\n/g,"\n");
var utftext = "";
for (var n = 0; n < string.length; n++) {
var c = string.charCodeAt(n);
if (c < 128) {
utftext += String.fromCharCode(c);
}
else if((c > 127) && (c < 2048)) {
utftext += String.fromCharCode((c >> 6) | 192);
utftext += String.fromCharCode((c & 63) | 128);
}
else {
utftext += String.fromCharCode((c >> 12) | 224);
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
utftext += String.fromCharCode((c & 63) | 128);
}
}
return utftext;
},
// private method for UTF-8 decoding
_utf8_decode : function (utftext) {
var string = "";
var i = 0;
var c = c1 = c2 = 0;
while ( i < utftext.length ) {
c = utftext.charCodeAt(i);
if (c < 128) {
string += String.fromCharCode(c);
i++;
}
else if((c > 191) && (c < 224)) {
c2 = utftext.charCodeAt(i+1);
string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
i += 2;
}
else {
c2 = utftext.charCodeAt(i+1);
c3 = utftext.charCodeAt(i+2);
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
i += 3;
}
}
return string;
}
}
/* Event Functions */
// Add an event to the obj given
// event_name refers to the event trigger, without the "on", like click or mouseover
// func_name refers to the function callback when event is triggered
function addEvent(obj,event_name,func_name){
if (obj.attachEvent){
obj.attachEvent("on"+event_name, func_name);
}else if(obj.addEventListener){
obj.addEventListener(event_name,func_name,true);
}else{
obj["on"+event_name] = func_name;
}
}
// Removes an event from the object
function removeEvent(obj,event_name,func_name){
if (obj.detachEvent){
obj.detachEvent("on"+event_name,func_name);
}else if(obj.removeEventListener){
obj.removeEventListener(event_name,func_name,true);
}else{
obj["on"+event_name] = null;
}
}
// Stop an event from bubbling up the event DOM
function stopEvent(evt){
evt || window.event;
if (evt.stopPropagation){
evt.stopPropagation();
evt.preventDefault();
}else if(typeof evt.cancelBubble != "undefined"){
evt.cancelBubble = true;
evt.returnValue = false;
}
return false;
}
// Get the obj that starts the event
function getElement(evt){
if (window.event){
return window.event.srcElement;
}else{
return evt.currentTarget;
}
}
// Get the obj that triggers off the event
function getTargetElement(evt){
if (window.event){
return window.event.srcElement;
}else{
return evt.target;
}
}
// For IE only, stops the obj from being selected
function stopSelect(obj){
if (typeof obj.onselectstart != 'undefined'){
addEvent(obj,"selectstart",function(){ return false;});
}
}
/* Caret Functions */
// Get the end position of the caret in the object. Note that the obj needs to be in focus first
function getCaretEnd(obj){
if(typeof obj.selectionEnd != "undefined"){
return obj.selectionEnd;
}else if(document.selection&&document.selection.createRange){
var M=document.selection.createRange();
try{
var Lp = M.duplicate();
Lp.moveToElementText(obj);
}catch(e){
var Lp=obj.createTextRange();
}
Lp.setEndPoint("EndToEnd",M);
var rb=Lp.text.length;
if(rb>obj.value.length){
return -1;
}
return rb;
}
}
// Get the start position of the caret in the object
function getCaretStart(obj){
if(typeof obj.selectionStart != "undefined"){
return obj.selectionStart;
}else if(document.selection&&document.selection.createRange){
var M=document.selection.createRange();
try{
var Lp = M.duplicate();
Lp.moveToElementText(obj);
}catch(e){
var Lp=obj.createTextRange();
}
Lp.setEndPoint("EndToStart",M);
var rb=Lp.text.length;
if(rb>obj.value.length){
return -1;
}
return rb;
}
}
// sets the caret position to l in the object
function setCaret(obj,l){
obj.focus();
if (obj.setSelectionRange){
obj.setSelectionRange(l,l);
}else if(obj.createTextRange){
m = obj.createTextRange();
m.moveStart('character',l);
m.collapse();
m.select();
}
}
// sets the caret selection from s to e in the object
function setSelection(obj,s,e){
obj.focus();
if (obj.setSelectionRange){
obj.setSelectionRange(s,e);
}else if(obj.createTextRange){
m = obj.createTextRange();
m.moveStart('character',s);
m.moveEnd('character',e);
m.select();
}
}
/* Escape function */
String.prototype.addslashes = function(){
return this.replace(/(["\\\.\|\[\]\^\*\+\?\$\(\)])/g, '\\$1');
}
String.prototype.trim = function () {
return this.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1");
};
/* --- Escape --- */
/* Offset position from top of the screen */
function curTop(obj){
toreturn = 0;
while(obj){
toreturn += obj.offsetTop;
obj = obj.offsetParent;
}
return toreturn;
}
function curLeft(obj){
toreturn = 0;
while(obj){
toreturn += obj.offsetLeft;
obj = obj.offsetParent;
}
return toreturn;
}
/* ------ End of Offset function ------- */
/* Types Function */
// is a given input a number?
function isNumber(a) {
return typeof a == 'number' && isFinite(a);
}
/* Object Functions */
function replaceHTML(obj,text){
while(el = obj.childNodes[0]){
obj.removeChild(el);
};
obj.appendChild(document.createTextNode(text));
}
// Number Functions
//
// obj.value = new NumberFormat(obj.value, 2).toFormatted();
// nf.setCurrency(true); // add $
// .toUnformatted = get the original number
//
// -----------------------------------------------------------------------
function NumberFormat(num, inputDecimal)
{
this.VERSION = 'Number Format v1.5.4';
this.COMMA = ',';
this.PERIOD = '.';
this.DASH = '-';
this.LEFT_PAREN = '(';
this.RIGHT_PAREN = ')';
this.LEFT_OUTSIDE = 0;
this.LEFT_INSIDE = 1;
this.RIGHT_INSIDE = 2;
this.RIGHT_OUTSIDE = 3;
this.LEFT_DASH = 0;
this.RIGHT_DASH = 1;
this.PARENTHESIS = 2;
this.NO_ROUNDING = -1
this.num;
this.numOriginal;
this.hasSeparators = false;
this.separatorValue;
this.inputDecimalValue;
this.decimalValue;
this.negativeFormat;
this.negativeRed;
this.hasCurrency;
this.currencyPosition;
this.currencyValue;
this.places;
this.roundToPlaces;
this.truncate;
this.setNumber = setNumberNF;
this.toUnformatted = toUnformattedNF;
this.setInputDecimal = setInputDecimalNF;
this.setSeparators = setSeparatorsNF;
this.setCommas = setCommasNF;
this.setNegativeFormat = setNegativeFormatNF;
this.setNegativeRed = setNegativeRedNF;
this.setCurrency = setCurrencyNF;
this.setCurrencyPrefix = setCurrencyPrefixNF;
this.setCurrencyValue = setCurrencyValueNF;
this.setCurrencyPosition = setCurrencyPositionNF;
this.setPlaces = setPlacesNF;
this.toFormatted = toFormattedNF;
this.toPercentage = toPercentageNF;
this.getOriginal = getOriginalNF;
this.moveDecimalRight = moveDecimalRightNF;
this.moveDecimalLeft = moveDecimalLeftNF;
this.getRounded = getRoundedNF;
this.preserveZeros = preserveZerosNF;
this.justNumber = justNumberNF;
this.expandExponential = expandExponentialNF;
this.getZeros = getZerosNF;
this.moveDecimalAsString = moveDecimalAsStringNF;
this.moveDecimal = moveDecimalNF;
this.addSeparators = addSeparatorsNF;
if (inputDecimal == null) {
this.setNumber(num, this.PERIOD);
} else {
this.setNumber(num, inputDecimal);
}
this.setCommas(true);
this.setNegativeFormat(this.LEFT_DASH);
this.setNegativeRed(false);
this.setCurrency(false);
this.setCurrencyPrefix('$');
this.setPlaces(2);
}
function setInputDecimalNF(val)
{
this.inputDecimalValue = val;
}
function setNumberNF(num, inputDecimal)
{
if (inputDecimal != null)
{
this.setInputDecimal(inputDecimal);
}
this.numOriginal = num;
this.num = this.justNumber(num);
}
function toUnformattedNF()
{
return (this.num);
}
function getOriginalNF()
{
return (this.numOriginal);
}
function setNegativeFormatNF(format)
{
this.negativeFormat = format;
}
function setNegativeRedNF(isRed)
{
this.negativeRed = isRed;
}
function setSeparatorsNF(isC, separator, decimal)
{
this.hasSeparators = isC;
if (separator == null) separator = this.COMMA;
if (decimal == null) decimal = this.PERIOD;
if (separator == decimal)
{
this.decimalValue = (decimal == this.PERIOD) ? this.COMMA : this.PERIOD;
}
else
{
this.decimalValue = decimal;
}
this.separatorValue = separator;
}
function setCommasNF(isC)
{
this.setSeparators(isC, this.COMMA, this.PERIOD);
}
function setCurrencyNF(isC)
{
this.hasCurrency = isC;
}
function setCurrencyValueNF(val)
{
this.currencyValue = val;
}
function setCurrencyPrefixNF(cp)
{
this.setCurrencyValue(cp);
this.setCurrencyPosition(this.LEFT_OUTSIDE);
}
function setCurrencyPositionNF(cp)
{
this.currencyPosition = cp
}
function setPlacesNF(p, tr)
{
this.roundToPlaces = !(p == this.NO_ROUNDING);
this.truncate = (tr != null && tr);
this.places = (p < 0) ? 0 : p;
}
function addSeparatorsNF(nStr, inD, outD, sep)
{
nStr += '';
var dpos = nStr.indexOf(inD);
var nStrEnd = '';
if (dpos != -1)
{
nStrEnd = outD + nStr.substring(dpos + 1, nStr.length);
nStr = nStr.substring(0, dpos);
}
var rgx = /(\d+)(\d{3})/;
while (rgx.test(nStr))
{
nStr = nStr.replace(rgx, '$1' + sep + '$2');
}
return nStr + nStrEnd;
}
function toFormattedNF()
{
var pos;
var nNum = this.num;
var nStr;
var splitString = new Array(2);
if (this.roundToPlaces) {
nNum = this.getRounded(nNum);
nStr = this.preserveZeros(Math.abs(nNum));
} else {
nStr = this.expandExponential(Math.abs(nNum));
}
if (this.hasSeparators) {
nStr = this.addSeparators(nStr, this.PERIOD, this.decimalValue, this.separatorValue);
} else {
nStr = nStr.replace(new RegExp('\\' + this.PERIOD), this.decimalValue);
}
var c0 = '';
var n0 = '';
var c1 = '';
var n1 = '';
var n2 = '';
var c2 = '';
var n3 = '';
var c3 = '';
var negSignL = (this.negativeFormat == this.PARENTHESIS) ? this.LEFT_PAREN : this.DASH;
var negSignR = (this.negativeFormat == this.PARENTHESIS) ? this.RIGHT_PAREN : this.DASH;
if (this.currencyPosition == this.LEFT_OUTSIDE) {
if (nNum < 0) {
if (this.negativeFormat == this.LEFT_DASH || this.negativeFormat == this.PARENTHESIS) n1 = negSignL;
if (this.negativeFormat == this.RIGHT_DASH || this.negativeFormat == this.PARENTHESIS) n2 = negSignR;
}
if (this.hasCurrency) c0 = this.currencyValue;
} else if (this.currencyPosition == this.LEFT_INSIDE) {
if (nNum < 0) {
if (this.negativeFormat == this.LEFT_DASH || this.negativeFormat == this.PARENTHESIS) n0 = negSignL;
if (this.negativeFormat == this.RIGHT_DASH || this.negativeFormat == this.PARENTHESIS) n3 = negSignR;
}
if (this.hasCurrency) c1 = this.currencyValue;
}
else if (this.currencyPosition == this.RIGHT_INSIDE) {
if (nNum < 0) {
if (this.negativeFormat == this.LEFT_DASH || this.negativeFormat == this.PARENTHESIS) n0 = negSignL;
if (this.negativeFormat == this.RIGHT_DASH || this.negativeFormat == this.PARENTHESIS) n3 = negSignR;
}
if (this.hasCurrency) c2 = this.currencyValue;
}
else if (this.currencyPosition == this.RIGHT_OUTSIDE) {
if (nNum < 0) {
if (this.negativeFormat == this.LEFT_DASH || this.negativeFormat == this.PARENTHESIS) n1 = negSignL;
if (this.negativeFormat == this.RIGHT_DASH || this.negativeFormat == this.PARENTHESIS) n2 = negSignR;
}
if (this.hasCurrency) c3 = this.currencyValue;
}
nStr = c0 + n0 + c1 + n1 + nStr + n2 + c2 + n3 + c3;
if (this.negativeRed && nNum < 0) {
nStr = '' + nStr + '';
}
return (nStr);
}
function toPercentageNF()
{
nNum = this.num * 100;
nNum = this.getRounded(nNum);
return nNum + '%';
}
function getZerosNF(places)
{
var extraZ = '';
var i;
for (i=0; i= 0 ? Math.floor(val) : Math.ceil(val);
} else {
val = Math.round(val);
}
val = this.moveDecimalLeft(val);
return val;
}
function preserveZerosNF(val)
{
var i;
val = this.expandExponential(val);
if (this.places <= 0) return val;
var decimalPos = val.indexOf('.');
if (decimalPos == -1) {
val += '.';
for (i=0; i