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,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 mute(m) {
    if ((m == "on") || (m == "off"))
        send_xmlhttprequest(null, "GET", "/audio_mute.php?mute=" + m);
}


function reload_confirm_image() {
	var d = new Date();
	var obj = document.getElementById('confirm_data_image_image');

	if (obj)
		obj.src = '/confirm_number.php?new&time=' + d.getTime();
}

function change_confirm_style(second) {
	var obj1 = document.getElementById('confirm_data_image');
	var obj2 = document.getElementById('confirm_data_flash');

	if (second) {
		obj1.style.display = 'none';
		obj2.style.display = 'block';
	} else {
		obj2.style.display = 'none';
		obj1.style.display = 'block';
	}
}

function on_off(_id, _this) {
    var elem = document.getElementById(_id); 

    if (elem == null)
        return;
               
    if (elem.style.display == "none")
        elem.style.display = "block";
    else
        elem.style.display = "none";
}

function on_off2(_id, _this) {
    var elem = document.getElementById(_id); 

    if (elem == null)
        return;
        
    var h2 = null;
    var catgval = 0;
        
    if (_this != undefined)
        h2 = _this.getElementsByTagName('H2');
    
    if (elem.style.display == "none") {
        elem.style.display = "block";
        catgval = 1;
        if (h2 != null)
            h2[0].className = "arrow_down";
    } else {
        elem.style.display = "none";
        if (h2 != null)
            h2[0].className = "arrow_right";   
    }

    send_xmlhttprequest(null, "GET", "/show_cat_group.php?catg=" + _id + "&catgval=" + catgval);   
}

function Klikos(_id) {
    el = document.getElementById(_id);
    if (el == null)
        return;

    var tds = el.getElementsByTagName("TD");
    var reg = /\s*klik\s*/;
    for (var i = 0; i < tds.length; i++) {
        if (reg.test(tds[i].className))
            tds[i].className += " rukos";
    }
}
