var bars=1; // stupeň rozvinutí baru
var settext;
function diskuse(o) {
	if(o.href) {
		var okno=window.open(o.href, 'forum', 'toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=yes,copyhistory=yes,width=676,height=500,left='+((screen.width-676)/2)+',top='+((screen.height-500)/2));
		if(okno.focus) {
			okno.focus();
		}
	}
}
/*
function Spust() {	// nastaví editační mód u iFramu
	if(document.all) {
		iView.document.designMode = 'On'; // editační mód
	} else {
		document.getElementById("iView").contentDocument.designMode="on"; 
	}
} 
function vloz(kod) {	// vloží HTML kód do iView
	var cursor;
	if(document.all) {	// IE prohlížeč
		iView.focus();
		cursor = iView.document.selection.createRange();
		cursor.pasteHTML(kod);
	} else {		// non-IE prohlížeč
		document.getElementById("iView").contentDocument.body.innerHTML=document.getElementById("iView").contentDocument.body.innerHTML+kod;
	}
}
*/
function shoMsgBar(text, nadpis) {	// rozvine list / infobar se zprávou
	// zobraz msg bar
	var bar=document.getElementById('msgbar');
	bar.style.overflow='hidden';
	bar.style.height=1;
	bar.innerHTML='<p title="Zavřít" onclick="closeMsgBar();" class="nfohead">'+nadpis+'</p>';
	bar.style.visibility='visible';
	settext=text;
	bigbar();
}
function closeMsgBar() {
	var bar=document.getElementById('msgbar');
	bar.style.overflow='hidden';
	cutbar();
	//document.getElementById('msgbar').style.visibility='hidden';
	}
function QcloseMsgBar() {
	var bar=document.getElementById('msgbar');
	bar.style.overflow='hidden';
	bar.style.height=1;
	bar.innerHTML='';
	settext='';
	bar.style.visibility='hidden';
	}
