function addHandler(target,eventName,handlerName) { 
	if (!target[handlerName]) target[handlerName] = window[handlerName];
  if ( target.addEventListener ) { 
    target.addEventListener(eventName, function(e){target[handlerName](e);}, false);
  } else if ( target.attachEvent ) { 
    target.attachEvent("on" + eventName, function(e){target[handlerName](e);});
  } else { 
    var originalHandler = target["on" + eventName]; 
    if ( originalHandler ) { 
      target["on" + eventName] = function(e){originalHandler(e);target[handlerName](e);}; 
    } else { 
      target["on" + eventName] = target[handlerName]; 
    } 
  } 
}

function setupEvent(event) {
	if (!event) event = window.event;
	if (event.pageX) {
		event.mouseX = event.pageX;
		event.mouseY = event.pageY;
	}
	else {
		event.mouseX = event.clientX + document.body.scrollLeft;
		event.mouseY = event.clientY + document.body.scrollTop;
		event.target = event.srcElement;
	}
}

function in_array(hArray, needle) {
	if (!hArray || typeof hArray != "object") return false;
	for (prop in hArray) {
		if (hArray[prop] == needle)	return true;
	}
	return false;
}

function array_pos(hArray, needle) {
	if (!hArray || typeof hArray != "object") return -1;
	var c = -1;
	for (prop in hArray) {
		c++;
		if (hArray[prop] == needle)	return c;
	}
	return -1;
}

function array_remove(oldArray, index) {
	var newArray = [];
	for (prop in oldArray) {
		if (prop!=index) newArray.push(oldArray[prop]);
	}
	return newArray;
}

function getChildren(parentElement, recursive, nodeType, tagName, attribute, attributeValue) {
	var childNodes = new Array();
	for (var i=0; i<parentElement.childNodes.length; i++) {
		if ((!nodeType || nodeType==parentElement.childNodes[i].nodeType) && (!tagName || tagName==parentElement.childNodes[i].tagName) && (!attribute || parentElement.childNodes[i].getAttribute(attribute)==attributeValue)) childNodes.push(parentElement.childNodes[i]);
		if (recursive) {
			var childChildNodes = getChildren(parentElement.childNodes[i], true, nodeType, tagName, attribute, attributeValue);
			for (var j=0; j<childChildNodes.length; j++) childNodes.push(childChildNodes[j]);
		}
	}
	return childNodes;
}

function getFirstChild(node) {
	for (var i=0; i<node.childNodes.length; i++) {
		if (node.childNodes[i].nodeType!=1) continue;
		return node.childNodes[i];
	}
}

function getAbsolutePosition(nodeOrId) {
	var node = (typeof nodeOrId == 'object') ? nodeOrId : document.getElementById(nodeOrId);
	if (!node) return new Array(0,0);
	var parentOffsets = getAbsolutePosition(node.offsetParent);
	return new Array(node.offsetLeft+parentOffsets[0], node.offsetTop+parentOffsets[1]);
}

function analyzeObject(object) {
	var returnValue = '';
	for (prop in object) {
		returnValue += prop+": "+object[prop]+"\n";
	}
	return returnValue;
}

function getDocumentHeight(doc) {
	if (doc.body.scrollHeight && navigator.appVersion.indexOf("Win") != -1) {
		return doc.body.scrollHeight;
	}
	else if (doc.documentElement.scrollHeight) {
		return doc.documentElement.scrollHeight;
	}
	else if (doc.documentElement.offsetHeight) {
		return doc.documentElement.offsetHeight;
	}
}
document.getHeight = function() {
	return getDocumentHeight(this);
}

function getDocumentWidth(doc) {
	if (doc.body.scrollWidth && navigator.appVersion.indexOf("Win") != -1) {
		return doc.body.scrollWidth;
	}
	else if (doc.documentElement.scrollWidth) {
		return doc.documentElement.scrollWidth;
	}
	else if (doc.documentElement.offsetWidth) {
		return doc.documentElement.offsetWidth;
	}
}
document.getWidth = function() {
	return getDocumentWidth(this);
}

function getScrollTop() {
	return (document.all) ? document.body.scrollTop : window.pageYOffset;
}