function getElementsByObject(p_object) {
	// IE
	var oElements = p_object.children;
	if (oElements!=null) {
		if(p_object.tagName!=null && p_object.tagName=="BODY")
			return p_object.all;
		else
			return p_object.children;		
	}
	// Mozilla, Netscape, Firefox
	else
		oElements = p_object.childNodes;
	
	return oElements;
}

function getObjectByEvent(p_event){
	var oObject = null;
	if (p_event.srcElement)
		oObject = p_event.srcElement;
	else
		oObject = p_event.target;	
	return oObject;
}


// Returns a reference to an object by its id
function getObject(p_objectId) {
	if (document.getElementById && document.getElementById(p_objectId)){
		return document.getElementById(p_objectId);
	} else if (document.all && document.all(p_objectId)) {
		return document.all(p_objectId);
	} else if (document.layers && document.layers[p_objectId]) {
		return document.layers[p_objectId];
	} else {
		return false;
  	}
}

function addEventOnObject(p_object, p_eventName, p_function) {
	// Mozilla, Netscape, Firefox
	if(window.addEventListener) {
		p_object.addEventListener(replaceEvent(p_eventName), p_function, false);
	}
	// IE
	else
		p_object.attachEvent(p_eventName, p_function);
}

function removeEventOnObject(p_object, p_eventName, p_function) {
	if (document.removeEventListener) {
		p_object.removeEventListener(replaceEvent(p_eventName), p_function, false);
	} else if (document.detachEvent) {
		p_object.detachEvent(p_eventName, p_function);
	}
}

function replaceEvent(p_eventName) {
	var eventName = p_eventName;
	if (p_eventName.substring(0, 2)=="on")
		eventName = p_eventName.substring(2, p_eventName.length);
		
	if (eventName.indexOf("mouseleave")!=-1) {
		eventName = eventName.replace("mouseleave", "mouseout");
	} else if (eventName.indexOf("mouseenter")!=-1) {
		eventName = eventName.replace("mouseenter", "mouseover");
	}
	return eventName;
}

function getCurrentStyle(p_object, p_propertyValue) {
	// IE
	if (p_object.currentStyle)
		return p_object.currentStyle.getAttribute(p_propertyValue);
	// Mozilla, Netscape, Firefox
	else
		return document.defaultView.getComputedStyle(p_object, null).getPropertyValue(p_propertyValue);
}
/*
if(typeof HTMLElement!="undefined" && !HTMLElement.prototype.insertAdjacentElement) {
	HTMLElement.prototype.insertAdjacentElement = function(where, parsedNode) {
		switch (where) {
			case 'beforeBegin':
				this.parentNode.insertBefore(parsedNode,this);
				break;
			case 'afterBegin':
				this.insertBefore(parsedNode,this.firstChild);
				break;
			case 'beforeEnd':
				this.appendChild(parsedNode);
				break;
			case 'afterEnd':
				if (this.nextSibling) this.parentNode.insertBefore(parsedNode,this.nextSibling);
				else this.parentNode.appendChild(parsedNode);
			break;
		}
	}

	HTMLElement.prototype.insertAdjacentHTML = function(where,htmlStr) {
		var r = this.ownerDocument.createRange();
		r.setStartBefore(this);
		var parsedHTML = r.createContextualFragment(htmlStr);
		this.insertAdjacentElement(where,parsedHTML)
	}

	HTMLElement.prototype.insertAdjacentText = function(where,txtStr) {
		var parsedText = document.createTextNode(txtStr)
		this.insertAdjacentElement(where,parsedText)
	}
}*/

function getEvent(p_event) {
	if (p_event.target)
		return p_event;
	else
		return event;
}

function getEventSource(p_event) {
	if(!p_event.target){
		return p_event.srcElement;
	}
	else {
		return p_event.target;
	}
}

function includeJS(p_path, p_doc) {
	if (p_doc==null) p_doc = window.document;
	var script = p_doc.createElement('script');
	script.src = p_path;
	script.type = 'text/javascript';
	script.defer = true;
	p_doc.getElementsByTagName('head')[0].appendChild(script);
}