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) - 13;
	shora = 120;
	popup_win = window.open(dokument,"popup_okno","width="+sirka+",height="+vyska+",left="+zleva+",top="+shora+",location=0,resizable=1,scrollbars="+scrollbars+",status=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 virtual_prod_r(xmlhttp) {
	if (xmlhttp.readyState == 4) {
		document.getElementById('dark_bg').style.display = 'block';
		document.getElementById('matwindow').style.display = 'block';
		document.getElementById('matwindow_in').style.display = 'block';
		document.getElementById('matwindow_in').innerHTML = xmlhttp.responseText;

        reg = /^.*MSIE 6.*$/;
        if (reg.test(navigator.appVersion)) {
            var sel = document.body.getElementsByTagName("SELECT");
            for (var i = 0; i < sel.length; i++)
                sel[i].style.visibility = "hidden";
        }
	}
}

function virtual_prod() {
	if (!send_xmlhttprequest(virtual_prod_r, 'GET', '/virt_prod.php')) {
		return true;
	}

	return false;
}

function close_matwindow() {
	var obj = document.getElementById('matwindow');
    var obj2 = document.getElementById('matwindow_in');
    var obj3 = document.getElementById('dark_bg');

	if (obj) {
		obj2.innerHTML = '';
		obj.style.display = 'none';
		obj2.style.display = 'none';
	}

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

    reg = /^.*MSIE 6.*$/;
    if (reg.test(navigator.appVersion)) {
        var sel = document.body.getElementsByTagName("SELECT");
        for (var i = 0; i < sel.length; i++)
            sel[i].style.visibility = "visible";
    }
}
