// JavaScript Document
//Funkce global JS verze 1.4

//Vytvoří HTTPobjekt pro AJAX
function getHTTPObject() {
   var xmlhttp=false;

   /*@cc_on @*/
   /*@if (@_jscript_version >= 5)

   try {
   	xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
   	} catch (e) {
   	try {
   		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   		} catch (E) {
   		xmlhttp = false;
   		}
   	}

   @else
   xmlhttp = false;
   @end @*/

   if (!xmlhttp && typeof XMLHttpRequest!='undefined') {

   	try {
        	xmlhttp = new XMLHttpRequest();
      		} catch (e) {
        	xmlhttp = false;
      		}
   }

   return xmlhttp;
}


//-------------------------------------------------------------------------------------
//vrat kod stisknute klavesy - vrati kod stisknute klavesy v udalosti onkeypress
function kod_klavesy(e)
   {
   var code;
   if (!e)
      var e = window.event; // nastaveni pro IE
   if (e.keyCode)
      code = e.keyCode; // IE a Mozilla
   else
      if (e.which)
         code = e.which; // NN4
   return code;
   }

//----------------------------------------------------------------------------------------

//-------------------------------------------------------------------------------------
//budeli u input text nastaven class="numeric", potom pujdou psat do tohoto pole pouze cisla
function inputNumeric() {
   var allfields = document.getElementsByTagName("input");
   for (var i=0; i<allfields.length; i++){
      var field = allfields[i];
      if (field.getAttribute("type") == "text" && field.className.indexOf("numeric") !== -1) {
         field.onkeypress = function(event) {
            kod = kod_klavesy(event);
            if ((kod < 48 || kod > 57) && kod != 37 && kod != 39 && kod != 8 && kod != 46 && kod != 9) return false;
         	};
         };
      };
   };

//-------------------------------------------------------------------------------------


//-------------------------------------------------------------------------------------
//budeli u input text nastaven class="xcss-css",
//pri nastaveni focus na tento prvek bude zmenen class na css, pri opusteni se zmeni zpet na 
//pocatecni hodnotu
function xcss() {
   var allfields = document.getElementsByTagName("input");
   for (var i=0; i<allfields.length; i++){
      var field = allfields[i];
      if (field.getAttribute("type") == "text" && field.className.indexOf("xcss-") !== -1) {
         field.tag = field.className;
			field.onfocus = function() {
         	this.className = this.className.replace("xcss-", ""); 
				};
			field.onblur = function() {
         	this.className = this.tag; 
				};
         };
      };
   };
//-------------------------------------------------------------------------------------


//-------------------------------------------------------------------------------------
//budeli u input text nastaven class="upper", potom pujdou psat do tohoto pole pouze velke znaky
function inputUpper() {
   if (whichBrs() == "Opera") return;
   var allfields = document.getElementsByTagName("input");
   for (var i=0; i<allfields.length; i++) {
      var field = allfields[i];
      if (field.getAttribute("type") == "text" && field.className == "upper") {
         field.onkeydown = function(event) {
            var kod = kod_klavesy(event);
            if ((kod > 64) && (kod < 91)) {
					this.value=this.value + String.fromCharCode(kod).toUpperCase(); return false;
					};
				};
         };
      };
   };
//-------------------------------------------------------------------------------------



//vrati jmeno prohlizece
function whichBrs() {
	var agt=navigator.userAgent.toLowerCase();
	if (agt.indexOf("chrome") != -1) return 'Chrome';
	if (agt.indexOf("opera") != -1) return 'Opera';
	if (agt.indexOf("staroffice") != -1) return 'Star Office';
	if (agt.indexOf("webtv") != -1) return 'WebTV';
	if (agt.indexOf("beonex") != -1) return 'Beonex';
	if (agt.indexOf("chimera") != -1) return 'Chimera';
	if (agt.indexOf("netpositive") != -1) return 'NetPositive';
	if (agt.indexOf("phoenix") != -1) return 'Phoenix';
	if (agt.indexOf("firefox") != -1) return 'Firefox';
	if (agt.indexOf("safari") != -1) return 'Safari';
	if (agt.indexOf("skipstone") != -1) return 'SkipStone';
	if (agt.indexOf("msie") != -1) return 'Internet Explorer';
	if (agt.indexOf("netscape") != -1) return 'Netscape';
	if (agt.indexOf("mozilla/5.0") != -1) return 'Mozilla';
	if (agt.indexOf('\/') != -1) {
	if (agt.substr(0,agt.indexOf('\/')) != 'mozilla') {
		return navigator.userAgent.substr(0,agt.indexOf('\/'));}
		else return 'Netscape';} else if (agt.indexOf(' ') != -1)
		return navigator.userAgent.substr(0,agt.indexOf(' '));
		else return navigator.userAgent;
}