function bigbar() {
	var bar=document.getElementById('msgbar');
	if(bars<101) {
		bar.style.height=bars;
		bars+=3;
		setTimeout("bigbar()", 20);
	} else {
		bar.innerHTML+='<p style="margin:1px; height:82px; text-align:justify; overflow:auto">'+settext+'</p>';
		settext='';
		window.scroll(0, 0)
	}
}
function cutbar() {
	var bar=document.getElementById('msgbar');
	if(bars>1) {
		bar.style.height=bars;
		bars-=3;
		setTimeout("cutbar()", 10);
	} else {
		bar.innerHTML='';
		settext='';
		bar.style.visibility='hidden';
	}
}
function shoplus(title, desc, idsklad,  pridal, lyrics) {
	var temp = 0;
	var bar2=document.getElementById('MsgBar2');
	temp=(document.layers)?window.pageYOffset:document.body.scrollTop;
	temp+=(document.layers)?event.pageY:event.y;
	if (temp < 0) temp = 0;  
	bar2.style.top=temp;
	bar2.innerHTML='<H3 onclick="shominus();" TITLE="Zavřít okno">'+title+'</H3><p><b><i>'+desc+'</i></b><br><br><a href="ext.php?id='+idsklad+'" target="poplyr" onclick="opop()">Zobrazit detailní informace o hlasování</a>';
	if(lyrics) bar2.innerHTML=bar2.innerHTML+'<a href="lyrics.php?akce=search&z=ano&'+lyrics+'" onclick="opop();" target="poplyr">Zobrazit lyrics v novém okně</a>';
	if(pridal) bar2.innerHTML=bar2.innerHTML+'<br><b>Skladbu přidal/a</b>: '+pridal;
	bar2.innerHTML=bar2.innerHTML+'<hr>Upozornění: Otevřená oblast "Více info" schovává hlasovací roletky, budete-li nyní chtít hlasovat, musíte předtím tuto oblast zavřít kliknutím na křížek.';
	bar2.style.visibility='visible';
	document.getElementById('j').style.visibility='hidden';
	document.getElementById('d').style.visibility='hidden';
	document.getElementById('t').style.visibility='hidden';
}
function OtevriOkno(retezec) {
window.open('lyrics.php?akce=search&z=ano&'+retezec,'','toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,width=493,height=600');
}
function opop() {
x=window.open('', 'poplyr','toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=yes,copyhistory=no,width=475,height=600');
x.focus();
}
function shominus() {
	document.getElementById('MsgBar2').innerHTML='';
	document.getElementById('MsgBar2').style.visibility='hidden';
	document.getElementById('j').style.visibility='visible';
	document.getElementById('d').style.visibility='visible';
	document.getElementById('t').style.visibility='visible';
}
function vipop() {
	window.open('vip.php?sho=bany','vip','toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=yes,copyhistory=no,width=470,height=270');
}
function uvolni() {	// dovolí stisknout tlačítko VLOŽIT
	document.getElementById('odebut').disabled=false;
}
function SendToServer(trida) {
	var tmp;
	if(document.all) {
		tmp= iView.document.body.innerHTML; 
		document.getElementById('komentar').value=tmp;
		if(tmp.length>700) {
			alert('Příspěvek je moc dlouhý, je zapotřebí jej zkrátit minimálně o '+(tmp.length-700)+' znaků!');
			return false;
		} else {
			iView.document.body.innerHTML ="";
		}
	} else {
		document.getElementById('komentar').value=document.getElementById("iView").contentDocument.body.innerHTML;
		document.getElementById("iView").contentDocument.body.innerHTML = "";
//		document.getElementById('komentar').value = document.createTextNode(document.getElementById("iView").contentDocument.body.innerHTML);
//		document.getElementById("iView").contentDocument.body.innerHTML = "";
	}
	document.getElementById('adk').submit();
if(trida<1) {
	document.getElementById('odebut').disabled=true;
	setTimeout("uvolni()", 30000);
}
}
function lyrwin(txt) {
alert('V přípravě: '+txt);
}
var reltimer;
function setint(interval) {
	document.getElementById('interval').innerHTML=interval;
	document.getElementById('inpint').value=interval;
}
function stopchat() {
	document.getElementById('akcmsg').innerHTML='<a onclick="startchat();" TITLE="Spustit automatické obnovování komentářů" STYLE="cursor:hand">start</a>';
	if(reltimer) clearTimeout(reltimer);
	reltimer=null;
	setint(0);
	window.alert('Automatické obnovování komentářů zastaveno');
}
function startchat() {
	document.getElementById('akcmsg').innerHTML='<a onclick="stopchat()" TITLE="Zastavit automatické obnovování komentářů" style="cursor:hand">stop</a>';
	setint(0);
	obnov();
}
function setmax(maximalni) {
	document.getElementById('msgpct').value=maximalni;
	obnovted();
}
function fokusit() {
	//if(document.all) window.setTimeout("document.getElementById('iView').focus();", 500);
	if(document.all) vloz('');
}
function obnovted() {
	document.getElementById('controlchat').style.background='#b30059';
	document.getElementById('koments').src=window.location.href.substr(0,window.location.href.lastIndexOf('/'))+'/komentari.php?shomax='+document.getElementById('msgpct').value+'&forw='+window.location.href.substr(0,window.location.href.lastIndexOf('/'))+'/komentari.php?';
	setTimeout("document.getElementById('controlchat').style.background='#000000';", 200);
}
function obnov() {
	reltimer=null;
	// zde se provádí obnovení stránky
	obnovted();
	// změna doby obnovení
	var prodleva=document.getElementById('inpint').value*1;
	if(prodleva<60) {
		prodleva=prodleva+5;
		setint(prodleva);
	}
	prodleva=prodleva*1000;
	reltimer=setTimeout("obnov()", prodleva);
	// v případě, že je vybráno sto, nastav 50 a stopni to
	if(document.getElementById('msgpct').value=='100') {
		document.getElementById('msgpct').value=50;
		stopchat();
	}
}
	var lobj=null;
	x1=0;
	x2=0;
	x3=0;
	function projdi() {
		tagy=document.getElementsByTagName("tr");
		for(i=0;i<tagy.length;i++) {
			inde=tagy[i].id;
			if(inde) {
				if(inde.substring(0,1)=="r") {
					if(document.getElementById('s'+inde.substring(1)).getElementsByTagName('a')[0]) document.getElementById('s'+inde.substring(1)).getElementsByTagName('a')[0].target='_blank';
					if(document.getElementById('s'+inde.substring(1)).getElementsByTagName('img')[0]) {
						document.getElementById('s'+inde.substring(1)).getElementsByTagName('img')[0].title="Zobraz lyrics";
						document.getElementById('s'+inde.substring(1)).getElementsByTagName('img')[0].alt="Zobraz lyrics";
					}
					if(document.getElementById('h'+inde.substring(1))) document.getElementById('h'+inde.substring(1)).innerHTML='<img width=13 height=12 src="img/h1.png" onclick="h('+inde.substring(1)+',1)" alt="Vyber na první místo" title="Vyber na první místo" style="cursor:pointer;cursor:hand"> <img width=13 height=12 src="img/h2.png" onclick="h('+inde.substring(1)+',2)"  alt="Vyber na druhé místo" title="Vyber na druhé místo" style="cursor:pointer;cursor:hand"> <img width=13 height=12 src="img/h3.png" onclick="h('+inde.substring(1)+',3)" alt="Vyber třetí místo" title="Vyber na třetí místo" style="cursor:pointer;cursor:hand">';
				}
			}
		}
	}
	function h(ide, misto) {
		switch(misto) {
			case 1:
				if(x1>0) odznac(x1,1);
				if(x2==ide) odznac(x2,2);
				if(x3==ide) odznac(x3,3);
				x1=ide;
				document.getElementById('jp').value=getCont(ide);
				document.getElementById('j').value=ide;
				break;
			case 2:
				if(x2>0) odznac(x2,2);
				if(x1==ide) odznac(x1,1);
				if(x3==ide) odznac(x3,3);
				x2=ide;
				document.getElementById('jd').value=getCont(ide);
				document.getElementById('d').value=ide;
				break;
			case 3:
				if(x3>0) odznac(x3,3);
				if(x2==ide) odznac(x2,2);
				if(x1==ide) odznac(x1,1);
				x3=ide;
				document.getElementById('jt').value=getCont(ide);
				document.getElementById('t').value=ide;
				break;
		}
		obj=document.getElementById('i'+ide)
		if(obj) {
			odznac(ide);
			obj.className=obj.className+'m'+misto;
		}
	}
	function det(vstup) {
		var outt='';
		var i=0;
		var kopiruj=true;
		while(i<vstup.length) {
			if(vstup.charAt(i)=='<') {
				kopiruj=false;
			}
			if(kopiruj) {
				outt+=vstup.charAt(i);
			}
			if(vstup.charAt(i)=='>') {
				kopiruj=true;
			}
			i++;
		}
		return outt;
	}
	function getCont(ide) {
		obj=document.getElementById('s'+ide);
		if(!obj) {
			return 'skladba již vypadla';
		} else {
			if(obj.innerText) {
				return obj.innerText;
			} else {
				return det(obj.innerHTML);
			}
		}
	}
	function confDel(ide) {
		bol=window.confirm('Skutečně chceš vymazat skladbu "'+getCont(ide)+'" z hitparády Ujdeto Charts?');
		if(bol) document.getElementById('r'+ide).style.display='none';
		return bol;
	}
	function odznac(ide,misto) {
		obj=document.getElementById('i'+ide);
		if(obj) {
			if(obj.className.toUpperCase().indexOf('M')>0) {
				obj.className=obj.className.substring(0,obj.className.toUpperCase().indexOf('M'));
			}
		}
		switch(misto) {
			case 1:
				document.getElementById('jp').value="nebylo vybráno";
				document.getElementById('j').value=0;
				break;
			case 2:
				document.getElementById('jd').value="nebylo vybráno";
				document.getElementById('d').value=0;
				break;
			case 3:
				document.getElementById('jt').value="nebylo vybráno";
				document.getElementById('t').value=0;
				break;
		}
	}
	function n(obj, smaz) {
		if(lobj!=obj) {
			if(lobj) {
				f(lobj);
			}
			lobj=obj;
			obj.style.backgroundColor='#aa0000';
			if(document.getElementById('s'+obj.id.substring(1)).innerHTML.indexOf('s.png')<0) {
				document.getElementById('s'+obj.id.substring(1)).innerHTML+=' <B></B><a href="ext.php?id='+obj.id.substring(1)+'" onclick="return o(this)"><img width=13 height=12 src="img/s.png" alt="Detailní statistiky" title="Detailní informace o hlasování"></a>';
				if(smaz>0) document.getElementById('s'+obj.id.substring(1)).innerHTML+=' <a onclick="return confDel('+obj.id.substring(1)+')" href=\"index.php?smaz='+obj.id.substring(1)+'" target="upengine"><img width=13 height=12 src="img/x.png" alt="Smaž" title="Smaž"></a>';
			}
		}
	}
