
function $(id)
{
	return document.getElementById(id)
}

function $A(c)
{
	var a=[]
	for(var i=0;i<c.length;i++)
		a.push(c[i])
	return a
}

// HTMLElement.contains(e)
try {
	if(!HTMLElement.prototype.contains)
		HTMLElement.prototype.contains = function(e) {
			return !!(this.compareDocumentPosition(e) & 16)
		}
} catch(x) {}

// Array.each(f)
if(!Array.prototype.each)
	Array.prototype.each = function(f) {
		for(var i=0;i<this.length;i++)
			f(this[i])
	}

// onload by Jan Bobrowski 2008
// onload(0,f) execute f, when document is parsed
// onload(1,f) execute f, when styles applied (not implemented; ==2)
// onload(2,f) execute f, when whole document is ready

onload = function(e,f) {
	var a=arguments, x=a.callee
	if(a.length==2) {
		if(!x.a) {
			x.a=[[],[],[]]
			var d = document
			if(d.addEventListener)
				d.addEventListener('DOMContentLoaded', x, 0)
/*@cc_on
d.write('<script defer src=// onreadystatechange=if(this.readyState=="complete")onload({})></'+'script>')
@*/
		}
		x.a[e].push(f)
		return
	}
	if(!x.a) return
	var m=2
	try {
		m=e.type=='load'?2:0
	} catch(u) {}
	a=x.a; x=0
	for(var i=0;i<=m;i++)
		while(f=a[i].shift())
			try {f.call(f.bind||window)} catch(e) {x=e}
	if(x) throw x
}