//----------------------------------------------------------------------------------------
//vrati pole s pozici mysi
function pozice_kurzoru(e, skrolovani) {
   var posx = 0;
   var posy = 0;
   var pole = new Array(0,0);
   
   if (!e) var e = window.event;
   if (e.pageX || e.pageY) {   //OPERA, IE7, FF
      if (skrolovani) {
         mX = e.pageX;
         mY = e.pageY;
         } else {
			mX = e.pageX - document.documentElement.scrollLeft;
         mY = e.pageY - document.documentElement.scrollTop;
			}
      }
      else if (e.clientX || e.clientY) {
      if (skrolovani) {
         mX = e.clientX + document.documentElement.scrollLeft;
         mY = e.clientY + document.documentElement.scrollTop;
         } else {
			mX = e.clientX;
         mY = e.clientY;
			}
      }

   pole[0] = mX;
   pole[1] = mY;
   
   return pole;
   
   };


//----------------------------------------------------------------------------------------
//Tato funkce vraci do objektu id=progress innerHTML s hodnotou aktualne uploudnuteho souboru.
//Funkce je postavena na uploadu vice souboru najednou z jednoho formulare
//Funkce predpoklada na ceste soubor ajax.php s casti PROGRESSBAR a MKTIME
function progressbar() {

   var xmlhttp=getHTTPObject();
   var docname = "ajax_global.php?akce=mktime";

   if (xmlhttp) {
      xmlhttp.open("GET", docname, true);
      xmlhttp.onreadystatechange=function() {
         if (xmlhttp.readyState==4) {
            progressbar_upload(xmlhttp.responseText);
            }
	 	   }
      xmlhttp.send(null)
      }

   }

function progressbar_upload(razitko) {

   var xmlhttp=getHTTPObject();
   var docname = "ajax_global.php?akce=progressbar&razitko=" + razitko;

   if (xmlhttp) {
      xmlhttp.open("GET", docname, true);
      xmlhttp.onreadystatechange=function() {
         if (xmlhttp.readyState==4) {
            document.getElementById("progress").innerHTML=xmlhttp.responseText;
            window.setTimeout("progressbar_upload("+razitko+")", 500);
            }
	 	   }
      xmlhttp.send(null)
      }

   }



//---------------------------------------------------------------------------------------
//Funkce vrati hodnotu ze zadaneho pole z Mysql tabulky
function mySelect(table, column, id) {

   var xmlhttp=getHTTPObject;
   var docname = "ajax.php?akce=mySelect&table="+table+"&column="+column+"&id=" + id;

   if (xmlhttp) {
      xmlhttp.open("GET", docname, false);
      xmlhttp.send(null)
      return xmlhttp.responseText;
      }
   }
//----------------------------------------------------------------------------------------



//----------------------------------------------------------------------------------------
//Funkce vrati pole s rozmery okna
function getPageSize(){
  browser = whichBrs();
  if (document.documentElement) {
    var iWidth = document.documentElement.clientWidth;
    var iHeight = document.documentElement.clientHeight;
     //DALSI FATALNI CHYBA V OPERE - ma prehozene udaje  BODY a documentElement !!
    if (browser == "Opera") {
      iHeight=document.body.clientHeight;
      };
  } else {
    var iWidth = window.innerWidth || self.innerWidth || document.body.clientWidth;
    var iHeight = window.innerHeight || self.innerHeight || document.body.clientHeight;
  }
	var aSize = new Array(iWidth, iHeight)
	return aSize;
}


//----------------------------------------------------------------------------------------
//Funkce vrati pole s nastavenim scrollbaru
function getPageScroll(){
	var iTop;
	var iLeft;
	if (self.pageYOffset || self.pageXOffset) {
		iTop = self.pageYOffset;
		iLeft = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop || document.documentElement.scrollLeft ){	 // Explorer 6 Strict
		iTop = document.documentElement.scrollTop;
		iLeft = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
		iTop = document.body.scrollTop;
		iLeft = document.body.scrollLeft;
	}
	aScroll = new Array(iLeft, iTop);
	return aScroll;
}


