var zalohaOnkey;
var toload = new Array();
var casovani_hlasky;
var potlac_loader = false;
var selecty_zaloha = new Array();
var otevreno_hlasek = 0;
window.onload = on_load;
document.onkeypress = zkratky;
var script_to_run = "";
var to_check = new Array();
var soupem_hlasku = false;
var byl_multiple = false;
var soup_sour = new Array();
var soup_elem_c = new Array();

var MSG = 1;var WARNING = 3;var ERROR = 2;var OK = 4;var odladit = false;//v1.7
// Flash Player Version Detection
// Detect Client Browser type
// Copyright 2005-2007 Adobe Systems Incorporated.  All rights reserved.
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function ControlVersion()
{
	var version;
	var axo;
	var e;

	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}

	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			
			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful. 
			
			// default to the first public version
			version = "WIN 6,0,21,0";

			// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
			axo.AllowScriptAccess = "always";

			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");

		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}
	
	return version;
}

// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;
	
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");			
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			var versionRevision = descArray[3];
			if (versionRevision == "") {
				versionRevision = descArray[4];
			}
			if (versionRevision[0] == "d") {
				versionRevision = versionRevision.substring(1);
			} else if (versionRevision[0] == "r") {
				versionRevision = versionRevision.substring(1);
				if (versionRevision.indexOf("d") > 0) {
					versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
				}
			}
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}	
	return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
	versionStr = GetSwfVer();
	if (versionStr == -1 ) {
		return false;
	} else if (versionStr != 0) {
		if(isIE && isWin && !isOpera) {
			// Given "WIN 2,0,0,11"
			tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
			tempString        = tempArray[1];			// "2,0,0,11"
			versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
		} else {
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];

        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
					return true;
			}
		}
		return false;
	}
}

function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '';
  if (isIE && isWin && !isOpera)
  {
    str += '<object ';
    for (var i in objAttrs)
    {
      str += i + '="' + objAttrs[i] + '" ';
    }
    str += '>';
    for (var i in params)
    {
      str += '<param name="' + i + '" value="' + params[i] + '" /> ';
    }
    str += '</object>';
  }
  else
  {
    str += '<embed ';
    for (var i in embedAttrs)
    {
      str += i + '="' + embedAttrs[i] + '" ';
    }
    str += '> </embed>';
  }
  
  if(document.getElementById("uploader_holder")){
     document.getElementById("uploader_holder").innerHTML = str;
  }else{
     document.write(str);
  }
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblclick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
      case "id":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}
/*
 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
 * Copyright (C) 2003-2008 Frederico Caldeira Knabben
 *
 * == BEGIN LICENSE ==
 *
 * Licensed under the terms of any of the following licenses at your
 * choice:
 *
 *  - GNU General Public License Version 2 or later (the "GPL")
 *    http://www.gnu.org/licenses/gpl.html
 *
 *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
 *    http://www.gnu.org/licenses/lgpl.html
 *
 *  - Mozilla Public License Version 1.1 or later (the "MPL")
 *    http://www.mozilla.org/MPL/MPL-1.1.html
 *
 * == END LICENSE ==
 *
 * This is the integration file for JavaScript.
 *
 * It defines the FCKeditor class that can be used to create editor
 * instances in a HTML page in the client side. For server side
 * operations, use the specific integration system.
 */

// FCKeditor Class
var FCKeditor = function( instanceName, width, height, toolbarSet, value )
{
	// Properties
	this.InstanceName	= instanceName ;
	this.Width			= width			|| '100%' ;
	this.Height			= height		|| '200' ;
	this.ToolbarSet		= toolbarSet	|| 'Default' ;
	this.Value			= value			|| '' ;
	this.BasePath		= FCKeditor.BasePath ;
	this.CheckBrowser	= true ;
	this.DisplayErrors	= true ;

	this.Config			= new Object() ;

	// Events
	this.OnError		= null ;	// function( source, errorNumber, errorDescription )
}

/**
 * This is the default BasePath used by all editor instances.
 */
FCKeditor.BasePath = '/fckeditor/' ;

/**
 * The minimum height used when replacing textareas.
 */
FCKeditor.MinHeight = 200 ;

/**
 * The minimum width used when replacing textareas.
 */
FCKeditor.MinWidth = 750 ;

FCKeditor.prototype.Version			= '2.6.2' ;
FCKeditor.prototype.VersionBuild	= '19417' ;

FCKeditor.prototype.Create = function()
{
	document.write( this.CreateHtml() ) ;
}

FCKeditor.prototype.CreateHtml = function()
{
	// Check for errors
	if ( !this.InstanceName || this.InstanceName.length == 0 )
	{
		this._ThrowError( 701, 'You must specify an instance name.' ) ;
		return '' ;
	}

	var sHtml = '' ;

	if ( !this.CheckBrowser || this._IsCompatibleBrowser() )
	{
		sHtml += '<input type="hidden" id="' + this.InstanceName + '" name="' + this.InstanceName + '" value="' + this._HTMLEncode( this.Value ) + '" style="display:none" />' ;
		sHtml += this._GetConfigHtml() ;
		sHtml += this._GetIFrameHtml() ;
	}
	else
	{
		var sWidth  = this.Width.toString().indexOf('%')  > 0 ? this.Width  : this.Width  + 'px' ;
		var sHeight = this.Height.toString().indexOf('%') > 0 ? this.Height : this.Height + 'px' ;

		sHtml += '<textarea name="' + this.InstanceName +
			'" rows="4" cols="40" style="width:' + sWidth +
			';height:' + sHeight ;

		if ( this.TabIndex )
			sHtml += '" tabindex="' + this.TabIndex ;

		sHtml += '">' +
			this._HTMLEncode( this.Value ) +
			'<\/textarea>' ;
	}

	return sHtml ;
}

