function hledatV() {
	var win = document.createElement("div");
	win.setAttribute("id","sx_alert");
	var lista = document.createElement("div");
	lista.setAttribute("className","lista");
	lista.setAttribute("class","lista");
	lista.appendChild( document.createTextNode("Hledat na Redart.cz") );
	win.appendChild( lista );
	win.setAttribute("className","sx_alert");
	win.setAttribute("class","sx_alert");
	var div = document.createElement("div");
	var formular = document.createElement("form");
  formular.setAttribute("action", "/?s=hledat");
  formular.setAttribute("method", "post");
	div.appendChild( formular );
	formular.appendChild( document.createTextNode("Hledat: ") );
	
	var inputField = document.createElement("input");
	inputField.setAttribute("name","hledej");
	formular.appendChild( inputField );
	
  win.appendChild(div);

	var input = document.createElement("input");
	input.setAttribute("type","button");
	input.setAttribute("value","Zavřít");
	input.onclick = function(e) {
		var element = document.getElementById("sx_alert");
		element.parentNode.removeChild( element );
	};
	
	var search = document.createElement("input");
	search.setAttribute("value","Hledat");
	search.setAttribute("type","submit");
	
	formular.appendChild(search);
	formular.appendChild(input);

	var root = document.documentElement.childNodes[1];
	root.appendChild(win);
}

// OnLoad
function load( gal_name ) {
	// Galerie srovnat
	var tabulky = document.getElementsByTagName("table");

	var w;
	for( i=0; i<tabulky.length; i++ ) {
		if( tabulky.item(i).getAttribute("class") == gal_name || tabulky.item(i).getAttribute("className") == gal_name  ) {
			w = tabulky.item(i).offsetWidth;
			
			if( w/155 >= 4 ) {}
			else {
				var move = Math.floor(w/155);
				var trs = tabulky.item(i).getElementsByTagName("tr");
				for( t=0; t<trs.length; t++ ) {
					var tds = trs.item(t).getElementsByTagName("td");
					
					if( t+1 < trs.length ) {
						while( tds.length > move ) {
							delete tds;
							var tds = trs.item(t).getElementsByTagName("td");
							trs.item(t+1).insertBefore( tds.item( tds.length-1 ), trs.item(t+1).getElementsByTagName("td").item(0) );
						}
					} else {
						while( tds.length > move ) {
							delete tds;
							var tds = trs.item(t).getElementsByTagName("td");
							trs.item(t).removeChild( tds.item( tds.length-1 ) );
						}
					}
					delete tds;
				}
			}
			tabulky.item(i).setAttribute("className","gal"); // IE
			tabulky.item(i).setAttribute("class","gal");
		}
	}
}

// Menu
function autori_dalsi( co ) {
	document.getElementById(co).firstChild.style.height='auto';
	var n = document.getElementById(co+'_dalsi');
	n.innerHTML = "zabalit";
	n.onclick = function() { autori_zabalit(co) }
}
function autori_zabalit( co ) {
	document.getElementById(co).firstChild.style.height='190px';
	var n = document.getElementById(co+'_dalsi');
	n.onclick = function() { autori_dalsi(co) }
	n.innerHTML = "další &gt;";
}


// Zobrazení popisku
function sI(img) { img.childNodes[1].style.visibility="visible" }
function sH(img) { img.childNodes[1].style.visibility="hidden" }

// Komentáře
var jmeno = "";