//----------------------------------------------------------------------------------------
//Funkce vygeneruje IFRAME nebo DIALOG okno
function xwindow(winId, params) {

	var winWidth = 150; //výchozí šířka okna
	var winHeight = 50; //výchozí výška okna
	var horizontCenter = true; //automatické horizontalni zarovnání na střed okna prohlížeče
   var verticalCenter = true; //automatické vertical zarovnání na střed okna prohlížeče
   var winTop = false; //odsazení zhora
	var winLeft = false; //odsazení zleva
	var minWidth = 150; //minimální šířka okna v px, mozno zadat i %  (např. 50%)
	var minHeight = 150; //minimální výška okna v px, mozno zadat i %  (např. 50%)
	var moveOpacity = 100; //průhlednost při přesouvání okna - zadava se procentuelne bez symbolu %
   var opacity = 100; //stálá průhlednost okna, zadava se procentuelne bez symbolu %
   var resizable = true; //povolení/zákaz změmny velikosti okna
	var moveable = true; //povolení/zákaz změmny přesunu okna
	var title = "Window"; //titulek okna
   var emptyBackground = "infoBackground"; //barva pozadí okna
   var urlFrame = false; //webova adresa zobrazovaného webu
	var dialog = true; // přepínač - zobrazí okno jako dialog
   var dialogText = false; //text dialogu, pro zadání znaku čárka zadejte ,,
   var dialogImg = false; //obrazek dialogu
   var dialogType = "alert";  //hodnoty:  alert, confirm
   var dialogOkButtonText = "OK"; //návěští tlačítka OK
   var dialogStornoButtonText = "Storno"; //návěští tlačítka STORNO
   var dialogBClass = false; //hodnota atributu class u buttonu
	var dialogTimeout = false; //aut. zavreni okna v sekundach, pri uzavreni vola uzivatelskou clickFunction stejne jako buttony
	var HTMLTemplate = false; //html kod, ktery se zobrazi v okne
	var widthMoveMantinel = false;
	var winColor = 1; //urcuje kod barvy okna  1-modra, 2-červená, 3-zelená, 4-hnědožlutá
	var winFramepicsFolder = "xwin_pics";  //adresar s grafikou pro xwindow
	var shadowWindow = false; //stmavi pozadi, hodnota je pruhlednost v procentech bez znacky % (napr.: 50)
				// pokud je zadana hodnota 0, bude DIV vytvoren s absolutni pruhlednosti
				// pri zadani false nebude DIV vubec vytvoren  (objekty na strance budou i nadale pristupne)
	var clickFunction = false; //nazev funkce, ktera se spusti pri kliku na button,
			// pokud funkce obsahuje parametr buttonCode preda se do nej kod tlacitka pripadne priznak zavreni krizkem (napr.: spustit(akce, buttonCode)   )
			//kody:  1 - stisknuto tlacitko OK,  2 - Storno,  3 - krizek zavreni okna nebo aut. zavreni po timeout


	//var params = "urlFrame=legislativa_data.php?druh_legislativy==6&cislo==200&vzorec==, winTop=150, winHeight=200, shadowWindow=0";
	while (params.indexOf(",,") > -1) params = params.replace(",,", "#@#");
	while (params.indexOf("==") > -1) params = params.replace("==", "#@@#");
   if (params.toString().length > 3) {
      parametry = params.split(",");
      for(var i = 0; i < parametry.length; i++) {
   		var prvek = parametry[i].replace(/^\s*(.*?)\s*$/, "$1"); //trim
   		//while (params.indexOf("#@#") > -1) prvek = prvek.replace("#@#", ",");
   		while (prvek.indexOf("#@#") > -1) prvek = prvek.replace("#@#", ",");
   		var pole = prvek.split("=");
         if ((pole[1] != "true") && (pole[1] != "false")) {
   			pole[0] = pole[0].replace(/^\s*(.*?)\s*$/, "$1");
   	      pole[1] = pole[1].replace(/^\s*(.*?)\s*$/, "$1");
            while (pole[1].indexOf("#@@#") > -1) pole[1] = pole[1].replace("#@@#", "=");
            prvek = pole[0] + '="' + pole[1] + '"';
   			};
   		eval(prvek);
   		};
      };


   //vyresi pozici pri nenulovych scrollbarech
   aScroll = getPageScroll();
   winTop = Math.abs(winTop) + Math.abs(aScroll[1]);
	winLeft = Math.abs(winLeft) + Math.abs(aScroll[0]);

   if (winWidth.toString().indexOf("%") > -1) {
      pole = winWidth.split("%");
      winWidth = Math.abs((document.documentElement.offsetWidth / 100) * pole[0]);
      };

   aSize = getPageSize();
   if (horizontCenter) {
      winLeft = (aSize[0] - winWidth) / 2;
      };
   if (verticalCenter) {
      winTop = ((aSize[1] - winHeight) / 2) + aScroll[1];
      };

   if (winWidth < minWidth) winWidth = minWidth;
   if (winHeight < minHeight) winHeight = minHeight;

   var browser = whichBrs();

	//tento div se vytvori v okamziku onmousedown a zrusi v okamziku onmouseup
	pomocnyDiv = document.createElement("div");
	pomocnyDiv.style.width = document.documentElement.offsetWidth + "px";
	pomocnyDiv.style.height = document.body.offsetHeight + 30 + "px";
	pomocnyDiv.style.position = "absolute";
	pomocnyDiv.style.top = "0px";
	pomocnyDiv.style.left = "0px";
	pomocnyDiv.style.filter = "alpha(opacity='0')";
	pomocnyDiv.style.opacity = 0;
	pomocnyDiv.style.backgroundColor = "blue";
	pomocnyDiv.style.zIndex = 98;
	pomocnyDiv.tag = 1;
   pomocnyDiv.id = "xwinPomocnyDiv";

	shadowWindowDiv = document.createElement("div");
	shadowWindowDiv.style.width = document.documentElement.offsetWidth + "px";
   shadowWindowDiv.style.height = aSize[1] + "px";
   if (document.documentElement.clientHeight > aSize[1]) shadowWindowDiv.style.height = document.documentElement.clientHeight + 30 + "px";
   if (document.body.clientHeight > aSize[1]) shadowWindowDiv.style.height = document.body.clientHeight + 30 + "px";
	shadowWindowDiv.style.position = "absolute";
	shadowWindowDiv.style.top = "0px";
	shadowWindowDiv.style.left = "0px";
	shadowWindowDiv.style.filter = "alpha(opacity='"+shadowWindow+"')";
	shadowWindowDiv.style.opacity = shadowWindow / 100 + "";
	shadowWindowDiv.style.backgroundColor = "black";
	shadowWindowDiv.style.zIndex = 78;

	if (shadowWindow !== false) document.body.appendChild(shadowWindowDiv);

	if (document.getElementById(winId)) {
		document.body.removeChild(xwin);
		};

	xwin = document.createElement("table");
	xwin.style.position = "absolute";
	xwin.style.width = winWidth + "px";
	xwin.style.height = winHeight + "px";
   if (winTop !== false) xwin.style.top = winTop + "px";
   if (winLeft !== false) xwin.style.left = winLeft + "px";
   xwin.style.borderCollapse = "collapse";
	xwin.style.padding = "0px";
	xwin.style.margin = "0px";
	xwin.style.padding = "0px";
	xwin.style.fontSize = "12px";
	xwin.style.fontFamily = "Verdana";
	xwin.tag = "0";
	xwin.style.zIndex = 80;
	xwin.id = winId;

	radek1 = xwin.insertRow(0);
	radek1.style.height = "23px";

	radek2 = xwin.insertRow(1);
	radek2.style.height = "100%";

	radek3 = xwin.insertRow(2);
	radek3.style.height = "4px";

	sloupec11 = radek1.insertCell(0);
	sloupec11.style.width = "4px";
	sloupec11.style.padding = "0px";
	sloupec11.style.verticalAlign = "top";

	sloupec12 = radek1.insertCell(1);
	sloupec12.style.backgroundImage = "url('"+winFramepicsFolder+"/"+winColor+"frame02.gif')";
	sloupec12.style.backgroundRepeat = "repeat-x";
	sloupec12.style.color = "white";
	sloupec12.style.fontWeight = "bold";
	sloupec12.style.padding = "0px";
	sloupec12.style.paddingLeft = "5px";

	sloupec13 = radek1.insertCell(2);
	sloupec13.style.width = "4px";
	sloupec13.style.verticalAlign = "top";
	sloupec13.style.padding = "0px";

	sloupec21 = radek2.insertCell(0);
	sloupec21.style.width = "4px";
	sloupec21.style.padding = "0px";
	sloupec21.style.verticalAlign = "top";
	sloupec21.style.backgroundImage = "url('"+winFramepicsFolder+"/"+winColor+"frame08.gif')";
	sloupec21.style.backgroundRepeat = "repeat-y";
   if (resizable) {
   	sloupec21.style.cursor = "e-resize";
   	sloupec21.onmousedown = function(event){
   		document.body.style.cursor = "e-resize";
   		xwin.tag = "5*" + ((xwin.offsetWidth) + (xwin.offsetLeft));
	      document.body.appendChild(pomocnyDiv);
			return false;
   		};
      };


	sloupec22 = radek2.insertCell(1);
	sloupec22.style.backgroundColor = emptyBackground;
	sloupec22.style.padding = "0px";
	sloupec22.style.filter = "alpha(opacity="+opacity+")";
	sloupec22.style.opacity = opacity / 100 + "";
   sloupec22.onmouseover = function () { pomocnyDiv.tag = 0; };
   sloupec22.onmouseout = function () { pomocnyDiv.tag = 1; };
   winiframe = document.createElement("iframe");
	winiframeDiv = document.createElement("div");
   var iframeHeight = 0;
   if (urlFrame) {
      if (browser == "Firefox" || browser == "Chrome") iframeHeight = winHeight - 42;
      if (browser == "Opera") iframeHeight = winHeight - 30;
      if (browser == "Internet Explorer") iframeHeight = winHeight;
      winiframe.src = urlFrame;
      winiframe.style.border = "0px none";
      winiframe.width = "100%";
      winiframe.height = iframeHeight + "px";
		sloupec22.appendChild(winiframe);
		};

   if (dialog && !urlFrame) {
      sloupec22.style.padding = "5px";
		dialogTable = document.createElement("table");
      dialogTable.style.width = "100%";
      dialogTable.style.border = "0px none";
      dialogTable.style.margin = "0px auto";
      var radekIndex = 0;
		if ((dialogImg) || (dialogText)) {
			dialogRadek1 = dialogTable.insertRow(radekIndex);
			radekIndex++;
			};
      var sloupecIndex = 0;
		if (dialogImg) {
			dialogR1Sloupec1 = dialogRadek1.insertCell(sloupecIndex);
      	dialogR1Sloupec1.style.width = "25%";
      	dialogR1Sloupec1.style.textAlign = "center";
      	sloupecIndex++;
      	oDialogImg = document.createElement("img");
      	oDialogImg.alt = "";
      	oDialogImg.src = dialogImg;
      	oDialogImg.style.border = "0px none";
      	dialogR1Sloupec1.appendChild(oDialogImg);
			};
		if (dialogText) {
			dialogR1Sloupec2 = dialogRadek1.insertCell(sloupecIndex);
      	dialogR1Sloupec2.style.textAlign = "center";
      	dialogR1Sloupec2.innerHTML = dialogText;
			sloupecIndex++;
			};
      dialogRadek2 = dialogTable.insertRow(radekIndex);
      dialogR2Sloupec1 = dialogRadek2.insertCell(0);
      dialogR2Sloupec1.colSpan = "2";
      dialogR2Sloupec1.style.textAlign = "center";
      oOkButton = document.createElement("input");
		oOkButton.setAttribute("type","button");
		oOkButton.setAttribute("value", dialogOkButtonText);
      oOkButton.style.margin = "6px";
      oOkButton.style.marginTop = "14px";
      if (dialogBClass) oOkButton.setAttribute("class", dialogBClass);
		if (!dialogBClass) {
			oOkButton.style.width = "90px";
      	};
      oOkButton.onclick = function() {
      	document.body.removeChild(xwin);
			if (shadowWindow !== false) document.body.removeChild(shadowWindowDiv);
			if (clickFunction !== false) eval(clickFunction.replace("buttonCode", "1"));
			return true;
			};
		dialogR2Sloupec1.appendChild(oOkButton);

      if (dialogType == "confirm") {
	      oStornoButton = document.createElement("input");
			oStornoButton.setAttribute("type","button");
			oStornoButton.setAttribute("value", dialogStornoButtonText);
      	oStornoButton.style.margin = "6px";
      	oStornoButton.style.marginTop = "14px";
	      if (dialogBClass) oStornoButton.setAttribute("class", dialogBClass);
			if (!dialogBClass) {
				oStornoButton.style.width = "90px";
	      	};
	      oStornoButton.onclick = function() {
	      	document.body.removeChild(xwin);
	      	if (shadowWindow !== false) document.body.removeChild(shadowWindowDiv);
				if (clickFunction !== false) eval(clickFunction.replace("buttonCode", "2"));
				return false;
				};
			dialogR2Sloupec1.appendChild(oStornoButton);
      	};

      sloupec22.appendChild(dialogTable);
      };

	if (HTMLTemplate && !urlFrame) {
		sloupec22.innerHTML = HTMLTemplate;
		};

	sloupec23 = radek2.insertCell(2);
	sloupec23.style.width = "4px";
	sloupec23.style.padding = "0px";
	sloupec23.style.verticalAlign = "top";
	sloupec23.style.backgroundImage = "url('"+winFramepicsFolder+"/"+winColor+"frame04.gif')";
	sloupec23.style.backgroundRepeat = "repeat-y";
   if (resizable) {
   	sloupec23.style.cursor = "e-resize";
   	sloupec23.onmousedown = function(event){
   		document.body.style.cursor = "e-resize";
   		xwin.tag = "3*" + (xwin.offsetLeft - 2);
	      document.body.appendChild(pomocnyDiv);
	      return false;
   		};
      };

	sloupec31 = radek3.insertCell(0);
	sloupec31.style.width = "4px";
	sloupec31.style.padding = "0px";
	sloupec31.style.verticalAlign = "top";

	sloupec32 = radek3.insertCell(1);
	sloupec32.style.padding = "0px";
	sloupec32.style.backgroundImage = "url('"+winFramepicsFolder+"/"+winColor+"frame06.gif')";
	sloupec32.style.backgroundRepeat = "repeat-x";
   if (resizable) {
   	sloupec32.style.cursor = "n-resize";
   	sloupec32.onmousedown = function(event){
   		document.body.style.cursor = "n-resize";
         if (browser == "Firefox" || browser == "Chrome") {
   			xwin.tag = "4*" + (xwin.offsetTop - 12);
   			};
         if (browser == "Opera") {
   			xwin.tag = "4*" + (xwin.offsetTop - 4);
   			};
         if (browser == "Internet Explorer") {
   			xwin.tag = "4*" + (xwin.offsetTop + 36);
   			};
	      document.body.appendChild(pomocnyDiv);
	      return false;
   		};
      };

	sloupec33 = radek3.insertCell(2);
	sloupec33.style.width = "4px";
	sloupec33.style.padding = "0px";
	sloupec33.style.verticalAlign = "top";
	sloupec33.style.backgroundImage = "url('"+winFramepicsFolder+"/"+winColor+"frame05.gif')";
	sloupec33.style.backgroundRepeat = "no-repeat";
   if (resizable) {
   	sloupec33.style.cursor = "nw-resize";
      sloupec33.onmousedown = function(event){
   		document.body.style.cursor = "nw-resize";
         if (browser == "Firefox" || browser == "Chrome") {
   			xwin.tag = "2*" + (xwin.offsetLeft - 2) + "*" + (xwin.offsetTop - 14);
   			};
         if (browser == "Opera") {
   			xwin.tag = "2*" + (xwin.offsetLeft - 2) + "*" + (xwin.offsetTop - 4);
   			};
         if (browser == "Internet Explorer") {
   			xwin.tag = "2*" + (xwin.offsetLeft - 2) + "*" + (xwin.offsetTop + 34);
   			};
	      document.body.appendChild(pomocnyDiv);
	      return false;
   		};
      };

	img1 = document.createElement("img");
	img1.alt = "";
	img1.src = ""+winFramepicsFolder+"/"+winColor+"frame01.gif";
	img1.style.padding = "0px";
	img1.style.margin = "0px";
	img1.style.border = "0px none";
	img1.style.verticalAlign = "top";
	sloupec11.appendChild(img1);

	img2 = document.createElement("img");
	img2.alt = "";
	img2.src = ""+winFramepicsFolder+"/"+winColor+"frame03.gif";
	img2.style.padding = "0px";
	img2.style.margin = "0px";
	img2.style.border = "0px none";
	img2.style.verticalAlign = "top";
	sloupec13.appendChild(img2);

	img3 = document.createElement("img");
	img3.alt = "";
	img3.src = ""+winFramepicsFolder+"/"+winColor+"frame07.gif";
	img3.style.padding = "0px";
	img3.style.margin = "0px";
	img3.style.border = "0px none";
	img3.style.verticalAlign = "top";
	sloupec31.appendChild(img3);


	divik = document.createElement("div");
	divik.setAttribute("style","float:left")
	divik.style.styleFloat = "left";
	divik.style.paddingTop = "3px";
	divik.style.height = "20px";
	divik.style.cursor = "default";
	divik.innerHTML = title;
	sloupec12.appendChild(divik);

	xclose = document.createElement("img");
	xclose.setAttribute("style","float:right")
	xclose.style.styleFloat = "right";
	xclose.src = ""+winFramepicsFolder+"/"+winColor+"close0.gif";
	xclose.onmousemove = function() {
		xclose.src = ""+winFramepicsFolder+"/"+winColor+"close1.gif"
		};
	xclose.onmouseout = function() {
		xclose.src = ""+winFramepicsFolder+"/"+winColor+"close0.gif"
		pomocnyDiv.tag = 1;
		};
	xclose.onclick = function() {
		document.body.removeChild(xwin);
		if (shadowWindow !== false) document.body.removeChild(shadowWindowDiv);
		if (clickFunction !== false) eval(clickFunction.replace("buttonCode", "3"));
		};
	xclose.onmouseover = function() {
		pomocnyDiv.tag = 0;
		};
	sloupec12.appendChild(xclose);


   if (moveable)
   sloupec12.onmousedown = function(event){
		souradniceM = pozice_kurzoru(event, true);
      xwin.tag = "1*" + (souradniceM[0] - xwin.offsetLeft);
      if (pomocnyDiv.tag == 1) document.body.appendChild(pomocnyDiv);
      if (moveOpacity < 100) {
         sloupec22.style.opacity = moveOpacity / 100;
         sloupec22.style.filter = "alpha(opacity="+moveOpacity+")";
         };
      return false;
      };

	if ((browser == "Firefox") || (browser == "Opera") || browser == "Chrome") hlavniElement = window;
	if (browser == "Internet Explorer") hlavniElement = document.body;
	hlavniElement.onmouseup = function(event){
	      xwin.tag = "0";
	      document.body.style.cursor = "default";
         if (moveOpacity < 100) sloupec22.style.opacity = opacity / 100 + "";
         if (moveOpacity < 100) sloupec22.style.filter = "alpha(opacity='"+opacity+"')";
         if (document.getElementById("xwinPomocnyDiv")) document.body.removeChild(pomocnyDiv);
			};
	hlavniElement.onmousemove = function(event){
			if (!event) var event = window.event;
			moving(event, xwin, minWidth, minHeight, widthMoveMantinel, winiframe, browser);
	      };

   document.body.appendChild(xwin);

	if (dialogTimeout) {
		window.setTimeout("xclose.onclick()", dialogTimeout * 1000);
		};

   };


