
p = new Image();
p.src="obr/pink.gif";



sip_r = new Image();
sip_r.src="obr/sipka.gif";

sip_l = new Image();
sip_l.src="obr/sipka_l.gif";


function add(bookmarkurl,bookmarktitle){
if (document.all)
window.external.AddFavorite(bookmarkurl,bookmarktitle);
}



function uprform(cislo)
	{
	if(cislo == 4) 	{document.getElementById('include_php').style.display='block';	}
	else			{document.getElementById('include_php').style.display='none';	}
	}
	

function vymazkos(polozka)
	{
	document.getElementById(polozka).value = 0;
	document.getElementById('kos_form').submit();
	}
	

function sub(elem)
	{
	// alert(document.body.scrollTop);
	document.getElementById('scroll').value = document.body.scrollTop;
	//document.body.getElementById("scroll").value = document.body.scrollTop;
	document.getElementById(elem).innerHTML="<br><br><br><br><br><div  class='transfer' align=\"center\">Odesílám data, čekejte prosím.<img src=\"obr/pink.gif\" width=\"90\" height=\"13\" border=\"0\" alt=\"transfer\" vspace=\"0\" hspace=\"1\" align=\"absbottom\"></div>"; 

	document.getElementById('edit_p').style.visibility = "hidden";
	//document.body.scrollTop = 0;
	
/* */
	 //alert(document.getElementById("scroll").value);
	 //alert("stop");
	}
	
function shop()
	{	
	if (document.getElementById('cena').value != "") 
		{
		document.getElementById('eshop').checked = true; 
		}
	}
	
function sub1(elem)
	{
	// alert(document.body.scrollTop);
	document.getElementById('eshop').focus();
	document.getElementById('scroll').value = document.body.scrollTop;
	document.getElementById(elem).innerHTML="<br><br><div  class='transfer' align=\"center\">Odesílám data, čekejte prosím.<img src=\"obr/pink.gif\" width=\"90\" height=\"13\" border=\"0\" alt=\"transfer\" vspace=\"0\" hspace=\"1\" align=\"absbottom\"></div>"; 
	}
	
function rozbal(pid)
	{
	// alert(pid+" --- "+document.getElementById(pid).style.display);
	if (document.getElementById(pid) != null) 	//alert("existuje");
		{
		if (document.getElementById(pid).style.display == "block")
			{
			return true;
			}
		else
			{
			document.getElementById(pid).style.display = "block";
			return false;	
			}
		}
	else return true;
	}	
	
function folders(pid)
	{
	// alert(pid+" --- "+document.getElementById(pid).style.display);
	if (document.getElementById(pid) != null) 	//alert("existuje");
		{
		if (document.getElementById(pid).style.display == "block")
			{
			document.getElementById(pid).style.display = "none";
			}
		else
			{
			document.getElementById(pid).style.display = "block";
			}
		}
	}		
	
function pozice(poloha)
	{
	document.body.scrollTop = poloha;
	}
	
	
	
function dosad(kam,co)
	{
	document.getElementById(kam).value = co;
	}	
	
	
	
	//  copy z poryby
function pol2()
	{
	document.all['zapi'].style.visibility = "hidden";
	// <?  if(!$p2) $p2=0 ?>
	// document.body.scrollTop=<? echo $p2;?> ; 
	}
	// xxx copy z poryby
	

function smazat(co)
	{
	pokracovat = confirm("Opravdu chcete nenávratně smazat "+co+"?");
	if( pokracovat )
		{
		//alert ("true");
		// sub('load'); 
		return true;
		}
	else 
		{
		//alert ("false");
		return false;
		}
	}
	
function move(id,akce)
	{
	var hlaska;
	// alert(id);
	// alert(akce);
	document.getElementById("move_id").value = id;
	document.getElementById("move_akce").value = akce;
	sub('load');
	// document.edit_p.submit();
	document.getElementById("edit_p").submit();
	}	
	
function edit(id_str)
	{
	var hlaska;
	// alert(id);
	// alert(akce);
	document.getElementById("edit_str").value = id_str;
	// document.edit_p.submit();
	document.getElementById("edit_p").submit();
	}	
	
	
	
	
function foto_move(id,akce)
	{
	var hlaska;
	document.getElementById("foto_move_id").value = id;
	document.getElementById("foto_move_akce").value = akce;
	// document.edit_p.submit();
	document.getElementById("edit_p").submit();
	}	
	
	
function detail(id)
	{
	if ( document.getElementById(id).style.display == "block" )  document.getElementById(id).style.display="none";
	else document.getElementById(id).style.display = "block";
	}


function detail_sezs(id)
	{
	if ( document.getElementById(id).style.display == "block" )  document.getElementById(id).style.display="none";
	else 
		{
		document.getElementById(id).style.display = "block";
		window.seznam_stranek.location.href = "seznam_stranek.php";
		}
	}	
	
	
	
function list_foto(id_str)
	{
	window.open("edit_foto.php", "fotos", "width=800,height=600,menubar=yes,resizable=yes,left=0,top=0")
	//alert('listuju');

	}	
	
		
function vlozit_foto(id_foto,kam)
	{
	var tm;
	window.opener.document.getElementById("foto_new"+kam).value = id_foto;
	//alert(id_foto);
	window.opener.document.getElementById("nahled_obr_server"+kam).innerHTML='náhled :<br><img src="img.php?src='+id_foto+'" border="0" width="200" height="150" >';
	//if (!id_foto) document.getElementById("nahled_obr"+kam).innerHTML = "";
	window.opener.document.getElementById("i_alt_s"+kam).style.display = "block";

	window.opener.focus();
	/*
	tm = setTimeout('window.opener.moveBy(4,0)', 50);
	tm = setTimeout('window.opener.moveBy(-8,0)', 100);
	tm = setTimeout('window.opener.moveBy(8,0)', 150);
	tm = setTimeout('window.opener.moveBy(-6,0)', 200);
	tm = setTimeout('window.opener.moveBy(2,0)', 250);
	*/
	// tm = setTimeout('window.opener.document.edit_p.submit()', 300);
	}	
	
	
		
function vlozit_soubor(jm_souboru)
	{
	var tm;
	window.opener.document.getElementById("soubor_new0").value = jm_souboru;
	window.opener.document.getElementById("soubor_ze_serveru").innerHTML = "<b>"+jm_souboru+"</b>";
	
	//alert(jm_souboru);
	//window.opener.document.getElementById("nahled_obr_server"+kam).innerHTML='náhled :<br><img src="img.php?src='+jm_souboru+'" border="0" width="200" height="150" >';

	//if (!jm_souboru) document.getElementById("nahled_obr"+kam).innerHTML = "";
	//window.opener.document.getElementById("i_alt_s"+kam).style.display = "block";

	window.opener.focus();
	tm = setTimeout('window.opener.moveBy(4,0)', 50);
	tm = setTimeout('window.opener.moveBy(-8,0)', 100);
	tm = setTimeout('window.opener.moveBy(8,0)', 150);
	tm = setTimeout('window.opener.moveBy(-6,0)', 200);
	tm = setTimeout('window.opener.moveBy(2,0)', 250);
	// tm = setTimeout('window.opener.document.edit_p.submit()', 300);
	}	
			
function sipka_n()
	{
	window.opener.focus();
	//alert(id);
	window.opener.document.getElementById('novy_obr_1').innerHTML="<img src=\"obr/sipka.gif\" border=\"0\" width=\"25\" height=\"7\" >";
	window.opener.document.getElementById('novy_obr_2').innerHTML="<img src=\"obr/sipka_l.gif\" border=\"0\" width=\"25\" height=\"7\" >";
	//window.opener.document.body.scrollTop = 500;
	}	
	
	
	

function sipka(id_str,id_odst,id_fot)
	{
	if (window.opener.document.getElementById("f"+id_fot) == "[object]")
		{
		window.opener.focus();
		window.opener.document.getElementById("f"+id_fot).innerHTML="<img src=\"obr/sipky.gif\" border=\"0\" width=\"120\" height=\"20\" >";	
		}
	else
		{
		//alert(id);
		nahled = window.open("index.php?id_str="+id_str+"&id_fot="+id_fot, "nahled", "width=1000,height=700,location=yes,status=yes,menubar=yes,resizable=yes,scrollbars=yes,left=0,top=0");
		nahled.focus();
		}	
	}	
	
function sipka_doc(id_str,id_odst,id_doc)
	{
	if (window.opener.document.getElementById("d"+id_doc) == "[object]")
		{
		window.opener.focus();
		window.opener.document.getElementById("d"+id_doc).innerHTML="<img src=\"obr/sipka.gif\" border=\"0\" >";	
		}
	else
		{
		//alert(id);
		nahled = window.open("index.php?id_str="+id_str+"&id_doc="+id_doc, "nahled", "width=1000,height=700,location=yes,status=yes,menubar=yes,resizable=yes,scrollbars=yes,left=0,top=0");
		nahled.focus();
		}	
	}		
	
	
function tab_move(id,akce)
	{
	document.getElementById("tab_move_id").value = id;
	document.getElementById("tab_move_akce").value = akce;
	// document.edit_p.submit();
	
	document.getElementById("edit_p").submit();
	}	
	
	/* druhý script*/

	

document.documentElement.className = "js";  /*stylopis se může okamžitě přizpůsobit tomu, že máme zapnutý JS*/

if(!"".trim) String.prototype.trim = function()
{
	return this.replace(/^\s+|\s+$/g, "");
};

if(typeof(document.documentElement.innerText) != "string")
{
	// === innerText v Mozille === www.djpw.cz/200 ===

	HTMLElement.prototype.__defineGetter__("innerText", function()
	{
		return this.textContent;
	});
	HTMLElement.prototype.__defineSetter__("innerText", function(text)
	{
		this.textContent = text;
	});
}

function getHttpRequest()
{
	return !window.XMLHttpRequest ? !window.ActiveXObject ? null : new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
}

var cs = true;
var inits = [];
var init = function(param)
{
	var p = param || {};
	p.base = location.href.match(/^[^?]+/)[0];
	if(p.jazyk && ~p.jazyk.indexOf("sk")) cs = false;
	location.href.replace(/[?&]([a-z0-9]+)=([^&#]+)/gi, function(m, m1, m2) { p["qs" + m1] = m2 });
	p.konecStrany = (document.getElementById("postcount") && document.getElementById("postcount").value) == "1";
	for(var i = 0; inits[i]; i++) inits[i](p);
}

var encodeURIComponent = (function()
{
	var euc = encodeURIComponent;
	var latin2 = " Ą˘Ł¤ĽŚ§¨ŠŞŤŹ­ŽŻ°ą˛ł´ľśˇ¸šşťź˝žżŔÁÂĂÄĹĆÇČÉĘËĚÍÎĎĐŃŇÓÔŐÖ×ŘŮÚŰÜÝŢßŕáâăäĺćçčéęëěíîďđńňóôőö÷řůúűüýţ˙";
	return function(string, encoding)
	{
		if(encoding && encoding.toLowerCase() == "iso-8859-2")
		{
			return string.replace(/\r?\n/g, "\r\n").replace(/([\u0000-\u007F]+)|[\u0080-\uFFFF]/g, function(m, m1)
			{
				if(m1) return euc(m);
				var p = latin2.indexOf(m);
				if(~p) return "%" + (p + 160).toString(16);
				return "%26%23" + m.charCodeAt(0) + "%3B";
			});
		}
		return euc(string);
	};
})();



/* ======================================== *
 * === Vkládání BB značek do <textarea> === *
 * ======================================== */

function insertText(inserted, cursor)
{
	try { // textarea může být neviditelná, to pak hází chybu, ale špatně se to testuje

	if(inserted != null)
	{
		inserted = inserted.toString().replace(/\r\n?/g, "\n");
		if(typeof cursor == "undefined") cursor = inserted.length;
	}

	var textarea = document.forms["edit_p"].elements["detail_popis"];
	if(textarea.readOnly) return;
	var scrollTop = textarea.scrollTop;
	var scrollHeight = textarea.scrollHeight;
	textarea.focus();
	
	if(typeof textarea.selectionStart != "undefined")
	{
		var sel = [], st = textarea.value.substr(0, textarea.selectionStart).replace(/\r\n?/g, "\n");
		sel[0] = Math.max(st.length + ((typeof cursor != "number") ? cursor[0] : cursor), 0);
		st += (inserted != null) ? inserted + textarea.value.substr(textarea.selectionEnd).replace(/\r\n?/g, "\n") : textarea.value.substr(textarea.selectionStart).replace(/\r\n?/g, "\n");
		sel[1] = Math.min(sel[0] + ((typeof cursor != "number") ? cursor[1] : 0), st.length);

		if(window.opera)
		{
			// Opera převádí \n na \r\n, kurzor by se netrefil.
			for(var i = 0; i < 2; i++)
			{
				var p = st.substr(0, sel[i]);
				sel[i] += p.length - p.replace(/\n/g, "").length;
			}
		}

		if(inserted != null) textarea.value = st;
		textarea.selectionStart = sel[0];
		textarea.selectionEnd = sel[1];
	}
	else if(typeof document.selection != "undefined")
	{
		var range = document.selection.createRange();
		var start = 0, end = 0;
		if(inserted != null)
		{
			start = end = -inserted.length;
			range.text = inserted;
		}
		else
		{
			end = -range.text.replace(/\r\n?/g, "\n").length;
		}
		
		// nastavení kurzoru na spravné místo / vybrání požadovaného textu
		if(typeof cursor != "number")
		{
			range.moveStart("character", start + cursor[0]);
			range.moveEnd("character", end + cursor[0] + cursor[1]);
		}
		else
		{
			if(start + cursor) range.move("character", start + cursor);
		}
		range.select();
	}
	} catch(exc) {};
	if(window.netscape)
	{
		textarea.scrollTop = scrollTop + (textarea.scrollHeight - scrollHeight);
	}
}
function changeSelection(cursor)
{
	insertText(null, cursor);
}

function insertTag(tag)
{
	var parovy = (tag != "hr");
	var  zalomit = "";
	if(tag == "ul" )  zalomit = "\n";
	if(tag == "tab" )  zalomit = "\n";
	
	var startTag = "[" + tag + "]"+zalomit;
	var endTag = zalomit+("[/" + tag + "]").replace(/(\[\/(?:pre|font))[^\]]+(\])|\[\/hr\]/gi, "$1$2");

	var selectionType = tag.match(/^pre|hr|mod/i) ? "" : "word";
	var selectionTrim = tag.match(/^pre|hr|mod/i) ? /^\n+|\n+$/g : /^\s+|\s+$/g;

	var tac = getTextareaSelection({ context: true, type: selectionType, trim: selectionTrim });
	var tagText = tac[1];

	if(tag.match(/^([bi]|del|edit|small|pre\w*)$/i))
	{
		var opened = (tac[0].lastIndexOf(startTag) > tac[0].lastIndexOf(endTag));
		var closed = ((tac[2] + endTag).indexOf(endTag) < (tac[2] + startTag).indexOf(startTag));
		tagText = tagText.replace(new RegExp((startTag.replace(/pre\w*/, "pre\\w*") + "|" + endTag).replace(/\[/g, "\\$&"), "gi"), "");

		if(opened && closed)
		{
			var temp;
			temp = startTag;
			startTag = endTag;
			endTag = temp;
		}
		else if(opened)
		{
			// http://djpw.cz/102673#10
			if(!tag.match(/[bi]/)) startTag = "";
		}
		else if(closed)
		{
			endTag = "";
		}
	}
	else if(tag == "img")
	{
		tagtext = tagText.replace(/\[\/?([bi]|del|edit|small|pre[a-z]*|img(left|right)?|hr|mod|url(\=[^\]]+)?)\]/gi, "");
	}

	// vytvoření textu pro vložení		
	var text2insert = startTag + tagText + endTag;

	var cursor = (tagText ? text2insert.length : startTag.length);
	insertText(text2insert, cursor);
}




function insertLink()
{

	var tac = getTextareaSelection({ context: true, type: "url", expand: true, trim: /^\s+|\s+/g });
	var cursor = tac[4];
	var text2insert = tac[1] || getTextareaSelection({ type: "word", trim: /^\s+|\s+/g });

	m = text2insert.match(/^(\[url=[^\]]+\])(.*)\[\/url\]$/i);
	if(m && !m[2].match(/\[url=[^\]]+\]|\[\/url\]/i))
	{
		cursor[0] -= m[1].length;
		if(cursor[0] < 0)
		{
			cursor[1] = Math.max(cursor[0] + cursor[1], 0);
			cursor[0] = 0;
		}
		if(cursor[0] > m[2].length)
		{
			cursor[0] = m[2].length;
			cursor[1] = 0;
		}
		if(cursor[0] + cursor[1] > m[2].length) cursor[1] = m[2].length - cursor[0];
		insertText(m[2], cursor);
		return;
	}
	m = text2insert.match(/^\s*\[img(?:left|right)?\](.*)\[\/img\]\s*$/i);
	if(m && !m[1].match(/\[img(?:left|right)?\]|\[\/img\]/i))
	{
		insertText("[url=" + m[1] + "]Obrázek[/url]", [m[1].length + 6, 7]);
		return;
	}

	var uris = [], unpack = false;
	text2insert = text2insert.replace(/\[url=([^\]]+)\](.*?)\[\/url\]|(\s*https?\:\/\/(?:["‚„“‘\)\.…,:;]*[^\s"‚„“‘\)\.…,:;]+)+\s*)|(\s*www\.(?:["‚„“‘\)\.…,:;]*[^\s"‚„“‘\)\.…,:;]+)+\s*)/gi, function(m, m1, m1t, m2, m3)
	{
		if(m1) unpack = true;
		uris.push((m1 || m2 || "http://" + m3).trim());
		return m1 ? m1t : "";
	});
	if(!uris.length)
	{
		insertText("[url=http://www.example.com]" + (text2insert || "Odkaz") + "[/url]", [5, 22]);
		return;
	}
	if(unpack)
	{
		text2insert = text2insert + " " + uris.join(" ");
		insertText(text2insert, [0, text2insert.length]);
		return;
	}
	if(uris.length == 1)
	{
		if(text2insert)
		{
			insertText("[url=" + uris[0] + "]" + text2insert + "[/url]", 12 + uris[0].length + text2insert.length);
		}
		else
		{
			text2insert = uris[0].replace(/^http\:\/\/www/, "www");
			insertText("[url=" + uris[0] + "]" + text2insert + "[/url]", [6 + uris[0].length, text2insert.length]);
		}
		return;
	}
	uris = uris.reverse();
	text2insert = text2insert.replace(/([-_a-z0-9áäéëěíóöôúůüýčďňŕřšťžĺľ]+|\[[^\]]+\])/gi, function(m)
	{
		var uri = uris.pop();
		return uri ? "[url=" + uri + "]" + m + "[/url]" : m;
	}).trim();
	for(var i = 1, uri; uri = uris.pop(); i++)
	{
		text2insert += (text2insert ? ", " : "") + "[url=" + uri + "]" + i + "[/url]";
	}
	insertText(text2insert, [0, text2insert.length]);
}