FCKeditor.prototype.ReplaceTextarea = function()
{
	if ( !this.CheckBrowser || this._IsCompatibleBrowser() )
	{
		// We must check the elements firstly using the Id and then the name.
		var oTextarea = document.getElementById( this.InstanceName ) ;
		var colElementsByName = document.getElementsByName( this.InstanceName ) ;
		var i = 0;
		while ( oTextarea || i == 0 )
		{
			if ( oTextarea && oTextarea.tagName.toLowerCase() == 'textarea' )
				break ;
			oTextarea = colElementsByName[i++] ;
		}

		if ( !oTextarea )
		{
			alert( 'Error: The TEXTAREA with id or name set to "' + this.InstanceName + '" was not found' ) ;
			return ;
		}

		oTextarea.style.display = 'none' ;

		if ( oTextarea.tabIndex )
			this.TabIndex = oTextarea.tabIndex ;

		this._InsertHtmlBefore( this._GetConfigHtml(), oTextarea ) ;
		this._InsertHtmlBefore( this._GetIFrameHtml(), oTextarea ) ;
	}
}

FCKeditor.prototype._InsertHtmlBefore = function( html, element )
{
	if ( element.insertAdjacentHTML )	// IE
		element.insertAdjacentHTML( 'beforeBegin', html ) ;
	else								// Gecko
	{
		var oRange = document.createRange() ;
		oRange.setStartBefore( element ) ;
		var oFragment = oRange.createContextualFragment( html );
		element.parentNode.insertBefore( oFragment, element ) ;
	}
}

FCKeditor.prototype._GetConfigHtml = function()
{
	var sConfig = '' ;
	for ( var o in this.Config )
	{
		if ( sConfig.length > 0 ) sConfig += '&amp;' ;
		sConfig += encodeURIComponent( o ) + '=' + encodeURIComponent( this.Config[o] ) ;
	}

	return '<input type="hidden" id="' + this.InstanceName + '___Config" value="' + sConfig + '" style="display:none" />' ;
}

FCKeditor.prototype._GetIFrameHtml = function()
{
	var sFile = 'fckeditor.html' ;

	try
	{
		if ( (/fcksource=true/i).test( window.top.location.search ) )
			sFile = 'fckeditor.original.html' ;
	}
	catch (e) { /* Ignore it. Much probably we are inside a FRAME where the "top" is in another domain (security error). */ }

	var sLink = this.BasePath + 'editor/' + sFile + '?InstanceName=' + encodeURIComponent( this.InstanceName ) ;
	if (this.ToolbarSet)
		sLink += '&amp;Toolbar=' + this.ToolbarSet ;

	html = '<iframe id="' + this.InstanceName +
		'___Frame" src="' + sLink +
		'" width="' + this.Width +
		'" height="' + this.Height ;

	if ( this.TabIndex )
		html += '" tabindex="' + this.TabIndex ;

	html += '" frameborder="0" scrolling="no"></iframe>' ;

	return html ;
}

FCKeditor.prototype._IsCompatibleBrowser = function()
{
	return FCKeditor_IsCompatibleBrowser() ;
}

FCKeditor.prototype._ThrowError = function( errorNumber, errorDescription )
{
	this.ErrorNumber		= errorNumber ;
	this.ErrorDescription	= errorDescription ;

	if ( this.DisplayErrors )
	{
		document.write( '<div style="COLOR: #ff0000">' ) ;
		document.write( '[ FCKeditor Error ' + this.ErrorNumber + ': ' + this.ErrorDescription + ' ]' ) ;
		document.write( '</div>' ) ;
	}

	if ( typeof( this.OnError ) == 'function' )
		this.OnError( this, errorNumber, errorDescription ) ;
}

FCKeditor.prototype._HTMLEncode = function( text )
{
	if ( typeof( text ) != "string" )
		text = text.toString() ;

	text = text.replace(
		/&/g, "&amp;").replace(
		/"/g, "&quot;").replace(
		/</g, "&lt;").replace(
		/>/g, "&gt;") ;

	return text ;
}

;(function()
{
	var textareaToEditor = function( textarea )
	{
		var editor = new FCKeditor( textarea.name ) ;

		editor.Width = Math.max( textarea.offsetWidth, FCKeditor.MinWidth ) ;
		editor.Height = Math.max( textarea.offsetHeight, FCKeditor.MinHeight ) ;

		return editor ;
	}

	/**
	 * Replace all <textarea> elements available in the document with FCKeditor
	 * instances.
	 *
	 *	// Replace all <textarea> elements in the page.
	 *	FCKeditor.ReplaceAllTextareas() ;
	 *
	 *	// Replace all <textarea class="myClassName"> elements in the page.
	 *	FCKeditor.ReplaceAllTextareas( 'myClassName' ) ;
	 *
	 *	// Selectively replace <textarea> elements, based on custom assertions.
	 *	FCKeditor.ReplaceAllTextareas( function( textarea, editor )
	 *		{
	 *			// Custom code to evaluate the replace, returning false if it
	 *			// must not be done.
	 *			// It also passes the "editor" parameter, so the developer can
	 *			// customize the instance.
	 *		} ) ;
	 */
	FCKeditor.ReplaceAllTextareas = function()
	{
		var textareas = document.getElementsByTagName( 'textarea' ) ;

		for ( var i = 0 ; i < textareas.length ; i++ )
		{
			var editor = null ;
			var textarea = textareas[i] ;
			var name = textarea.name ;

			// The "name" attribute must exist.
			if ( !name || name.length == 0 )
				continue ;

			if ( typeof arguments[0] == 'string' )
			{
				// The textarea class name could be passed as the function
				// parameter.

				var classRegex = new RegExp( '(?:^| )' + arguments[0] + '(?:$| )' ) ;

				if ( !classRegex.test( textarea.className ) )
					continue ;
			}
			else if ( typeof arguments[0] == 'function' )
			{
				// An assertion function could be passed as the function parameter.
				// It must explicitly return "false" to ignore a specific <textarea>.
				editor = textareaToEditor( textarea ) ;
				if ( arguments[0]( textarea, editor ) === false )
					continue ;
			}

			if ( !editor )
				editor = textareaToEditor( textarea ) ;

			editor.ReplaceTextarea() ;
		}
	}
})() ;