function moving(event, xwin, minWidth, minHeight, widthMoveMantinel, winiframe, browser) {

	pole = xwin.tag.split("*");
	if (pole[0] == "1") {   //presun okna
      souradniceM = pozice_kurzoru(event, true);
		xwin.style.left = souradniceM[0] - pole[1] + "px";
      if ((widthMoveMantinel) && (xwin.offsetLeft < 0)) xwin.style.left = "0px";
      if ((widthMoveMantinel) && (xwin.offsetLeft + xwin.offsetWidth > document.documentElement.offsetWidth)) xwin.style.left = document.documentElement.offsetWidth - xwin.offsetWidth +"px";
		xwin.style.top = souradniceM[1] - 5 + "px";
      }
	if (pole[0] == "2") {  //resize pravy dolni roh
		souradniceM = pozice_kurzoru(event, true);
		if ((souradniceM[0] - pole[1]) > minWidth) {
			xwin.style.width = souradniceM[0] - pole[1] + "px";
         if ((widthMoveMantinel) && (xwin.offsetLeft + xwin.offsetWidth > document.documentElement.offsetWidth)) xwin.style.width = document.documentElement.offsetWidth - xwin.offsetLeft +"px";
			};
		if ((souradniceM[1] - pole[2]) > minHeight)
			xwin.style.height = souradniceM[1] - pole[2] + "px";
		};
	if (pole[0] == "3") { //resize prava strana
		souradniceM = pozice_kurzoru(event, true);
		if ((souradniceM[0] - pole[1]) > minWidth) {
			xwin.style.width = souradniceM[0] - pole[1] + "px";
         if ((widthMoveMantinel) && (xwin.offsetLeft + xwin.offsetWidth > document.documentElement.offsetWidth)) xwin.style.width = document.documentElement.offsetWidth - xwin.offsetLeft +"px";		};
         };
	if (pole[0] == "4") { //resize spodni strana
		souradniceM = pozice_kurzoru(event, true);
		if ((souradniceM[1] - pole[1]) > minHeight)
			xwin.style.height = souradniceM[1] - pole[1] + "px";
		};
	if (pole[0] == "5") { //resize leva strana
		souradniceM = pozice_kurzoru(event, true);
		if ((pole[1] - souradniceM[0]) > minWidth) {
			xwin.style.left = souradniceM[0] + "px";
			xwin.style.width = pole[1] - souradniceM[0] + "px";
			};
		};

   //oprava height u IFRAME
   if ((pole[0] == 4) && ((souradniceM[1] - pole[1]) > minHeight)) {
      if (browser == "Firefox" || browser == "Chrome") winiframe.style.height = souradniceM[1] - pole[1] - 38 + "px";
      if (browser == "Opera") winiframe.style.height = souradniceM[1] - pole[1] - 30 + "px";
      if (browser == "Internet Explorer") winiframe.style.height = souradniceM[1] - pole[1] + 10 + "px";
      };
   if ((pole[0] == 2) && ((souradniceM[1] - pole[2]) > minHeight)) {
      if (browser == "Firefox" || browser == "Chrome") winiframe.style.height = souradniceM[1] - pole[2] - 38 + "px";
      if (browser == "Opera") winiframe.style.height = souradniceM[1] - pole[2] - 30 + "px";
      if (browser == "Internet Explorer") winiframe.style.height = souradniceM[1] - pole[2] + 10 + "px";
      };
	};



