/**
 *	Shortcut to document.getElementById(element) - 
 *	instead you can now use $('element'); for the 
 *	same result.
**/
function $ (elementId) {
	return document.getElementById(elementId);
}


/**
 *	Clear all existing elements (children) from the 
 *	given element.
**/
function clearElement (element) {
	if(!element.hasChildNodes())
		return true;
	while(element.firstChild)
		element.removeChild(element.firstChild);
}


/**
 *	Find the real position of the given object - 
 *	code [s]stolen[/s] borrowed from QuirksMode.
**/
function getPosition (obj) {
	var curleft = curtop = 0;
	do {
			curleft += obj.offsetLeft;
			curtop 	+= obj.offsetTop;
	} while (obj = obj.offsetParent);
	return[curleft, curtop];
}


/**
 *	Get an input field with a specific name and value.
 *
 *	@param	variable	String		Name of the variable.
 *	@param	value			String		Value of the variable.
 *	@return	DOM Obj		Input DOM element with given name and value.
**/
function getInput (variable, value) {
	var	element			=	document.createElement('input');
	element.name		=	variable;
	element.value		=	value;
	return element;
}
		

/**
 *	Obtain the source DOM element of an event - takes into
 *	account browser incompatibilities.
**/
function getEventSource (event) {
	event 			=	event || window.event;
	
	if (!event.originalTarget)
		return event.srcElement;
	else
		return event.originalTarget;
}


/**
 *	Browser info
**/
var browserInfo = new Object();

browserInfo.chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;