function FCKeditor_IsCompatibleBrowser()
{
	var sAgent = navigator.userAgent.toLowerCase() ;

	// Internet Explorer 5.5+
	if ( /*@cc_on!@*/false && sAgent.indexOf("mac") == -1 )
	{
		var sBrowserVersion = navigator.appVersion.match(/MSIE (.\..)/)[1] ;
		return ( sBrowserVersion >= 5.5 ) ;
	}

	// Gecko (Opera 9 tries to behave like Gecko at this point).
	if ( navigator.product == "Gecko" && navigator.productSub >= 20030210 && !( typeof(opera) == 'object' && opera.postError ) )
		return true ;

	// Opera 9.50+
	if ( window.opera && window.opera.version && parseFloat( window.opera.version() ) >= 9.5 )
		return true ;

	// Adobe AIR
	// Checked before Safari because AIR have the WebKit rich text editor
	// features from Safari 3.0.4, but the version reported is 420.
	if ( sAgent.indexOf( ' adobeair/' ) != -1 )
		return ( sAgent.match( / adobeair\/(\d+)/ )[1] >= 1 ) ;	// Build must be at least v1

	// Safari 3+
	if ( sAgent.indexOf( ' applewebkit/' ) != -1 )
		return ( sAgent.match( / applewebkit\/(\d+)/ )[1] >= 522 ) ;	// Build must be at least 522 (v3)

	return false ;
}


function ie(){
   if('\v'=='v') return true;
   else return false;
}

function ie6(){
   if(ie()==true){
      if(window.XMLHttpRequest) return false;
      else return true;
   }else{
      return false;
   }
}

function smaz(){
      var ok = confirm("Opravdu chcete odstranit danou položku? Tento krok nelze vrátit zpět!");
      return ok;
}

function zkratky(event){
     var code = keyCode(event);
     if(kl_zkratky[code]) eval(kl_zkratky[code]);
}

function menuExpand(jake){
   if(document.getElementById(jake)){
     //alert(document.getElementById(jake).parentNode.parentNode.nodeName);
     var ostatni = document.getElementById(jake).parentNode.parentNode.childNodes;
     for(var i=0;i<ostatni.length;i++){
        if(ostatni[i].nodeType==3) continue; // text nas nezajima
        if(ostatni[i].childNodes){
           for(var j=0;j<ostatni[i].childNodes.length;j++){
              if(ostatni[i].childNodes[j].id && ostatni[i].childNodes[j].id!="langform") ostatni[i].childNodes[j].style.display = "none";
           }
        }
     }
     document.getElementById(jake).style.display = "block";
   }
}

function menuClose(jake){
   if(document.getElementById(jake)) document.getElementById(jake).style.display = "none";
}

function ukazLoader(){
   if(potlac_loader==true) return false;
   var loader = document.createElement("div");
   loader.className = "at-loader";
   loader.setAttribute("id","at-loader-holder");
   var rozmery = vratRozmery();
   var img = document.createElement("img");
   img.setAttribute("src","tpl/admin/img/loading.gif");
   img.className= "at-image";
   img.setAttribute("width","100");
   img.setAttribute("height","100");
   img.style.marginTop = Math.floor(rozmery[0]/2-100)+"px";
   loader.appendChild(img);
   loader.style.height = document.body.scrollHeight;
   loader.ondblclick = schovejLoader;
   selecty_schovej();
   document.body.appendChild(loader);
}

function schovejLoader(){
   if(potlac_loader==true) return false;
   if(document.getElementById("at-loader-holder")){
        var loader = document.getElementById("at-loader-holder");
        document.body.removeChild(loader);
        selecty_vrat();
   }
}