function insertQuote(el)
{
	var q = "";
	var cursor;

	var text = getDocumentSelection();
	if(!text && !el.happy) return alert("Označte prosím text, který si přejete citovat.\nNecitujte prosím větší množství textu, než je nezbytné k pochopení vaší reakce.");

	var tac = getTextareaSelection({ context: true });
	if(tac[0] && tac[0].substr(tac[0].length - 2) != "\n\n")
	{
		if(!tac[0].match(/\[b\].*\[\/b\]:?\n$/)) q += "\n";
		if(tac[0].substr(tac[0].length - 1) != "\n") q += "\n";
	}

	try
	{
		// jméno citovaného stvoření
		var jmeno = "[b]" + orezJmeno(el.parentNode.parentNode.parentNode.getElementsByTagName("b")[0].innerText) + "[/b]";

		if(tac[0].indexOf(jmeno) < 0)
		{
			q += jmeno + ":\n";
		}
	} catch(exc) { }

	if(!text)
	{
		var strejdyBratr = el.parentNode.parentNode.getElementsByTagName("div")[2];
		var line = strejdyBratr.innerText.split("\n");
		
		for(var i = 0; i < line.length; i++)
		{
			line[i] = line[i].trim();
			if(line[i] && !line[i].match(/^(„.*“|> .*|rea(guj[ui]|kce) na .*|[^\s]{1,20}\s?:|[^\w]+|.*?[\.\$][a-z].*|<+[\/\?\!]?\w+.*|.*;)$/i))
			{
				q += getLineQuote(line[i]) + "\n\n";
				if(!cursor) cursor = q.length - 2;
			}
		}
	}
	else
	{
		q += getQuote(text);
	}
	if(q.match(/\[b\](.*?)\[\/b\]:\n„\[i\]\1\[\/i\]“\n/))
	{
		alert("Proč se pokoušíte CITOVAT jméno?\n\nChcete-li někomu odpovídat, vložte jeho jméno tučně, tak, jako to dělají ostatní diskutující. Jak na to? Odcituji vám část z nápovědy:\n„Nápověda“");
		alert("Prostě na to jméno klikněte normálně levým tlačítkem.");
		return;
	}
	insertText(q, cursor);
}
function fixBB(text)
{
	return text.replace(/(\[\/?)((?:[bi\!]|hr|del|edit|small|pre[a-z]*|img(?:left|right)?|mod|url(?:\=[^\]]+)?)\])/gi, "$1[!]$2").replace(/\&(\#\d+)/g, "&[!]$1").replace(/www\./g, "w[!]ww.").replace(/ht(tps?\:\/\/)/g, "ht[!]$1");
}

function getQuote(text)
{
	if(!text) return "";
	text = text.replace(/\r\n/g, "\n");
	text = text.replace(/#\d+\s+·\s+Zasláno:\s+\d\d?\.\d\d?\.\d\d\d\d\s+\d\d:\d\d:\d\d(\s+·\s+Změnil\/a:\s+.*)?(\n?Citovat)?(\s*Změnit)?\n*/g, "");
	text = text.replace(/.*\n(Člen|Moderátor)\n*/g, "");
	text = text.trim();
	if(!text) return "";

	if(text.indexOf("\n") > -1)
	{
		return getBlockQuote(text);
	}
	else
	{
		return getLineQuote(text);
	}
}

function getLineQuote(line, notBB)
{
	var q = line;
	q = q.trim();
	q = q.replace(/^(?:„([^“]+)“|‚([^‘]+)‘|"([^"]+)")$/g, "$1$2$3");
	if(!notBB) q = fixBB(q);
	q = q.replace(/[„“‚‘]/g, function(m)
	{
		return {"„": "‚", "“": "‘", "‚": "»", "‘": "«"}[m];
	});
	return (notBB) ? "„" + q + "“" : "„[i]" + q + "[/i]“\n";
}

// tento regulární výraz se využije i jinde
var listRegExp = /^(?:([\(\[\{\/&#9679;•· ]*\s*)\d+(\s*[\)\]\}\/\.\:&minus;\-–—…]+\s*|[\s ])(.*)|\s*(?:[&#9679;•·\*\+&minus;\-–— ]+\s*)?(.*))$/;

function getBlockQuote(block, numbersAllowed)
{
	var line = block.split("\n");
	var info = false;
	var numbers = [], exclude = [];

	for(var i = 0; i < line.length; i++)
	{
		line[i] = line[i].trim();
		if(numbersAllowed) continue;
		numbers[i] = line[i].replace(listRegExp, "$1$2");
		if(numbers[i] && (numbers[i] == numbers[i - 1]) && (numbers[i] == numbers[i - 2]))
		{
			exclude[i] = exclude[i - 1] = exclude[i - 2] = true;
			info = true;
		}
		if(!line[i] && exclude[i - 1]) exclude[i] = true;
	}

	var bq = [];
	for(var i = 0; i < line.length; i++)
	{
		if(!exclude[i]) bq.push(line[i] ? "> [i]" + fixBB(line[i]) + "[/i]" : ">");
	}

	if(info)
	{
		alert("Reagujete-li na očíslovaný seznam, je zbytečné jej celý citovat. Stačí, když se v odpovědi odkážete na jednotlivé body pomocí jejich čísel.");
		if(bq.length == 1) return "";
	}

	return bq.join("\n") + "\n";
}

function getTextareaSelection(options)
{
	try { // může být neviditelná, to pak hází chybu, ale špatně se to testuje

	var textarea = document.forms["edit_p"].elements["detail_popis"];
	textarea.focus();

	var complete = options && (options.context || options.type || options.trim);
	var parts = [];

	if(typeof textarea.selectionStart != "undefined")
	{
		var pos = [textarea.selectionStart, textarea.selectionEnd];
		if(complete) pos = [0, pos[0], pos[1], textarea.value.length];
		for(var i = 1; i < pos.length; i++)
		{
			parts.push(textarea.value.substring(pos[i - 1], pos[i]).replace(/\r\n?/g, "\n"));
		}
		if(!complete) return parts[0];
	}
	else if(document.selection)
	{
		var range = [];
		range[2] = document.selection.createRange().duplicate();
		for(var i = (complete ? 0 : 2); i <= 2; i++)
		{
			if(i != 2)
			{
				range[i] = document.body.createTextRange();
				range[i].moveToElementText(textarea);
				range[i].setEndPoint(["EndToStart", "StartToEnd"][i], range[2]);
			}
			var text = range[i].text, lf = "";
			while(range[i].compareEndPoints("StartToEnd", range[i]))
			{
				range[i].moveEnd("character", -1);
				if(text == range[i].text) lf += "\n"; else break;
			}
			parts[{0:0, 1:2, 2:1}[i]] = text.replace(/\r\n?/g, "\n") + lf;
		}
		if(!complete) return parts[1];
	}
	else
	{
		if(!complete) return "";
		parts = ["", "", ""];
	}
	} catch(exc) {};

	if(options.trim)
	{
		var pt0 = "", pt2 = "";
		var pt1 = parts[1].replace(options.trim, function(m, index)
		{
			if(index == 0)
			{
				pt0 = m;
				return "";
			}
			if(index + m.length == parts[1].length)
			{
				pt2 = m;
				return "";
			}
			return m;
		});

		if(pt1 != parts[1])
		{
			changeSelection([pt0.length, pt1.length]);
			parts = [parts[0] + pt0, pt1, pt2 + parts[2]];
		}
	}

	if(options.type && ((!parts[1].length && !options.allowEmpty) || (parts[1].length && options.expand)))
	{
		if(options.type == "word" || options.type == "line")
		{
			var p0, p2;
			if(options.type == "word")
			{
				p0 = (parts[0].match(/[-_a-z0-9áäéëěíóöôúůüýčďňŕřšťžĺľ]+$/i) || [""])[0];
				p2 = p0.length ? (parts[2].match(/^[-_a-z0-9áäéëěíóöôúůüýčďňŕřšťžĺľ]+/i) || [""])[0] : "";
			}
			else
			{
				p0 = parts[0].substr(("\n" + parts[0]).lastIndexOf("\n"));
				p2 = parts[2].substr(0, (parts[2] + "\n").indexOf("\n"));
			}
			if(p0 || p2)
			{
				var p1 = parts[1];
				changeSelection([-p0.length, p0.length + p1.length + p2.length]);
				parts = [parts[0].substr(0, parts[0].length - p0.length), p0 + p1 + p2, parts[2].substr(p2.length)];
			}
		}
		else if(options.type = "url")
		{
			var text = textarea.value.replace(/\r\n?/g, "\n");
			var pos1 = parts[0].length, pos2 = pos1 + parts[1].length, uri = "";
			text.replace(/(?:\r?\n|^)•\s+\[url=([^\]]+)\].*?\[\/url\]|\[url=([^\]]+)\].*?\[\/url\]|\[img(?:left|right)?\](.*?)\[\/img\]|(https?\:\/\/(?:["‚„“‘\)\.…,:;]*[^\s"‚„“‘\)\.…,:;]+)+)|(www\.(?:["‚„“‘\)\.…,:;]*[^\s"‚„“‘\)\.…,:;]+)+)/gi, function(m, m1, m2, m3, m4, m5, index)
			{
				if(uri || index > pos1 || index + m.length < pos2) return m;
				changeSelection([-pos1 + index, m.length]);
				uri = m1 || m2 || m3 || m4 || ("http://" + m5);
				var cursor = [pos1 - index, pos2 - pos1];
				parts = [text.substr(0, index), text.substr(index, m.length), text.substr(index + m.length), uri, cursor];
				return m;
			});
		}
	}

	return (options.context ? parts : (parts[3] || parts[1]));
}


function getDocumentSelection()
{	
	if(document.getSelection) return document.getSelection().toString();
	if(document.selection) return document.selection.createRange().text;
	if(window.getSelection) return window.getSelection().toString();
	return "";
}
function getQuotation()
{
	document.writeln("\
		<a href=\"javascript:;\" onclick=\"reply(this)\">Odpovědět</a>\
		<a href=\"javascript:;\" onclick=\"insertQuote(this)\" onmouseover=\"fondleQuotation(this)\" onmouseout=\"fondleQuotation(this)\">Citovat</a>\
	");
}
function fondleQuotation(el)
{
	el.happiness = (el.happiness || 0) + 1;
	clearTimeout(el.timeout);
	el.timeout = setTimeout(function()
	{
		el.happiness = 0;
	}, 500);
	if(el.happiness >= 20)
	{
		el.happy = true;
		el.innerText = "Rozcitovat";
		el.onmouseover = el.onmouseout = null;
	}
}

function reply(a)
{
	a.parentNode.parentNode.parentNode.getElementsByTagName("td")[0].getElementsByTagName("b")[0].onclick();
}



/* ====================================== *
 * === Kontrola odesílacího formuláře === *
 * ====================================== */

var zakazOdeslani = false, vadnyTitulek = false;
function kontrolaFormulare()
{
	var jmeno = document.getElementById("user_usr");
	var prispevek = document.forms["edit_p"].elements["detail_popis"];
	var titulek = document.forms["edit_p"].elements["topicTitle"];
	if(zakazOdeslani) return false;
	if(prispevek && !prispevek.value.trim())
	{
		prispevek.focus();
		return false;
	}
	if(jmeno && jmeno.tagName == "INPUT")
	{
		var v = jmeno.value;
		if(!v.trim())
		{
			alert("Napište nám prosím své jméno nebo přezdívku. Jinak budete v diskusi vystupovat jako „anonymní“.\n\nNemusíte se registrovat, ani zadávat heslo. Když nyní jméno zadáte, diskuse si ho zapamatuje a nebude vás příště nutit jej vyplňovat.");
			jmeno.focus();
			return false;
		}
		else
		{
			var aMasTo = ", učiňte tak prosím v textu příspěvku. Kolonka „Vaše jméno“ je určená pro vaše jméno.\n\nPokud se potřebujete vyhnout svému registrovanému jménu, doplňte pouze podtržítko — takový příspěvek si po přihlášení můžete příspěvek připsat do profilu.";

			v = v.replace(/[-_\/\\\s\(\)\[\]\{\}\.\*]+/g, " ").trim().toLowerCase();
			if(v.match(/ (za(pomn?[eě]|budo?)la?(\s*j?s[eo]m)?|ne(v[íi]e?|zn[aá])m)\s*heslo/))
			{
				alert("Chcete-li světu oznámit, že neznáte heslo" + aMasTo);
				jmeno.focus();
				return false;
			}
			else if(v.match(/ ((v )?pr[aá]c(uj)?[ie]|((at|@) )?(work(ing)?|home)|(ve\s+)?[šs]kol[ae]|doma|nemoc(en|n[ay])|jinde)/))
			{
				alert("Návštěvníci této diskuse nejspíše nepotřebují vědět, kde zrovna jste. Chcete-li jim to přesto sdělit" + aMasTo);
				jmeno.focus();
				return false;
			}
		}
	}

	if(titulek)
	{
		var kategorie = (location.href.match(/[?&]forum=(\d+)/) || [])[1];
		var k = kvalitaTitulku(titulek.value, kategorie);

		var rady = "\n\nSprávný titulek by měl:\n • shrnovat pointu dotazu,\n • přizvat diskutéry schopné poradit,\n • přilákat lidi vyhledávající tytéž rady,\n • být unikátní, je-li to možné.";
		if(Kategorie[kategorie].druh == "názory")
		{
			rady = "\n\nSprávný titulek by měl obsahovat název či adresu hodnoceného webu.";
		}
		else if(Kategorie[kategorie].druh == "práce")
		{
			rady = "\n\nSprávný titulek by měl zmiňovat:\n • zda jde o nabídku či poptávku,\n • co nejpřesnější výčet poptávaných/nabízených dovedností,\n • zda je práce placená.";
		}

		if(k < 5 || vadnyTitulek) log("[" + titulek.value + "][" + kategorie + "][Q:" + (k < 5 ? k < 3 ? "A" : "C" : "OK") + "][N/A]");

		if(k == -51)
		{
			alert("Nepoužívejte prosím v názvu vlákna anglické skřeky.");
		}
		else if(k < 3)
		{
			alert("Zvolte prosím lepší název vlákna." + rady);
		}
		else if(k < 5)
		{
			if(confirm("Stávající název vlákna se zdá být málo výstižný. Chcete jej i přesto použít?" + rady + "")) return true;
		}
		else
		{
			zakazOdeslani = true;
			setTimeout(function() { zakazOdeslani = false }, 1000);
			return true;
		}
		vadnyTitulek = true;
		titulek.focus();
		return false;
	}
	zakazOdeslani = true;
	setTimeout(function() { zakazOdeslani = false }, 1000);
	return true;
}

function log(data)
{
	var jmeno = document.getElementById("user_usr") || "";
	if(jmeno) jmeno = (jmeno.value || jmeno.innerHTML);
	data = "[" + jmeno + "]" + data;
	var img = new Image();
	img.src = "bb_logger.php?data=" + encodeURIComponent(data);
}

function kvalitaTitulku(titulek, kategorie)
{
	var druh = Kategorie[kategorie] ? Kategorie[kategorie].druh : "";

	var vaty = "";

	var servat = /^(help|pl[sz]|please?|thx|omg|hilfe)$/;
	var sezrat = /^(|t(oho?|[ioa]m?|e[jn]?|u|ady)(to)?|[pdh]o|m[ei]|uz|[nsdj]a|by(s(te)?|ch(om)?)?|pr?o|[szvuaikuo]|[zkjnvts]e|pre(ds)?|cez|ne(kdo|[bc]o|jak[yae]?)?|zase?|znov[ua]|opet|jen|bez|(pr(oc|eco)|ako|jak([aey]|ou|ej)?|c[oi]|c[ie]m|coz|cemu|kde|ke?dy)(pak)?|vs|versus|atd)$/;
	vaty += "prosime?|poradi?(te)?|mame?|je|neni|nie|(ne)?((pu)?jde|slo|u?dela(t|lo?)?|funguj(e|ici)|funkcn[ei])|spatn([ey]m?|ou)|problem(y|e[mk]|u)?|[nv]a[sm]|m[uo]j|rad[ayu]|otazk([auy]|ami?)|dotaz(y|um?|e(ch|[mk])?)?|mensia?|(mal|drobn|hloup|kratk|snadn)[yae]|pom(o[cz]|[ou]ze)(te?)?|kod|web([ue]m?)?|wWw|odkazy?|strank([auy]|ou|ami)|webdesign\\w*|\\d+|uvita(me?|l)|desi(gn|ng)\\w*|server\\w*";
	vaty += {
		"vývoj":	"|x?(h(tm|mt)|m)l?|cSs|dom|(j(ava)?|action)s(cript(em?|um?|(ov)?y)?)?|s[ck]ript(em?|um?|(ov)?y)?|ajax\\w*|jquery|jav[ae]|php(ck\\w*)?|oOp|(my)?sql|htaces|mod|sesion|float|menu|height|width|rs|dt?b|databaz\\w+|funkc[ei]|echo|chyb([ayue]|am[ia]?|ou)?|(warning|eror)(y|um?|em)?|apach(em?|i)|div(y|[ue]m?)?|(mod_)?rewrite|mod|valid(ator|it(a|ou))|kod(u|em?)?|layout\\w*|asp\\.net|flash\\w*|zacatecn\\w*|lightbox\\w*",
		"názory":	"|[oz]?hodno(t(e|ite?)|ceni)|nazory?|kresb([ayu]|ami?)|log(a|o(typ\\w*)?)?|kritik[auy]|(ne)?[zs]?kritizuj(te)|navrc?h([yu]|em?)?|graf(ick([yae]|ou))?|x?h(tm|mt)l?|nov[ayei]|nov[ae]jsi|dalsi[ua]?|verz([ei]|i[aiu])|projekt\\w*|webov\\w*|osobn([aiy]|ou)",
		"práce":	"|(ne)?(hl[ea]da|sc?hani|nabi(zi|dne)|(popt|prod)a(va)?|udela)([mt]e?)?|(poptav|nabid)ka|prodej\\w*|sluz(eb|b[uyae]|bam)",
		"seo":  	"|gogl\\w+|adsen[sc]e|klicov[aye]|(vy)?hledat|vyhledava[ct]e?|seo|cena|optimali[sz]\\w*",
		"hosting":	"|(web)?hosting\\w*|hostuj[ieu]",
		"sw":   	"|(excel|word)([ue]|em)|ofice|outloc?k\\w*|microsoft\\w*|frontpag(i|em?)|windows\\w*|linux\\w*|rs|wp|wordpres\\w*|icq|qip|pspad\\w*|wi\\-?fi|antivir\\w*|redakcni(ch|mu?|ho)?|system[eyu]"
	}[druh] || "";
	var vata = new RegExp("^(" + vaty + ")$");

	//// převod na malá písmena
	var t = titulek.toLowerCase();

	//// záchrana operátorů, které by zničilo oddiakritizování a odpaznakování
	t = t.replace(/[!=]==?|([&\|\+\-])\1|\-\>|[-\+\*\/\&\|]=/g, "OP");

	//// záchrana zkratek, které by zničila likvidace opakujících se znaků, a plžů
	t = t.replace(/css|www|oop|plž/g, function(m)
	{
		return { "css": "cSs", "www": "wWw", "oop": "oOp", "plž": "Plž" }[m] || m;
	});

	//// oddiakritizování a odpaznakování
	t = t.replace(/[^_\w\s]/g, function(m)
	{
		return {"á": "a", "ä": "a", "é": "e", "ë": "e", "ě": "e", "í": "i", "ó": "o", "ö": "o", "ô": "o", "ú": "u", "ů": "u", "ü": "u", "ý": "y", "č": "c", "ď": "d", "ň": "n", "ř": "r", "š": "s", "ť": "t", "ž": "z", "ĺ": "l", "ľ": "l"}[m] || " ";
	});

	//// likvidace opakujících se znaků
	t = t.replace(/(.)\1+/g, "$1");

	//// nasekání na slova
	var slova = t.replace(/^\W+|\W+$/g, "").split(/\W*\s\W*/);

	var hodnota = 0;
	for(var i = 0; i < slova.length; i++)
	{
		var slovo = slova[i];
		if(sezrat.test(slovo)) continue;
		if(servat.test(slovo))
		{
			return -51;
		}
		else if(vata.test(slovo))
		{
			hodnota += { "názory": 0 }[druh] || 1;
		}
		else
		{
			hodnota += { "práce": 3, "vývoj": 3 }[druh] || 4;
			if(slovo.length > 3) hodnota += 1;
		}
	}
	if(slova.length == 1)
	{
		// penalizace za jednoslovnost
		hodnota -= { "vývoj": 2 }[druh] || 0;
	}
	return hodnota;
}
var kontrolaJmena = kontrolaFormulare;
var rozepsano = false;
function kontrolaFormularePrubezna()
{
	var upozorneni = document.getElementById("upozorneni");
	if(!upozorneni) return;

	var prispevek = document.forms["edit_p"].elements["detail_popis"];
	var puvodni = upozorneni.innerHTML.replace(/<br>/i, "");
	var stavajici = puvodni;

	var bezDiakritiky = /\b(kt[eo]r[eay]|pr(oc|eco)|jeste|takze|ne(kd[oy]|co|jak([eay]|ou)?)|stran(k[ayu]|ce)|resi([mt]e?)?|potrebuj([ieu]|e([mt]e?|s))|nazor[euy]?|diky|dekuj[ui]|priklad[yu]?|zkousela?)\b/i;
	var sDiakritikou = /[áäéëěíóöôúůüýčďňŕřšťžĺľ]/i;
	var chybiDiakritika = false;

	var v = prispevek.value;
	prispevek.defaultValue = "";
	prispevek.value = v;

	var minule = v + "-";
	var prubeh = function()
	{
		if(prispevek.value == minule) return;
		minule = prispevek.value;

		if(prispevek.value != prispevek.defaultValue)
		{
			if(!rozepsano) document.title = "'" + document.title;
			rozepsano = true;
		}
		else
		{
			if(rozepsano) document.title = document.title.replace(/^'/, "");
			rozepsano = false;
		}
		var text = prispevek.value.toLowerCase();
		var hlasky = [];
		var oholeny = text.replace(/\[url[^\]]*\].*?\[\/url\]|\[img(?:left|right)?\].*?\[\/img\]|\[i\].*?\[\/i\]/g, "");

		if(sDiakritikou.test(oholeny))
			chybiDiakritika = false;
		else if(bezDiakritiky.test(oholeny))
			chybiDiakritika = true;

		hlasky.push(chybiDiakritika ? { text: puvodni.replace(/p[^k]+kritiku/, "*$&*"), priorita: 5 } : { text: puvodni, priorita: 1 });

		if(text.match(/mmm/)) hlasky.push({ text: "Zkratka „*mmm*“ přivolá moderátory.", priorita: 10 });
		if(text.match(/\[url=([^h]|h[^t]|ht[^t]|htt[^p])[^\]]+]/g)) hlasky.push({ text: "V adrese odkazu musí být i „http://“.", priorita: 8 });
		for(var i = 0, tag; tag = ["b", "i"][i]; i++)
		{
			if(text.lastIndexOf("[" + tag + "]") > text.lastIndexOf("[/" + tag + "]")) hlasky.push({ text: "Neuzavřené [" + tag + "].", priorita: 6 + i });;
		}

		hlasky.sort(function(a, b) { return b.priorita - a.priorita });
		var u = (hlasky[1] ? hlasky[1].text + " | " : "") + hlasky[0].text;

		if(stavajici != u)
		{
			stavajici = u;
			upozorneni.innerHTML = u.replace(/\*([^\*]+)\*/g, "<span class=\"warning\">$1</span>");
		}
	};
	setInterval(prubeh, 2000);
}
inits.push(kontrolaFormularePrubezna);



/* ====================================== *
 * === Popisky formátovacích tlačítek === *
 * ====================================== */

function popiskyTlacitek()
{
	var tlacitka = document.getElementById("tlacitkas");
	if(!tlacitka) return;

	var obr = tlacitka.getElementsByTagName("img");
	for(var i = 0; i < obr.length; i++)
	{
		obr[i].onmouseover = function()
		{
			var puvodni = document.getElementById("popis_stylu").innerHTML;
			document.getElementById("popis_stylu").innerHTML = this.title;
			this.onmouseout = function()
			{
				document.getElementById("popis_stylu").innerHTML = puvodni;
				this.onmouseout = null;
			};
		};
	}
}
inits.push(popiskyTlacitek);



/* =================================================== *
 * === Vkládání číselných kotev z příspěvků a jmen === *
 * =================================================== */

function ciselneKotvy(param)
{
	var tab = document.getElementById("prispevky");
	if(!tab || !document.forms["edit_p"] || document.forms["edit_p"].elements["topicTitle"]) return;

	var radky = tab.getElementsByTagName("tr");
  	for(var i = 1; i < radky.length; i++)
	{
		var bunka = radky[i].getElementsByTagName("td");
		(function(kotva, jmeno)
		{
			if(!jmeno || !jmeno.firstChild) return;
			var j = "[b]" + orezJmeno(jmeno.innerText) + "[/b]";
			if(!param.konecStrany)
			{
				kotva.onclick = function()
				{
					var k = "[" + this.innerHTML + "]";
	
					location.hash = this.innerHTML.substr(1);
					insertText(k + " " + j, [k.length, j.length + 1]);
					return false;
				};
				kotva.title = "Přidat do textu odkaz na příspěvek " + kotva.innerHTML;
			}

			jmeno.onclick = function()
			{
				var tac = getTextareaSelection({ context: true });
				var vlozit = j, cursor;
				if(!tac[0] || tac[0].substr(tac[0].length - 1, 1) == "\n")
				{
					vlozit += ":\n";
					if(tac[0].match(/\[b\].*?\[\/b\]:\n$/i))
					{
						insertText("", [-2, 2]);
						vlozit = ", " + vlozit;
					}
				}
				else if(tac[0].substr(tac[0].length - 1, 1) != " ")
				{
					vlozit = (tac[0].match(/\[b\].*?\[\/b\]$/i) ? ", " : " ") + vlozit;
				}
				insertText(vlozit, cursor);
			};

			var ozdoba = document.createElement("span");
			ozdoba.className = "kotva-highlight";
//			var moznosti = ["<strong>#</strong>", "#", "&darr;", "&#9660;", "<strong>V</strong>", "v", "•", "&asymp;", "|", "\\|/"];
//			var moznosti = ["&#9660;", "<strong>V</strong>", "v", "•"];
//			ozdoba.innerHTML = moznosti[(i - 1) % moznosti.length];
			ozdoba.innerHTML = "&#9660;";
			jmeno.parentNode.insertBefore(ozdoba, jmeno);
		})(bunka[1].getElementsByTagName("a")[0], bunka[0].getElementsByTagName("b")[0]);
	}
}
inits.push(ciselneKotvy);



/* =============================== *
 * === Protivytahovací zábrana === *
 * =============================== */

function protivytahovaciZabrana(param)
{
	if(!param.stareVlakno || !param.posledniStrana || param.moderator) return;

	var kategorieLink = "?action=vtopic&forum=" + param.qsforum + "#newtopic";

	var f = document.edit_p;
	if(!f) return false;
	var d = document.createElement("div");
	d.innerHTML = "<div class=\"backg closed\">\
		<strong>Toto vlákno je staré, již dlouho do něj nikdo nepřispíval.</strong>\
	</div>\
	<p style=\"margin: 4px 0\">Informace a odkazy zde uváděné už nemusí být aktuální. Nechcete-li řešit zde uvedenou <b>konkrétní</b> otázku, <a href=\"" + kategorieLink + "\">založte si vlastní vlákno</a>, <b>nepište do tohoto</b>. Vložíte-li sem nyní příspěvek, upoutáte pozornost mnoha lidí a někteří z nich si jen kvůli vám přečtou i všechny předcházející příspěvky. Předpokládáte-li, že váš text skutečně bude hodnotný, stiskněte následující tlačítko:\
	<div class=\"center\">\
		<button type=\"button\" id=\"edit_pButton\" style=\"margin: 0 0 4px\">Chci psát zprávu</button>\
		<br>Běda vám, jestli to bude blábol.<br>Vložíte-li nesouvisející dotaz, bude <b>smazán</b>!\
	</div>";

	f.style.display = "none";
	f.parentNode.insertBefore(d, f);

	document.getElementById("edit_pButton").onclick = function()
	{
		f.style.display = "";
		d.style.display = "none";
	};
}
inits.push(protivytahovaciZabrana);



/* ====================================================== *
 * === Zvýrazňování slov a elementů podle hashe v URL === *
 * ====================================================== */

function zvyrazniKotvy()
{
	var hash = decodeURI(location.hash.substr(1));
	var staryHash = location.hash;
	var hashchange = setInterval(function()
	{
		if(staryHash == location.hash) return;
		clearInterval(hashchange);
		document.body.className = "";
		if(el) el.className = jehoStara;
		zvyrazniKotvy();
	}, 2000);

	if(!hash) return;

	var el = document.getElementById(hash);
	var jehoStara = "";
	if(el)
	{
		if(el.tagName == "TD") el = el.parentNode;
		jehoStara = el.className;
		el.className += " highlight";
	}
	else if(m = hash.match(/^najdi\(([^\),]+)(?:,\s*([^\),]+))?\)/))
	{
		var hledany = m[1];
		var najdi;

		if(hledany.match(/^\/.*\/$/))
		{
			najdi = function(node, text)
			{
				var h = new RegExp(hledany.substr(1, hledany.length - 2).replace(/\//g, "\\"), "i");
				var p = text.search(h);
				if(p == -1) return null;
				return {node: node, index: p, length: text.match(h)[0].length};
			};
		}
		else if(hledany.match(/\|/))
		{
			hledany = hledany.toLowerCase();
			najdi = function(node, text)
			{
				text = text.toLowerCase();
				var h = hledany.split("|");
				for(var i = 0; hs = h[i]; i++)
				{
					var p = text.indexOf(hs);
					if(p != -1)
					{
						return {node: node, index: p, length: hs.length};
					}
				}
				return null;
			};
		}
		else
		{
			hledany = hledany.toLowerCase();
			najdi = function(node, text)
			{
				text = text.toLowerCase();
				var p = text.indexOf(hledany);
				if(p == -1) return null;
				return {node: node, index: p, length: hledany.length};
			};
		}

		var treewalker = function(e)
		{
			var r;
			for(var ch = e.firstChild; ch; ch = ch.nextSibling)
			{
				r = null;
				if(ch.nodeType == 3)
				{
					r = najdi(ch, ch.data);
				}
				else if(ch.nodeType == 1)
				{
					r = treewalker(ch);
				}
				if(r) return r;
			}
			return null;
		};
		var kde = (m[2] && document.getElementById(m[2]));

		var nalez = treewalker(kde || document.body);
		if(!nalez) return;

		// nasekání textových uzlů na uzlíčky
		var slovo = nalez.node.splitText(nalez.index);
		slovo.splitText(nalez.length);

		// zvýrazňující <span>
		el = document.createElement("span");
		slovo.parentNode.insertBefore(el, slovo);
		el.className = "highlight";
		el.appendChild(slovo);
		
		(kde || el).scrollIntoView();
		if(!kde) scrollBy(-30000, -30);
	}
	else if(m = hash.match(/^roluj\(([^\)]+)\)/))
	{
		window.scrollTo(0, parseInt(m[1], 10));
		return;
	}
	else
	{
		return;
	}
	document.body.className = "highlighting";
}
inits.push(zvyrazniKotvy);



/* ====================== *
 * === Klávesová mapa === *
 * ====================== */

var klavesovaMapa = new (function()
{
	var reference = {
		"Jak psát web": {
			base: "http://www.jakpsatweb.cz/",
			group: ["Jak psát web – HTML", "Jak psát web – CSS"],
			list: {
				"css": "css/", "javascript": "javascript/", "js": "javascript/", "frontpage": "frontpage/", "php": "php/",
				"kurz": "navigace/zakladni-kurz.html", "cestina": "cestina.html", "interpunkce": "interpunkce.html", "robots": "robots-txt.html", "favicon": "favicon.html", "heslo": "heslo.html", "zaheslování": "heslo.html", "include": "include.html", "nepárové": "zaklady-html.html#parove", "párové": "zaklady-html.html#parove", "xhtml": "html/xhtml.html", "url": "html/url.html", "entity": "html/entity.html", "barvy": "html/barva.html", "hover": "enc/hover.html",
				"fieldset": "formulare-4.html#fieldset", "label": "formulare-4.html#label", "optgroup": "formulare-4.html#optgroup", "accesskey": "formulare-4.html#accesskey", "tabindex": "formulare-4.html#tabindex", "disabled": "formulare-4.html#disabled", "readonly": "formulare-4.html#disabled", "input": "formulare-html.html#input", "name": "formulare-html.html#name", "value": "formulare-html.html#value", "checked": "formulare-html.html#checked", "selected": "formulare-html.html#checked", "nobr": "clanky/fosilie-nobr.html", "xmp": "clanky/fosilie-xmp.html", "wbr": "clanky/fosilie-wbr.html", "dl": "definice.html#seznam", "compact": "definice.html#compact",
				"settimeout": "javascript/casovani.html#pocase", "setinterval": "javascript/casovani.html#opakovane"
			}
		},
		"Jak psát web – HTML": {
			base: "http://www.jakpsatweb.cz/html/",
			replace: [{ pattern: /^h[1-6]$/, replacement: "h1" }],
			list: {
				"a": "odkazy.html#a", "abbr": "text.html#abbr", "acronym": "text.html#acronym", "address": "bloky.html#address", "applet": "objekty.html#applet", "area": "obrazky.html#area", "b": "text.html#b", "base": "hlavicka.html#base", "basefont": "text.html#basefont", "bgsound": "rozsireni.html#bgsound", "big": "text.html#big", "blink": "text.html#blink", "blockquote": "bloky.html#blockquote", "body": "struktura.html#body", "br": "bloky.html#br", "button": "formulare.html#button", "caption": "tabulky.html#caption", "center": "bloky.html#center", "cite": "text.html#cite", "code": "text.html#code", "col": "tabulky.html#col", "colgroup": "tabulky.html#colgroup", "dd": "seznamy.html#dd", "del": "text.html#del", "dfn": "text.html#dfn", "dir": "seznamy.html#dir", "div": "bloky.html#div", "dl": "seznamy.html#dl", "dt": "seznamy.html#dt", "em": "text.html#em", "embed": "objekty.html#embed", "fieldset": "formulare.html#fieldset", "font": "text.html#font", "form": "formulare.html#form", "frame": "ramy.html#frame", "frameset": "ramy.html#frameset", "h1": "bloky.html#hn", "head": "struktura.html#head", "hr": "bloky.html#hr", "html": "struktura.html#html", "i": "text.html#i", "iframe": "ramy.html#iframe", "img": "obrazky.html#img", "input": "formulare.html#input", "ins": "text.html#ins", "kbd": "text.html#kbd", "label": "formulare.html#label", "layer": "rozsireni.html#layer", "legend": "formulare.html#legend", "li": "seznamy.html#li", "link": "hlavicka.html#link", "map": "obrazky.html#map", "marquee": "rozsireni.html#marquee", "menu": "seznamy.html#dir", "meta": "hlavicka.html#meta", "multicol": "rozsireni.html#multicol", "nobr": "text.html#nobr", "noembed": "objekty.html#noembed", "noframes": "ramy.html#noframes", "noscript": "skripty.html#noscript", "object": "objekty.html#object", "ol": "seznamy.html#ol", "optgroup": "formulare.html#optgroup", "option": "formulare.html#option", "p": "bloky.html#p", "param": "objekty.html#param", "pre": "bloky.html#pre", "q": "text.html#q", "s": "text.html#s", "samp": "text.html#samp", "script": "skripty.html#script", "select": "formulare.html#select", "small": "text.html#small", "spacer": "rozsireni.html#spacer", "span": "text.html#span", "strike": "text.html#strike", "strong": "text.html#strong", "style": "skripty.html#style", "sub": "text.html#sub", "sup": "text.html#sup", "table": "tabulky.html#table", "tbody": "tabulky.html#tbody", "td": "tabulky.html#td", "textarea": "formulare.html#textarea", "tfoot": "tabulky.html#tfoot", "th": "tabulky.html#th", "thead": "tabulky.html#thead", "title": "hlavicka.html#title", "tr": "tabulky.html#tr", "tt": "text.html#tt", "u": "text.html#u", "ul": "seznamy.html#ul", "var": "text.html#var", "accesskey": "obecne-atributy.html#acceskey", "class": "obecne-atributy.html#class", "dir": "obecne-atributy.html#dir", "id": "obecne-atributy.html#id", "lang": "obecne-atributy.html#lang", "name": "obecne-atributy.html#name", "alt": "obrazky.html#alt", "target": "odkazy.html#target"
			}
		},
		"Jak psát web – CSS": {
			base: "http://www.jakpsatweb.cz/css/",
			replace: [{ pattern: /^\-\w+\-/, replacement: "" }, { pattern: /^scrollbar\-(base|track|face|highlight|3dlight|(dark)?shadow|arrow)\-color$/, replacement: "scrollbar-x-color" }],
			list: {
				"background": "background.html", "background-attachment": "background-attachment.html", "background-color": "background-color.html", "background-image": "background-image.html", "background-position": "background-position.html", "background-repeat": "background-repeat.html", "behavior": "behavior.html", "border": "border.html", "border-collapse": "border-collapse.html", "border-color": "border-color.html", "border-spacing": "border-spacing.html", "border-style": "border-style.html", "border-width": "border-width.html", "bottom": "bottom.html", "clear": "clear.html", "clip": "clip.html", "color": "color.html", "cursor": "cursor.html", "display": "display.html", "filter": "filter.html", "float": "float.html", "font": "font.html", "font-family": "font-family.html", "font-size": "font-size.html", "font-style": "font-style.html", "font-variant": "font-variant.html", "font-weight": "font-weight.html", "height": "height.html", "left": "left.html", "letter-spacing": "letter-spacing.html", "line-height": "line-height.html", "list-style": "list-style.html", "list-style-image": "list-style-image.html", "list-style-position": "list-style-position.html", "list-style-type": "list-style-type.html", "margin": "margin.html", "max-height": "max-height.html", "max-width": "max-width.html", "min-height": "min-height.html", "min-width": "min-width.html", "border-radius": "moz-border-radius.html", "box-sizing": "moz-box-sizing.html", "opacity": "moz-opacity.html", "overflow": "overflow.html", "padding": "padding.html", "page-break-after": "page-break-after.html", "page-break-before": "page-break-before.html", "position": "position.html", "right": "right.html", "scrollbar-x-color": "scrollbar-x-color.html", "table-layout": "table-layout.html", "text-align": "text-align.html", "text-decoration": "text-decoration.html", "text-indent": "text-indent.html", "text-overflow": "text-overflow.html", "text-transform": "text-transform.html", "top": "top.html", "vertical-align": "vertical-align.html", "visibility": "visibility.html", "white-space": "white-space.html", "width": "width.html", "word-spacing": "word-spacing.html", "writing-mode": "writing-mode.html", "z-index": "z-index.html", "text-overflow": "css-orez.html#tritecky", "overflow-x": "css-orez.html#overflow", "overflow-y": "css-orez.html#overflow"
			}
		},
		"Sémantika.name": {
			base: "http://semantika.name/",
			info: "Před dohledáním odkazu projde slovo filtrem, který oseká všelijaká skloňování.",
			replace: [{ pattern: /^h[1-6]$/, replacement: "h1" }, { pattern: /^(nadpis|seznam|odstavc|citac|zkratk|kód|zdroják|vý?stup|proměnn|adres|index(?!of)|tabulk|formulář|nesémantick|div|desater)([^-_\d\s]+)$/, replacement: function(m, m1) { return {"odstavc": "odstavec", "citac": "citace", "zkratk": "zkratka", "proměnn": "proměnná", "tabulk": "tabulek", "nesémantick": "nesémantické", "desater": "desatero"}[m1] || m1 } }],
			list: {
				"nadpis": "zakladni-kostra-stranky.html#nadpisy", "seznam": "seznamy.html", "odstavec": "zakladni-kostra-stranky.html#formatovani", "citace": "citace-zkratky.html#citace", "zkratka": "citace-zkratky.html#zkratky", "kód": "zdrojove-kody.html#pocitacovy", "zdroják": "zdrojove-kody.html#pocitacovy", "výstup": "zdrojove-kody.html#vystup", "vstup": "zdrojove-kody.html#vstup", "proměnná": "zdrojove-kody.html#promenna", "adresa": "logicke-formatovani.html#address", "index": "logicke-formatovani.html#indexy", "tabulek": "tabulky.html", "formulář": "formulare.html", "nesémantické": "nesemanticke-znacky.html", "div": "nesemanticke-znacky.html", "fekální": "fekalni-styl.html", "desatero": "desatero-semantickeho-webu.html",
				"h1": "zakladni-kostra-stranky.html#nadpisy", "p": "zakladni-kostra-stranky.html#formatovani", "b": "zvyrazneni-textu.html#rozdil", "strong": "zvyrazneni-textu.html#rozdil", "small": "zvyrazneni-textu.html#zeslabeni", "font": "uprava-textu.html#font", "blink": "uprava-textu.html#blikajici", "marquee": "uprava-textu.html#blikajici", "ol": "seznamy.html#cislovany", "ul": "seznamy.html#necislovany", "menu": "seznamy.html#menu", "dir": "seznamy.html#dir", "dl": "seznamy.html#definice", "cite": "citace-zkratky.html#citace", "q": "citace-zkratky.html#citace", "blockquote": "citace-zkratky.html#citace", "abbr": "citace-zkratky.html#zkratky", "acronym": "citace-zkratky.html#zkratky", "pre": "zdrojove-kody.html#pocitacovy", "samp": "zdrojove-kody.html#vystup", "kbd": "zdrojove-kody.html#vstup", "var": "zdrojove-kody.html#promenna", "dfn": "logicke-formatovani.html#dfn", "address": "logicke-formatovani.html#address", "del": "logicke-formatovani.html#del", "ins": "logicke-formatovani.html#del", "sub": "logicke-formatovani.html#indexy", "sup": "logicke-formatovani.html#indexy", "table": "tabulky.html", "tfoot": "tabulky.html", "thead": "tabulky.html", "th": "tabulky.html", "tr": "tabulky.html", "td": "tabulky.html", "form": "formulare.html", "fieldset": "formulare.html#fieldset", "legend": "formulare.html#legend", "label": "formulare.html#label"
			}
		},
		"CSS 2.1": {
			base: "http://www.w3.org/TR/CSS21/",
			list: {
				"azimuth": "aural.html#propdef-azimuth", "background-attachment": "colors.html#propdef-background-attachment", "background-color": "colors.html#propdef-background-color", "background-image": "colors.html#propdef-background-image", "background-position": "colors.html#propdef-background-position", "background-repeat": "colors.html#propdef-background-repeat", "background": "colors.html#propdef-background", "border-collapse": "tables.html#propdef-border-collapse", "border-color": "box.html#propdef-border-color", "border-spacing": "tables.html#propdef-border-spacing", "border-style": "box.html#propdef-border-style", "border-top": "box.html#propdef-border-top", "border-right": "box.html#propdef-border-right", "border-bottom": "box.html#propdef-border-bottom", "border-left": "box.html#propdef-border-left", "border-top-color": "box.html#propdef-border-top-color", "border-right-color": "box.html#propdef-border-right-color", "border-bottom-color": "box.html#propdef-border-bottom-color", "border-left-color": "box.html#propdef-border-left-color", "border-top-style": "box.html#propdef-border-top-style", "border-right-style": "box.html#propdef-border-right-style", "border-bottom-style": "box.html#propdef-border-bottom-style", "border-left-style": "box.html#propdef-border-left-style", "border-top-width": "box.html#propdef-border-top-width", "border-right-width": "box.html#propdef-border-right-width", "border-bottom-width": "box.html#propdef-border-bottom-width", "border-left-width": "box.html#propdef-border-left-width", "border-width": "box.html#propdef-border-width", "border": "box.html#propdef-border", "bottom": "visuren.html#propdef-bottom", "caption-side": "tables.html#propdef-caption-side", "clear": "visuren.html#propdef-clear", "clip": "visufx.html#propdef-clip", "color": "colors.html#propdef-color", "content": "generate.html#propdef-content", "counter-increment": "generate.html#propdef-counter-increment", "counter-reset": "generate.html#propdef-counter-reset", "cue-after": "aural.html#propdef-cue-after", "cue-before": "aural.html#propdef-cue-before", "cue": "aural.html#propdef-cue", "cursor": "ui.html#propdef-cursor", "direction": "visuren.html#propdef-direction", "display": "visuren.html#propdef-display", "elevation": "aural.html#propdef-elevation", "empty-cells": "tables.html#propdef-empty-cells", "float": "visuren.html#propdef-float", "font-family": "fonts.html#propdef-font-family", "font-size": "fonts.html#propdef-font-size", "font-style": "fonts.html#propdef-font-style", "font-variant": "fonts.html#propdef-font-variant", "font-weight": "fonts.html#propdef-font-weight", "font": "fonts.html#propdef-font", "height": "visudet.html#propdef-height", "left": "visuren.html#propdef-left", "letter-spacing": "text.html#propdef-letter-spacing", "line-height": "visudet.html#propdef-line-height", "list-style-image": "generate.html#propdef-list-style-image", "list-style-position": "generate.html#propdef-list-style-position", "list-style-type": "generate.html#propdef-list-style-type", "list-style": "generate.html#propdef-list-style", "margin-right": "box.html#propdef-margin-right", "margin-left": "box.html#propdef-margin-left", "margin-top": "box.html#propdef-margin-top", "margin-bottom": "box.html#propdef-margin-bottom", "margin": "box.html#propdef-margin", "max-height": "visudet.html#propdef-max-height", "max-width": "visudet.html#propdef-max-width", "min-height": "visudet.html#propdef-min-height", "min-width": "visudet.html#propdef-min-width", "orphans": "page.html#propdef-orphans", "outline-color": "ui.html#propdef-outline-color", "outline-style": "ui.html#propdef-outline-style", "outline-width": "ui.html#propdef-outline-width", "outline": "ui.html#propdef-outline", "overflow": "visufx.html#propdef-overflow", "padding-top": "box.html#propdef-padding-top", "padding-right": "box.html#propdef-padding-right", "padding-bottom": "box.html#propdef-padding-bottom", "padding-left": "box.html#propdef-padding-left", "padding": "box.html#propdef-padding", "page-break-after": "page.html#propdef-page-break-after", "page-break-before": "page.html#propdef-page-break-before", "page-break-inside": "page.html#propdef-page-break-inside", "pause-after": "aural.html#propdef-pause-after", "pause-before": "aural.html#propdef-pause-before", "pause": "aural.html#propdef-pause", "pitch-range": "aural.html#propdef-pitch-range", "pitch": "aural.html#propdef-pitch", "play-during": "aural.html#propdef-play-during", "position": "visuren.html#propdef-position", "quotes": "generate.html#propdef-quotes", "richness": "aural.html#propdef-richness", "right": "visuren.html#propdef-right", "speak-header": "aural.html#propdef-speak-header", "speak-numeral": "aural.html#propdef-speak-numeral", "speak-punctuation": "aural.html#propdef-speak-punctuation", "speak": "aural.html#propdef-speak", "speech-rate": "aural.html#propdef-speech-rate", "stress": "aural.html#propdef-stress", "table-layout": "tables.html#propdef-table-layout", "text-align": "text.html#propdef-text-align", "text-decoration": "text.html#propdef-text-decoration", "text-indent": "text.html#propdef-text-indent", "text-transform": "text.html#propdef-text-transform", "top": "visuren.html#propdef-top", "unicode-bidi": "visuren.html#propdef-unicode-bidi", "vertical-align": "visudet.html#propdef-vertical-align", "visibility": "visufx.html#propdef-visibility", "voice-family": "aural.html#propdef-voice-family", "volume": "aural.html#propdef-volume", "white-space": "text.html#propdef-white-space", "widows": "page.html#propdef-widows", "width": "visudet.html#propdef-width", "word-spacing": "text.html#propdef-word-spacing", "z-index": "visuren.html#propdef-z-index"
			}
		},
		"HTML 4.01": {
			base: "http://www.w3.org/TR/html4/",
			replace: [{ pattern: /^h[1-6]$/, replacement: "h1" }],
			list: {
				"a": "struct/links.html#edef-A", "abbr": "struct/text.html#edef-ABBR", "acronym": "struct/text.html#edef-ACRONYM", "address": "struct/global.html#edef-ADDRESS", "applet": "struct/objects.html#edef-APPLET", "area": "struct/objects.html#edef-AREA", "b": "present/graphics.html#edef-B", "base": "struct/links.html#edef-BASE", "basefont": "present/graphics.html#edef-BASEFONT", "bdo": "struct/dirlang.html#edef-BDO", "big": "present/graphics.html#edef-BIG", "blockquote": "struct/text.html#edef-BLOCKQUOTE", "body": "struct/global.html#edef-BODY", "br": "struct/text.html#edef-BR", "button": "interact/forms.html#edef-BUTTON", "caption": "struct/tables.html#edef-CAPTION", "center": "present/graphics.html#edef-CENTER", "cite": "struct/text.html#edef-CITE", "code": "struct/text.html#edef-CODE", "col": "struct/tables.html#edef-COL", "colgroup": "struct/tables.html#edef-COLGROUP", "dd": "struct/lists.html#edef-DD", "del": "struct/text.html#edef-del", "dfn": "struct/text.html#edef-DFN", "dir": "struct/lists.html#edef-DIR", "div": "struct/global.html#edef-DIV", "dl": "struct/lists.html#edef-DL", "dt": "struct/lists.html#edef-DT", "em": "struct/text.html#edef-EM", "fieldset": "interact/forms.html#edef-FIELDSET", "font": "present/graphics.html#edef-FONT", "form": "interact/forms.html#edef-FORM", "frame": "present/frames.html#edef-FRAME", "frameset": "present/frames.html#edef-FRAMESET", "h1": "struct/global.html#h-7.5.5", "head": "struct/global.html#edef-HEAD", "hr": "present/graphics.html#edef-HR", "html": "struct/global.html#edef-HTML", "i": "present/graphics.html#edef-I", "iframe": "present/frames.html#edef-IFRAME", "img": "struct/objects.html#edef-IMG", "input": "interact/forms.html#edef-INPUT", "ins": "struct/text.html#edef-ins", "isindex": "interact/forms.html#edef-ISINDEX", "kbd": "struct/text.html#edef-KBD", "label": "interact/forms.html#edef-LABEL", "legend": "interact/forms.html#edef-LEGEND", "li": "struct/lists.html#edef-LI", "link": "struct/links.html#edef-LINK", "map": "struct/objects.html#edef-MAP", "menu": "struct/lists.html#edef-MENU", "meta": "struct/global.html#edef-META", "noframes": "present/frames.html#edef-NOFRAMES", "noscript": "interact/scripts.html#edef-NOSCRIPT", "object": "struct/objects.html#edef-OBJECT", "ol": "struct/lists.html#edef-OL", "optgroup": "interact/forms.html#edef-OPTGROUP", "option": "interact/forms.html#edef-OPTION", "p": "struct/text.html#edef-P", "param": "struct/objects.html#edef-PARAM", "pre": "struct/text.html#edef-PRE", "q": "struct/text.html#edef-Q", "s": "present/graphics.html#edef-S", "samp": "struct/text.html#edef-SAMP", "script": "interact/scripts.html#edef-SCRIPT", "select": "interact/forms.html#edef-SELECT", "small": "present/graphics.html#edef-SMALL", "span": "struct/global.html#edef-SPAN", "strike": "present/graphics.html#edef-STRIKE", "strong": "struct/text.html#edef-STRONG", "style": "present/styles.html#edef-STYLE", "sub": "struct/text.html#edef-SUB", "sup": "struct/text.html#edef-SUP", "table": "struct/tables.html#edef-TABLE", "tbody": "struct/tables.html#edef-TBODY", "td": "struct/tables.html#edef-TD", "textarea": "interact/forms.html#edef-TEXTAREA", "tfoot": "struct/tables.html#edef-TFOOT", "th": "struct/tables.html#edef-TH", "thead": "struct/tables.html#edef-THEAD", "title": "struct/global.html#edef-TITLE", "tr": "struct/tables.html#edef-TR", "tt": "present/graphics.html#edef-TT", "u": "present/graphics.html#edef-U", "ul": "struct/lists.html#edef-UL", "var": "struct/text.html#edef-VAR"
			}
		},
		"HTML 5": {
			base: "http://www.whatwg.org/specs/web-apps/current-work/",
			replace: [{ pattern: /^h[1-6]$/, replacement: "h1" }],
			list: {
				"a": "#the-a", "abbr": "#the-abbr", "address": "#the-address", "area": "#the-area", "article": "#the-article", "aside": "#the-aside", "audio": "#audio", "b": "#the-b", "base": "#the-base", "bdo": "#the-bdo", "blockquote": "#the-blockquote", "body": "#the-body", "br": "#the-br", "canvas": "#the-canvas", "caption": "#the-caption", "cite": "#the-cite", "code": "#the-code", "col": "#the-col", "colgroup": "#the-colgroup", "command": "#the-command", "datagrid": "#datagrid", "datalist": "/web-forms/current-work/#the-datalist", "datatemplate": "#the-datatemplate", "dd": "#the-dd", "del": "#the-del", "details": "#the-details", "dfn": "#the-dfn", "dialog": "#the-dialog", "div": "#the-div", "dl": "#the-dl", "dt": "#the-dt", "em": "#the-em", "embed": "#the-embed", "event-source": "#the-event-source", "figure": "#the-figure", "font": "#the-font", "footer": "#the-footer", "h1": "#the-h1", "head": "#the-head", "header": "#the-header", "hr": "#the-hr", "html": "#the-html", "i": "#the-i", "iframe": "#the-iframe", "img": "#the-img", "ins": "#the-ins", "kbd": "#the-kbd", "legend": "#the-legend", "li": "#the-li", "link": "#the-link", "map": "#the-map", "mark": "#the-mark", "menu": "#menus", "meta": "#meta", "meter": "#the-meter", "nav": "#the-nav", "nest": "#the-nest", "noscript": "#the-noscript", "object": "#the-object", "ol": "#the-ol", "output": "/web-forms/current-work/#the-output", "p": "#the-p", "param": "#the-param", "pre": "#the-pre", "progress": "#the-progress", "q": "#the-q", "rule": "#the-rule", "samp": "#the-samp", "script": "#script", "section": "#the-section", "small": "#the-small", "source": "#the-source", "span": "#the-span", "strong": "#the-strong", "style": "#the-style", "sub": "#the-sup", "sup": "#the-sup", "table": "#the-table", "tbody": "#the-tbody", "td": "#the-td", "tfoot": "#the-tfoot", "th": "#the-th", "thead": "#the-thead", "time": "#the-time", "title": "#the-title0", "tr": "#the-tr", "ul": "#the-ul", "var": "#the-var", "video": "#video", "class": "#class6", "contenteditable": "#contenteditable0", "contextmenu": "#contextmenu", "dir": "#dir", "draggable": "#draggable", "id": "#id", "irrelevant": "#irrelevant", "lang": "#lang", "onabort": "#onabort", "onbeforeunload": "#onbeforeunload", "onblur": "#onblur", "onchange": "#onchange", "onclick": "#onclick", "oncontextmenu": "#oncontextmenu", "ondblclick": "#ondblclick", "ondrag": "#ondrag", "ondragend": "#ondragend", "ondragenter": "#ondragenter", "ondragleave": "#ondragleave", "ondragover": "#ondragover", "ondragstart": "#ondragstart", "ondrop": "#ondrop", "onerror": "#onerror", "onfocus": "#onfocus", "onkeydown": "#onkeydown", "onkeypress": "#onkeypress", "onkeyup": "#onkeyup", "onload": "#onload", "onmessage": "#onmessage", "onmousedown": "#onmousedown", "onmousemove": "#onmousemove", "onmouseout": "#onmouseout", "onmouseover": "#onmouseover", "onmouseup": "#onmouseup", "onmousewheel": "#onmousewheel", "onresize": "#onresize", "onscroll": "#onscroll", "onselect": "#onselect", "onsubmit": "#onsubmit", "onunload": "#onunload", "ref": "#ref", "registrationmark": "#registrationmark", "repeat": "/web-forms/current-work/#repeat", "repeat-max": "/web-forms/current-work/#repeat-max", "repeat-min": "/web-forms/current-work/#repeat-min", "repeat-start": "/web-forms/current-work/#repeat-start", "tabindex": "#tabindex", "template": "#template"
			}
		},
		"PHP": {
			base: "http://cz.php.net/",
			info: "Využívá funkci z JUSHe, což je zdejší zvýrazňovač kódu.",
			evaluator: function(slovo)
			{
				var jushHTML = jush.highlight_states(["php"], slovo, true)[0];
				var m = jushHTML.match(/<a href="(http:\/\/[^"]+)" target="_blank">/);
				return m ? m[1] : null;
			}
		},
		"MDC – JavaScript": {
			base: "http://developer.mozilla.org/",
			info: "Využívá funkci z JUSHe, což je zdejší zvýrazňovač kódu.",
			evaluator: function(slovo)
			{
				var jushHTML = jush.highlight_states(["js"], slovo, true)[0];
				var m = jushHTML.match(/<a href="(http:\/\/[^"]+)" target="_blank">/);
				return m ? m[1] : null;
			}
		},
		"Vše": {
			info: "Není v klávesové mapě, vyvolává se zkratkou Ctrl+tečka.",
			group: ["Jak psát web", "HTML 4.01", "CSS 2.1", "Sémantika.name", "HTML 5", "PHP", "MDC – JavaScript"]
		}
	};

	var proTextareu = {
		kontextovyOdkazNajdi: function(kam, text)
		{
			var t = reference[kam].honorCase ? text : text.toLowerCase();
			if(reference[kam].replace)
			{
				for(var i = 0; i < reference[kam].replace.length; i++)
				{
					t = t.replace(reference[kam].replace[i].pattern, reference[kam].replace[i].replacement);
				}
			}
			if(reference[kam].evaluator)
			{
				var uri = reference[kam].evaluator(t);
				if(uri) return uri;
			}
			if(reference[kam].list && reference[kam].list[t])
			{
				return ((reference[kam].list[t].charAt(0) != "/") ? (reference[kam].base || "") : reference[kam].base.match(/^\w+:\/+[^\/]+/)[0]) + reference[kam].list[t];
			}
			if(reference[kam].group)
			{
				for(var i = 0; i < reference[kam].group.length; i++)
				{
					var uri = proTextareu.kontextovyOdkazNajdi(reference[kam].group[i], t);
					if(uri) return uri;
				}
			}
			return "";
		},
		kontextovyOdkaz: function(kam)
		{
			return function(text, nazev, ticho)
			{
				if(!text)
				{
					if(!reference[kam].base)
					{
						if(!ticho) alert("Označte prosím text, k němuž chcete doplnit kontextové odkazy.");
						return "";
					}
					return "[url=" + reference[kam].base + "]" + kam + "[/url]";
				}
				if(text.trim() == "?")
				{
					if(ticho) return "Ukáže seznam dostupných kontextových odkazů.";
					if(!reference[kam].list)
					{
						alert("Tento typ nemá kontextové odkazy zadané výčtem. Zkuste si nějaké slovo tipnout a třeba se trefíte.");
						return "";
					}

					var v = [];
					for(n in reference[kam].list) v.push(n + " ——> " + reference[kam].list[n]);
					v.sort();

					var text = "Dostupné kontextové odkazy" + (reference[kam].base ? " na „" + kam + "“ <" + reference[kam].base + ">" : "") + ":";
					var str = 25;
					var l = Math.ceil(v.length / str);
					for(var i = 0; i < l; i++)
					{
						alert(text + (l > 1 ? " (část " + (i + 1) + "/" + l + ")" : "") + "\n\n" + v.slice(i * str, (i + 1) * str).join("\n"));
					}
					return "";
				}
	
				var chyby = [];
	
				var ochranaBB = [];
				text.replace(/\[url[^\]]*\].*?\[\/url\]|\[img(?:left|right)?\].*?\[\/img\]|\[\/?(?:[bi]|hr|del|edit|small|pre[a-z]*|img(?:left|right)?|mod|url(?:\=[^\]]+)?)\]/gi, function(m, index)
				{
					for(var i = 0; i < m.length; i++) ochranaBB[index + i] = true;
					return m;
				});

				var ochranaMinislov = false;
				if((/[-_a-z0-9áäéëěíóöôúůüýčďňŕřšťžĺľ]{2,}/i).test(text)) ochranaMinislov = true;

				var uzBylo = {};
				text = text.replace(/[-_a-z0-9áäéëěíóöôúůüýčďňŕřšťžĺľ]+/gi, function(m, index)
				{
					if(ochranaBB[index]) return m;
					if(m.length == 1 && ochranaMinislov && (/\s.\s/).test((" " + text + " ").substr(index, 3))) return m;

					if(uzBylo[m]) return m; else uzBylo[m] = true;
					var uri = proTextareu.kontextovyOdkazNajdi(kam, m);
					if(uri)
					{
						if(uzBylo[uri]) return m; else uzBylo[uri] = true;
						return "[url=" + uri + "]" + m + "[/url]";
					}
					chyby.push(m);
					return m;
				});

				return text;
			};
		},
		text: function(co, cursor)
		{
			return [co.toString(), cursor];
		},
		odkaz: function(kam, popis)
		{
			return function(text, nazev)
			{
				if(text)
					return "[url=" + kam + "]" + text.replace(/\[url[^\]]*\]|\[\/url\]/gi, "") + "[/url]";
				else
					return ["[url=" + kam + "]" + (popis || nazev) + "[/url]", [6 + kam.length, (popis || nazev).length]];
			};
		},
		jmeno: function(jmeno)
		{
			return function(text, nazev)
			{
				if(text == "re" || text == "ri" || text == "4")
				{
					var jmeno4 = "[b]" + jmeno.replace(/([^\s_]{2,}?)([aeou]y|us|e[kcl]|[aoýxsjcčřžšiyíwrtpdfghklzvbnmů])(\d*(?:$|\s|_))/gi, function(m, m0, m1, m2)
					{
						return m0 + ({"ay": "aye", "ey": "eye", "oy": "oye", "uy": "uye", "us": "a", "ek": "ka", "el": "la", "ec": "ce", "a": "u", "o": "a", "ý": "ého"}[m1.toLowerCase()] || m1 + ({"x": "e", "s": "e", "j": "e", "c": "e", "č": "e", "ř": "e", "ž": "e", "š": "e", "i": "ho", "y": "ho", "í": "ho"}[m1.toLowerCase()] || "a")) + m2;
					}) + "[/b]";
					return text != "ri" ? text != "re" ? jmeno4 : "Reakce na " + jmeno4 + ":\n" : "Reaguji na " + jmeno4 + ":\n";
				}
				if(text == "o" || text == "om" || text == "3")
				{
					var jmeno3 = "[b]" + jmeno.replace(/([aýoiyíxsjcčřžwrtpdfghklzvbnmů])(\d*(?:$|\s))/gi, function(m, m1, m2)
					{
						return ({"a": "ovi", "ý": "ému"}[m1.toLowerCase()] || m1 + ({"o": "vi", "i": "mu", "y": "mu", "í": "mu"}[m1.toLowerCase()] || "ovi")) + m2;
					}) + "[/b]";
					return text != "om" ? text != "o" ? jmeno3 : "Odpověď " + jmeno3 + ":\n" : "Odpovídám " + jmeno3 + ":\n";
				}
				return "[b]" + jmeno + "[/b]";
			};
		},
		seznam: function(format)
		{
			return function(text)
			{
				var m, pocet = 10;
				if(m = text.match(/^\s*(\d+)\s*$/))
				{
					pocet = Math.min(parseInt(m[1]), 50);
					text = null;
				}
				if(text)
				{
					var lines = text.split("\n"), j = 1;
					for(var i = 0; i < lines.length; i++)
					{
						lines[i] = lines[i].trim();
						if(lines[i]) lines[i] = format.replace(/1/g, j++) + lines[i].replace(listRegExp, "$3$4");
					}
					return lines.join("\n");
				}
				else
				{
					var lines = [];
					for(var i = 0; i < pocet; i++)
					{
						lines[i] = format.replace(/1/g, i + 1);
					}
					return [lines.join("\n"), lines[0].length];
				}
			}
		},
		typografie: function()
		{
			return function(text)
			{
				text = text.replace(/ +/, " ");
				text = text.replace(/([\.\!\?,:])(\w)/g, "$1 $2");      // doplnění mezer za .!?,:
				text = text.replace(/([^\.])\.\.\.([^\.])/g, "$1…$2");  // trojtečka
				text = text.replace(/([\?\!]){3,}/g, "$1");             // zredukování otazníků a vykřičníků
				text = text.replace(/\s*([\.\!\?,:])/g, "$1");          // likvidace mezer před .!?,:
				text = text.replace(/([^\s]):(\-?[\)\(\/Dp])/g, "$1 :$2");      // odlepení smajlíků přilepených likvidací mezer
				text = text.replace(/([\.\!\?]\s*|\n|^)[a-z]/g, function(m) { return m.toUpperCase(); }); // velké písmeno na začátku věty/řádku
		
				// zkratky psané velkými písmeny
				text = text.replace(/\b(x?html|css|js|asp|php|ie|ff|d?jpw)\b/gi, function(m) { return m.toUpperCase(); });
				return text;
			};
		},
		malaPismena: function()
		{
			return function(text) { return text.toLowerCase(); }
		},
		blokovaCitace: function()
		{
			return function(text) { return getBlockQuote(text, true); };
		},
		zamezitFormatovani: function()
		{
			return function(text, nazev, ticho)
			{
				if(ticho) return "";
				if(!text)
				{
					alert("Označte text, u kterého si přejete ošetřit BB-značky, aby se neinterpretovaly.");
					return "";
				}
				return fixBB(text);
			};
		},
		hromadneNahrazeni: function()
		{
			return function(text, nazev, ticho)
			{
				if(ticho) return "";
				if(!text)
				{
					alert("Označte text, který si přejete hromadně nahradit.");
					return "";
				}
				var textarea = document.forms["edit_p"].elements["detail_popis"];
				var zaco = prompt("Za jaký text si přejete nahradit „" + text.replace(/[\r\n\s+]/gm, " ") + "“?", "");
				if(!zaco) return text;
				var v = textarea.value.split(text).join(zaco);
				textarea.value = "";
				return v;
			};
		},
		duplicitniVlakno: function()
		{
			return function(text)
			{
				if(!text) return ["[url=http://]Duplicitn" + (cs ? "í" : "é") + "[/url] vlákno, volámmm moderátora.", [5, 7]];
				return ["[url=" + text + "]Duplicitní[/url] vlákno, volámmm moderátora.", [6 + text.length, 10]];
			};
		},
		hledaPoprve: true,
		hledat: function(kde, parametr)
		{
			var moment = "(moment, hledá se)";
			return function(text, nazev, ticho)
			{
				if(ticho) return "";
				if(text == moment) return "";
				var start = 0;
				text = text.replace(/(?:\(\s*(\d+)\s*\)|\[\s*(\d+)\s*\])\s*$/, function(m, m1, m2) { start = Math.max(parseInt(m1 || m2) || 0, 1) - 1; return ""; } );
				text = text.trim().replace(/\s+/, " ");
				text = text.replace(/\[\/?([bi]|del|small|pre[a-z]*|img(left|right)?|hr|mod|url(\=[^\]]+)?)\]/gi, "");
				if(!text)
				{
					alert("Označte text, který si přejete použít jako dotaz při vyhledávání.");
					return "";
				}

				var s = document.createElement("script");
				var tac = getTextareaSelection({ context: true });
				var callback = function(vloz, oznac)
				{
					document.body.removeChild(s);

					var tac2 = getTextareaSelection({ context: true });
					if(tac2[1] == moment)
					{
						insertText(vloz, oznac);
					}
					else
					{
						document.forms["edit_p"].elements["detail_popis"].value = tac[0] + vloz + tac[2];
					}
				};
				var expandEntities = function(html)
				{
					return html.replace(/&([^;]+);/g, function(m, m1)
					{
						return {"lt": "<", "gt": ">", "amp": "&", "quot": "\""}[m1] || String.fromCharCode(parseInt(m1.substr(1)));
					});
				};

				window.jsonCallback = {
					"diskuse": function(data)
					{
						var oznac = [0, text.length];
						if(data.responseStatus != 200)
						{
							alert("Došlo k chybě: „" + data.responseDetails + "“.");
							callback(text, oznac);
							return;
						}
						if(!data.responseData.results.length)
						{
							alert("Nic nenalezeno.");
							callback(text, oznac);
							return;
						}
						var v = [];
						var uzBylo = {};
						for(var i = 0, r; r = data.responseData.results[i]; i++)
						{
							var uri = orezAdresu(r.unescapedUrl, true);
							if(uzBylo[uri]) continue; else uzBylo[uri] = true;
							v.push("• [url=" + uri + "]" + expandEntities(orezTitulek(r.titleNoFormatting)) + "[/url]\n");
						}
						var vv = v.join("");
						callback(vv + text, [vv.length, text.length]);
						if(proTextareu.hledaPoprve && v.length > 3)
						{
							proTextareu.hledaPoprve = false;
							setTimeout(function()
							{
								alert("Prověřte prosím před odesláním, zda jsou všechny uvedené výsledky skutečně k tématu.\n\n(Na rozkliknutí odkazu v rozepsaném příspěvku využijte zkratku Ctrl+Enter.)");
							}, 100);
						}
					},
					"google": function(data)
					{
						// http://code.google.com/apis/ajaxsearch/documentation/reference.html

						if(data.responseStatus != 200)
						{
							callback("(chyba)");
							return;
						}
						var v = [];
						v.push("Výsledky " + (cs ? "hledání" : "hľadanie") + " „[url=" + data.responseData.cursor.moreResultsUrl + "]" + text + "[/url]“ v Googlu:");
						if(data.responseData.results.length)
						{
							v.push("\n[hr]");
							for(var i = 0, r; r = data.responseData.results[i]; i++)
							{
								v.push(" " + (i + 1) + " • [url=" + r.unescapedUrl + "]" + expandEntities(r.title.replace(/<(\/)?b>/g, "[$1b]")) + "[/url]\n");
							}
						}
						else
						{
							v.push(" Nic.");
						}
						v.push("\n");
						callback(v.join(""));
					},
					"wikipedia": (function(jazyk)
					{
						return function(data)
						{
							var titulek;
							if(!data.query) return;
							for(var n in data.query.pages) titulek = data.query.pages[n].title;
							callback("[url=http://" + jazyk + ".wikipedia.org/wiki/" + titulek.replace(/\s/g, "_") + "]" + titulek + "[/url]");
						};
					})(parametr)
				}[kde];
				s.charset = "utf-8";
				s.src = {
					"google": "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=" + encodeURIComponent(text) + "&hl=cs&rsz=large" + (parametr ? "&lr=" + encodeURIComponent(parametr) : ""),
					"diskuse": "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=" + encodeURIComponent(text + " site:diskuse.jakpsatweb.cz inurl:vthread") + "&hl=cs&rsz=large&start=" + start * 8,
					"wikipedia": "http://" + parametr + ".wikipedia.org/w/api.php?action=query&titles=" + encodeURIComponent(text) + "&format=json&redirects=1"
				}[kde] + "&callback=jsonCallback";
				
				document.body.appendChild(s);

				return [moment, [0, moment.length]];
			};
		}
	};

	var sestavMapu = function(fce)
	{
		return {
			"":
			[
			    "odkazy",
			    "JPW",
			    "diskuse",
			    "fráze",
			    "funkce"
			],
			"JPW":
			[
			    "HTML",
			    "CSS",
			    "JavaScript",
			    ["Základní kurz",                        fce.odkaz("http://www.jakpsatweb.cz/navigace/zakladni-kurz.html")],
			    ["Skládání z kousků",                    fce.odkaz("http://www.jakpsatweb.cz/include.html", "Skládání stránek z kousků")],
			    ["Na co čeká",                           fce.odkaz("http://www.jakpsatweb.cz/clanky/na-co-stranka-ceka.html", "Na co stránka při vykreslování čeká")],
			    ["~ JPW",                                fce.kontextovyOdkaz("Jak psát web")]
			],
			"HTML":
			[
			    ["Úvod",                                 fce.odkaz("http://www.jakpsatweb.cz/html/", "HTML na JPW")],
			    ["Základy",                              fce.odkaz("http://www.jakpsatweb.cz/zaklady-html.html", "Základy HTML")],
			    ["Syntaxe",                              fce.odkaz("http://www.jakpsatweb.cz/html/syntaxe.html", "Syntaxe HTML")],
			    ["Čeština",                              fce.odkaz("http://www.jakpsatweb.cz/cestina.html")],
			    ["Struktura dokumentu",                  fce.odkaz("http://www.jakpsatweb.cz/html/struktura.html")],
			    ["&lt;div> a &lt;span>",                 fce.odkaz("http://www.jakpsatweb.cz/div-span.html", "<div> a <span>")],
			    ["Nevýhody rámů",                        fce.odkaz("http://www.jakpsatweb.cz/ramy-problemy.html")]
			],
			"CSS":
			[
			    ["Úvod",                                 fce.odkaz("http://www.jakpsatweb.cz/css/", "CSS na JPW")],
			    ["Módy prohlížečů",                      fce.odkaz("http://www.jakpsatweb.cz/css/mody-prohlizecu.html")],
			    ["Box model",                            fce.odkaz("http://www.jakpsatweb.cz/okraje.html")],
			    ["Třídy a identifikátory",               fce.odkaz("http://www.jakpsatweb.cz/css/css-tridy-class.html")],
			    ["Hacky",                                fce.odkaz("http://www.jakpsatweb.cz/css/css-prohlizece-hacky.html")]
			],
			"JavaScript":
			[
			    ["Úvod",                                 fce.odkaz("http://www.jakpsatweb.cz/javascript/", "JavaScript na JPW")],
			    ["Příklady",                             fce.odkaz("http://www.jakpsatweb.cz/javascript/priklady/index.html", "JavaScriptové příklady")],
			    ["Začlenění",                            fce.odkaz("http://www.jakpsatweb.cz/javascript/zacleneni.html", "Začlenění skriptu do stránky")],
			    ["Časování",                             fce.odkaz("http://www.jakpsatweb.cz/javascript/casovani.html")],
			    ["Nové okno",                            fce.odkaz("http://www.jakpsatweb.cz/javascript/window.open.html")]
			],
			"odkazy":
			[
			    "finty v CSS",
			    "ladění CSS",
			    "taje HTML",
			    "sémantika",
			    ["Uvozovky",                             fce.odkaz("http://tiso.wz.cz/articles/uvodzovky.php", "Úvodzovky")],
			    "inspirace",
			    "nástroje",
			    "JS",
			    "PHP",
			    "W3C"
			],
			"finty v CSS":
			[
			    "knihovna",
			    ["Vodorovné centrování",                 fce.odkaz("http://tiso.wz.cz/articles/vycentrovanie-obsahu-stranky.php")],
			    ["Svislé centrování",                    fce.odkaz("http://klient.plavacek.net/centrovani.html")],
			    ["Patička vždy dole",                    fce.odkaz("http://weblog.plavacek.net/2005-02.html#1108716997")],
			    ["Překrytí textu obrázkem",              fce.odkaz("http://wellstyled.com/css-replace-text-by-image.html")],
			    ["Změna obrázku po najetí myši",         fce.odkaz("http://diskuse.jakpsatweb.cz/?action=vthread&forum=4&topic=62224")],
			    ["Stylování formulářů",                  fce.odkaz("http://latrine.dgx.cz/jeste-dokonalejsi-stylovani-formularu")],
			    ["Float a clear",                        fce.odkaz("http://www.pixy.cz/pixylophone/2003_12_archiv.html#1071056082", "Jak funguje „float“ a „clear“")]
			],
			"knihovna":
			[
			    ["Úvod",                                 fce.odkaz("http://css.interval.cz/", "CSS Knihovna na Intervalu")],
			    ["Menu",                                 fce.odkaz("http://css.interval.cz/menu/", "Menu v CSS Knihovně")],
			    ["Layouty",                              fce.odkaz("http://css.interval.cz/layouty/", "Layouty v CSS Knihovně")]
			],
			"inspirace":
			[
			    ["Trendy",                               fce.odkaz("http://www.webdesignerwall.com/category/trends/", "Trendy na webdesignerwall.com")],
			    ["Seznam galerií",                       fce.odkaz("http://css-galerie.tomcik.cz/")],
			    ["Použití a definice fontů",             fce.odkaz("http://www.dgx.cz/tools/fonts/", "Fontotéka")]
			],
			"nástroje":
			[
			    ["Firebug",                              fce.odkaz("http://addons.mozilla.org/en-US/firefox/addon/1843")],
			    ["Fiddler",                              fce.odkaz("http://www.fiddler2.com/Fiddler2/version.asp")],
			    ["Web-Sniffer",                          fce.odkaz("http://web-sniffer.net/")],
			    ["Pingdom",                              fce.odkaz("http://tools.pingdom.com/fpt/")]
			],
			"taje HTML":
			[
			    ["Podmíněné komentáře",                  fce.odkaz("http://www1.mraveniste.org/weblog/2006/03/16-msie-komentare.html")],
			    ["Jak funguje HTML",                     fce.odkaz("http://atd.havrlant.net/jak-funguje-html")]
			],
			"sémantika":
			[
			    ["~ Sémantika.name",                     fce.kontextovyOdkaz("Sémantika.name")],
			    ["Fekální styl",                         fce.odkaz("http://semantika.name/fekalni-styl.html")],
			    ["Desatero",                             fce.odkaz("http://semantika.name/desatero-semantickeho-webu.html", "Desatero sémantického webu")],
			    ["Plaváčkovy formuláře",                 fce.odkaz("http://www.plavacek.net/formulare/")]
			],
			"JS":
			[
			    ["Universální fce pro AJAX",             fce.odkaz("http://citron.blueboard.cz/clanek-270-univerzalni-funkce-pro-ajax.html", "Univerzální funkce pro AJAX")],
			    ["Antispam",                             fce.odkaz("http://diskuse.jakpsatweb.cz/?action=vthread&forum=18&topic=27573", "Zdejší antispam")],
			    ["&lt;iframe&gt; s pružnou výškou",      fce.odkaz("http://teststranek.kvalitne.cz/iframe2/", "<iframe> s pružnou výškou")],
			    ["Problémy s getAttribute/setAttribute", fce.odkaz("http://diskuse.jakpsatweb.cz/?action=vthread&forum=8&topic=90307")],
			    ["~ MDC",                                fce.kontextovyOdkaz("MDC – JavaScript")]
			],
			"ladění CSS":
			[
			    ["Box model",                            fce.odkaz("http://ie-brouci.dero.name/box-model.html")],
			    ["Selector Shell",                       fce.odkaz("http://selector-shell.appspot.com/")],
			    ["Zdvojený margin",                      fce.odkaz("http://ie-brouci.dero.name/double-margin.html")],
			    ["Peekaboo",                             fce.odkaz("http://ie-brouci.dero.name/peekaboo.html")],
			    ["3px",                                  fce.odkaz("http://ie-brouci.dero.name/3px-bug.html")],
			    ["Alfakanál PNG",                        fce.odkaz("http://www.twinhelix.com/test/iepngfix.zip")]
			],
			"PHP":
			[
			    ["~ PHP.net",                            fce.kontextovyOdkaz("PHP")],
			    ["Seriál",                               fce.odkaz("http://www.linuxsoft.cz/php/", "Seriál o PHP")],
			    ["Knihy o OOP",                          fce.odkaz("http://diskuse.jakpsatweb.cz/?action=vthread&forum=15&topic=76122", "OOP a jeho použití v PHP - přehled studijních pramenů")],
			    ["Oddiakritizování",                     fce.odkaz("http://latrine.dgx.cz/odstraneni-diakritiky-z-ruznych-kodovani", "Odstranění diakritiky z různých kódování")],
			    ["Přátelské URL",                        fce.odkaz("http://php.vrana.cz/vytvoreni-pratelskeho-url.php", "Vytvoření přátelského URL")],
			    ["mod_rewrite",                          fce.odkaz("http://mike.treba.cz/mod_rewrite-a-hezke-url/")],
			    ["Traverzování kolem stromu",            fce.odkaz("http://php.vrana.cz/traverzovani-kolem-stromu-prakticky.php")],
			    ["Sessions",                             fce.odkaz("http://www.linuxsoft.cz/article.php?id_article=440")],
			    ["Upload/download",                      fce.odkaz("http://www.linuxsoft.cz/article.php?id_article=310", "Upload a download souborů")],
			    ["Pole",                                 fce.odkaz("http://www.linuxsoft.cz/article.php?id_article=179")]
			],
			"W3C":
			[
			    "validita",
			    "specifikace",
			    ["Diskuse o XHTML",                      fce.odkaz("http://diskuse.jakpsatweb.cz/?action=vthread&forum=10&topic=11358", "Výhody XHTML oproti HTML")]
			],
			"validita":
			[
			    ["Český validátor",                      fce.odkaz("http://validator.w3.cz")],
			    ["W3C HTML Validátor",                   fce.odkaz("http://validator.w3.org")],
			    ["W3C CSS validátor",                    fce.odkaz("http://jigsaw.w3.org/css-validator/")]
			],
			"specifikace":
			[
			    ["~ HTML 4.01",                          fce.kontextovyOdkaz("HTML 4.01")],
			    ["~ CSS 2.1",                            fce.kontextovyOdkaz("CSS 2.1")],
			    ["~ HTML 5",                             fce.kontextovyOdkaz("HTML 5")]
			],
			"fráze":
			[
			    ["Živá ukázka",                          fce.text(cs ? "Prosím o odkaz na živou ukázku." : "Prosím o odkaz na živú ukážku.")],
			    ["Rozbité",                              fce.text("Máš to [url=http://www.it-joker.cz/Pocitace-weby/67-Nefunguje-to--aneb-jak-napsat-dotaz.html]rozbité[/url].")],
			    ["Duplicitní vlákno",                    fce.duplicitniVlakno()],
			    "přepínače režimů",
			    ["&lt;mimo-téma>",                       fce.text(cs ? "<mimo-téma>\n\n</mimo-téma>" : "<mimo-tému>\n\n</mimo-tému>", 12)]
			],
			"přepínače režimů":
			[
			    ["Standard (HTML 4)",                    fce.text("[prehtml]<!doctype html public \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">[/pre]")],
			    ["Standard (HTML 5)",                    fce.text("[prehtml]<!doctype html>[/pre]")],
			    ["Quirk",                                fce.text("[prehtml]<!doctype html public \"-//W3C//DTD HTML 4.01 Transitional//EN\">[/pre]")],
			    ["Explorer 8 jako 7",                    fce.text("[prehtml]<meta http-equiv=\"X-UA-Compatible\" content=\"IE=EmulateIE7\">[/pre]")]
			],
			"funkce":
			[
			    "seznamy",
			    ["Hromadné nahrazení",                   fce.hromadneNahrazeni()],
			    ["Na malá písmena",                      fce.malaPismena()],
			    ["Bloková citace",                       fce.blokovaCitace()],
			    ["Zamezit BB formátování",               fce.zamezitFormatovani()],
			    "hledání"
			],
			"seznamy":
			[
			    ["Závorkovaný",                          fce.seznam("1) ")],
			    ["Tečkovaný",                            fce.seznam("1. ")],
			    ["Mistrovský",                           fce.seznam("(1) ")],
			    ["Lomítkový",                            fce.seznam("1/ ")],
			    ["Pomlčkový",                            fce.seznam("– ")],
			    ["Puntíkatý",                            fce.seznam("• ")]
			],
			"hledání":
			[
			    ["Googlem (cs+sk)",                      fce.hledat("google", "lang_cs|lang_sk")],
			    ["Googlem (en)",                         fce.hledat("google", "lang_en")],
			    ["Googlem na diskusi",                   fce.hledat("diskuse")],
			    ["Na Wikipedii (en)",                    fce.hledat("wikipedia", "en")],
			    ["Na Wikipedii (cs)",                    fce.hledat("wikipedia", "cs")]
			],
			"moderování":
			[
			    ["Diakritika",                           fce.text("\n[mod]Tvůj projev je špatně srozumitelný, piš prosím s diakritikou.[/mod]")],
			    ["Nadepisujte názvem/adresou",           fce.text("\n[mod][url=http://diskuse.jakpsatweb.cz/?action=vthread&forum=2&topic=77255]Téma nadepisujte názvem/adresou webu[/url].[/mod]")],
			    ["Užívej [pre]",                         fce.text("\n[mod]Vkládej prosím kódy mezi značky [[b]pre[/b]] a [[b]/pre[/b]] (stačí kliknout na [img]http://diskuse.jakpsatweb.cz/img/button_code.gif[/img]).[/mod]")]
			],
			"pravidla":
			[
			    ["Pravidla",                             fce.odkaz("http://diskuse.jakpsatweb.cz/rules.htm")],
			    ["Práce a zakázky",                      fce.odkaz("http://diskuse.jakpsatweb.cz/?action=vthread&forum=26&topic=18527", "Pravidla pro kategorii Práce a zakázky")],
			    ["Zákaz dražeb",                         fce.odkaz("http://diskuse.jakpsatweb.cz/?action=vthread&forum=26&topic=46826", "Dražby nejsou povoleny")],
			    ["Hosting",                              fce.odkaz("http://diskuse.jakpsatweb.cz/?action=vthread&forum=6&topic=59416", "Pravidla pro sebepropagaci v kategorii Hosting")],
			    ["Názor na stránku",                     fce.odkaz("http://diskuse.jakpsatweb.cz/?action=vthread&forum=2&topic=3811", "Než vložíte své stránky do diskuze")]
			],
			"diskuse":
			[
			    "pravidla",
			    ["Vir",                                  fce.odkaz("http://diskuse.jakpsatweb.cz/?action=vthread&forum=1&topic=96004", "Máte na webu virus — co s tím?")],
			    ["Rady prvopisatelům",                   fce.odkaz("http://diskuse.jakpsatweb.cz/?action=vthread&forum=1&topic=23882", "Než založíte nové téma, přečtěte si!")],
			    ["Nejčastější chyby webů",               fce.odkaz("http://diskuse.jakpsatweb.cz/?action=vthread&forum=2&topic=3670", "Nejčastější chyby na webu")],
			    ["SEO FAQ",                              fce.odkaz("http://diskuse.jakpsatweb.cz/?action=vthread&forum=13&topic=8786", "SEO – Často kladené dotazy")],
			    ["MySQL FAQ",                            fce.odkaz("http://diskuse.jakpsatweb.cz/?action=vthread&forum=28&topic=37836", "Některé časteji řešené dotazy pro MySQL")],
			    "PHP FAQ"
			],
			"PHP FAQ":
			[
			    ["Nejčastější potíže",                   fce.odkaz("http://diskuse.jakpsatweb.cz/?action=vthread&forum=9&topic=2111", "Nejčastější potíže s PHP")],
			    ["Knihy o OOP",                          fce.odkaz("http://diskuse.jakpsatweb.cz/?action=vthread&forum=15&topic=76122", "OOP a jeho použití v PHP - přehled studijních pramenů")]
			]
		};
		/*
			Další kandidáti:
			    ["OOP",                                  fce.odkaz("http://clanky.havrlant.net/oop/")]
		*/
	};
	
	var mapa = sestavMapu(proTextareu);
	mapa["zdejší jména"] = [];

	var mapaKuk;
	var vMape = null;

	this.kontextovyOdkaz = function(kam)
	{
		var text = getTextareaSelection({ type: "word" });
		insertText(proTextareu.kontextovyOdkaz(kam)(text));
	};
	this.hledat = function(kde)
	{
		var text = getTextareaSelection({ type: "line" });
		var r = proTextareu.hledat(kde)(text);
		insertText(r[0], r[1]);
	};

	var konec = function()
	{
		mapaKuk.innerHTML = "";
		vMape = null;
		window.status = "";
	};

	var textareaSelection = "";
	var vyber = function(co, ticho)
	{
		if(typeof co == "string")
			return [co];
		else
		{
			if(typeof co[1] != "function")
				return co[1];
			else
			{
				var insert = co[1](textareaSelection, co[0], ticho);
				if(typeof insert == "string")
					return [insert, co[2]];
				else
					return insert;
			}
		}
	};

	this.vykonej = function()
	{
		if(vMape)
		{
			var vybrane = mapa[vMape.misto][vMape.rotace];
			konec();
			if(vybrane && !mapa[vybrane])
			{
				var r = vyber(vybrane, false);
				insertText(r[0], r[1])
			}
		}
	};

	this.naviguj = function(key)
	{
		if(!vMape)
		{
			if(key != 40) return (key != 38);
			textareaSelection = getTextareaSelection({ type: "word" });
			vMape = { misto: "", rotace: 0, cesta: [] };
		}
		else
		{
			if(key == 37 || key == 39)
			{
				vMape.rotace = (vMape.rotace + key - 38 + mapa[vMape.misto].length) % mapa[vMape.misto].length;
			}
			else if(key == 40)
			{
				if(mapa[mapa[vMape.misto][vMape.rotace]])
				{
					vMape.cesta.push([vMape.misto, vMape.rotace]);
					vMape.misto = mapa[vMape.misto][vMape.rotace];
					vMape.rotace = 0;
				}
			}
			else
			{
				var p = vMape.cesta.pop();
				if(!p)
				{
					konec();
					return false;
				}
				vMape.misto = p[0];
				vMape.rotace = p[1];
			}
		}

		var kuk = [];
		for(var i = 0; i < mapa[vMape.misto].length; i++)
		{
			var j = i;
			var k = "<span class=\"klavmapa-polozka\">" + ((typeof mapa[vMape.misto][j] == "string") ? mapa[vMape.misto][j] : mapa[vMape.misto][j][0]) + "</span>";
			if(mapa[mapa[vMape.misto][j]])
			{
				k = "<b>" + k + "</b>";
			}
			if(i == vMape.rotace)
			{
				k = "<u>" + k + "</u>";
				var vybrane = mapa[vMape.misto][i];
				window.status = (vybrane && !mapa[vybrane]) ? vyber(vybrane, true)[0] : "";
			}
			kuk.push(k);
		}
		if(!kuk.length) kuk.push("<i>(nic)</i>");

		var kukHTML = "";
		for(var i = 1; i <= (vMape.cesta.length || 1); i++)
		{
			kukHTML += "/<b>" + (vMape.cesta[i] || [vMape.misto || ""])[0] + "</b>";
		}
		
		mapaKuk.innerHTML = "<span class=\"klavmapa\"><span class=\"klavmapa-cesta\">" + kukHTML + "</span> <b class=\"klavmapa-separator\"> » </b> " + kuk.join("<span class=\"klavmapa-puntik\"> · </span>") + "</span>";
		return false;
	};

	this.init = function(param)
	{
		if(!document.forms["edit_p"]) return;
		mapaKuk = document.getElementById("popis_stylu");

//		TODO: Vyrobit frázi popisující aktuálně užívaný prohlížeč
//		mapa["fráze"].push(["Prohlížeč a rozlišení", "Mám Fytopuf 4.0, 2560×1600"]);

		if(param.moderator)
		{
			mapa[""].reverse();
			mapa[""].push("moderování");
			mapa[""].reverse();

			mapa["moderování"].push(["Špatný titulek", proTextareu.text("\n[mod]Titulek „" + orezTitulek(document.title) + "“ nevystihuje podstatu dotazu. Příště zkus prosím vymyslet lepší.[/mod]")]);

			var presunutoZ = "[mod]Přesunuto z [url=" + orezAdresu(location.href) + "]" + orezTitulek(document.title);
			presunutoZ += "[/url]" + (presunutoZ.match(/[\.\?\!…]$/i) ? "" : ".");
			presunutoZ += "[/mod]\n";
			mapa["moderování"].push(["Přesunuto", proTextareu.text(presunutoZ)]);
		}

		var tab = document.getElementById("prispevky");
		if(!tab) return;

		// tvorba seznamu jmen z této stránky
		var jmena = {};
		var radky = tab.getElementsByTagName("tr");
		mapa[""].push("zdejší jména");

		if(document.getElementById("user_usr") && document.getElementById("user_usr").tagName != "INPUT")
		{
			jmena[orezJmeno(document.getElementById("user_usr").innerHTML)] = true;
		}
	  	for(var i = radky.length - 1; i > 0; i--)
		{
			var jmeno = radky[i].getElementsByTagName("td")[0].getElementsByTagName("b")[0];
			if(!jmeno) continue;

			if(!jmena[orezJmeno(jmeno.innerHTML)])
			{
				jmena[orezJmeno(jmeno.innerHTML)] = true;
				mapa["zdejší jména"].push([orezJmeno(jmeno.innerHTML), proTextareu.jmeno(orezJmeno(jmeno.innerText))]);
			}
		};
	};


	this.napoveda = function(fce)
	{
		var koa = ["<dl class=\"napoveda-ko\">"];
		var koid = function(t){ return t.replace(/[\Waeiouy]/gi, "") };
		for(var r in reference)
		{
			koa.push("<dt id=\"" + r.replace(/\W/gi, "") + "\"></a>" + r + "");
			if(reference[r].base)
			{
				koa.push("<dd>Základní adresa: <a href=\"" + reference[r].base + "\">" + reference[r].base + "</a>.");
			}
			if(reference[r].info)
			{
				koa.push("<dd>" + reference[r].info);
			}
			if(reference[r].group)
			{
				koa.push("<dd>Začleněné množiny: ");
				var g = [];
				for(var i = 0; i < reference[r].group.length; i++)
				{
					g.push("<a href=\"#" + reference[r].group[i].replace(/\W/gi, "") + "\">" + reference[r].group[i] + "</a>");
				}
				koa.push(g.join(", ") + ".");
			}
			if(reference[r].list)
			{
				koa.push("<dd>Slova: ");
				var li = [];
				for(var l in reference[r].list)
				{
					li.push("<!--" + l + "--><a href=\"" + (reference[r].base || "") + reference[r].list[l] + "\">" + l + "</a>");
				}
				li.sort();
				koa.push(li.join(", ") + ".");
			}

		}
		koa.push("</dl>");
		
		var nm = sestavMapu(fce);

		var ma = ["<table class=\"napoveda-mapa\">"];
		ma.push("<tr><th>Příkaz v mapě<th>Co vloží/udělá");
		var vypsat = function(vetev, odsad)
		{
			for(var i = 0; i < nm[vetev].length; i++)
			{
				if(typeof nm[vetev][i] == "string")
				{
					ma.push("<tr><td colspan=\"2\" class=\"s-podvetvemi\"><span>" + odsad + "</span><b>" + nm[vetev][i] + "</b>");
					vypsat(nm[vetev][i], "     " + odsad);
				}
				else
				{
					ma.push("<tr><td class=\"podvetev\"><span>" + odsad + "</span>" + nm[vetev][i][0]);
					ma.push("<td>" + nm[vetev][i][1]);
				}
			}
		}
		vypsat("", "• ");
		ma.push("</table>");

		return { mapa: ma.join(""), kontextovyOdkaz: koa.join("") };
		
	};

})();
inits.push(klavesovaMapa.init);



