function send_xmlhttprequest(obsluha, method, url, content, headers) {
	var xmlhttp = (window.XMLHttpRequest ? new XMLHttpRequest : (window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : false));

	if (!xmlhttp)
		return false;

	xmlhttp.open(method, url);

	if (obsluha != null)
		xmlhttp.onreadystatechange = function() {
			obsluha(xmlhttp);
		};

	if (headers) {
		for (var key in headers)
			xmlhttp.setRequestHeader(key, headers[key]);
	}

	xmlhttp.send(content);
	return true;
}

function open_popup(dokument, sirka, vyska, scrollbars) {
	so = screen.width;
	vo = screen.height;
	zleva = ((so - sirka) / 2) - 1;
	shora = 120;
	popup_win = window.open(dokument,"popup_okno","width="+sirka+",height="+vyska+",left="+zleva+",top="+shora+",location=0,menubar=0,resizable=1,scrollbars="+scrollbars+",status=0,titlebar=0,toolbar=0");
	popup_win.focus();
}

function Show(id, show) {
  if (show)
    document.getElementById(id).style.visibility='visible';
  else
    document.getElementById(id).style.visibility='hidden';
}

function effigiare_finestra(obieto, identificatore) {
	var finestra = document.getElementById('el_oknos');
	var sinistra = sopraccennato = 0;
	var altezza = obieto.offsetHeight;
	var larghezza = obieto.offsetWidth;
	var contentos = document.getElementById('el_oknos_contentos');

	if (obieto.offsetParent) {
		do {
			sinistra += obieto.offsetLeft;
			sopraccennato += obieto.offsetTop;
		} while (obieto = obieto.offsetParent);
	}

	if (contentos)
		contentos.innerHTML = 'Loading...';

	if (finestra) {
		finestra.style.display = 'block';
		//finestra.style.left = sinistra + 'px';
		finestra.style.left = (sinistra - finestra.offsetWidth + larghezza) + 'px';
		finestra.style.top = (sopraccennato + altezza) + 'px';

		send_xmlhttprequest(allibrare, 'GET', '/properties_ajax.php?idp=' + identificatore);
	}

	return false;
}

function chiudere_finestra() {
	var finestra = document.getElementById('el_oknos');

	if (finestra)
		finestra.style.display = 'none';

	return false;
}

function allibrare(xmlhttp) {
	if (xmlhttp.readyState == 4) {
		var contentos = document.getElementById('el_oknos_contentos');

		if (contentos)
			contentos.innerHTML = xmlhttp.responseText;
	}
}
