function reply(id)
{
  var el = document.getElementById('pole1');
  if (el) {
     el.focus();
     if (el.value != '') el.value += "\r\n";
     el.value += '[[ ' + (id) + ' ]] ';
  }
}

var oldCellColor = "#000";
function focusRow(row) {
	var cells = row.cells;
	if (!cells) return;
	oldCellColor = cells[0].style.backgroundColor;
	for (var i=0;i<cells.length;i++) {
		cells[i].style.backgroundColor='white';
	}
}
function blurRow(row) {
	var cells = row.cells;
	if (!cells) return;
	for (var i=0;i<cells.length;i++) {
		cells[i].style.backgroundColor=oldCellColor;
	}
}

function ajax(url)
{
    if (typeof window.ActiveXObject != 'undefined')
    {
        httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
    } else {
        httpRequest = new XMLHttpRequest();
    }

    httpRequest.open("GET", url, true);
    httpRequest.setRequestHeader('Connection', 'Close');
    httpRequest.send(null);
}

function image(src,height,width)
{
    var max_strana = 650;

    if (max_strana > Math.max(width,height))
    {
        max_strana = Math.max(width,height);
    }

    if (height > width) 
    {
        width = width/height*max_strana;
        height = max_strana;
        
    } else {
        height = height/width*max_strana;
        width = max_strana;   
    }

    var okno = window.open('','okno','width='+width+',height='+height+',resizble=0,menubar=0,toolbar=0,left=10,top=10,directories=0,location=0,scroolbars=0,copyhistory=0');
    okno.document.open();
    okno.document.writeln('<html>\n<head>\n <title>'+src+'</title>\n </head>\n<body style="margin: 0px;">');
    okno.document.writeln('<img src="'+src+'" title="'+src+'" alt="Obrázek nenalezen." style="height: '+height+'px" onclick="window.close();" />');
    okno.document.writeln('</body>\n</html>');
    okno.document.close();
}

function thisBgColor(color)
{
    this.style.backgroundColor = color;
}


function changeClass(elementID, className)
{
    document.getElementById(elementID).className = className;
}

function UnHide(elementID)
{
    var id;
    
    id = elementID;
    document.getElementById(id).style.display= 'block';
}

function rand( min, max ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Leslie Hoare
    // *     example 1: rand(1, 1);
    // *     returns 1: 1
 
    if( max ) {
        return Math.floor(Math.random() * (max - min + 1)) + min;
    } else {
        return Math.floor(Math.random() * (min + 1));
    }
}

function Hide(elementID)
{
    var id;
    
    id = elementID;
    document.getElementById(id).style.display= 'none';
}

color = new Array('#00FF00','#FFFF00','#0000FF','#FF0000');
var oldBgColor = "#000";
function changeBgColor(elementID) 
{
  var id;
    
  id = elementID;
	oldCellColor = document.getElementById(id).style.backgroundColor;
	document.getElementById(id).style.backgroundColor = color[rand(1,4)];
}
function returnBgColor(elementID) 
{
    var id;
    
    id = elementID;
		document.getElementById(id).style.backgroundColor=oldCellColor;
}












