//Verze 4

var dom = (document.getElementById);
var ie4 = (document.all && !document.getElementById);
var ns4 = (document.layers);
var opera = (window.opera);

var pageWidth;
var pageHeight;

function getPageSize(){
	if (opera) {
		pageWidth = window.innerWidth;
		pageHeight = window.innerHeight;
	} else if(dom||ns4) {
		pageWidth = document.documentElement.clientWidth;
		pageHeight = document.documentElement.clientHeight;
	}else if(ie4) {
		pageWidth = document.body.clientWidth;
		pageHeight = document.body.clientHeight;
	}
}

getPageSize();

if (!document.getElementById && document.all) document.getElementById = document.all;

function idStyle(idf) { 
    if (dom) {
      return document.getElementById(idf).style;
    } else if (ie4) {
      return document.all[idf].style;
    } else if (ns4) {
      return document.layers[idf];
    } else { return null }
}

function newStyle(idEl,prop,value) {
     var object_style= idStyle(idEl);
	 if(object_style) 
        eval( 'object_style.' + prop + '="' + value+ '"' );
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

/*:::::::::::::::::::::::::::::::::::::
Otevira nove okno bez navigacnich prvku
Opicarny kolem jsWinH, jsWinW a resizeWindow jsou kvuli pluginu ve Firefoxu, ktery umoznuje otevirat vsechna popUp okna v novem
tabu (zalozce) a v takovem pripade je nezadouci aby se se velikost okna menila podle velikosti obrazku
:::::::::::::::::::::::::::::::::::::::
*/
function winOpen(link,w,h, winname,scroll) {
	var url;
	if (link.href != undefined) {
		url = link.href;
	}else{
		url = link;
	}
	if (url.indexOf('?')>=0) {
		url = url + '&jsWinW='+w+'&jsWinH='+h;
	}else{
		url = url + '?jsWinH='+w+'&jsWinH='+h;
	}
	window.open(url, winname, "toolbar=no,location=no,scrollbars="+scroll+",directories=no,status=no,menubar=no,resizable=yes,width="+w+",height="+h+",left=20,top=20");
}

/*:::::::::::::::::::::::::::::::::::::
Nastavuje velikost popUp okna podle nacteného obrazku. Vola se v body popUp okna na udalost onLoad.
Obrazek podle ktereho so okno nastavuje musi mit attribut id="MyImg"
Opicarny kolem jsWinH, jsWinW a resizeWindow jsou kvuli pluginu ve Firefoxu, ktery umoznuje otevirat vsechna popUp okna v novem
tabu (zalozce) a v takovem pripade je nezadouci aby se se velikost okna menila podle velikosti obrazku
:::::::::::::::::::::::::::::::::::::::
*/
function setWindowSize(corW, corH){
	if ((Request.QueryString('jsWinW') == winW() && Request.QueryString('jsWinH') == winH()) || Request.QueryString('resizeWindow')=='1'){
		var ImgObj=document.getElementById('MyImg');
		var newWindowWidth = ImgObj.width+12;
		var newWindowHeight = ImgObj.height+53;
		resizeWindow = 1
		if (navigator.appName.indexOf("Microsoft") != -1) {
			newWindowHeight = newWindowHeight-18;
			newWindowWidth = newWindowWidth+3;
		}
		
		//Zvetsime okno, aby se vesla navigace
		newWindowHeight = newWindowHeight+50;

		//Male obrazky nezmensi okno pod stanovenou mez
		if (newWindowHeight<250) newWindowHeight = 250;
		if (newWindowWidth<250) newWindowWidth = 250;
		
		//Zvetsime okno - prostor kolem obrazku
		newWindowHeight = newWindowHeight+35;
		newWindowWidth = newWindowWidth+30;

		//Zapocteme korekcni hodnoty z argumentu
		if (corH !="" ) newWindowHeight = newWindowHeight+corH;
		if (corW !="" ) newWindowWidth = newWindowWidth+corW;
		
		//Velke obrazky nezvetsi okno nad stanovenou mez
		if (newWindowHeight>710) newWindowHeight = 710;
		if (newWindowWidth>850) newWindowWidth = 850;
		
		self.resizeTo(newWindowWidth,newWindowHeight)
	}
}

/*
Otevirani odkazu do noveho okna bez pouziti atributu target (ktery nesezere norma 4.01 strict)
Staci dat odkazu ktere se maji otevirat do noveho okna atribut rel="external":
priklad: <a href="cosikdesi.html" rel="external">cosikdesi</a>
Funkci pak opet zavolas v tagu BODY pri udalosti onLoad:
onLoad="externalLinks(); "
*/
function externalLinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href")) {
			switch (anchor.getAttribute("rel")) {
				case "external":
					anchor.target = "_blank";
					break;
				case "imgPopUp":
					anchor.href = "javascript:winOpen('" + anchor.href + "',450,350, 'imgPopUp','no');";
					break;
			}
		}
	}
}