var search = new Array(
/(\n)/g,
/\[:(\d+):\]/g,
    /\[img\](.*?)\[\/img\]/g,
    /\[url=([\w]+?:\/\/[^ \\"\n\r\t<]*?)\](.*?)\[\/url\]/g,
    /\[url\]((www|ftp|)\.[^ \\"\n\r\t<]*?)\[\/url\]/g,
    /\[url=((www|ftp|)\.[^ \\"\n\r\t<]*?)\](.*?)\[\/url\]/g,
    /\[email\](([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)?[\w]+))\[\/email\]/g,
    /\[b\](.*?)\[\/b\]/g,
    /\[i\](.*?)\[\/i\]/g,
    /\[url\](http:\/\/[^ \\"\n\r\t<]*?)\[\/url\]/g
	,/([\s]+)http:\/\/([\S]+)([\s,;]+)/g
);
	
var replace = new Array(
"\n<br>",
"<img class=\"smile\" src=\"/d/smajly/$1.gif\" style=\"vertical-align:bottom;\">",
    "<img src=\"$1\" alt=\"An image\">",
    "<a href=\"$1\" target=\"blank\">$2</a>",
    "<a href=\"http://$1\" target=\"blank\">$1</a>",
    "<a href=\"$1\" target=\"blank\">$1</a>",
    "<a href=\"mailto:$1\">$1</a>",
    "<b>$1</b>",
    "<i>$1</i>",
    "<a href=\"$1\" target=\"blank\">$1</a>"
	,"$1<a href=\"http://$2\" target=\"blank\">http://$2</a>$3"
);

function keyPress(e) {
	var text = document.getElementById("komentar_textarea").value+" ";
	
	for(i = 0; i < search.length; i++) {
	     text = text.replace(search[i],replace[i]);
	}

	document.getElementById("komentar_preview").innerHTML = text;
}

// imgZoom

var zoomed;
function imgZoom( img ) {
	var parentNode = img.parentNode;//document.getElementById("body");
	zoomed = document.createElement("div");
	zoomed.setAttribute("style","position:absolute;");
	zoomedImg = document.createElement("img");
	zoomedImg.setAttribute("src", img.getAttribute("src") );
	zoomedImg.setAttribute("style", "position:relative; top:-50px; left:-50px; max-width:800px; max-height:800px; width:auto; border:5px solid #fff;");
	zoomedImg.addEventListener('click', function(){ this.parentNode.removeChild( this ) }, false);
	//alert(parentNode);
	zoomed.appendChild( zoomedImg );
	parentNode.appendChild( zoomed );
}

// Komentovat
function komentovat( umisteni, id, typ, nadrazenej_id ) {
	var form = document.getElementById("komentar_form")
	if( form != undefined ) form.parentNode.removeChild( form )
	var form = document.createElement("form")
	form.setAttribute("id","komentar_form")
	form.setAttribute("method","post")
	form.setAttribute("action", location.pathname+location.search+( (location.search.charAt(0)=="?")?"&":"?" )+"komentar=1&id="+id+"&typ="+typ+"&kid="+nadrazenej_id)
	form.setAttribute("className","komentar")
	form.setAttribute("class","komentar")


	var kod = Math.round( Math.random()*6 );
	var pozadovanej_kod = document.createElement("input")
	pozadovanej_kod.setAttribute("type","hidden")
	pozadovanej_kod.setAttribute("value", kod )
	pozadovanej_kod.setAttribute("name","pozadovanej_kod")
	form.appendChild(pozadovanej_kod)

	var zadanej_kod = document.createElement("input")
	zadanej_kod.setAttribute("name","zadanej_kod")

	// Tabulka
	var table = document.createElement("table")
	var tr = document.createElement("tr")
	table.appendChild(tr)

	if( jmeno == "" ) jmeno = "Anonym"

	var td = document.createElement("td")
	td.setAttribute("style","width:50%")
	td.appendChild( document.createTextNode("Jméno autora: ") )
	var i = document.createElement("i");
	i.appendChild( document.createTextNode( jmeno ) )
	td.appendChild( i )
	tr.appendChild(td)

	if( jmeno == "Anonym" ) {
		var td = document.createElement("td")
		td.setAttribute("class","doprava")
		td.appendChild( document.createTextNode("Opište kontrolní kód:") )
		td.appendChild(zadanej_kod)
		tr.appendChild(td)
		
		var td = document.createElement("td")
		td.setAttribute("class","kod")
		var img = document.createElement("img")
		img.setAttribute("src","/d/kody/"+kod+".jpg")
		td.appendChild(img)
		tr.appendChild(td)
	}

	form.appendChild( table )

	var tr = document.createElement("tr")
	table.appendChild(tr)
	
	var td = document.createElement("td")
	tr.appendChild(td)
	var textarea = document.createElement("textarea")
	textarea.setAttribute("id","komentar_textarea")
	textarea.setAttribute("name","komentar_text")
	textarea.setAttribute("onkeydown","keyPress(event)")
	textarea.setAttribute("onclick","keyPress(event)")
	if( typeof(gKomentarText) != "undefined" ) textarea.value = gKomentarText;
	td.appendChild(textarea)
	
	var td = document.createElement("td")
	tr.appendChild(td)
	var preview = document.createElement("div")
	preview.setAttribute("id","komentar_preview")
	td.setAttribute("colspan","2")
	td.appendChild(preview)

	var odeslat = document.createElement("input")
	odeslat.setAttribute("type","submit")
	odeslat.setAttribute("value","odeslat")

	var smajly = document.createElement("div")
	smajly.setAttribute("id","komentar_smajly")

	for( i=1; i<8; i++) {
		var smajl = document.createElement("img")
		smajl.setAttribute("src","/d/smajly/"+i+".gif")
		smajl.setAttribute("onclick","vlozit(document.getElementById('komentar_textarea'),'[:"+i+":]')")
		smajly.appendChild(smajl)
	}

	form.appendChild(smajly)
	form.appendChild(odeslat)
	document.getElementById(umisteni).appendChild(form)
}

