function gebi(id)
{
	return document.getElementById(id);
}

function addEvent(obj, evt, fn)
{
	if (obj.addEventListener)
		obj.addEventListener(evt, fn, false);
	else if (obj.attachEvent)
		obj.attachEvent('on'+evt, fn);
	else
		obj['on'+evt] = fn;
}

function removeEvent(obj, evt, fn)
{
	if (obj.removeEventListener)
		obj.removeEventListener(evt, fn, false);
	else if (obj.detachEvent)
		obj.detachEvent('on'+evt, fn);
	else
		obj['on'+evt] = null;
}

function partial(func /*, 0..n args */)
{
	var args = Array.prototype.slice.call(arguments).splice(1);
	return function()
	{
		var allArguments = args.concat(Array.prototype.slice.call(arguments));
		return func.apply(this, allArguments);
	};
}

function findChildren(parent, className)
{
	var matches = new Array();
	for(var i in parent.childNodes)
	{
		if(parent.childNodes[i].className==className)
			matches.push(parent.childNodes[i]);
		
		if(!!parent.childNodes[i].childNodes)
			matches = matches.concat(findChildren(parent.childNodes[i], className));
	}
	return matches;
}

function getAvailWidthHeight()
{
	var w = 0, h = 0;
	if(typeof(window.innerWidth) == 'number') //Non-IE
	{
		w = window.innerWidth;
		h = window.innerHeight;
	}
	else if(window.document.documentElement && (window.document.documentElement.clientWidth || window.document.documentElement.clientHeight)) //IE 6+ in strict mode
	{
		w = window.document.documentElement.clientWidth;
		h = window.document.documentElement.clientHeight;
	}
	else if(window.document.body && (window.document.body.clientWidth || window.document.body.clientHeight)) //IE 4 compatible
	{
		w = window.document.body.clientWidth;
		h = window.document.body.clientHeight;
	}
	
	return {
		'w': parseInt(w),
		'h': parseInt(h)
	};
}

function setCookie(cookieName, value, expireminutes)
{
	var expDate=new Date();
	expDate.setMinutes(expDate.getMinutes()+expireminutes);
	document.cookie=cookieName+'='+escape(value)+((expireminutes==null) ? '' : ';expires='+expDate.toGMTString())+';path=/';
}

function getCookie(cookieName, defaultVal)
{
	if(document.cookie.length > 0)
	{
		start=document.cookie.indexOf(cookieName+'=');
		if(start != -1)
		{
			start+=(cookieName.length+1); 
			end=document.cookie.indexOf(";",start);
			if(end == -1)
				end=document.cookie.length;
			return unescape(document.cookie.substring(start, end));
		}
	}
	return defaultVal;
}