//Zjisteni hodnoty radiobuttonu
function getRadioValue(radio) {
	for (index=0; index<radio.length; index++) 	{
		if (radio[index].checked) return radio[index].value;
	}
	return null;
}

//Potvrzeni mazani cehokoli
function confirmDel(hlaska, adr){
	if (hlaska=='' || hlaska==undefined) hlaska = "Skuten chcete tento zznam smazat?";
	if(confirm(hlaska)){
		self.location.href = adr
		//alert(adr)
	}
}

//Ochrana proti robotum sbirajicim e-mailove adresy
function CreateLink(emil, str){
		if (str=="") str = "e"+"-m"+"ail";
		emil = regexpReplace(emil,'','@')
		emil = regexpReplace(emil,'','.')
		document.write("<A HREF=\"ma"+"ilt"+"o:"+emil+"\">"+str+"</a>")
}

function ClipBoard(i)
{
	document.formDhtml.holdtext.innerText = eval("copytext"+i+".innerText");
	Copied = document.formDhtml.holdtext.createTextRange();
	Copied.execCommand("RemoveFormat");
	Copied.execCommand("Copy");
}

function Smile(kde, co)
{
  frm = eval('document.forms.'+kde);
  frm.focus();
  frm.value=frm.value+co;
}

function reply(re,what){
  document.forms.frm_diskuze.prispevek.focus();
  document.forms.frm_diskuze.nadpis.value=re;
  document.forms.frm_diskuze.prispevek.value=document.forms.frm_diskuze.prispevek.value+what+': ';
}

function winH() {
   if (window.innerHeight)
      return window.innerHeight;
   else if
   (document.documentElement &&
   document.documentElement.clientHeight)
      return document.documentElement.clientHeight;
   else if
   (document.body && document.body.clientHeight)
      return document.body.clientHeight;
   else
      return null;
}

function winW() {
   if (window.innerWidth)
      return window.innerWidth;
   else if
   (document.documentElement &&
   document.documentElement.clientWidth)
      return document.documentElement.clientWidth;
   else if
   (document.body && document.body.clientWidth)
      return document.body.clientWidth;
   else
      return null;
}

function toASCII(what) {
	var strCS = "áéíóúůýäëüöěščřžďťľň";
	var strASCII = "aeiouuyaeuoescrzdtln";
	 
	for (var i=0; i<strCS.length; i++) {
	  what = regexpReplace(what, strCS.substring(i,i+1), strASCII.substring(i,i+1), "gi");
	}
	what = what.toLowerCase();
	what = regexpReplace(what, '[^a-z0-9.]+','-', "gi");
	return what;
}

function regexpReplace(kde, co, cim, params) {
  var re = new RegExp(co, params);
  str =  kde.replace(re, cim);
  re = '';
  return str;
}

function trim(str) {
   return str.replace(/^\s*|\s*$/g,"");
}

function genSeoUrl(src,dest){
	src = eval('document.frm.'+src);
	dest = eval('document.frm.'+dest);
	str = toASCII(src.value);
	dest.value = str;
}

/*
//Nahrazeni znaku (kde, co, cim)
function replace(str, original, replacement) {
	var result;
	result = "";
	while(str.indexOf(original) != -1) {
		if (str.indexOf(original) > 0)
			result = result + str.substring(0, str.indexOf(original)) + replacement;
		else
			result = result + replacement;
			str = str.substring(str.indexOf(original) + original.length, str.length);
	}
	return result + str;
}*/

/********************************************
         AJAX
********************************************/
function processRequest(mistoZobrazeni,js)
{
  if (httpRequest.readyState == 4)
  {
    if(httpRequest.status == 200)
    {
      var mistoZobrazeni = document.getElementById(mistoZobrazeni);
      mistoZobrazeni.innerHTML = httpRequest.responseText;
	  if(js!='') eval(js);
    }
    else
    {
        alert("Chyba pi natn AJAX"+ httpRequest.status +":"+ httpRequest.statusText);
    }
  }
}

function sendHttpRequest(mistoZobrazeni,url, js){
	if (url != '') {
		if (window.ActiveXObject) {
			httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
		}else{
			httpRequest = new XMLHttpRequest();
		}
		httpRequest.open("GET", url, true);
		httpRequest.onreadystatechange= function () {processRequest(mistoZobrazeni,js); } ;
		httpRequest.send(null);
	}
}


