//barva = new Array("FF0000","00FF00","0000FF","FFFF00","FF00FF","00FFFF");
barva = "FF0000";
velikost = "3";

//Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
//Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none:
var iframeids=["ifobsah"]

//Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):
var iframehide="yes"

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers

function resizeCaller() {
var dyniframe=new Array()
for (i=0; i<iframeids.length; i++){
if (document.getElementById)
resizeIframe(iframeids[i])
//reveal iframe for lower end browsers? (see var above):
if ((document.all || document.getElementById) && iframehide=="no"){
var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
tempobj.style.display="block"
}
}
}

function resizeIframe(frameid){
var currentfr=document.getElementById(frameid)
if (currentfr && !window.opera){
currentfr.style.display="block"
if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight;
else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
currentfr.height = currentfr.Document.body.scrollHeight;
if (currentfr.addEventListener)
currentfr.addEventListener("load", readjustIframe, false)
else if (currentfr.attachEvent){
currentfr.detachEvent("onload", readjustIframe) // Bug fix line
currentfr.attachEvent("onload", readjustIframe)
}
}
}

function readjustIframe(loadevt) {
var crossevt=(window.event)? event : loadevt
var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
if (iframeroot)
resizeIframe(iframeroot.id);
}

function loadintoIframe(iframeid, url){
if (document.getElementById)
document.getElementById(iframeid).src=url
}

if (window.addEventListener)
window.addEventListener("load", resizeCaller, false)
else if (window.attachEvent)
window.attachEvent("onload", resizeCaller)
else
window.onload=resizeCaller

function wstop() {
  window.stop();
}

function calcHeight(id) {
  //find the height of the internal page
  var the_height=
    document.getElementById(id).contentWindow.
      document.body.scrollHeight;
  //change the height of the iframe
  document.getElementById(id).height=
      the_height;
}

function autofitIframe(id){
  if (!window.opera && !document.mimeType && document.all && document.getElementById){
    parent.document.getElementById(id).style.height=this.document.body.offsetHeight+"px";
  } else if(document.getElementById) {
    parent.document.getElementById(id).style.height=this.document.body.scrollHeight+"px";
  }
}

function resizeIframe() {
	// Must launched on the body onload event handler for IE
	// Use document.documentElement if you are in Compat mode
	i = parent.document.getElementById(window.name);
	iHeight = document.body.scrollHeight;
	i.style.height = iHeight + 5 + "px";
}

function iFrameHeight(iframeid) {
 // used by iframes to adjust size to content
 if(document.getElementById && !(document.all))
 {
   h = document.getElementById(iframeid).contentDocument.body.scrollHeight;
   document.getElementById(iframeid).style.height = h;
 }
 else if(document.all)
 {
   h = document.frames(iframeid).document.body.scrollHeight;
   document.all[iframeid].style.height=h;
 }
}

function resizeFrame(f) {
  f.style.height = f.contentWindow.document.body.scrollHeight + "px";
}  

function killReturn() {
  alert("ok");
  key = event.keyCode;
  if (key == 13) {
    document.content.contentWindow.document.execCommand('paste', false, unescape("%0A"));
    return false;
  }
}

function shiftEnter() {
  var browser = navigator.userAgent.toLowerCase();
  if (browser.indexOf("msie") != -1) document.write("- Při psaní příspěvku zbůsobí klávesa Enter skok o dva řádky, po vložení příspěvku se však tato mezera automaticky odstraní. Chcete-li tomuto skoku při psaní předejít, používejte Shift+Enter.<br />");
}

function openLink(URI){
  win = window.open(URI,"_blank");
  win.focus();
}

function pocitadlo() {
	Tmp=Math.floor(1000000 * Math.random());
	document.write("<SCR" + "IPT SRC=\"http://cnt1.pocitadlo.cz/counter.php?poc=1983&ref="+escape(top.document.referrer)+"&depth="+screen.colorDepth+"&width="+screen.width+"&height="+screen.height+"&tmp="+Tmp+"\" Language=\"JavaScript\" type=\"text/javascript\"></SCR" + "IPT>");
}

function tagSelection(tag, id) {
				var sTagBegin = "(" + tag;
			  if (tag == ":") sTagBegin = "(http://adresa:"; 
			  if (tag == "@") sTagBegin = "(mailto:jmeno@domena@"; 
			  if (tag == "*") sTagBegin = "(img/soubor*";
			  if (tag == "#") sTagBegin = "(#" + barva + "#"; 
			  if (tag == "|") sTagBegin = "(|" + velikost + "|"; 
				var sTagEnd = tag + ")";
				if (tag == ")") sTagEnd = "";
				//window.prompt("\<a href = \"http\://www.sophics.cz\" target = \"_blank\" /\>\</a\>");
				var el = document.getElementById(id);
				//var el = document.getElementById(id);
				var sStart = el.value.substring(0, el.selectionStart);
				var sSel = el.value.substring(el.selectionStart, el.selectionEnd);
				var sEnd = el.value.substring(el.selectionEnd);
				var result = sStart + sTagBegin + sSel + sTagEnd + sEnd;
				el.value = result;
				el.focus();
			}
			