//oznaceni textu 
function textboxSelect (oTextbox, iStart, iEnd) {

	var isOpera = navigator.userAgent.indexOf("Opera") > -1;
	var isIE = navigator.userAgent.indexOf("MSIE") > 1 && !isOpera;
	var isMoz = navigator.userAgent.indexOf("Mozilla/5.") == 0 && !isOpera;	

   switch(arguments.length) {
       case 1:
           oTextbox.select();
           break;

       case 2:
           iEnd = oTextbox.value.length;
           /* falls through */
           
       case 3:          
           if (isIE) {
               var oRange = oTextbox.createTextRange();
               oRange.moveStart("character", iStart);
               oRange.moveEnd("character", -oTextbox.value.length + iEnd);      
               oRange.select();                                              
           } else if (isMoz || isOpera){
               oTextbox.setSelectionRange(iStart, iEnd);
               oTextbox.focus();
           }                    
   }
}	


//vypocet pozice objektu zleva a zhora
function getTopPos(inputObj) {
	var returnValue = inputObj.offsetTop;
	while((inputObj = inputObj.offsetParent) != null)returnValue += inputObj.offsetTop;
	return returnValue;
	}

function getLeftPos(inputObj) {
	var returnValue = inputObj.offsetLeft;
	while((inputObj = inputObj.offsetParent) != null)returnValue += inputObj.offsetLeft;
	return returnValue;
	}


//-------------------------------------------------------------------------------------
//funkce pro X_STROM
function ajax_xstrom_cenc(session, id) {
   var xmlhttp=getHTTPObject();
   var docname = "ajax.php?akce=xstrom_cenc&session=" + session + "&id=" + id;

   if (xmlhttp) {
      xmlhttp.open("GET", docname, false);
      xmlhttp.send(null)
      //alert(xmlhttp.responseText);
      };
   };


//Zaokrouhlovani na x des. mist
function roundNumber(num, dec) {
var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
return result;
}

