/****************************************************************************
*	
*	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;
}