function odeslatDotaz(adresa,zpracovani,onloadHlaska){
   // vytvorime objekt pro komunikaci se serverem
   if(window.XMLHttpRequest){
      var xmlhttp = new XMLHttpRequest;
   }else if(window.ActiveXObject){
       try{
           var xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e){
            var xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
   }else{
      return false;
   }
   // odstranime otaznik ze zacatku
   adresa = adresa.replace(/^\?/,""); 
   xmlhttp.open("POST","http://www.chatakubik.cz/ajax/?1760159752");
   xmlhttp.onreadystatechange = function() { zpracovatDotaz(xmlhttp,zpracovani,onloadHlaska); };
   xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
   xmlhttp.setRequestHeader("Content-length", adresa.length);
   xmlhttp.setRequestHeader("Connection", "close");
   xmlhttp.send(adresa);
   ukazLoader();
   return false;
}

function odeslatDotazZModulu(adresa,id_modulu,zpracovani,onloadHlaska){
   return odeslatDotaz(adresa+"&mod="+id_modulu,zpracovani,onloadHlaska);
}

function odeslatDotazExt(adresa,nazev_ext,zpracovani,onloadHlaska){
   return odeslatDotaz(adresa+"&ext="+nazev_ext,zpracovani,onloadHlaska);
}

function zpracovatDotaz(xmlhttp,zpracovani,onloadHlaska){
   // pokud status neni 4, nema cenu nic dalsiho delat. 
   if(xmlhttp.readyState == 4){ 
     try{
       if(xmlhttp.status != 200) throw 1500;
       if(!xmlhttp.responseXML || !xmlhttp.responseXML.documentElement) throw 1501;
       if(xmlhttp.responseXML.documentElement.nodeName=="parsererror") throw 1501;
       root = xmlhttp.responseXML.documentElement;
       //alert(xmlhttp.responseText);
       for(var i=0;i<root.childNodes.length;i++){
         if(root.childNodes[i].nodeName=="chyby" && root.childNodes[i].hasChildNodes()==true){
            var navrat = zpracujChyby(root.childNodes[i]);
            // pokud se text vrati, neslo o fatalni chybu, takze ji s klidem vypiseme a jedeme dal
            zapisChybu(navrat[0],navrat[1]);
            continue;
         }
         if(root.childNodes[i].nodeName=="data" && root.childNodes[i].hasChildNodes()==true){
            if(window[zpracovani]) window[zpracovani](root.childNodes[i],onloadHlaska);
         } 
       }
       //alert(xmlhttp.responseText);
       /*document.getElementById("nfju").innerHTML = xmlhttp.responseText;
       var scripty = document.getElementById("nfju").getElementsByTagName("script");
       for(var w=0;w<scripty.length;w++){
          if(ie()){
            if(scripty[w].childNodes){ 
              alert(scripty[w].childNodes.length);
              //if(ie()) var scr = scripty[w].innerHTML;
              //else var scr = scripty[w].firstChild.nodeValue;
             
              //eval(scr);
             
            }else{
              // toto je externi script
              alert("tu");
              alert(scripty[w].getAttribute("src"));
            }
          }else{
             if(scripty[w].childNodes.length>0){
                // interni
             }else{
                // externi
                var attr = scripty[w].getAttribute("src");
                scripty[w].setAttribute("src",attr);
             }
          }
       }*/
     }catch(error){ 
         var text = "Neznámá chyba.";
         switch(error){
             case 1500:
               zapisChybu(ERROR,"Chyba 1500:\nDošlo k problému při komunikaci se serverem. Zkuste obnovit stránku.");
               break;
             case 1501:
               zapisChybu(ERROR,"Chyba 1501:\nŠpatná syntaxe XML souboru.");
               break;
             default:
               if(typeof(error)!="string") throw error;
               else zapisChybu(ERROR,error);
               break;
         }
         if(odladit==true) alert("KOMPLETNÍ ODPOVĚĎ SERVERU:\n\n"+xmlhttp.responseText);
     }
     schovejLoader();
   }
}

function zapisChybu(povaha,text){
   if(document.getElementById("hlaseniZpravy")==null){
       var hlaska = document.createElement("div");
       hlaska.setAttribute("id","hlaseniZpravy");
       if(povaha==ERROR) hlaska.className = "alert error";
       else if(povaha==WARNING) hlaska.className = "alert warning";
       else if(povaha==OK) hlaska.className = "alert";
       else hlaska.className = "alert normal";
       /*var leg = document.createElement("legend");
       leg.appendChild(document.createTextNode("Hlášení systému"));
       hlaska.appendChild(leg);*/
       hlaska.innerHTML=text;
       //document.getElementById("content").insertBefore(hlaska,document.getElementById("topnadpis").nextSibling);
       var nadpis = document.getElementsByTagName("h1");
       nadpis[0].parentNode.insertBefore(hlaska,nadpis[0].nextSibling);
       window.clearTimeout(casovani_hlasky);
       casovani_hlasky = window.setTimeout("smazChybu()",10*1000);
       window.scrollTo(0,0);
   }else{
       //document.getElementById("content").removeChild(document.getElementById("hlaseniZpravy"));
       document.getElementById("hlaseniZpravy").parentNode.removeChild(document.getElementById("hlaseniZpravy"));
       zapisChybu(povaha,text);
   }
}

function smazChybu(){
    //document.getElementById("content").removeChild(document.getElementById("hlaseniZpravy"));
    document.getElementById("hlaseniZpravy").className = "alert smazchybu";
}

function zpracujChyby(chyby){
   text = "";
   povaha = 0;
   for(var i=0;i<chyby.childNodes.length;i++){
      
      if(chyby.childNodes[i].nodeName != "povaha") text += "<p>" + chyby.childNodes[i].firstChild.nodeValue + "</p>"; else povaha = chyby.childNodes[i].firstChild.nodeValue;
   }
   if(povaha>0) return new Array(povaha,text); else throw text;
   
}

function keyCode(event){
   var code = 0;
   if(window.event) code = window.event.keyCode;
   else code = event.keyCode;
   return code;
}

function enterPressed(event){
   var code = keyCode(event);
   if(code==13) return true; else return false;
}

function escPressed(event){
   var code = keyCode(event);
   if(code==27) return true; else return false;
}

/* Hlaska */

function zobrazitHlasku(adresa,nadpis,onload,params){  
   // spocitame umisteni v ramci obrazovky
   rozmery = vratRozmery();
   hl_top = rozmery[0]/3;
   hl_left = rozmery[1]/2 - 670/2;
   
   // zjistime odskrolovani shora a posuneme prvek o tuto hodnotu
   var scr = 0;
   if(document.body.scrollTop) scr = document.body.scrollTop;
   else scr = document.documentElement.scrollTop;
   
   selecty_schovej();
   
   otevreno_hlasek++;
   document.onmouseup =  konecPremistovaniHlasky;
   document.onmousemove = premistovatHlasku;
   odeslatDotaz("?fce=load_hlaska&hlasek="+otevreno_hlasek+"&hl_top="+hl_top+"&scr="+scr+"&poz_vyska="+rozmery[0]+"&hl_nadpis="+nadpis+"&ldfce="+adresa.substring(5),"hlaskaData",new Array(onload,params));
}

function zobrazitHlaskuModul(adresa,id_modul,nadpis,onload,params){
   zobrazitHlasku(adresa+"&mod="+id_modul,nadpis,onload,params);
}

function zobrazitHlaskuExt(adresa,nazev_ext,nadpis,onload,params){
   zobrazitHlasku(adresa+"&ext="+nazev_ext,nadpis,onload,params);
}

function str_repeat(co,kolikrat){
    var navrat = "";
    for(var i=0;i<kolikrat;i++) navrat+=co;
    return navrat; 
}

function hlaskaData(data,onloadHlaska){
   vlozObsah(data,document.body);
   if(document.getElementById("aitom-hlaska")&& ie6()){
       window.onscroll = scrollHlaska;
   }
   // funkce pro hybani hlaskou - nejdriv je sebereme z posledni otevrene hlasky a pak je priradime te nove otevrene
   if(document.getElementById("aitom-hlaska-nadpis-"+otevreno_hlasek)){
      document.getElementById("aitom-hlaska-nadpis-"+otevreno_hlasek).onmousedown = zacniPremistovatHlasku;
   }
   if(document.getElementById("aitom-hlaska-nadpis-"+(otevreno_hlasek-1))){
      document.getElementById("aitom-hlaska-nadpis-"+(otevreno_hlasek-1)).onmousedown = null;
   }
   
   if(onloadHlaska[0]!="") if(window[onloadHlaska[0]]) window[onloadHlaska[0]](onloadHlaska[1]);
}

function scrollHlaska(){
   // zjistime odskrolovani shora a posuneme prvek o tuto hodnotu
   var scr = 0;
   if(ie6()){
      if(document.body.scrollTop) scr = document.body.scrollTop;
      else scr = document.documentElement.scrollTop;
      //alert(scr);
      //alert(otevreno_hlasek);
      if(document.getElementById("aitom-pozadi-"+otevreno_hlasek)) document.getElementById("aitom-pozadi-"+otevreno_hlasek).style.top = scr+"px";
   }
}

function zacniPremistovatHlasku(e){
   soup_sour = zjistiSouradnici(e);
   soup_elem_c[0] = parseInt(document.getElementById("aitom-hlaskoholder-"+otevreno_hlasek).style.left);
   soup_elem_c[1] = parseInt(document.getElementById("aitom-hlaskoholder-"+otevreno_hlasek).style.top);
   soupem_hlasku = true;
}

function konecPremistovaniHlasky(){
   soupem_hlasku = false;
}

function premistovatHlasku(e){
   if(soupem_hlasku==true){
      var souradnice = zjistiSouradnici(e);
      
      //alert(oldx+" , "+oldy);
      
      // zjistime jaky byl posun
      souradnice[0] = souradnice[0] - soup_sour[0];
      souradnice[1] = souradnice[1] - soup_sour[1];
      
      // a aplikujeme ho na cil
      document.getElementById("aitom-hlaskoholder-"+otevreno_hlasek).style.left = (soup_elem_c[0] + souradnice[0]) + "px";
      document.getElementById("aitom-hlaskoholder-"+otevreno_hlasek).style.top = (soup_elem_c[1] + souradnice[1]) + "px";
      
      //alert(parseInt(document.getElementById("aitom-hlaskoholder-"+otevreno_hlasek).style.left)+" -- "+oldx);
      
      // zrusime oznacen itextu 
      document.body.focus(); 
      
      // prevent text selection in IE 
      document.onselectstart = function () { return false; }; 
   
      // kvuli neoznacovani textu v normalnich prohlizecich (neplati pro IE)
      return false;
   }
}

function zjistiSouradnici(e){
    var coords = new Array(0,0);
    if(ie()){
      //coords[0] = event.clientX + document.body.scrollLeft;
      //coords[1] = event.clientY + document.body.scrollTop;
      coords[0] = event.clientX;
      coords[1] = event.clientY;
    }else{
      //coords[0] = e.pageX;
      //coords[1] = e.pageY;
      coords[0] = e.clientX;
      coords[1] = e.clientY;
    }  
    
    if (coords[0] < 0){coords[0] = 0;}
    if (coords[1] < 0){coords[1] = 0;} 
    
    return coords;
}

function hlaskaObsah(data){
   var poleNodu = new Array();

   for(var i=0;i<data.childNodes.length;i++){
   
     // pokud je tohle textNode, pokracujeme dalsim
     if(data.childNodes[i].nodeType==3){ 
        poleNodu.push(document.createTextNode(data.childNodes[i].nodeValue));
        continue;
     }
     
     // cdata node zpracovani
     if(data.childNodes[i].nodeType==4){
           var tnode = document.createTextNode("<![CDATA[ " + data.childNodes[i].nodeValue + "]]>");
           poleNodu.push(tnode);
           continue;
     }
     
     if(data.childNodes[i].nodeName.toLowerCase()=="script" && ie()){
         // externi skripty funguji ok ..
         if(data.childNodes[i].childNodes.length>0){
            var txt = "";
            for(var j=0;j<data.childNodes[i].childNodes.length;j++){
               txt += data.childNodes[i].childNodes[j].nodeValue;
            }
            script_to_run += txt;
            continue;
         }
     }
     
     if(data.childNodes[i].nodeName.toLowerCase()=="style" && ie()){
         if(data.childNodes[i].childNodes.length>0){
            var txt = "";
            for(var j=0;j<data.childNodes[i].childNodes.length;j++){
               txt += data.childNodes[i].childNodes[j].nodeValue;
            }
            var styl = document.createElement("style");
            styl.setAttribute("type", "text/css");
            styl.styleSheet.cssText = txt;
            poleNodu.push(styl);
         }
         continue;
     }
     
     var tmp = document.createElement(data.childNodes[i].nodeName);
     
     if(ie() && data.childNodes[i].nodeName.toLowerCase()=="input"){
         if(data.childNodes[i].getAttribute("checked")=="checked") var chck = "checked=\"checked\""; else var chck = "";
         tmp = document.createElement("<"+data.childNodes[i].nodeName+" name=\""+data.childNodes[i].getAttribute("name")+"\" "+chck+">");
     }
     
     if(ie() && (data.childNodes[i].nodeName.toLowerCase()=="select" || data.childNodes[i].nodeName.toLowerCase()=="textarea" || data.childNodes[i].nodeName.toLowerCase()=="form" || data.childNodes[i].nodeName.toLowerCase()=="button")){
         tmp = document.createElement("<"+data.childNodes[i].nodeName+" name=\""+data.childNodes[i].getAttribute("name")+"\">");
     }
     
     if(ie6() && data.childNodes[i].nodeName.toLowerCase()=="select" && data.childNodes[i].getAttribute("multiple")=="multiple"){
         tmp = document.createElement("<select multiple></select>");
         byl_multiple = true;
     }
     
     // projdeme a okopirujeme vsechny atributy
     for(var j=0;j<data.childNodes[i].attributes.length;j++){
        if(ie() && data.childNodes[i].attributes[j].name=="class"){
            tmp.className = data.childNodes[i].attributes[j].value;
        }else if(ie() && data.childNodes[i].attributes[j].name.search(/^on.*/)==0){
            tmp.setAttribute(data.childNodes[i].attributes[j].name,data.childNodes[i].attributes[j].value);
            tmp.attachEvent(data.childNodes[i].attributes[j].name,new Function(data.childNodes[i].attributes[j].value)); //function(){ eval(this.event.srcElement.getAttribute("onclick")); });
            //tmp.attachEvent(data.childNodes[i].attributes[j].name,function(){ eval(this.event.srcElement.getAttribute("onclick")); });
        }else if(ie() && data.childNodes[i].attributes[j].name=="style"){
            // kdyby sem nahodou spadlo neco co tu nema co delat ...
            try{
              tmp.style.setAttribute('cssText',data.childNodes[i].attributes[j].value);
            }catch(err){
              tmp.setAttribute(data.childNodes[i].attributes[j].name,data.childNodes[i].attributes[j].value);
            }
        }else{
            tmp.setAttribute(data.childNodes[i].attributes[j].name,data.childNodes[i].attributes[j].value);
        }
     }
     
     // a pokud jsou nejake childNody, zavolame se na ne rekurzivne
     if(data.childNodes[i].childNodes.length>0){
        var pole = hlaskaObsah(data.childNodes[i]);
        for(var k=0;k<pole.length;k++){
                 tmp.appendChild(pole[k]);
        }
     }
     
     // pridame Node do pole
     poleNodu.push(tmp);
   }
   
   return poleNodu;
}

function vlozObsah(obsah,element){
  var pole = hlaskaObsah(obsah);
   for(var k=0;k<pole.length;k++){
     element.appendChild(pole[k]);
   }
   if(ie() && script_to_run!=""){
      window.execScript(script_to_run);
      script_to_run = "";
   }
}

function smazObsah(element){
  // normalni prohlizece umi innerHTML i na tabulky apod.
  if(!ie()){
     element.innerHTML = "";
  }else{
     // naprosto neschopnemu IE to musime vysvetlit jeho vlastnimi spesl metodami ..
     if(element.nodeName=="TBODY" || element.nodeName=="TR" || element.nodeName=="TABLE"){
         while(element.childNodes.length>0){
            element.removeChild(element.firstChild);
         }
     }else{
        element.innerHTML = "";
     }
  }
}

function keyHlaska(event){
   // cancel? (Esc)
   if(escPressed(event)){
      var nodes = document.getElementById("aitom-hlaska").getElementsByTagName("button");
      if(document.getElementById("aitom-hlaska-cancel")){
         document.getElementById(document.getElementById("aitom-hlaska-cancel").value).click();
      }else{
         nodes[nodes.length-1].click();
      }
   } 
   // ok? (Enter)
   if(enterPressed(event)){
      var nodes = document.getElementById("aitom-hlaska").getElementsByTagName("button");
      if(document.getElementById("aitom-hlaska-ok")){
         document.getElementById(document.getElementById("aitom-hlaska-ok").value).click();
      }else{
         nodes[0].click();
      }
   }
}

function closeHlaska(){
   // funkce pro hybani hlaskou - nejdriv je sebereme ze zavirane hlasky a pak je priradime te posledni otevrene, pokud nejaka existuje
   if(document.getElementById("aitom-hlaska-nadpis-"+(otevreno_hlasek-1))){
      document.getElementById("aitom-hlaska-nadpis-"+(otevreno_hlasek-1)).onmousedown = zacniPremistovatHlasku;
   }
   if(document.getElementById("aitom-hlaskoholder-"+otevreno_hlasek)) document.getElementById("aitom-hlaskoholder-"+otevreno_hlasek).parentNode.removeChild(document.getElementById("aitom-hlaskoholder-"+otevreno_hlasek));
   if(document.getElementById("aitom-pozadi-"+otevreno_hlasek)){
      //document.getElementById("aitom-pozadi-"+otevreno_hlasek).style.display="none";
      if(document.getElementById("aitom-pozadi-"+otevreno_hlasek)) document.getElementById("aitom-pozadi-"+otevreno_hlasek).parentNode.removeChild(document.getElementById("aitom-pozadi-"+otevreno_hlasek));
      otevreno_hlasek--;
      //alert("beee");
   }
   return false; // at se neprovede odkaz
}

function on_load(){
     if(toload.length!=0){
         for(i=0;i<toload.length;i++){
            eval(toload[i]+"()");
         }
     }
}

function selecty_schovej(){
  if(!ie6()) return false;
  // selecty musime schovat kvuli "mirne prihlouplemu" IE6 ...
   var selecty = document.getElementsByTagName("select");
   for(var i=0;i<selecty.length;i++){
       selecty_zaloha[i] = selecty[i].style.display;
       selecty[i].style.display = "none";
   }
}

function selecty_vrat(){
  if(!ie6()) return false;
  // selecty musime schovat kvuli "mirne prihlouplemu" IE6 ...
   var selecty = document.getElementsByTagName("select");
   for(var i=0;i<selecty.length;i++){
       selecty[i].style.display = selecty_zaloha[i]; 
   }
}

function vratRozmery(){
   if(window.innerHeight){
      win_height = window.innerHeight;
      win_width = window.innerWidth;
      return new Array(win_height,win_width);
   }else if(document.documentElement && document.documentElement.clientHeight){
      win_height = document.documentElement.clientHeight;
      win_width = document.documentElement.clientWidth;
      return new Array(win_height,win_width);
   }else if(document.body && document.body.clientHeight){
      win_height = document.body.clientHeight;
      win_width = document.body.clientWidth;
      return new Array(win_height,win_width);
   }
}

// IE neumi getElementsByName na neformularovych elementech ...
function getByName(jmeno,tag){
    var prvky = document.getElementsByName(jmeno);
    // vsechny ostatni normalni prohlizece, ktere to znaji skonci uz tady
    if(prvky.length>0) return prvky;
    // a ted zvlast pro IE ..,
    prvky = document.getElementsByTagName(tag);
    if(prvky.length<1) return prvky;
    var navrat = new Array();
    for(var i=0;i<prvky.length;i++){
       if(prvky[i].name==jmeno) navrat.push(prvky[i]);
    }
    return navrat;
}

function Upload_File_Finished(vstup){
   try{
     
     var casti = vstup.split("##");
     
     var root;
     // nejdrive premenime string v xml
     try{
         // firefox a ostatni NORMALNI prohlizece
         var xmlDoc = (new DOMParser()).parseFromString(casti[1], "text/xml");
         root = xmlDoc.documentElement;
         if(root.nodeName=="parsererror") throw 1501;
     }catch(e){
         if(typeof(e)=="number" || typeof(e)=="string") throw e;
         // no a IE ..
         var xmlDoc;
         xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
         xmlDoc.async="false";
         xmlDoc.loadXML(casti[1]);
         root = xmlDoc.documentElement;
         if(!root) throw 1501;
     }
     // zpracovani chyb
     var chyby = root.getElementsByTagName("chyby");
     if(chyby.length>0){
       if(chyby[0].childNodes.length>0){ 
          var navrat = zpracujChyby(chyby[0]);
          zapisChybu(navrat[0],navrat[1]);
       }
     }
     var data = root.getElementsByTagName("data");
     if(data.length>0){
        if(window[casti[0]]) window[casti[0]](data[0]);
        else zapisChybu(WARNING,"Chyba 1503:\nSelhalo volání následné JS funkce po nahrání souborů pomocí uploaderu.");
     }
   }catch(error){
         var text = "Neznámá chyba.";
         switch(error){
             case 1501:
               zapisChybu(ERROR,"Chyba 1501:\nŠpatná syntaxe XML souboru.");
               break;
             default:
               if(typeof(error)!="string") throw error;
               else zapisChybu(ERROR,error);
               break;
         }
         if(odladit==true) alert("KOMPLETNÍ ODPOVĚĎ SERVERU:\n\n"+casti[1]);
   }
}

function zobrazVyberSouboru(id,multi,typ,jsfce,phpfce,mod,hdir,jencist){
    zobrazitHlasku("?fce=nacti_soubory_hlaska&id="+id+"&multi="+multi+"&typ="+typ+"&jsfce="+jsfce+"&phpfce="+phpfce+"&mod_id="+mod+"&hdir="+hdir+"&jencist="+jencist,"Vyberte soubory","zobrazitSoubory",Array(jsfce));
}

function zobrazitSobory(data){
    document.getElementById("hlaska-vnitrek").innerHTML = "";
    vlozObsah(data,document.getElementById("hlaska-vnitrek"));
}

function nactiAdrHlaska(dir,id_pol,multi,typ,zobrazeni,razeni,smer){
    // zjistime data o phpfci, jsfci a modulu
    var jsfce = ""; var phpfce = ""; var mod = "";
    if(zobrazeni==0 || zobrazeni=="" || zobrazeni==undefined) zobrazeni = -1;
    if(razeni==undefined) razeni = "nazev";
    if(smer==undefined) smer = "asc";
    if(document.getElementById("jsfce")) jsfce = document.getElementById("jsfce").value;
    if(document.getElementById("phpfce")) phpfce = document.getElementById("phpfce").value;
    if(document.getElementById("mod")) mod = document.getElementById("mod").value;
    odeslatDotaz("?fce=nacti_soubory_hlaska&id="+id_pol+"&multi="+multi+"&dir="+dir+"&typ="+typ+"&phpfce="+phpfce+"&mod_id="+mod+"&jsfce="+jsfce+"&styl_zobr="+zobrazeni+"&radit="+razeni+"&smer="+smer,"zobrazAdresarHlaska");
    return false;
}

function zobrazAdresarHlaska(data){
    document.getElementById("hlaska-vnitrek-"+otevreno_hlasek).innerHTML = "";
    vlozObsah(data,document.getElementById("hlaska-vnitrek-"+otevreno_hlasek));
}

function vyberSoubor(dir,id_pol,cesta){
    // zjistime data o phpfci, jsfci a modulu
    var jsfce = ""; var phpfce = ""; var mod = "";
    if(document.getElementById("jsfce")) jsfce = document.getElementById("jsfce").value;
    if(document.getElementById("phpfce")) phpfce = document.getElementById("phpfce").value;
    if(document.getElementById("mod")) mod = document.getElementById("mod").value;
    odeslatDotaz("?fce=vrat_id_souboru&dir="+dir+"&id_pol="+id_pol+"&oznacit="+cesta+"&phpfce="+phpfce+"&mod_id="+mod,"vystavIdSouboru",new Array(jsfce,id_pol));
    return false;
}

function oznacPolickoSouboru(id){
   if(!document.getElementById("smaz_"+id)) return false;
   if(document.getElementById("smaz_"+id).checked==true) document.getElementById("smaz_"+id).checked = false; else document.getElementById("smaz_"+id).checked = true;
   return false;
}

function oznacitVseSoubory(){
   var inputy = getByName("mazaci-policko","input");
   var oznacit = false;
   if(document.getElementById("mazaci").checked==true) oznacit = true;
   for(var i=0;i<inputy.length;i++){
      inputy[i].checked = oznacit; 
   }
   return false;
}

function oznacitViceSouboru(dir,id_pol){
   var odkazy = getByName("file-odkaz","a");
   if(odkazy.length>0){
      var mazane = "";
      for(var i=0;i<odkazy.length;i++){
          if(!document.getElementById("smaz_"+odkazy[i].id)) continue;
          if(document.getElementById("smaz_"+odkazy[i].id).checked==true) mazane += odkazy[i].id+",";
      }
      if(mazane=="") return;
      mazane = mazane.substring(0,mazane.length-1);
      
      // zjistime data o phpfci, jsfci a modulu
      var jsfce = ""; var phpfce = ""; var mod = "";
      if(document.getElementById("jsfce")) jsfce = document.getElementById("jsfce").value;
      if(document.getElementById("phpfce")) phpfce = document.getElementById("phpfce").value;
      if(document.getElementById("mod")) mod = document.getElementById("mod").value;
      
      odeslatDotaz("?fce=vrat_id_souboru&dir="+dir+"&id_pol="+id_pol+"&oznacit="+mazane+"&phpfce="+phpfce+"&mod_id="+mod,"vystavIdSouboru",new Array(jsfce,id_pol));
   }
}

function vystavIdSouboru(data,pole){
   var jsfce = pole[0];
   var pol_id = pole[1];
   document.getElementById("zobr_"+pol_id).value = "";
   document.getElementById("jmena_"+pol_id).value = "";
   document.getElementById(pol_id).value = "";
   var soubory = data.getElementsByTagName("soubor");
   var vystup = document.createElement("div");
   if(soubory.length>0){
      for(var j=0;j<soubory.length;j++){
        var cesta = soubory[j].getAttribute("cesta");
        var id = soubory[j].getAttribute("id");
        document.getElementById("zobr_"+pol_id).value += cesta+", ";
        document.getElementById("jmena_"+pol_id).value += cesta+",";
        document.getElementById(pol_id).value += id+",";
        //var blbeie = document.createElement("div");
        //blbeie.appendChild(document.createTextNode("IE je debilní!"));
        //for(var i=0;i<soubory[j].childNodes.length;i++){ vystup.appendChild(blbeie); alert(soubory[j].childNodes[i].nodeValue);}//vystup.appendChild(soubory[j].childNodes[i]);}
        vlozObsah(soubory[j],vystup);
      }
      document.getElementById("zobr_"+pol_id).value = document.getElementById("zobr_"+pol_id).value.substring(0,document.getElementById("zobr_"+pol_id).value.length-2);
      document.getElementById("jmena_"+pol_id).value = document.getElementById("jmena_"+pol_id).value.substring(0,document.getElementById("jmena_"+pol_id).value.length-1);
      document.getElementById(pol_id).value = document.getElementById(pol_id).value.substring(0,document.getElementById(pol_id).value.length-1);
   }
   closeHlaska();
   if(window[jsfce]) window[jsfce](document.getElementById(pol_id).value,document.getElementById("jmena_"+pol_id).value,vystup);
}

function odznacMazaci(){
   document.getElementById("mazaci").checked = false;
}

function adresarPridatHlaska(dir,id_pol,multi,typ,zobrazeni,razeni,smer){
    var nazev = prompt("Zadejte název nového adresáře:");
    if(nazev==null){
       return false;
    }else{
       if(nazev.length<1){
           alert("Zadaný název nesmí být prázdný.");
       }else{
            // zjistime data o phpfci, jsfci a modulu
            var jsfce = ""; var phpfce = ""; var mod = "";
            if(zobrazeni==0 || zobrazeni=="" || zobrazeni==undefined) zobrazeni = -1;
            if(razeni==undefined) razeni = "nazev";
            if(smer==undefined) smer = "asc";
            if(document.getElementById("jsfce")) jsfce = document.getElementById("jsfce").value;
            if(document.getElementById("phpfce")) phpfce = document.getElementById("phpfce").value;
            if(document.getElementById("mod")) mod = document.getElementById("mod").value;
            odeslatDotaz("?fce=nacti_soubory_hlaska&id="+id_pol+"&multi="+multi+"&dir="+dir+"&typ="+typ+"&phpfce="+phpfce+"&mod_id="+mod+"&jsfce="+jsfce+"&styl_zobr="+zobrazeni+"&radit="+razeni+"&smer="+smer+"&adr="+nazev,"zobrazAdresarHlaska");
        }
    }
    return false;
}

function souboryPridatHlaska(dir,id_pol,multi,typ,zobrazeni,razeni,smer){
    // zjistime data o phpfci, jsfci a modulu
    var jsfce = ""; var phpfce = ""; var mod = "";
    if(zobrazeni==0 || zobrazeni=="" || zobrazeni==undefined) zobrazeni = -1;
    if(razeni==undefined) razeni = "nazev";
    if(smer==undefined) smer = "asc";
    if(document.getElementById("jsfce")) jsfce = document.getElementById("jsfce").value;
    if(document.getElementById("phpfce")) phpfce = document.getElementById("phpfce").value;
    if(document.getElementById("mod")) mod = document.getElementById("mod").value;
    
    zobrazitHlasku("?fce=pridat_soubory_hlaska_fs&id="+id_pol+"&multi="+multi+"&dir="+dir+"&typ="+typ+"&phpfce="+phpfce+"&mod_id="+mod+"&jsfce="+jsfce+"&styl_zobr="+zobrazeni+"&radit="+razeni+"&smer="+smer,"Vyberte soubory k nahrání");
    return false;
}

function souborFinishedFS(data){
   if(document.getElementById("jsfce")) jsfce = document.getElementById("jsfce").value;
   if(document.getElementById("phpfce")) phpfce = document.getElementById("phpfce").value;
   if(document.getElementById("mod")) mod = document.getElementById("mod").value;
   smazObsah(document.getElementById('hlaska-vnitrek-'+(otevreno_hlasek-1)));
   vlozObsah(data,document.getElementById('hlaska-vnitrek-'+(otevreno_hlasek-1)));
   if(jsfce.length>0) document.getElementById("jsfce").value = jsfce;
   if(phpfce.length>0) document.getElementById("phpfce").value = phpfce;
   if(mod.length>0) document.getElementById("mod").value = mod;
}

function souborFinished(data){
   // prevezmeme udaje o fcich
   if(document.getElementById("jsfce")) jsfce = document.getElementById("jsfce").value;
   if(document.getElementById("phpfce")) phpfce = document.getElementById("phpfce").value;
   if(document.getElementById("mod")) mod = document.getElementById("mod").value;
   if(data.childNodes.length>0){
        document.getElementById("soubory_list").innerHTML = "";
        vlozObsah(data,document.getElementById("soubory_list"));
   }
   if(jsfce.length>0) document.getElementById("jsfce").value = jsfce;
   if(phpfce.length>0) document.getElementById("phpfce").value = phpfce;
   if(mod.length>0) document.getElementById("mod").value = mod;
}
