function $(s){return document.getElementById(s)}

var xbox = document.createElement('div');

xbox.open = function (s, w, h) {
	var d = document, a, b = xbox;
	if(!b.x) {
		a = d.createElement('div');
		a.setAttribute('id', 'xbox_overlay');
		b.setAttribute('id', 'xbox');
		a.onclick = b.close;
		d.body.appendChild(b.a = a);
		d.body.appendChild(b);
	}
	b.w = w ? w : 320;
	b.h = h ? h : 240;
	b.x = b.y = true;
	b.ps();
	b.innerHTML = s;
};

xbox.close = function() {
	var b = xbox;
	b.y = false;
	b.a.style.display = b.style.display = 'none';
	b.innerHTML = '';
};

xbox.ps = function() {
	var d = document.documentElement, b = xbox, a = b.a, w = b.w, h = b.h;
	b.style.width = w + 'px';
	b.style.height = h + 'px';
	x = d.scrollLeft + (d.clientWidth - w) / 2;
	y = d.scrollTop + (d.clientHeight - h) / 2;
	if(x < 0) x = 0;
	if(y < 0) y = 0;
	b.style.left = x + 'px';
	b.style.top = y + 'px';
	b.style.display = 'block';
	a.style.width = d.scrollWidth + 'px';
	a.style.height = Math.max(d.scrollHeight, d.clientHeight) + 'px';
	a.style.display = 'block';
};


window.onresize = function() {
	var b = xbox;
	if(!b.y) return;
	b.a.style.display = b.style.display = 'none';
	if(navigator.appName == 'Microsoft Internet Explorer') setTimeout(b.ps, 1);
	else b.ps();
};

function contact() {
	var s = '<h1>Contact</h1>';

	s += '<table>';
	s += '<tr><th>Email:</th><td><input type="text" class="t" /></td></tr>';
	s += '<tr><th>Telefon:</th><td><input type="text" class="t" /></td></tr>';
	s += '</table>';

	xbox.open(s);
}