/*
Pomoci JavaScritptu cteme parametry z URL. Syntaxe pouziti:  Request.QueryString("nazev_promenne")
Andrew Urquhart : Client-Side Request Object for javascript : http://andrewu.co.uk/tools/request/
COPYRIGHT:You are free to use this script for any use you wish if this comment is left intact. Feel free to enhance the script and send me the updated version. Please don't redistribute. This script is provided as is,with no warranty of any kind. Use it at your own risk. Copyright Andrew R Urquhart; VERSION:#1.2 2004-02-18 18:48 UTC
*/
function RObj(ea){var LS="";var QS=new Object();var un="undefined";var f="function";var n="number";var r="string";var e1="ERROR:Index out of range in\r\nRequest.QueryString";var e2="ERROR:Wrong number of arguments or invalid property assignment\r\nRequest.QueryString";var e3="ERROR:Object doesn't support this property or method\r\nRequest.QueryString.Key";function Err(arg){if(ea)alert("Request Object:\r\n"+arg)};function URID(t){var d="";if(t){for(var i=0;i<t.length;++i){var c=t.charAt(i);d+=(c=="+"?" ":c);};};return unescape(d);};function OL(o){var l=0;for(var i in o){if(typeof(o[i])!=f) l++;};return l;};function AK(key){var auk=true;for(var u in QS){if(typeof(QS[u])!=f&&u.toString().toLowerCase()==key.toLowerCase()){auk=false;return u;}};if(auk){QS[key]=new Object();QS[key].toString=function(){return TS(QS[key])};QS[key].Count=function(){return OL(QS[key])};QS[key].Count.toString=function(){return OL(QS[key]).toString()};QS[key].Item=function(e){if(typeof(e)==un) return QS[key];else {if(typeof(e)==n){var a=QS[key][Math.ceil(e)];if(typeof(a)==un) Err(e1+"(\""+key+"\").Item("+e+")");return a;}else Err("ERROR:Expecting numeric input in\r\nRequest.QueryString(\""+key+"\").Item(\""+e+"\")");}};QS[key].Item.toString=function(e){if(typeof(e)==un) return QS[key].toString();else {var a=QS[key][e];if(typeof(a)==un) Err(e1+"(\""+key+"\").Item("+e+")");return a.toString();};};QS[key].Key=function(e){var t=typeof(e);if(t==r){var a=QS[key][e];return(typeof(a)!=un&&a&&a.toString()?e:"");}else Err(e3+"("+(e?e:"")+")");};QS[key].Key.toString=function(){return un};};return key};function AVTK(key,val){if(key!=""){var key=AK(key);var l=OL(QS[key]);QS[key][l+1]=val;}};function TS(o){var s="";for(var i in o){var ty=typeof(o[i]);if(ty=="object") s+=TS(o[i]);else if(ty!=f) s+=o[i]+", ";};var l=s.length;if(l>1)return(s.substring(0,l-2));return(s==""?un:s);};function KM(k,o){var k=k.toLowerCase();for(var u in o){if(typeof(o[u])!=f&&u.toString().toLowerCase()==k) return u;};}if(window.location&&window.location.search){LS=window.location.search;var l=LS.length;if(l>0){LS=LS.substring(1,l);var preAmpAt=0;var ampAt=-1;var eqAt=-1;var k=0;var skip=false;for(var i=0;i<l;++i){var c=LS.charAt(i);if(LS.charAt(preAmpAt)=="="||(preAmpAt==0&&i==0&&c=="=")) skip=true;if(c=="="&&eqAt==-1&&!skip) eqAt=i;if(c=="&"&&ampAt==-1){if(eqAt!=-1) ampAt=i;if(skip) preAmpAt=i+1;skip=false;};if(ampAt>eqAt){AVTK(URID(LS.substring(preAmpAt,eqAt)),URID(LS.substring(eqAt+1,ampAt)));preAmpAt=ampAt+1;eqAt=ampAt=-1;++k;};};if(LS.charAt(preAmpAt)!="="&&(preAmpAt!=0||i!=0||c!="=")){if(preAmpAt!=l){if(eqAt!=-1) AVTK(URID(LS.substring(preAmpAt,eqAt)),URID(LS.substring(eqAt+1,l)));else if(preAmpAt!=l-1) AVTK(URID(LS.substring(preAmpAt,l)),"");};if(l==1) AVTK(LS.substring(0,1),"");};};};var TC=OL(QS);if(!TC) TC=0;QS.toString=function(){return LS.toString()};QS.Count=function(){return(TC?TC:0)};QS.Count.toString=function(){return(TC?TC.toString():"0")};QS.Item=function(e){if(typeof(e)==un) return LS;else {if(typeof(e)==n){var e=Math.ceil(e);var c=0;for(var i in QS){if(typeof(QS[i])!=f&&++c==e) return QS[i];};Err(e1+"().Item("+e+")");}else return QS[KM(e,QS)];};return un;};QS.Item.toString=function(){return LS.toString()};QS.Key=function(e){var t=typeof(e);if(t==n){var e=Math.ceil(e);var c=0;for(var i in QS){if(typeof(QS[i])!=f&&++c==e) return i;}}else if(t==r){var e=KM(e,QS);var a=QS[e];return(typeof(a)!=un&&a&&a.toString()?e:"");}else Err(e2+"().Key("+(e?e:"")+")");Err(e1+"().Item("+e+")");};QS.Key.toString=function(){Err(e2+"().Key");};this.QueryString=function(k){if(typeof(k)==un) return QS;else {var k=KM(k,QS);if(typeof(QS[k])==un){t=new Object();t.Count=function(){return 0};t.Count.toString=function(){return "0"};t.toString=function(){return un};t.Item=function(e){return un};t.Item.toString=function(){return un};t.Key=function(e){Err(e3+"("+(e?e:"")+")");};t.Key.toString=function(){return un};return t;}if(typeof(k)==n) return QS.Item(k);else return QS[k];}};this.QueryString.toString=function(){return LS.toString();};this.QueryString.Count=function(){return(TC?TC:0)};this.QueryString.Count.toString=function(){return(TC?TC.toString():"0")};this.QueryString.Item=function(e){if(typeof(e)==un) return LS.toString();else {if(typeof(e)==n){var e=Math.ceil(e);var c=0;for(var i in QS){if(typeof(QS[i])!=f&&++c==e) return QS[i];};Err(e1+".Item("+e+")");}else return QS[KM(e,QS)];}if(typeof(e)==(n)) Err(e1+".Item("+e+")");return un;};this.QueryString.Item.toString=function(){return LS.toString()};this.QueryString.Key=function(e){var t=typeof(e);if(t==n){var e=Math.ceil(e);var c=0;for(var i in QS){if(typeof(QS[i])=="object"&&(++c==e)){return i;}}}else if(t==r){var e=KM(e,QS);var a=QS[e];return(typeof(a)!=un&&a&&a.toString()?e:"");}else Err(e2+".Key("+(e?e:"")+")");Err(e1+".Item("+e+")");};this.QueryString.Key.toString=function(){Err(e2+".Key");};this.Version=1.2;this.Author="Andrew Urquhart (www.andrewu.co.uk)";};var Request=new RObj(false);