function colorChange(id, idtxt) {
				barva = id.options[id.selectedIndex].value;
				document.getElementById('utlacbar').color = "#" + barva;
				//window.open("index.php?barva=" + barva);
				document.getElementById(idtxt).focus();
				//window.prompt(barva);
}

function sizeChange(id, idtxt) {
				velikost = id.options[id.selectedIndex].value;
				document.getElementById('utlacvel').size = velikost;
				document.getElementById(idtxt).focus();
				//window.prompt(barva);
}


function preview(idnahled, idfocus) {
				//var tmp = document.getElementById(id);
				//var tmp2 = document.getElementById(id2);
				//barva = barvao.options[id.selectedIndex].value;
				var tmp = document.getElementById(idfocus).value;
				//window.prompt(document.all.txt.value);
				while(tmp.indexOf('\n') >= 0) tmp = tmp.replace("\n", "\<br /\>");
				while(tmp.indexOf("(http://adresa:") >= 0) tmp = tmp.replace("(http://adresa:", "\<a href = \"http://www.sophics.cz\" target = \"_blank\" /\>");
				while(tmp.indexOf(":)") >= 0) tmp = tmp.replace(":)", "\</a/\>");
				while(tmp.indexOf("(mailto:jmeno@domena@") >= 0) tmp = tmp.replace("(mailto:jmeno@domena@", "\<a href = \"mailto:ondra@sophics.cz\" target = \"_blank\" /\>");
				while(tmp.indexOf("@)") >= 0) tmp = tmp.replace("@)", "\</a/\>"); 
				while(tmp.indexOf("(img/soubor*") >= 0) tmp = tmp.replace("(img/soubor*", "\<img src = \"favicon.ico\" border = \"1\" vspace=\"5\" hspace=\"5\" align=\"left\" /\>");
				while(tmp.indexOf("*)") >= 0) tmp = tmp.replace("*)", ""); 
				while(tmp.indexOf('(=') >= 0) tmp = tmp.replace("(=", "\<b/\>");
				while(tmp.indexOf('=)') >= 0) tmp = tmp.replace("=)", "\</b/\>");
				while(tmp.indexOf('(/') >= 0) tmp = tmp.replace("(/", "\<i/\>");
				while(tmp.indexOf('/)') >= 0) tmp = tmp.replace("/)", "\</i/\>");
				while(tmp.indexOf('(-') >= 0) tmp = tmp.replace("(-", "\<s/\>");
				while(tmp.indexOf('-)') >= 0) tmp = tmp.replace("-)", "\</s/\>");
				while(tmp.indexOf('(_') >= 0) tmp = tmp.replace("(_", "\<u/\>");
				while(tmp.indexOf('_)') >= 0) tmp = tmp.replace("_)", "\</u/\>");
				while(tmp.indexOf('()') >= 0) tmp = tmp.replace("()", "\&nbsp;\&nbsp;");
				while(tmp.indexOf("(#FF0000#") >= 0) tmp = tmp.replace("(#FF0000#", "\<font color = \"#FF0000\"/\>");
				while(tmp.indexOf("(#00FF00#") >= 0) tmp = tmp.replace("(#00FF00#", "\<font color = \"#00FF00\"/\>");
				while(tmp.indexOf("(#0000FF#") >= 0) tmp = tmp.replace("(#0000FF#", "\<font color = \"#0000FF\"/\>");
				while(tmp.indexOf("(#FFFF00#") >= 0) tmp = tmp.replace("(#FFFF00#", "\<font color = \"#FFFF00\"/\>");
				while(tmp.indexOf("(#FF00FF#") >= 0) tmp = tmp.replace("(#FF00FF#", "\<font color = \"#FF00FF\"/\>");
				while(tmp.indexOf("(#00FFFF#") >= 0) tmp = tmp.replace("(#00FFFF#", "\<font color = \"#00FFFF\"/\>");
				while(tmp.indexOf('#)') >= 0) tmp = tmp.replace("#)", "\</font/\>");
				while(tmp.indexOf('(|3|') >= 0) tmp = tmp.replace("(|3|", "\<font style = \"font-size: 14px\"/\>");
				while(tmp.indexOf('(|5|') >= 0) tmp = tmp.replace("(|5|", "\<font style = \"font-size: 20px\"/\>");
				while(tmp.indexOf('(|6|') >= 0) tmp = tmp.replace("(|6|", "\<font style = \"font-size: 26px\"/\>");
				while(tmp.indexOf('(|1|') >= 0) tmp = tmp.replace("(|1|", "\<font style = \"font-size: 10px\"/\>");
				while(tmp.indexOf('|)') >= 0) tmp = tmp.replace("|)", "\</font/\>");
				document.getElementById(idnahled).innerHTML = tmp;
				//window.prompt(tmp);
				document.getElementById(idfocus).focus();
			}
			//function tagy(type, info) {
			//	var nametag = window.prompt(info);
			//	if(nametag != \'\' && nametag != null) {
			//	document.forms.vzkaz.zprava.focus();
			//	document.forms.vzkaz.zprava.value=
			//	document.forms.vzkaz.zprava.value+\'(\'+type+\'>\'+nametag+\'<\'+type+\')\'
			//	} else {
			//	if(nametag == \'\' || nametag == null) {window.alert(\'Nebyl napsán text\');}
			//	}