/*
 * requires jQuery (written with jQuery 1.4.2)
 * 
 * Author: Philipp Wrann
 * last-changed-by: Martin Supanz
 * last-changed: 22.07.2010
 */

var c = '.';
var libPath = "/resources/js/actions/";

var keys =
{
	up : 38,
	down : 40,
	left : 37,
	right : 39,
	esc : 27,
	back : 8,
	tab : 9,
	enter : 13,
	shift : 16,
	ctrl : 17,
	alt : 18,
	del : 46
};

$(document).ready(function(){
	if (typeof lib == 'object'){
		execute(lib)
	}
});

function execute(l,e)
{
	for (k in l)
	{
		try
		{
			l[k](arguments[1])();
		}
		catch(error)
		{
			$.getScript(libPath+l[k]);
		}
	}
}

function setId(e)
{
	if ($(e).attr('id') == '')
	{
		var _tmpDate = new Date;
		var _tmpTime = _tmpDate.getTime();
		var _tmpId = _tmpTime;
		$(e).attr('id','z'+_tmpId.toString());
	}
	
	return $(e).attr('id');
}

function getNodes(e,p)
{
	switch (typeof e)
	{
		case 'string': // id or class has to be prepended before
			return $(e+' '+p);
			break;
		case 'object':
			return $(p,e);
			break;
		default:
			return $(p);
			break;
	}
}

function getScrollY()
{
	var h = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop;
	return h ? h : 0;
}

function getInnerHeight()
{	
	var h = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
	return h ? h : 0;
}

function clearSelection ()
{
	if (document.selection) document.selection.empty();
	else if (window.getSelection) window.getSelection().removeAllRanges();
}