function OpenWindow(url, name, width, height) {
	sTop = (screen.height-height) / 2;
	sLeft = (screen.width-width) / 2;
	var winZoom = window.open(url, name, "width=" + width + ",height=" + height + ",top=" + sTop + ",left=" + sLeft + ",toolbar=no,menubar=no,resizable=yes,scrollbars=yes");
	winZoom.focus();
}
	function f(obj) {
		obj.style.backgroundColor='#660000';
		obj=document.getElementById('s'+obj.id.substring(1));
		if(obj.innerHTML.toUpperCase().indexOf('<B')>0) {
			kod=obj.innerHTML.substring(0,obj.innerHTML.toUpperCase().indexOf('<B>'));
			obj.innerHTML=kod;
		}
	}
	function o (obj) {
		var o=window.open(obj.href, 'pop', 'toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=yes,copyhistory=no,width=492,height=605'); 
		o.focus();
		return false;
	}

  function generujHlasovaciKod(obj) {
    if(1*obj.form.jedna.value<1) {
      alert('Zvolte alespoň první místo, pro které chcete hlasovat.');
      return;
    }
    var kod='<p>Níže uvedený HTML kód zobrazí aktuální pořadí a počet bodů u Vašich oblíbených skladeb. Kód si můžete zkopírovat na své stránky nebo blog a umožnit tak svým návštěvníkům hlasovat přímo. Kód je samozřejmě možné libovolně upravovat, nastylovat, doplnit o další prvky,... Je vhodné kód přizpůsobit grafice Vašich stránek.</p><textarea cols="20" rows="5"><form action="http://www.ujdeto.cz" method="post" target="_blank"><fieldset><legend><a href="http://www.ujdeto.cz" target="_BLANK" title="Hitparáda Ujdeto Charts, texty písní (lyrics), pokec,...">Ujdeto Charts</a></legend>';
    kod+='<script type="text/javascript" src="http://www.ujdeto.cz/getinfo.php?mod=poradi&amp;id='+obj.form.jedna.value+'"></script>. | '+document.getElementById('jp').value+' | <script type="text/javascript" src="http://www.ujdeto.cz/getinfo.php?mod=body&amp;id='+obj.form.jedna.value+'"></script><br />';

    if(1*obj.form.dva.value>0) {
      kod+='<script type="text/javascript" src="http://www.ujdeto.cz/getinfo.php?mod=poradi&amp;id='+obj.form.dva.value+'"></script>. | '+document.getElementById('jd').value+' | <script type="text/javascript" src="http://www.ujdeto.cz/getinfo.php?mod=body&amp;id='+obj.form.dva.value+'"></script><br />';  
    }    
    if(1*obj.form.tri.value>0) {
      kod+='<script type="text/javascript" src="http://www.ujdeto.cz/getinfo.php?mod=poradi&amp;id='+obj.form.tri.value+'"></script>. | '+document.getElementById('jt').value+' | <script type="text/javascript" src="http://www.ujdeto.cz/getinfo.php?mod=body&amp;id='+obj.form.tri.value+'"></script><br />';  
    }    
    kod+='<br/><img src="http://www.ujdeto.cz/code.php?" alt="Kontrolní kód" width="40" height="20" style="background:#000000" /> Opište kontrolní kód: <input name="code" type="text" size="3" /><input name="btn" type="submit" value="Hlasovat" /><input type="hidden" name="jedna" value="'+obj.form.jedna.value+'" /><input type="hidden" name="dva" value="'+obj.form.dva.value+'" /><input type="hidden" name="tri" value="'+obj.form.tri.value+'" /><input type="hidden" name="hlasovano" value="hlasovat" /></fieldset></form></textarea><p>Tip: Chcete vědět, kolik lidí přes Vaše stránky chodí hlasovat? Najděte svou adresu v <a href="./backlinks.php" target="_BLANK">backlinks</a>!</p>';
    document.getElementById('koddiv').innerHTML=kod;
  }