function enableModalDialog(h, w){
	var h = 200;
	var w = 300;
	
	getPageSize();
	
	/*bg=document.createElement("div");
	bg.id="modalbg";
	bg.setAttribute("id","modalbg");
	document.getElementsByTagName("body")[0].appendChild(bg);

	h=document.createElement("div");
	h.id="modaldialog";
	h.setAttribute("id","modaldialog");
	h.appendChild(document.createTextNode('test'));
	h.appendChild(document.createElement("br"));
	btn = h.appendChild(document.createElement("button"));
	btn.style.width="60px";
	btn.style.height="24px";
	btn.setAttribute("onclick","alert('ok')");
	btntext = document.createTextNode('OK');
	btn.appendChild(btntext);
	document.getElementsByTagName("body")[0].appendChild(h);*/

	
	el = idStyle('modalbg');
	el.filter="alpha(opacity:50)";
	el.KHTMLOpacity="0.50";
	el.MozOpacity="0.50";
	el.opacity="0.50";
	el.width = pageWidth+'px';
	el.height = pageHeight+'px';

	
	el = idStyle('modaldialog');
	el.top= ((pageHeight/2)-(h/2))+'px';
	el.left=((pageWidth/2)-(w/2))+'px';
	
}

function modalDialog(idEl, h, w, edittime, mistoZobrazeni, text){
	var mistoZobrazeni = document.getElementById(mistoZobrazeni);
	mistoZobrazeni.innerHTML = text;
	f = document.forms.modalForm;
	if (f.origzacatekakce != undefined) {
		f.origzacatekakce.value = edittime;
	}
	newStyle('modalbg','display','block');
	newStyle(idEl,'display','block');
	newStyle(idEl,'display','block');

}

function modalSendUdalost(f, r){
	var val = getRadioValue(r);
	newStyle('modalbg','display','none');
	newStyle('modaldialog','display','none');
	if (val==null || val == 'undefined' || val === false) val=''; 
	//alert(val);
	if (val!=""){
		f.submit();
	}
}