/* ======================================== *
 * === Klávesové zkratky pro <textarea> === *
 * ======================================== */

function orezTitulek(t)
{
	return t.replace(/^'?Diskuse:\s+(.*?)\s*\*?(\s+\(\d+\))?$/, "$1");
}
function orezAdresu(a, iStranu)
{
	if(iStranu) a = a.replace(/&page=\-?\d+/g, "");
	return a.replace(/index\.php|&page=(?:-1|0)|\/\.sandbox|\#roluj\(\d+\)/g, "").replace(/(&topic=\d+)(&forum=\d+)/, "$2$1");
}
function orezJmeno(j)
{
	return j.replace(/_$/, "");
}

function tabovani(key, shift)
{
	var text = "";
	if(key == 9) text = getTextareaSelection({ expand: true, allowEmpty: true, type: "line", trim: /\n+$/g });
	if(!text)
	{
		var tac = getTextareaSelection({ context: true });
		var m = tac[0].substr((tac[0] + tac[2].substr(0, 5)).lastIndexOf("[/pre]") + 1).match(/\[pre\w*\]/i);
		if(tac[2].indexOf("[/pre]") == -1) return false;
		if(!m) return false;
		if(key == 9)
		{
			if(shift)
			{
				if(m = tac[0].match(/(\t|  | )$/))
				{
					changeSelection([-m[0].length, m[0].length]);
					insertText("");
				}
			}
			else
			{
				insertText("  ");
			}
		}
		else
		{
			m = tac[0].match(/(?:\[pre\w*\]|\n)([\t ]*)[^\n]*$/i);
			if(!m || !m[1]) return false;
			insertText("\n" + m[1]);
		}
		return true;
	}

	if(shift)
	{
		text = text.replace(/^(\t|  | )/gm, "");
	}
	else
	{
		text = text.replace(/^/gm, "  ");
	}
	insertText(text, [0, text.length]);
	return true;
}

function klavesoveZkratky(param)
{
	document.documentElement.onkeypress = window.onkeypress = function(e)
	{
		var event = window.event || e;
		var target = event.target || event.srcElement;
		if(target.form && (target.type == "text" || target.type == "password" || target.tagName == "TEXTAREA" || target.tagName == "SELECT")) return;
		var key = (event.which + 1) ? event.which : event.keyCode;
		if(event.ctrlKey || event.altKey) return true;
		if(key > 96 && key < 123) key -= 32;

		if(key == 81)
		{
			if(!document.forms["edit_p"]) return true;
			var text = getDocumentSelection();
			if(!text) return;
			insertText(getQuote(text));
		}
		else if(key == 85 || (key == 76 && param.qstopic))
		{
			var copyText = {
				85: "[url=" + orezAdresu(location.href) + "]" + orezTitulek(document.title) + "[/url]",
				76: "http://djpw.cz/" + param.qstopic + (parseInt(param.qspage) > 0 ? "/" + (parseInt(param.qspage) + 1) : "")
			}[key];
			var showText = {
				85: "BB kód odkazu na tuto stránku",
				76: "zkrácená adresa této stránky"
			}[key];
			if(window.clipboardData)
			{
				if(!navigator.userAgent.match(/MSIE [0-6]\.\d/i) || navigator.userAgent.match(/SV1/i) || confirm("Do schránky se zkopíruje " + showText + ". Souhlasíte?"))
					clipboardData.setData("text", copyText);
			}
			else
			{
				prompt("Zde je " + showText + ":", copyText);
			}
		}
		else if(key == 82)
		{
			listuj();
		}
		else if(key == 79)
		{
			if(!document.forms["edit_p"]) return true;
			document.forms["edit_p"].elements["detail_popis"].focus();
		}
		else if(param.moderator && (key == 88 || key == 80))
		{
			var link = document.getElementById("mod-" + {80: "presunout", 88: "vymazat"}[key]);
			link.onclick();
		}
		else
			return true;
		if(event.stopPropagation) event.stopPropagation();
		return false;
	};

	if(!document.forms["edit_p"]) return;
	var textarea = document.forms["edit_p"].elements["detail_popis"];
	var CtrlJ = false;
	var tagJ = {
		82: "hr",
		68: "del",
		69: "edit",
		83: "small",
		80: "prephp",
		74: "prejs",
		72: "prehtml",
		67: "precss",
		89: "premysql",
		81: "presqlite",
		71: "prepgsql",
		65: "preapache",
		78: "prenone",
		73: "img"
	};
	var textJ = {
		37: "&larr;",
		38: "&uarr;",
		39: "&rarr;",
		40: "&darr;",
		32: " ",
		191: "—",
		45: "—"
	};
	var tagJPopis = (function()
	{
		var v = [];
		for(var n in tagJ)
		{
			var z = String.fromCharCode(n);
			v.push("[" + tagJ[n].replace(z.toLowerCase(), "<u><b>" + z + "</b></u>") + "]");
		}
		return "<span class=\"ctrl-j\">" + v.join("<span class=\"ctrl-j-puntik\"> · </span>") + "</span>";
	})();
	if(param.moderator) tagJ[70] = "font#efefef";

	textarea[window.opera ? "onkeypress" : "onkeydown"] = function(e)
	{
		var event = window.event || e;
		var key = event.keyCode;

		if(CtrlJ)
		{
			if(window.opera && !event.ctrlKey && key > 96 && key < 123) key -= 32;
			if(tagJ[key]) insertTag(tagJ[key]);
			if(textJ[key]) insertText(textJ[key]);

			document.getElementById("popis_stylu").innerHTML = "";
			CtrlJ = false;
			return false;
		}
		if((key == 9 || key == 13) && !event.ctrlKey && !event.altKey)
		{
			return !tabovani(key, event.shiftKey);
		}
		if(!event.ctrlKey || event.altKey) return true;

		var r = false;
		if(key == 66)
			insertTag("b");
		else if(key == 73)
			insertTag("i");
		else if(key == 75)
			insertLink();
		else if(key == 69)
			insertTag("pre");
		else if(key == 81)
		{
			var text = getTextareaSelection();
			if(text)
				insertText(getLineQuote(text, true));
			else
				insertText("„“", 1);
		}
		else if(key == 74)
		{
			CtrlJ = true;
			document.getElementById("popis_stylu").innerHTML = tagJPopis;
		}
		else if(key == 77)
		{
			if(!param.moderator)
				insertText("mmm");
			else
				insertTag("mod");
		}
		else if(key >= 37 && key <= 40)
		{
			r = klavesovaMapa.naviguj(key);
		}
		else if(key == 190 || (key == 46 && window.opera))
		{
			klavesovaMapa.kontextovyOdkaz("Vše");
		}
		else if(key == 71)
			klavesovaMapa.hledat("diskuse");
		else if(key == 13)
		{
			var uri = getTextareaSelection({ type: "url", expand: true });
			if(uri)
			{
				uri = uri.replace(/^http:\/\/diskuse\.jakpsatweb\.cz\/(index\.php)?\?/, "?");
				if(window.opera || navigator.userAgent.match(/MSIE [0-6]\.\d/i))
				{
					window.open(uri, "_blank");
				}
				else
				{
					var klik = document.createElement("a");
					klik.href = uri;
					klik.target = "_blank";
					textarea.parentNode.insertBefore(klik, textarea);
					klik.focus();
					klik.onclick = function()
					{
						textarea.focus();
						setTimeout(function()
						{
							klik.parentNode.removeChild(klik);
						}, 1);
					};
					r = true;
				}
			}
		}
		else
			r = true;

		return r;
	};
	textarea.onkeyup = function(e)
	{
		var event = window.event || e;
		if(event.keyCode == 17) klavesovaMapa.vykonej();
	};
	textarea.onblur = function()
	{
		klavesovaMapa.vykonej();
	};
}
inits.push(klavesoveZkratky);



/* ========================================== *
 * === Transplantace editačního formuláře === *
 * ========================================== */

function transplantaceEditace(param)
{
	var f = document.forms["edit_p"];
	var tab = document.getElementById("prispevky");
	if(!f || !tab) return;
	var naNazev = f.getElementsByTagName("p")[1], naNazevHTML = naNazev.innerHTML, naNazevClass = naNazev.className, proNavrat, proNavratHTML, proNavratClass;
	var puvodniText = "", puvodniDefaultText = "";
	var rodic = f.parentNode;

	var edited = null;
	var block = false;
	var getEditForm = function(el)
	{
		if(f.className.match(/(^|\s+)nahlizejic(\s+|$)/))
		{
			alert("Máte rozkoukaný náhled.");
			return true;
		}
		var xhr = getHttpRequest();
		if(!xhr) return false;
		if(block) return true;
		block = true;
	
		xhr.open("GET", el.href + "&rnd=" + Math.random())
		xhr.setRequestHeader("Referer", location.href);
		xhr.onreadystatechange = function()
		{
			if(xhr.readyState != 4) return;
			block = false;
			var html = xhr.responseText.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
			var m = html.match(/<textarea name="detail_popis"[^>]*>((.|\n)*?)<\/textarea>/im);
			var m2 = html.match(/<input type="text" name="postTopic"[^>]+>/im);
			if(m)
			{
				moveEditForm(el, m[1], m2 && m2[0]);
			}
			else if(html.match(/referer/i))
			{
				alert("Úprava příspěvku vyžaduje zapnutou HTTP hlavičku Referer.\n" + (window.opera ? "V nabídce „Místní nastavení“ na kartě „Připojení“ aktivujte volbu „Odesílat info o předešlé navštívené adrese“." : "Zkontrolujte prosím nastavení firewallu či prohlížeče."));
			}
		}
		xhr.send(null);
		return true;
	};

	var revert = function()
	{
		naNazev.innerHTML = naNazevHTML;
		naNazev.className = naNazevClass;
		proNavrat.innerHTML = proNavratHTML;
		proNavrat.className = proNavratClass;
		edited.className = "";
		f.onsubmit = null;
	};

	var inputs = {};
	var moveEditForm = function(el, text, postTopic)
	{
		if(edited)
		{
			if(edited == el.parentNode.parentNode)
			{
				return returnEditForm(el);
			}
			else
			{
				revert();
			}
		}
		else
		{
			puvodniText = f.elements["detail_popis"].value;
			puvodniDefaultText = f.elements["detail_popis"].defaultValue;
			f.elements["action"].value = "editmsg2";

			for(var i = 0, n; n = ["post", "anchor"][i]; i++)
			{
				inputs[n] = document.createElement("input");
				inputs[n].type = "hidden";
				inputs[n].name = n;
				inputs[n].setAttribute("name", n);
				f.appendChild(inputs[n]);
			}
		}
		edited = el.parentNode.parentNode;

		proNavrat = el;
		proNavratHTML = el.innerHTML;
		proNavratClass = el.className;
		el.innerHTML = "Zrušit úpravy a vrátit formulář";
		el.className = "edit-return";

		f.elements["detail_popis"].value = text.replace(/&(#(\d+)|lt|gt|amp|quot)\;/g, function(m, m1, m2)
		{
			return { "lt": "<", "gt": ">", "amp": "&", "quot": "\"", "#036": "$", "#039": "'", "#92": "\\" }[m1] || (parseInt(m2, 10) < 160 ? m : String.fromCharCode(m2));
		}) + "\n";
		f.elements["detail_popis"].defaultValue = f.elements["detail_popis"].value;

		for(var i = 0, n; n = ["post", "anchor"][i]; i++)
		{
			inputs[n].value = el.href.match(new RegExp("[\\?\\&]" + n + "=(\\d+)"))[1];
		}


		if(edited.offsetHeight)
		{
			var scvrkY = Math.round(edited.getElementsByTagName("div")[0].offsetHeight * 2) - 3;
			f.elements["detail_popis"].style.height = Math.min(Math.max((edited.offsetHeight - scvrkY), 80), screen.availHeight / 5 * 3) + "px";
		}
		if(odpovidaci.parentNode != rodic)
		{
			rodic.insertBefore(odpovidaci, f);
		}
		edited.appendChild(f);
		edited.className = "editing";

		if(postTopic)
		{
			naNazev.className = "topic-title";
			naNazev.innerHTML = postTopic;
		}

		var textDiv = edited.getElementsByTagName("div")[2];
		f.onsubmit = function()
		{
			var h = getHttpRequest();
			h.open("POST", ".", true);
			h.setRequestHeader("Referer", location.href);
			h.setRequestHeader("Content-Type", 'application/x-www-form-urlencoded');
			var fd = {}, fds = [];
			for(var i = 0, n; n = f.elements[i]; i++)
			{
				if(n.type == "checkbox" && !n.checked) continue;
				if(n.type.substr(0, 4) == "text") n.readOnly = true; else n.disabled = true;
				fd[n.name] = n.value;
			}
			for(n in inputs) fd[n] = inputs[n].value;
			for(n in fd)
			{
				fds.push(n + "=" + encodeURIComponent(fd[n], "iso-8859-2"));
			}
			h.onreadystatechange = function()
			{
				if(h.readyState != 4) return;
				var rt = h.responseText.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
				var m = rt.match(/<!--text\[((.|\n)*?)\]-->/m);
				var hlaska = [];
				if(m && m[1])
				{
					textDiv.innerHTML = m[1];
					try
					{
						pridejJushClass(textDiv);
					} catch(e) {}
					hlaska.push("Upravený příspěvek je uložen.");
				}
				m = rt.match(/<!--nadpis\[((.|\n)*?)\]-->/m);
				if(m && m[1])
				{
					document.getElementsByTagName("h1")[0].innerHTML = m[1];
					document.getElementById("breadcrumb2").getElementsByTagName("strong")[0].innerHTML = m[1];
					document.title = "Diskuse: " + m[1].replace(/&(#(\d+)|lt|gt|amp|quot)\;/g, function(m, m1, m2)
					{
						return { "lt": "<", "gt": ">", "amp": "&", "quot": "\"", "#036": "$", "#039": "'", "#92": "\\" }[m1] || String.fromCharCode(m2);
					});
					hlaska.push("Upravený nadpis je uložen.");
				}
				for(var i = 0, n; n = f.elements[i]; i++)
				{
					if(n.type.substr(0, 4) == "text") n.readOnly = false; else n.disabled = false;
				}
				proNavrat.style.display = "";
				if(!hlaska.length)
				{
					alert("Uložení úpravy se nezdařilo.");
				}
				else
				{
					returnEditForm();
				}
			}
			h.send(fds.join("&"));
			proNavrat.style.display = "none";
			return false;
		};
		f.elements["detail_popis"].focus();
	};

	var returnEditForm = function()
	{
		if(!edited) return false;
		if(f.elements["detail_popis"].readOnly) return true;
		revert();

		f.elements["action"].value = "pthread";
		f.elements["detail_popis"].value = puvodniText;
		f.elements["detail_popis"].defaultValue = puvodniDefaultText;

		for(var i = 0, n; n = ["post", "anchor"][i]; i++)
		{
			if(f.elements[n]) f.removeChild(f.elements[n]);
		}

		rodic.insertBefore(f, odpovidaci);
		rodic.removeChild(odpovidaci);
		f.elements["detail_popis"].style.height = "";

		edited = null;
		return true;
	}

	var odkazy = document.getElementsByTagName("a");
	var odpovidaci = null;
	for(var i = 0, a; a = odkazy[i]; i++)
	{
		// Pokud je v hrefu "www.jakpsatweb.cz...neříkám,", vyhodí zjišťování a.hrefu v Exploreru výjimku, viz djpw.cz/55315
		var href = ((typeof(a.href) == "string") && a.href) || "";

		if(href.indexOf("?action=editmsg&") > -1)
		{
			a.onclick = function()
			{
				return !getEditForm(this);
			};
		}
		else if(!odpovidaci && href.indexOf("#newreply") > -1)
		{
			odpovidaci = a.cloneNode(true);
			odpovidaci.id = "newreply-return";
			odpovidaci.style.marginBottom = odpovidaci.style.marginTop = Math.round((f.offsetHeight - odpovidaci.offsetHeight) / 3) + "px";
			odpovidaci.onclick = a.onclick = function()
			{
				return !returnEditForm(this);
			};
		}
	}
}

inits.push(transplantaceEditace);



/* =================================== *
 * === Hledač souvisejících vláken === *
 * =================================== */

function hledacVlaken(param)
{
	var hledaPoprve = true, pocetHledani = 0;
	var f = document.forms["edit_p"];
	if(!f) return;
	var titulek = document.forms["edit_p"].elements["topicTitle"];
	if(!titulek) return;

	var obal = document.createElement("div");
	titulek.parentNode.insertBefore(obal, titulek);
	obal.appendChild(titulek);
	obal.className = "hledac";
	while(obal.nextSibling.nodeName == "BR" || obal.nextSibling.nodeName == "#text") obal.parentNode.removeChild(obal.nextSibling);

	var kde = Kategorie[param.qsforum] ? Kategorie[param.qsforum].kdeHledat || "" : "";

	if(kde)
	{
		if(!kde.length) return;
		for(var i = 0; i < kde.length; i++) kde[i] = "inurl:forum=" + kde[i];
		kde = " " + (kde.length == 1 ? kde[0] : ("(" + kde.join(" OR ") + ")"));
	}

	var datablok = document.createElement("div");
	obal.appendChild(datablok);

	var googleapi = {};
	var requestID = 1;

	var ocistit = function(text, mezera)
	{
		return text.trim().replace(/[-+"':]/g, " ").replace(/\s+/g, " ");
	};

	var vysledky = {};

	datablok.onmousedown = function(e)
	{
		var event = window.event || e;
		var target = event.target || event.srcElement;
		if(target.tagName == "A")
		{
			var topic = parseInt((target.href + "&topic=0").match(/&topic=(\d+)/)[1]);
			if(topic) log("[" + titulek.value + "][" + param.qsforum + "][N/A][" + topic + "]");
		}
	};

	var doToho = function()
	{
		var t = ocistit(titulek.value);
		if(t.length < 4) return;
		if(vysledky[t])
		{
			datablok.innerHTML = vysledky[t];
		}
		else
		{
			var gaid = "req" + requestID++;
			googleapi[gaid] = { titulek: t };
			googleapi[gaid].script = document.createElement("script");
			googleapi[gaid].script.charset = "utf-8";
			googleapi[gaid].script.src = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=" + encodeURIComponent(t + " site:diskuse.jakpsatweb.cz inurl:vthread" + kde) + "&hl=cs&rsz=large&callback=hledacCallback&context=" + gaid;
			document.body.appendChild(googleapi[gaid].script);
		}
	};


	window.hledacCallback = function(context, data, status)
	{
		setTimeout(function()
		{
			document.body.removeChild(googleapi[context].script);
			delete googleapi[context].script;
		}, 1);

		if(status != 200) return;
		if(data.results.length)
		{
			var v = ["<table>"];
			v.push("<tfoot><tr><td class=\"center\" width=\"5%\">&#9650;<td>Výsledky <a href=\"" + data.cursor.moreResultsUrl +"\" target=\"_blank\">hledání zadaného titulku</a> na této diskusi. Odkazy vedou do nového okna.");
			v.push("<tbody>");
			for(var i = 0, r; r = data.results[i]; i++)
			{
				var uri = orezAdresu(r.unescapedUrl);
				var strana = parseInt((uri + "&page=0").match(/&page=(\d+)/)[1]) + 1;
				var kat = parseInt((uri + "&forum=0").match(/&forum=(\d+)/)[1]);

				v.push("<tr class=\"tbCel" + (i % 2 + 1) + (i ? "" : " prvni") + "\">");
				
				v.push("<td width=\"5%\" class=\"center\" valign=\"middle\"><img src=\"img/forum_icons/");
				v.push((Kategorie[kat] ? Kategorie[kat].ikonka : "transparent") + ".gif");
				v.push("\"><td><a href=\"" + uri + "\" target=\"_blank\">" + orezTitulek(r.title) + "</a>");
				v.push("&nbsp;<sup class=\"navCell\">" + (strana > 1 ? ". " + strana + " ." : "") + "</sup>");
				v.push("<span> — " + r.content + "</span>");
			}
			v.push("</table>");
			vysledky[googleapi[context].titulek] = v.join("");
		}
		else
		{
			vysledky[googleapi[context].titulek] = "";
		}
		var t = ocistit(titulek.value);
		if(t == googleapi[context].titulek)
		{
			datablok.innerHTML = vysledky[t];
			if(vysledky[t])
			{
				pocetHledani++;
				titulek.style.background = "url('img/hledac-kolonka.gif?" + pocetHledani%2 +"') repeat-x 0 50%";

				if(hledaPoprve)
				{
					hledaPoprve = false;
					var tableHeight = Math.max(datablok.firstChild.offsetHeight / 3, datablok.firstChild.tFoot.offsetHeight * 2);
					var tableScroll = obal.offsetTop - tableHeight - document.documentElement.scrollTop;
					if(tableScroll < 0)
					{
						for(var i = 1; i <= 10; i++)
						{
							setTimeout(function()
							{
								window.scrollBy(0, tableScroll / 10);
							}, i * 20)
						}					
					}
				}
			}
		}
	};

	var cekaSe = false;
	var minulyTitulek = titulek.value;
	titulek.onkeyup = function()
	{
		var tout;
		var t = ocistit(titulek.value);
		if(minulyTitulek == t) return true;
		minulyTitulek = t;

		if(vysledky[t])
		{
			datablok.innerHTML = vysledky[t];
			return true;
		}
		else
		{
			datablok.innerHTML = "";
		}

		titulek.onkeydown = function(e)
		{
			var event = window.event || e;
			if(event.keyCode < 32) return true;
			clearTimeout(tout);
			titulek.onkeydown = null;
		}
		tout = setTimeout(doToho, 2000);
	};
}
inits.push(hledacVlaken);



/* ================================ *
 * === Moderátorské vymoženosti === *
 * ================================ */

function moderatorskeVymozenosti(param)
{
	if(!param.moderator) return;
	var tab = document.getElementById("prispevky");
	if(!tab) return;

	var zpravy = [];
	for(var i = 0; i < tab.rows.length; i++)
	{
		var div = tab && tab.rows[i].cells[1].getElementsByTagName("div")[1];
		if(!div) continue;
		var a = div.getElementsByTagName("a");
		for(var j = 0; j < a.length; j++)
		{
			if(a[j].href.match(/action=delmsg&/))
			{
				var label = document.createElement("label");
				label.innerHTML = "Zatrhnout";
				label.htmlFor = "mod-checkbox-" + i;
				var checkbox = document.createElement("input");
				checkbox.id = "mod-checkbox-" + i;
				checkbox.tabIndex = 100 + j;
				checkbox.type = "checkbox";
				checkbox.msg = {checkbox: checkbox, referer: a[j].href, post: a[j].href.match(/[?&]post=(\d*)/)[1], row: tab.rows[i]};
				checkbox.checked = false;
				checkbox.onclick = function()
				{
					this.msg.row.style.backgroundColor = (this.checked) ? "#F4F4D1" : "";
				};
				zpravy.push(checkbox.msg);
				a[j].parentNode.appendChild(checkbox);
				a[j].parentNode.appendChild(label);
				a[j].parentNode.removeChild(a[j].previousSibling); // mezera
				a[j].parentNode.removeChild(a[j]);
			}
		}
	}
	var hromadne = document.createElement("span");
	hromadne.className = "hromadne";
	tab.rows[0].cells[1].insertBefore(hromadne, tab.rows[0].cells[1].firstChild);

	var zkat;
	for(var k = 0; k < 3; k++) (function(k)
	{
		var a = document.createElement("a");
		a.appendChild(document.createTextNode(["Změnit kategorii", "Přesunout zatržené", "Vymazat zatržené"][k]));
		a.href = "javascript:;";
		a.id = "mod-" + ["kategorie", "presunout", "vymazat"][k];
		if(k)
			hromadne.appendChild(document.createTextNode(" · "));
		else
			zkat = a;
		hromadne.appendChild(a);

		a.onclick = function()
		{
			if(!k)
			{
				this.className = this.className == "rozbaleno" ? "" : "rozbaleno";
				return;
			}
			var p = 0;
			for(var i = 0; i < zpravy.length; i++)
				if(zpravy[i].checkbox && zpravy[i].checkbox.checked) p++;
			if(!p)
			{
				alert("Nic není zatrženo.");
				return false;
			}
			if(k - 1)
			{
				if(!confirm("Vymazat " + p + " příspěv" + (p < 5 ? p < 2 ? "ek" : "ky" : "ků") + "?")) return false;
			}
			else
			{
				var kam = Math.max(parseInt(prompt("Kam přesunout?", "111"), 10) || 0, 0);
				if(!kam) return false;
			}


			for(var i = 0; i < zpravy.length; i++)
			{
				if(zpravy[i].checkbox.checked) (function(zprava)
				{
					var xhr = getHttpRequest();
					var referer, data, p = (param.qstopic || "") + "&forum=" + (param.qsforum || "") + "&post=" + zprava.post + "&page=" + (param.qspage || "0");
					if(k - 1)
					{
						referer = "?action=delmsg&topic=" + p;
						data = "action=delmsg2&topic=" + p + "&dy=1";
					}
					else
					{
						referer = "?action=editmsg&topic=" + p;
						data = "action=movemsg&topic=" + kam + "&odkud=" + p;
					}

					xhr.open("POST", ".", true);
					xhr.setRequestHeader("Referer", param.base + referer);
					xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
					xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
					xhr.onreadystatechange = function()
					{
						if(xhr.readyState != 4) return;
						if(xhr.status != 200)
						{
							alert("Došlo k chybě.");
							return;
						}
						zprava.checkbox.checked = false;
						zprava.row.parentNode.removeChild(zprava.row);
					}
					xhr.send(data);
				})(zpravy[i])
			}
		};
	})(k);

	var seznam = document.createElement("span");
	zkat.appendChild(seznam);
	for(var n in Kategorie)
	{
		if(!Kategorie[n].nazev) continue;
		var img = document.createElement("img");
		img.src = "img/forum_icons/" + ((param.qsforum != n) ? Kategorie[n].ikonka : "transparent") + ".gif";
		var tady = "&topic=" + (param.qstopic || "") + "&forum=" + (param.qsforum || "")
		if(param.qsforum == n)
		{
			img.className = "mod-kategorie-tato";
			img.title = "Vymazat vlákno";
			img.xhrReferer = "?action=deltopic" + tady;
			img.xhrData = "action=deltopic" + tady + "&dy=1";
			img.xhrConfirm = true;
		}
		else
		{
			img.title = Kategorie[n].nazev;
			img.xhrReferer = "?action=movetopic" + tady;
			img.xhrData = "action=movetopic2" + tady + "&forumWhere=" + n + "&dy=1&page=0";
		}
		img.onclick = function()
		{
			if(this.xhrConfirm && !confirm("Opravdu vymazat vlákno?")) return false;
			var mazat = this.xhrConfirm;
			var xhr = getHttpRequest();
			xhr.open("POST", ".", true);
			xhr.setRequestHeader("Referer", param.base + this.xhrReferer);
			xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
			xhr.onreadystatechange = function()
			{
				if(xhr.readyState != 4) return;
				if(mazat)
				{
					var m = xhr.responseText.match(/Vymazané\s+příspěvky:\s*(\d+)/);
					alert("Počet smazaných odpovědí: " + m[1]);
				}
				else
				{
					listuj();
				}
			}
			xhr.send(this.xhrData);
			return false;
		};
		seznam.appendChild(img);
		
	}
}
inits.push(moderatorskeVymozenosti);



/* ================================================ *
 * === Listování stránkami bez ztráty příspěvku === *
 * ================================================ */

function listovaniStranami(param)
{
	if(!document.forms["edit_p"]) return;

	for(var i = 0, p; p = document.getElementsByTagName("p")[i]; i++)
	{
		if(p.className != "pages") continue;
		for(var j = 0, a; a = p.getElementsByTagName("a")[j]; j++)
		{
			a.onclick = function()
			{
				return !listuj(this.href);
			};
		}
		if(j) p.appendChild(document.createTextNode("   [?]"));
		p.title = "Rozepsaný příspěvek přežije listování.";
	}
}
function listuj(uri)
{
	var formData = {}, send = false;
	if(document.forms["edit_p"] && document.forms["edit_p"].parentNode.className != "editing")
	{
		for(var i = 0, n; n = ["detail_popis", "topicTitle"][i]; i++)
		{
			if(document.forms["edit_p"][n] && (formData[n] = document.forms["edit_p"][n].value)) send = true;
		}
	}
	var currentUri = location.href.replace(/^([^\#]+)(\#.*)?$/, "$1#roluj(" + document.documentElement.scrollTop + ")");
	if(!send)
	{
		if(uri)
		{
			location.href = uri;
		}
		else
		{
			location.href = currentUri;
			location.reload();
		}
		return true;
	}

	var f = document.createElement("form");
	f.style.display = "none";
	document.body.appendChild(f);
	f.method = "POST";
	f.action = uri || currentUri;

	for(var n in formData)
	{
		var input = document.createElement("input");
		input.type = "hidden";
		input.name = n;
		input.value = formData[n];
		f.appendChild(input);
	}

	f.submit();
	return true;
}

inits.push(listovaniStranami);



/* ================================================= *
 * === Průběžná kontrola změn ve vlákně + náhled === *
 * ================================================= */

function kontrolaZmen(param)
{
	var f = document.forms["edit_p"];
	var np = document.getElementById("newposters");
	var submitbtn = document.getElementById("submitbtn");
	if(!f || !submitbtn) return;
	var nzpUri = "bb_nzp.php?";
	var d;

	if(np && param.date && param.posledniStrana)
	{
		var m = param.date.match(/^(\d+)\-(\d+)\-(\d+)\s+(\d+):(\d+):(\d+)$/);
		d = new Date(parseInt(m[1], 10), parseInt(m[2], 10) - 1, parseInt(m[3], 10), parseInt(m[4], 10), parseInt(m[5], 10), parseInt(m[6], 10));
		nzpUri += "topic=" + param.qstopic + "&forum=" + param.qsforum + "&date=" + param.date + "&page=" + ((param.konecStrany ? 1 : 0) + document.getElementById("topicpage").value * 1) + "&anchor=" + document.getElementById("postcount").value;
		var lastNp = "";
	}

	var kontrola = function(data)
	{
		if(!rozepsano && !data)
		{
			setTime();
			return;
		}
		var xhr = getHttpRequest();
		xhr.open("POST", nzpUri + "&rnd=" + Math.random(), true);	
		xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
		xhr.onreadystatechange = function()
		{
			if(xhr.readyState != 4) return;
			var rt = xhr.responseText.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
			rt = rt.replace(/<!--text\[((.|\n)*?)\]-->/m, function(m, m1)
			{
				ukazNahled(m1);
				return "";
			});
			if(!np) return;
			if(rt != lastNp)
			{
				lastNp = np.innerHTML = xhr.responseText;
				for(var i = 0, a; a = np.getElementsByTagName("a")[i]; i++)
				{
					a.onclick = function()
					{
						return !listuj(this.href);
					};
				}
				d = new Date();
			}
			setTime();
		};
		xhr.send(data || "");
	};
	var timeoutID = 0;
	var setTime = function()
	{
		if(timeoutID) clearTimeout(timeoutID);
		var ted = new Date().getTime();

		// v noci poroste interval rychleji
		var doba = 1 - Math.pow(Math.cos(((ted - 14400000) % 86400000) / 86400000 * Math.PI), 4);

		var dif = (ted - d) / 60000;
		var cas = 5 - doba * 4 + Math.pow(Math.max(dif, 0) / (5 + doba * 55), 2) * 5;
		if(cas > 1440) return;
		setTimeout(function()
		{
			// Kdyby tu byla jen „kontrola“ bez obalující funkce, Firefox by jí posílal jakési číslo v argumentu, což nechci.
			kontrola();
		}, cas * 60000);
	};
	if(d) setTime();


	var originalClassName = f.className, nahlizejic = false;
	var nahled = document.createElement("div");
	nahled.id = "nahled";

	var scroll = 0;
	var titulekSpan;

	var ukazNahled = function(html)
	{
		if(f.elements["topicTitle"])
		{
			titulekSpan = document.createElement("span");
			titulekSpan.innerHTML = " <b>»</b> <strong>" + f.elements["topicTitle"].value.replace(/[<&]/g, "$&<!>") + "</strong>";
			var bc2 = document.getElementById("breadcrumb2");
			bc2.insertBefore(titulekSpan, bc2.getElementsByTagName("strong")[0].nextSibling);
		}
		var m = document.getElementById("user_usr") && document.getElementById("user_usr").innerHTML;

		var jmeno = m || ((f.elements["user_usr"] && f.elements["user_usr"].value) || "Anonymní");
		var popisek = !param.moderator ? !m ? "" : "Člen" : "Moderátor";

		nahlizejic = true;
		tlacitko.value = "Upravit zprávu";
		var st = document.documentElement.scrollTop;
		nahled.innerHTML = "<table><tr><th width=\"15%\">Autor<th width=\"85%\">Náhled zprávy<tr class=\"tbCel1\"><td width=\"15%\" valign=\"top\" class=\"names\"><strong>" + jmeno + "</strong><br><a><u>" + popisek + "</u></a><td><div class=\"postinfo\"><a><u>#?</u></a> · Zasláno: zatím ne</div><div class=\"posttext\">" + html + "</div></table>";
		try
		{
			pridejJushClass(nahled);
		}
		catch(e) {}
		f.parentNode.insertBefore(nahled, f);
		scroll = nahled.offsetHeight - f.offsetHeight;
		f.className = originalClassName + " nahlizejic";
		scroll += f.offsetHeight;
		window.scrollTo(0, st + scroll);
		submitbtn.focus();
	};
	var tlacitko = document.createElement("input");
	tlacitko.id = "nahled-tlacitko";
	tlacitko.type = "button";
	tlacitko.value = "Ukázat náhled";
	tlacitko.tabIndex = 4;
	tlacitko.onclick = function()
	{
		if(nahlizejic)
		{
			var st = document.documentElement.scrollTop;
			tlacitko.value = "Ukázat náhled";
			nahlizejic = false;
			f.className = originalClassName;
			f.parentNode.removeChild(nahled);
			if(titulekSpan) titulekSpan.parentNode.removeChild(titulekSpan);
			window.scrollTo(0, st - scroll);
			f.elements["detail_popis"].focus();
		}
		else
		{
			if(kontrolaFormulare())
			{
				kontrola("detail_popis=" + encodeURIComponent(f.elements["detail_popis"].value, "iso-8859-2") /* + "&disbbcode=" + (f.elements["disbbcode"].checked ? 1 : 0)*/ );
			}
		}
		return false;
	};
	submitbtn.parentNode.insertBefore(tlacitko, submitbtn.nextSibling);
}

inits.push(kontrolaZmen);



/* ======================== *
 * === Život v sandboxu === *
 * ======================== */

function vSandboxu(param)
{
	if(!location.href.match(/\/\.sandbox/)) return;
	for(var i = 0, a; a = document.getElementsByTagName("a")[i]; i++)
	{
		var href = ((typeof(a.href) == "string") && a.href) || "";
		var novyHref = href.replace(/^http:\/\/diskuse\.jakpsatweb\.cz\/(index\.php)?\?/, "?");

		if(href != novyHref)
		{
			var temp = a.innerHTML;
			a.href = novyHref;
			a.innerHTML = temp;
		}
	}
}

inits.push(vSandboxu);	
	
	
	
	
	
	
	
	
	
