/**
 *
 * Picabo AjaxFramework
 *
 * @category   PcbJs
 * @package    PcbJs_Popup
 * @copyright  Copyright (c) 2008 Picabo s.r.o.(http://www.picabo.cz)
 * @author     Lukas Musalek(musalek@picabo.cz)
 * @version    007 0005 27.07.2011 17:31
 * 
 * @todo sbirani vice nez jednoho formulare 
 * @todo loading window??? jak resit? - nyni se nepohybuje pri nacitani + spatne pozicovani okna pri nacteni obsahu
 *  
 */


/**
 *  globalni pole, ktere udrzuje objekty (Popupokna)  
 * 
 *  @global array popupObject  
 */
var popupObject = new Array();



/**
 *  nepouzito 
 * 
 *  @global int isLoaded  
 */
//var isLoaded = 0;

/**
 *  Loading text
 *  @global string popupTextLoading  
 */
var popupTextLoading = "";
var popupTextClose = "";
var popupTextMinimalize = "";
var popupTextMaximalize = "";
var popupTextRemainingTime  = "";
var popupTextElapsedTime  = "";
var popupTextUploadSpeed  = "";

// use in html code !!!!
setGlobalPopupParameters("","Zavřít","Minimalizovat","Maximalizovat","Remaining","Elapsed","Speed");
// end

//**********  slouzi k urceni pozice mysi
var rv = -1;
var ua = navigator.userAgent;
var re = new RegExp("Trident\/([0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) != null) {
  rv = parseFloat(RegExp.$1);
}
if (rv == 4) IE8 = true;
else IE8 = false;
/*@cc_on
	/*@if (@_jscript)
		IE = (document.all && !window.opera) ? true : false;
	/*@else @*/
		IE = false;
	/*@end
@*/
IE7 = (IE && window.XMLHttpRequest);	
//if (!this.ie) document.captureEvents(Event.MOUSEMOVE);
var CHROME = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;

var IE = document.all?true:false
if (!IE) document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = getMouseXY;
var PopupTempX = 0;
var PopupTempY = 0;
function getMouseXY(e) {
  if (IE) {
    try {
    PopupTempX = event.clientX + document.body.scrollLeft;
    PopupTempY = event.clientY + document.body.scrollTop;
    } catch(ex) {
      // neni nacten dokument
    }

  } else {
    PopupTempX = e.pageX;
    PopupTempY = e.pageY;
  } 
  if (PopupTempX < 0){PopupTempX = 0};
  if (PopupTempY < 0){PopupTempY = 0};  
  return true;
}

/* ************************************
 *
 *  Description: simulate object creation and display
 *
 *  see function (constructor) TinyPopup
 *  see TinyPopup.prototype.showPopup()
 *
 * ************************************ */
function newPopup(id, nazev, width, height, script, classname, constructParams, method, methodParams ,disableBackground, windowIcon, formId, position) {
  if (!position) position = 1;
  if (popupObject) {
    if (!popupObject[id]) {
      popupObject[id] = new TinyPopup(1, id, nazev, width, height, script, classname, constructParams, method, methodParams,disableBackground,windowIcon, formId, position);
    }
    if (popupObject[id]._isClosing==0) {
      if (popupObject[id].isGenerated()==0) {
        popupObject[id].showPopup();
        
      }
      else { 
        if (popupObject[id]._isMinimized==1) {
          popupObject[id].unminimalizePopup();
        } else {
          //popupObject[id].sendRequest();
          popupObject[id].focusPopup();
        }
      } 
    }   
  }
  return false;
}

/* ************************************
 *
 *  Description: simulate object creation and display
 *
 *  see function (constructor) TinyPopup
 *  see TinyPopup.prototype.showPopup()
 *
 * ************************************ */
function newPopupCenterNoBar(id, width, height, script, classname, constructParams, method, methodParams ,formId, position) {
  if (!position) position = 1;
  if (popupObject) {
    if (!popupObject[id]) {
      popupObject[id] = new TinyPopup(3, id, 'nobar', 0, 0, script, classname, constructParams, method, methodParams, 4, '', formId, position);
    }
    if (popupObject[id]._isClosing==0) {
      if (popupObject[id].isGenerated()==0) {
        popupObject[id].showPopup();
        
      }
      else { 
        if (popupObject[id]._isMinimized==1) {
          popupObject[id].unminimalizePopup();
        } else {
          //popupObject[id].sendRequest();
          popupObject[id].focusPopup();
        }
      } 
    }   
  }
  return false;
}

/* ************************************
 *
 *  Description: simulate object creation and display - remote call
 *
 *  see function (constructor) TinyPopup
 *
 * ************************************ */
function newRemCall(id, script, classname, constructParams, method, methodParams, formId) {
  if (popupObject) {
    if (!popupObject[id]) {
      popupObject[id] = new TinyPopup(2, id, 'remcall',300,300,script, classname, constructParams, method, methodParams, 1,'',formId, 1);
    }
    popupObject[id].showPopup();
  }
  return false;
}

/* ************************************
 *
 *  Description: simulate object creation and display - hint
 *
 *  see function (constructor) TinyPopup
 *  see TinyPopup.prototype.showPopup()
 *
 * ************************************ */
function newHint(id, script, classname, constructParams, method, methodParams , formId, position) {
  if (!position) position = 2;
  if (popupObject) {
    if (!popupObject[id]) {
      popupObject[id] = new TinyPopup(3, id, 'hint', 0, 0, script, classname, constructParams, method, methodParams, 2, '', formId, position);
    }
    if (popupObject[id]._isClosing==0) {
      if (popupObject[id].isGenerated()==0) {
        popupObject[id].showPopup();
        
      }
      else { 
        if (popupObject[id]._isMinimized==1) {
          popupObject[id].unminimalizePopup();
        } else {
          //popupObject[id].sendRequest();
          popupObject[id].focusPopup();
        }
      } 
    }   
  }
  return false;
}

/* ************************************
 *
 *  Description: simulate object creation and display - remote call
 *
 *  see function (constructor) TinyPopup
 *
 * ************************************ */
function newFileUpload(id, el, pomIcons) {

  if (popupObject) {
    if (!popupObject[id]) {
      popupObject[id] = new TinyPopup(2, id, 'remcall',300,300,'Pcb/Upload.php', 'Pcb_Upload', '', 'ajBlankRequest', '', 1,'',null, 1);
    }
    if (pomIcons) popupObject[id].setIconsToDisable(pomIcons);
    popupObject[id].showPopup();
    if (!el.id) {
      el.setAttribute('id',el.name);
    }
    
    var pomIdUpload = id;
    
    var timer = setTimeout(function () {if (popupObject[pomIdUpload]) popupObject[pomIdUpload].startFileUload(el.id);}, 100);
    //popupObject[id].startFileUload(el.id);
  }
  return false;
}

/* ************************************
 * 
 *  Description: simulate object display
 *
 *  see TinyPopup.prototype.showPopup()
 *
 * ************************************ */
function showPopup(id) {
  if (popupObject) {
    popupObject[id].showPopup();
  }
}

/* ************************************
 * 
 *  Description: simulate object hide
 *
 *  see TinyPopup.prototype.hidePopup()
 *
 * ************************************ */
function hidePopup(id) {
  if (popupObject) {
    popupObject[id].hidePopup();
  }
}

/* ************************************
 * 
 *  Description: set global parameters
 *
 * ************************************ */
function setGlobalPopupParameters(popupTextLoadingPom,popupTextClosePom,popupTextMinimalizePom,popupTextMaximalizePom,popupTextRemainingTimePom,popupTextElapsedTimePom,popupTextUploadSpeedPom) {
  popupTextLoading = popupTextLoadingPom;
  popupTextClose = popupTextClosePom;
  popupTextMinimalize = popupTextMinimalizePom;
  popupTextMaximalize = popupTextMaximalizePom;
  popupTextRemainingTime  = popupTextRemainingTimePom;
  popupTextElapsedTime  = popupTextElapsedTimePom;
  popupTextUploadSpeed  = popupTextUploadSpeedPom;
}

/**
 *
 * Popup okno - Constructor
 *   
 * @param string id -id popup okna
 * @param string nazev -popisek okna  
 * @param int width -sirka okna v px (0=automaticky)
 * @param int height -vyska okna v px (0=automaticky)
 * @param string script -cesta a nazev php scriptu
 * @param string classname -nazev tridy v php scriptu
 * @param string|array constructParams -parametry konstruktoru tridy
 * @param string method -metoda tridy
 * @param string|array methodParams -parametry metody tridy
 * @param bool disableBackground -druh pozadi okna (0|1|2)
 * @param string windowIcon -cesta a nazev ikonky okna
 * @param string formId -id formulare
 * @param string position -pozice okna (center|mouse)
 *         
 */  
function TinyPopup(type, id, nazev, width, height, script, classname, constructParams, method, methodParams, disableBackground, windowIcon, formId, position) {
  this._debug_mode = 1;
  
  if (this._debug_mode==1) {
    this.debug = new Debug();
  }  
  
  this._imagePath = '/';
  this._disableBackground = disableBackground;
  this._id = id;
  this._nazev = nazev;
  this._php = "ajax";
  this._width = width;
  this._height = height;
  this._left = 0;
  this._top = 0;
  this._formId = formId;
  this._type = type;
  this._sessionId = 0;
  this._disabledIcon = new Array();
  this._lastRequest = '';
  this._lastResponse = '';
  this._errorHandling = false;
  
  /*if (position!=null && position!='') {
    this._position = 'mouse';
  }
  else this._position = 'center';
  this._mousePos = [0,0];*/


  this._script = "<paramscript>"+script+"</paramscript>";
  this._classname = "<paramclassname>"+classname+"</paramclassname>";
  // paremtry konstruktoru (string nebo array)
  if (this.isArray(constructParams)) {
    this._constructParams = "<paramconstructparams>";
    //for (var i in constructParams) {
    for (var i = 0; i < constructParams.length; i++) {
      if (this.isNumeric(i)) {
        this._constructParams += "<param"+i+">"+constructParams[i]+"</param"+i+">";
      } else {
        this._constructParams += "<"+i+">"+constructParams[i]+"</"+i+">";
      }
    }
    this._constructParams += "</paramconstructparams>";
  }
  else {
    this._constructParams = "<paramconstructparams>"+constructParams+"</paramconstructparams>";
  }

  this._method = "<parammethod>"+method+"</parammethod>";
  // paremtry metody (string nebo array)
  if (this.isArray(methodParams)) {
    this._methodParams = "<parammethodparams>";
    //for (var i in methodParams) {
    for (var i = 0; i < methodParams.length; i++) {
      if (this.isNumeric(i)) {
        this._methodParams += "<param"+i+">"+methodParams[i]+"</param"+i+">";
      } else {
        this._methodParams += "<"+i+">"+methodParams[i]+"</"+i+">";
      }
    }
    this._methodParams += "</parammethodparams>";
  }
  else {
    this._methodParams = "<parammethodparams>"+methodParams+"</parammethodparams>";
  }
  
  this.doc = document;
  this._tabs = new Array();
  this._isGenerated = 0;
  this._isLoading = 0;
  this._isClosing = 0;
  this._isMinimized = 0;
  this._firstLoad = 0;
  this._firstLoadData = 0;
  this._activeTab = 0;
  this._icon = "";
  this._formData = "";
  this._nonAnsfare = 0;
  this._sendingFiles = 0;
  this._fileInfoTimer = new Array();
  this._elementVisibility = new Array();
  this._forceCenter = 0;
  this._onclose = false;
  this._onIcon = false;
  this._resizeOnUpload = 0;
  this._centerOnUpload = 0;
  this._tabChange = 0;
  this._autoSize = 0;
  
  // default values
  this._endMessage = '';
  this._def_disappear_increase = 5;
  this._def_disappear_timeout = 20;
  this._def_popup_disappear_enable = 0;
  this._def_popup_disappear_increase = 20;
  this._def_popup_disappear_timeout = 10;
  this._def_width = width;
  this._def_height = height;
  this._def_left = 0;
  this._def_top = 0;
  this._def_outer_border = 1;
  this._def_inner_border = 5;
  this._def_but_height = 26;
  this._def_resizebox_height = 10;
  this._def_full_move_allowed = 0;
  this._setButtons = 0;
  this._setResize = 0;
  this._allowMinimal = 0;
  this._allowMaximal = 0;
  this._allowUnMaximal = 0;
  this._def_tab_height = 23;
  this._setTabs = 0;
  this._def_nazev = nazev;
  this._def_timeout = 1000;
  this._file_upload_refresh_timeout = 500; // 500
  this._def_loading_message = popupTextLoading;
  this._def_close_message = popupTextClose;
  this._def_minimal_message = popupTextMinimalize;
  this._def_maximal_message = popupTextMaximalize;
  this._def_open_timeout = 500;
  if (windowIcon) this._def_icon = windowIcon;
  else this._def_icon = "/images/popupWindow/popupicon_default.png";
  this._def_icon_big_postfix = "_big";
  this._icon = this._def_icon;
  
  if (this._type == 3) this._minHeight = 50;
  else this._minHeight = 100;
  if (this._type == 3) this._minWidth = 150;
  else this._minWidth = 200;
  
  this._bottom_border = 0;

  this._uploadFiles = new Array();

  if (position) this._position = position;
  else this._position = 1;
  if (this._position == 2) {
    this._left = PopupTempX;
    this._top = PopupTempY;
  }
  
  var rv = -1;
  var ua = navigator.userAgent;
  var re = new RegExp("Trident\/([0-9]{1,}[\.0-9]{0,})");
  var rie8 = new RegExp("MSIE ([0-9]{1,}[0-9]{0,})");
  if (rie8.exec(ua) != null) {
    rv2 = parseFloat(RegExp.$1);
  }
  if (re.exec(ua) != null) {
    rv = parseFloat(RegExp.$1);
  }
  if (rv == 4 && rv2 == 8) this.ie8 = true;
  else this.ie8 = false;
  this.ie = false;
  
  if (rv == 5 && rv2 == 9) this.ie9 = true;
  else this.ie9 = false;
  
  /*@cc_on
		/*@if (@_jscript)
			this.ie = (document.all && !window.opera) ? true : false;
		/*@else @*/
			this.ie = false;
		/*@end
	@*/
	this.ie7 = (this.ie && window.XMLHttpRequest);	
	//if (!this.ie) document.captureEvents(Event.MOUSEMOVE);
	if (this.ie8) this.ie = false;
	if (this.ie9) this.ie = false;
	this.chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
	this.safari = navigator.userAgent.toLowerCase().indexOf('safari') > -1;
}

/* ************************************
 *
 *  Description: return x position of element
 *
 *  Params: obj - [object]
 *   
 * ************************************ */
TinyPopup.prototype.findPosX = function(obj) {	
  var curleft = 0;
  if(obj.offsetParent)
      while(1) 
      {
        curleft += obj.offsetLeft;
        if(!obj.offsetParent)
          break;
        obj = obj.offsetParent;
      }
  else if(obj.x)
      curleft += obj.x;
  return curleft;
}
  
/* ************************************
 *
 *  Description: return y position of element
 *
 *  Params: obj - [object]
 *   
 * ************************************ */
TinyPopup.prototype.findPosY = function(obj) {
  var curtop = 0;
  if(obj.offsetParent)
      while(1)
      {
        curtop += obj.offsetTop;
        if(!obj.offsetParent)
          break;
        obj = obj.offsetParent;
      }
  else if(obj.y)
      curtop += obj.y;
  return curtop;
}

/* ************************************
 *
 *  Description: return true if object is generated
 *
 * ************************************ */
TinyPopup.prototype.isGenerated = function() {
  return this._isGenerated;
}

/* ************************************
 *
 *  Description: return true if input is a number
 *
 * ************************************ */
TinyPopup.prototype.isNumeric = function(input) {
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < input.length && IsNumber == true; i++) 
      { 
      Char = input.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
}

/* ************************************
 *
 *  Description: return true if input is an array
 *
 * ************************************ */
TinyPopup.prototype.isArray = function(obj) {
  if ({}.toString.call(obj).slice(8, -1) == 'Array') return true;
  else return false;  
}


/* ************************************
 *
 *  Description: return z-index of a window
 *
 * ************************************ */
TinyPopup.prototype.getZindex = function() {
  return this._zIndex;
}

/* ************************************
 *
 *  Description: set z-index of a window
 *
 * ************************************ */
TinyPopup.prototype.setZindex = function(zIndex) {
  this._zIndex = zIndex;
}

/* ************************************
 *
 *  Description: create XMLHttp request
 *
 * ************************************ */
TinyPopup.prototype.createXmlHttpRequestObject = function() {
  var xmlHttp;
  // pro vsechny prohlizece krome IE6 a starsich
  try {
    xmlHttp = new XMLHttpRequest();
  }
  // IE6 a starsi
  catch(e) {
    var XmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0",
                                    "MSXML2.XMLHTTP.5.0",
                                    "MSXML2.XMLHTTP.4.0",
                                    "MSXML2.XMLHTTP.3.0",
                                    "MSXML2.XMLHTTP",
                                    "Microsoft.XMLHTTP");
    for (var i = 0; i < XmlHttpVersions.length && !xmlHttp; i++) {
      try { 
        xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
      } 
      catch (e) {}
    }
  }
  // vraci objekt nebo zobrazi chybu
  if (!xmlHttp) {
    alert("Error creating the XMLHttpRequest object.");
  }
  else { 
    return xmlHttp;
  }
}

/* ************************************
 *
 *  Description: set element position to the center of the visible page area
 *
 * ************************************ */
TinyPopup.prototype.centruj = function(id) {
  if (!id) id = this._id;
  if (document.getElementById(id)) {
    el = document.getElementById(id);
    if (this.chrome || this.safari) {
      var scrollTop = document.body.scrollTop;
      var scrollLeft = document.body.scrollLeft;
    } else {
      var scrollTop = document.documentElement.scrollTop;
      var scrollLeft = document.documentElement.scrollLeft;
    }
    var pomTop = ((document.documentElement.clientHeight)/2)-(el.offsetHeight/2)+scrollTop;
    if (pomTop<0) pomTop = 0;
    el.style.top = pomTop+"px";
    var pomLeft = ((document.documentElement.clientWidth)/2)-(el.offsetWidth/2)+scrollLeft;
    if (pomLeft<0) pomLeft = 0;
    el.style.left = pomLeft+"px";
  }
}


/* ************************************
 *
 *  Description: generate popup windows objects
 *
 * ************************************ */
TinyPopup.prototype.generatePopup = function() {
  var objBody = this.doc.getElementsByTagName("body").item(0);
  
  if (this._disableBackground==0 || this._disableBackground==4) {
  var objOverlay = this.doc.createElement("div");
		objOverlay.setAttribute('id','lbOverlay'+this._id);
		objOverlay.setAttribute((this.ie ? 'className' : 'class'), 'popup_window_prekryti_obrazovky');
		if ((this.ie && !this.ie7) || (this.ie7 && this.doc.compatMode == 'BackCompat')) {
			objOverlay.style.position = 'absolute';
		}
		objOverlay.style.display = 'none';
		/*if (this._disableBackground == 2) {
      objOverlay.style.background = "none";
      //objOverlay.onmousedown = popupObject[this._id].hideLbPopup;
      objBody.onMouseDown
    } */
		objBody.appendChild(objOverlay);
	}

  var objSiditko = this.doc.createElement("div");
  objSiditko.setAttribute('id','lbSiditko'+this._id);
  objSiditko.setAttribute((this.ie ? 'className' : 'class'), 'popup_window_hlavni_siditko');
  objSiditko.style.display = 'none';
  objBody.appendChild(objSiditko);


	if (this._disableBackground==2 || this._disableBackground==4) {
  	pomId = this._id;
  	if (objBody.onmousedown) {
  	  pomDocMouse = document.onmousedown;
  	} else {
      pomDocMouse = "";
    }   
  	document.onmousedown = popupObject[pomId].hidePopupIf;
  }	
  var objIs_popup1 = this.doc.createElement("div");
		objIs_popup1.setAttribute('id',this._id);
		objIs_popup1.setAttribute((this.ie ? 'className' : 'class'), 'popup_window_hlavni');
		//objIs_popup1.setAttribute('onmousedown','popupObject[\''+this._id+'\'].focusPopup();');
		objIs_popup1.style.display = 'none';
		objIs_popup1.innerHTML = '<div class="popup_window_vnejsi_ram" id="ramecek_'+this._id+'" onmousedown="popupObject[\''+this._id+'\'].focusPopup();"></div>';
		objBody.appendChild(objIs_popup1);
		
  var objRamecek = document.getElementById('ramecek_'+this._id);
  
  var objLista = this.doc.createElement("div");
    objLista.setAttribute((this.ie ? 'className' : 'class'), 'popup_window_lista_active');
    objLista.setAttribute('id','is_popup1_lista'+this._id);
    objLista.innerHTML = '<a class="popup_window_zavrit" id="is_popup1_close'+this._id+'" onmousedown="popupObject[\''+this._id+'\'].setActiveIcon(true);return false;" onmouseup="popupObject[\''+this._id+'\'].setActiveIcon(false);return false;" onclick="popupObject[\''+this._id+'\'].hidePopup();return false;" title="'+this._def_close_message+'"></a>';
    objLista.innerHTML += '<a class="popup_window_maximal" id="is_popup1_maximal'+this._id+'" onmousedown="popupObject[\''+this._id+'\'].setActiveIcon(true);return false;" onmouseup="popupObject[\''+this._id+'\'].setActiveIcon(false);return false;" onclick="popupObject[\''+this._id+'\'].maximalizePopup();return false;" title="'+this._def_maximal_message+'"></a>';
    objLista.innerHTML += '<a class="popup_window_unmaximal" id="is_popup1_unmaximal'+this._id+'" onmousedown="popupObject[\''+this._id+'\'].setActiveIcon(true);return false;" onmouseup="popupObject[\''+this._id+'\'].setActiveIcon(false);return false;" onclick="popupObject[\''+this._id+'\'].unmaximalizePopup();return false;" title="'+this._def_maximal_message+'"></a>';
    objLista.innerHTML += '<a class="popup_window_minimal" id="is_popup1_minimal'+this._id+'" onmousedown="popupObject[\''+this._id+'\'].setActiveIcon(true);return false;" onmouseup="popupObject[\''+this._id+'\'].setActiveIcon(false);return false;" onclick="popupObject[\''+this._id+'\'].minimalizePopup();return false;" title="'+this._def_minimal_message+'"></a>';
		objLista.onmousedown = popupObject[this._id].startMove;
		var afcId = this._id;
		objLista.ondblclick = function (){popupObject[afcId].forceAutosize();popupObject[afcId].forceCenter();};
    objRamecek.appendChild(objLista); 
  var objNazev = this.doc.createElement("div");
    objNazev.setAttribute((this.ie ? 'className' : 'class'), 'popup_window_nazev');
    objNazev.setAttribute('id','is_popup1_nazev'+this._id);
		objLista.appendChild(objNazev); 
		
	var objBox = this.doc.createElement("div");
    objBox.setAttribute((this.ie ? 'className' : 'class'), 'popup_window_ram');
    objBox.setAttribute('id','is_popup1_content_box'+this._id);
    objRamecek.appendChild(objBox);	

  var objForm = this.doc.createElement("form");
    objForm.setAttribute('id','is_popup1_form'+this._id);
    objForm.setAttribute('method','post');
    objBox.appendChild(objForm); 	

  var objTabs = this.doc.createElement("div");
    objTabs.setAttribute((this.ie ? 'className' : 'class'), 'popup_window_tabs');
    objTabs.setAttribute('id','is_popup1_tabs'+this._id);
		objForm.appendChild(objTabs); 
    	
  var objContent = this.doc.createElement("div");
    objContent.setAttribute((this.ie ? 'className' : 'class'), 'popup_window_obsah2');
    objContent.setAttribute('id','is_popup1_content'+this._id);
		objForm.appendChild(objContent); 
	var objButtons = this.doc.createElement("div");
    objButtons.setAttribute((this.ie ? 'className' : 'class'), 'popup_window_tlacitka');
    objButtons.setAttribute('id','is_popup1_buttons'+this._id);
		objBox.appendChild(objButtons); 
		
  var objResizebox = this.doc.createElement("div");
    objResizebox.setAttribute((this.ie ? 'className' : 'class'), 'popup_window_resizebox');
    objResizebox.setAttribute('id','is_popup1_resizebox'+this._id);
    //objResizebox.innerHTML = '<div class="popup_window_resize" id="is_popup1_resize'+this._id+'"></div>';
	
  var objResizeSmall = this.doc.createElement("div");	
    objResizeSmall.setAttribute((this.ie ? 'className' : 'class'), 'popup_window_resize');
    objResizeSmall.setAttribute('id','is_popup1_resize'+this._id);
    objResizeSmall.onmousedown = popupObject[this._id].startResize;
    objResizebox.appendChild(objResizeSmall);
		//onmousedown="popupObject[\''+this._id+'\'].startResize();"
    objRamecek.appendChild(objResizebox);  
    
    
   //objRamecek.innerHTML += '<div class="popup_window_resizebox" id="is_popup1_resizebox'+this._id'"></div>';  	

   this._isGenerated = 1;  
}

/* ************************************
 *
 *  Description: display popup window and send request to server
 *
 * ************************************ */
TinyPopup.prototype.showPopup = function() {
  if (this._isGenerated==0) {
    this.generatePopup();
  }
  //this.focusPopup();
  if (document.getElementById(this._id)) {
    if (this._disableBackground==0 || this._disableBackground==4) {
      var lbOverlay = document.getElementById('lbOverlay'+this._id);
      //lbOverlay.style.display = 'block';
      var pageSize = this.getPageSizeWithScroll();
      lbOverlay.style.height = pageSize[1];
    }  
    popup = document.getElementById(this._id);
    this.setSizeTimer();
    this.sendRequest();
  }  
}

/* ************************************
 *
 *  Description: send request to server
 *
 * ************************************ */
TinyPopup.prototype.sendRequest = function(script, classname, constructParams, method, methodParams) {
  if (this._isLoading!=1) {
    if (this._debug_mode==1) {
      this.debug.addMessage('CALLED METHOD: TinyPopup.prototype.sendRequest');
    } 
    if (typeof(tinyMCE) != "undefined") tinyMCE.triggerSave(); 
    this._isLoading = 1;
    var popup = document.getElementById(this._id);

    if (script) this._script = "<paramscript>"+script+"</paramscript>";
    if (classname) this._classname = "<paramclassname>"+classname+"</paramclassname>";
    if (constructParams) {
      // paremtry konstruktoru (string nebo array)
      if (this.isArray(constructParams)) {
        this._constructParams = "<paramconstructparams>";
        for (var i in constructParams) {
          if (this.isNumeric(i)) {
            this._constructParams += "<param"+i+">"+constructParams[i]+"</param"+i+">";
          } else {
            this._constructParams += "<"+i+">"+constructParams[i]+"</"+i+">";
          }
        }
        this._constructParams += "</paramconstructparams>";
      }
      else {
        this._constructParams = "<paramconstructparams>"+constructParams+"</paramconstructparams>";
      }
    }
    if (method) this._method = "<parammethod>"+method+"</parammethod>";
    if (methodParams) {
      // paremtry metody (string nebo array)
      if (this.isArray(methodParams)) {
        this._methodParams = "<parammethodparams>";
        for (var i in methodParams) {
          if (this.isNumeric(i)) {
            this._methodParams += "<param"+i+">"+methodParams[i]+"</param"+i+">";
          } else {
            this._methodParams += "<"+i+">"+methodParams[i]+"</"+i+">";
          }
        }
        this._methodParams += "</parammethodparams>";
      }
      else {
        this._methodParams = "<parammethodparams>"+methodParams+"</parammethodparams>";
      }
    }
    
    this.getForm();
    this._new_param = "params=<body><popup_id>"+this._id+"</popup_id>"+this._script+this._classname+this._constructParams+this._method+this._methodParams+this._formData+"</body>";
    if (!this._errorHandling) this._lastRequest = this._new_param;
    if (this._debug_mode==1) {
      //alert('PARAMS TO SEND: '+this._new_param);
      this.debug.addMessage('PARAMS TO SEND: '+this._new_param);
    }  
    //this.hidePopup();
    var http = this.createXmlHttpRequestObject();
    var id = this._id;
    
    //this._endMessage = this._def_loading_message;
    if (this._sendingFiles == 0) this.showResult();

    http.open("POST", this._imagePath + this._php+".php", true);

    http.onreadystatechange=function() {
      if(http.readyState == 4) {
        if (http.status == 200) {
          if (http.responseText) {
            if (popupObject[id]) popupObject[id].decodeRequest(http);
            delete http;
          }
        }
      }
    }

    http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    http.send(this._new_param);
  }  
}

/* ************************************
 *
 *  Description: check form to select input type file
 *
 * ************************************ */
TinyPopup.prototype.checkContent = function() {
  var objForm = document.getElementById('is_popup1_form'+this._id);
  var formData = objForm.elements;
  var counter = 0;
  if (formData.length>0) {

    for (var i=0; i < formData.length; i++) {
      formData[i].setAttribute("autocomplete", "false");
      formData[i].autocomplete="false";
      if (formData[i].type == "file") {
        var pomId = this._id;
        if (this._uploadFiles[i]) delete(this._uploadFiles[i]);
        formData[i].onchange = function() {popupObject[pomId].startFileUload(this.id)};
      }
      if (formData[i].type == "text") {
        formData[i].setAttribute("autocomplete", "false");

      }
    }
  }  
}

/* ************************************
 *
 *  Description: set icons to disable
 *
 * ************************************ */
TinyPopup.prototype.setIconsToDisable = function(pomIcons) {
  //this._disabledIconfff = new Array();
  if (pomIcons) {
      if (this.isArray(pomIcons)) {
        for (var counter in pomIcons) {
          if (document.getElementById(pomIcons[counter])) {
              var pomI = document.getElementById(pomIcons[counter]);
              var pomId = pomI.getAttribute('id');
              //alert(pomId);
              if (!this._disabledIcon[pomId]) {
                  this._disabledIcon[pomId] = new Array();
                  this._disabledIcon[pomId]['id'] = pomId;
              }
          }
        }
      }
      else {
        if (document.getElementById(pomIcons)) {
          var pomEl = document.getElementById(pomIcons);
          if (!this._disabledIcon[pomIcons]) {
            var pomI = document.getElementById(pomIcons);
            var pomId = pomI.getAttribute('id');
            this._disabledIcon[pomId] = new Array();
            this._disabledIcon[pomId]['id'] = pomId;
          }
        }
      }
    }
}

/* ************************************
 *
 *  Description: save log to database
 *
 * ************************************ */
TinyPopup.prototype.saveLog = function() {
  var methParams = '<param1><![CDATA['+this.urlencode(window.location)+']]></param1>'+
    '<param2><![CDATA['+this.urlencode(this.prepareForSend(this._lastRequest))+']]></param2>'+
    '<param3><![CDATA['+this.urlencode(this.prepareForSend(this._lastResponse))+']]></param3>';
  this._errorHandling = true;
  this.sendRequest('Pcb/Ajax/PopupWindow/Log.php', 'Pcb_Ajax_PopupWindow_Log', '', 'saveLog', methParams);
  /*var pomId = this._id; 
  var llTimer = setTimeout(function () {
      popupObject[pomId].sendRequest('Pcb/Ajax/PopupWindow/Log.php', 'Pcb_Ajax_PopupWindow_Log', '', 'saveLog', methParams);
    }, 500);*/
}


/* ************************************
 *
 *  Description: initialize file upload
 *
 * ************************************ */
TinyPopup.prototype.initUpload = function() {
  this._sendingFiles = 1;
  for (var butId in this._disabledIcon) {
    var pomButton = document.getElementById(butId);
    this._disabledIcon[butId]['onclick'] = pomButton.onclick;
    this._disabledIcon[butId]['class'] = (this.ie ? pomButton.getAttribute('className') : pomButton.getAttribute('class'));
    pomButton.onclick = function() {return false;};
    pomButton.setAttribute((this.ie ? 'className' : 'class'), (this.ie ? pomButton.getAttribute('className') : pomButton.getAttribute('class'))+'-disabled');
  }
}

/* ************************************
 *
 *  Description: finalize file upload
 *
 * ************************************ */
TinyPopup.prototype.finalizeUpload = function() {
  for (var butId in this._disabledIcon) {
    var pomButton = document.getElementById(butId);
    pomButton.onclick = this._disabledIcon[butId]['onclick'];
    pomButton.setAttribute((this.ie ? 'className' : 'class'), this._disabledIcon[butId]['class']);
  }
}

/* ************************************
 *
 *  Description: start upload file
 *
 * ************************************ */
TinyPopup.prototype.startFileUload = function(fileid) {
  if (this._sessionId==0) {
    var pomIdUpload = this._id;
    this.sendRequest('Pcb/Upload.php', 'Pcb_Upload', '', 'ajBlankRequest', '');
    var Timer = setTimeout(function () {if (popupObject[pomIdUpload]) popupObject[pomIdUpload].startFileUload(fileid);}, this._file_upload_refresh_timeout);
  } else {
    // input file
    var elFile = document.getElementById(fileid);
    var nameFrom = 0;
    if (elFile.value.lastIndexOf('\\') > -1) nameFrom = elFile.value.lastIndexOf('\\')+1;
    var pomName = elFile.value.substr(nameFrom);
    // kontrola pripon
    var extension = pomName.substring(pomName.length-(pomName.length-pomName.lastIndexOf('.')-1));
    var extOk = 0;
    if (document.getElementById(fileid+'_ext_allow')) {
      var arrAllow = document.getElementById(fileid+'_ext_allow').value.split('_');
      for (var ind in arrAllow) {
        if (arrAllow[ind]==extension) {
          extOk = 1;
          break;
        }
      }
    } else if (document.getElementById(fileid+'_ext_deny')) {
      var arrDeny = document.getElementById(fileid+'_ext_deny').value.split('_');
      extOk = 1;
      for (var ind in arrDeny) {
        if (arrDeny[ind]==extension) {
          extOk = 0;
          break;
        }
      }
    } else {
      extOk = 1;
    }
    // test pripony
    if (extOk == 0) {
      alert(this._fileexterror);
      var newBlankFile = document.createElement("input");
      newBlankFile.setAttribute('type','file');
      newBlankFile.setAttribute('id', elFile.id);
      newBlankFile.setAttribute('name', elFile.name);
      var pomId = this._id;
      newBlankFile.onchange = function() {popupObject[pomId].startFileUload(this.id)};
      elFile.parentNode.insertBefore(newBlankFile, elFile);
      elFile.parentNode.removeChild(elFile);
    } else {
      var elContainer = document.getElementById(fileid+'_container'); 
      // multiupload
      if (document.getElementById(fileid+'_numbers')) {
        var multiupload = true;
        var lastNumner = document.getElementById(fileid+'_numbers').value;
        lastNumner++;
        document.getElementById(fileid+'_numbers').value = lastNumner;
        fileid = fileid+'_'+lastNumner;
      } else {
        var multiupload = false;
      }
      // objects
      var objBody = this.doc.getElementsByTagName("body").item(0);
      var objBox = document.getElementById('is_popup1_content_box'+this._id);
      var objFormDiv = this.doc.createElement("div");
      objFormDiv.setAttribute((this.ie ? 'className' : 'class'), 'popup_window_form_div');
      objFormDiv.setAttribute('id','is_popup1_formdiv' + this._id + fileid);
      objFormDiv.style.display = "none";
      objBox.appendChild(objFormDiv);
  
      
      // progress bar
      var progressBox = document.createElement("div");
      progressBox.setAttribute('id','is_popup1_progresbox'+fileid);
      if (multiupload == true) {
        progressBox.setAttribute((this.ie ? 'className' : 'class'),'progressboxmulti');
      } else {
        progressBox.setAttribute((this.ie ? 'className' : 'class'),'progressbox');
      }
      progressBox.innerHTML = '<div id="is_popup1_progresbar'+fileid+'" class="progressbar"><input type="hidden" name="'+fileid+'" id="hidden_upload_'+fileid+'" value=""><img id="is_popup1_progresbarimg'+fileid+'" src="'+this._imagePath+'images/popupWindow/upload_progress.jpg" /></div><div id="is_popup1_progresdelete'+fileid+'" onclick="popupObject[\''+this._id+'\'].stopFileUload(\''+fileid+'\');" class="progressstop"></div><div id="is_popup1_progresinfo'+fileid+'" class="progressinfo" onmouseover="popupObject[\''+this._id+'\'].showFileInfo(\''+fileid+'\');" onmouseout="popupObject[\''+this._id+'\'].hideFileInfo(\''+fileid+'\');"></div><div id="is_popup1_progresname'+fileid+'" class="progressname">...</div><div id="is_popup1_progresstatus'+fileid+'" class="progressstatus">0%</div><div id="is_popup1_infobox'+fileid+'" class="progressinfobox"><br /><br /><br /></div>';
      var cleaner = document.createElement("div");
      cleaner.setAttribute('id','is_popup1_cleaner'+fileid);
      cleaner.setAttribute((this.ie ? 'className' : 'class'),'popup_window_cleaner');
      if (elContainer) {
        if (elContainer.firstChild) {
          elContainer.insertBefore(progressBox, elContainer.firstChild);
        } else {
          elContainer.appendChild(progressBox);
        }  
      } else {
        if(elFile.nextSibling) {
      		elFile.parentNode.insertBefore(progressBox, elFile.nextSibling);
      	} else {
      		elFile.parentNode.appendChild(progressBox);
      	}
      }	
  
      //elFile.parentNode.insertBefore(cleaner, elFile);
      
      delete(this._uploadFiles[fileid]);
      this.updateFile(fileid, 0, 0, pomName, 0);
      var start = new Date();
      this._uploadFiles[fileid]['time_start'] = start.getTime();
      var objFileName = document.getElementById('is_popup1_progresname'+fileid);
      if (pomName.length > 25) {
        objFileName.innerHTML = pomName.substring(0,13)+' ... '+pomName.substring(pomName.length-5);
      }
      else objFileName.innerHTML = pomName;
      // hidden upload
      var newElFile = elFile.cloneNode(true);
      newElFile.id = fileid;
      //this.clearUploadTempFile(fileid, 'a');
      if (multiupload == true) {
        var newBlankFile = document.createElement("input");
        newBlankFile.setAttribute('type','file');
        newBlankFile.setAttribute('id', elFile.id);
        newBlankFile.setAttribute('name', elFile.name);
        var pomId = this._id;
        newBlankFile.onchange = function() {popupObject[pomId].startFileUload(this.id)};
        elFile.parentNode.insertBefore(newBlankFile, elFile);
        this._uploadFiles[fileid]['multiupload'] = 1;
        elFile.parentNode.removeChild(elFile);
        if (this._resizeOnUpload == 1) {
          this.forceAutosize();
        }
        if (this._centerOnUpload == 1) {
          this.forceCenter();
        }
      } else {
        this._uploadFiles[fileid]['multiupload'] = 0;
        elFile.parentNode.removeChild(elFile);
      } 
      
      objFormDiv.innerHTML = '<form action="/cgi-bin/upload.cgi?sID='+this._sessionId+'form'+fileid+'" method="post" enctype="multipart/form-data" target="form'+fileid+'_frame" name="form'+fileid+'" id="form'+fileid+'">'
      objFormDiv.innerHTML += '<iframe name="form'+fileid+'_frame" id="form'+fileid+'_frame"></iframe>';
      var hiddenForm = document.getElementById('form'+fileid);
      elFile.id = fileid;
      hiddenForm.appendChild(elFile);
      hiddenForm.submit();
      if (this._sendingFiles == 0) {
          //this.checkFileUload();
        this.initUpload();
        var pomIdUpload = this._id;
        var Timer = setTimeout(function () {if (popupObject[pomIdUpload]) popupObject[pomIdUpload].checkFileUload();}, this._file_upload_refresh_timeout);
      }
    }  
  }
  //else alert('uz nahravam');
}

/* ************************************
 *
 *  Description: write file values
 *
 * ************************************ */
TinyPopup.prototype.updateFile = function(fileid, uploaded, totalsize, name, finished) {
  if (!this._uploadFiles[fileid]) {
    this._uploadFiles[fileid] = new Array();
  }
  this._uploadFiles[fileid]['uploaded'] = uploaded;
  if (totalsize) this._uploadFiles[fileid]['totalsize'] = totalsize;
  if (name) this._uploadFiles[fileid]['name'] = name;
  if (finished) this._uploadFiles[fileid]['finished'] = finished;
}

/* ************************************
 *
 *  Description: clear temp directory
 *
 * ************************************ */
TinyPopup.prototype.clearUploadTempFile = function(fileid, name) {
  var constParams = '<param1>'+fileid+'</param1>';
  var methParams = '<param1>'+name+'</param1>';
  this.sendRequest('Pcb/Upload.php', 'Pcb_Upload', constParams, 'ajClearTemp', methParams);
}

/* ************************************
 *
 *  Description: delete file
 *
 * ************************************ */
TinyPopup.prototype.deleteFile = function(fileid) {
  if (this._uploadFiles[fileid]) {
    var constParams = '<param1>'+fileid+'</param1>';
    var methParams = '<param1>'+this._uploadFiles[fileid]['name']+'</param1>';
    
    var pomIdUpload = this._id;
    var pomDelId = fileid;
    var pomDelName = this._uploadFiles[fileid]['name'];
    //var Timer6 = setTimeout(function () {if (popupObject[pomIdUpload]) popupObject[pomIdUpload].clearUploadTempFile(pomDelId, pomDelName);}, this._file_upload_refresh_timeout);
    delete(this._uploadFiles[fileid]);
    this.sendRequest('Pcb/Upload.php', 'Pcb_Upload', constParams, 'ajCancelUpload', methParams);
    //var Timer6 = setTimeout(function () {popupObject[pomIdUpload].sendRequest('Pcb/Upload.php', 'Pcb_Upload', constParams, 'ajCancelUpload', methParams);}, this._file_upload_refresh_timeout);
  }
  
  var sendingFile = 0;
  for (var fileid in this._uploadFiles) {
    if (this._uploadFiles[fileid]['finished']!=1) sendingFile = 1;
  }
  if (sendingFile == 0) this.finalizeUpload();
  
}

/* ************************************
 *
 *  Description: refresh files upload progress bars
 *
 * ************************************ */
TinyPopup.prototype.refreshUploadProgressBars = function() {
  var nextRefresh = 0;
  for (var fileid in this._uploadFiles) {
    if (this._uploadFiles[fileid]) {
       var objProgressText = document.getElementById('is_popup1_progresstatus'+fileid);
       if (objProgressText) {
         if (this._uploadFiles[fileid]['uploaded']>0 && this._uploadFiles[fileid]['totalsize']>0) {
           var pomProgress = Math.round((this._uploadFiles[fileid]['uploaded']*1000)/this._uploadFiles[fileid]['totalsize'])/10;
           objProgressText.innerHTML = pomProgress.toFixed(1)+'%';
           var objProgressBar = document.getElementById('is_popup1_progresbar'+fileid);
           var objProgressImg = document.getElementById('is_popup1_progresbarimg'+fileid);
           objProgressImg.style.width = Math.round(((objProgressBar.offsetWidth-2)*pomProgress)/100)+"px";
           this.refreshFileInfo(fileid);
           if (pomProgress == 100) {
             objProgressImg.src = this._imagePath+"images/popupWindow/upload_progress_done.jpg";
             if (this._uploadFiles[fileid]['finished']!=1) {
               this._uploadFiles[fileid]['finished'] = 1;
               this.fileUploadFinished(fileid);
               var pomIdUpload = this._id;
               var pomDelId = fileid;
               var pomDelName = this._uploadFiles[fileid]['name'];
               //alert('konec'+this._uploadFiles[fileid]['uploaded']+'-'+this._uploadFiles[fileid]['totalsize']);
               //var Timer6 = setTimeout(function () {if (popupObject[pomIdUpload]) popupObject[pomIdUpload].clearUploadTempFile(pomDelId, pomDelName);}, this._file_upload_refresh_timeout);

             }
           } else {
             nextRefresh = 1;
           }
         } else nextRefresh = 1;
       }
    }
  }
  if (nextRefresh == 0) {
    this.finalizeUpload();
  }
}

/* ************************************
 *
 *  Description: count file upload infos
 *
 * ************************************ */
TinyPopup.prototype.countFileInfo = function(fileid) {
   var counted = new Array();
   var timeNow = new Date();
   if (this._uploadFiles[fileid]['finished'] == 1) {
     var diference = new Date(this._uploadFiles[fileid]['time_end'] - this._uploadFiles[fileid]['time_start']);
   } else {
     var diference = new Date(timeNow.getTime() - this._uploadFiles[fileid]['time_start']);
     this._uploadFiles[fileid]['time_end'] = timeNow.getTime();
   }
   counted['diference'] = '';
   if (diference.getHours()>1) counted['diference'] += diference.getHours()-1 + 'h ';
   if (diference.getMinutes()>0) counted['diference'] += diference.getMinutes() + 'm ';
   counted['diference'] += diference.getSeconds() + 's ';

   var speed = this._uploadFiles[fileid]['uploaded'] / (diference/1000);
   var speedPom = speed;
   var value = 'B/s';
   if (speed > 1024) {
     speed = speed/1024;
     value = 'kB/s';
   }
   if (speed > 1024) {
     speed = speed/1024;
     value = 'MB/s';
   }
   speed = Math.round(speed*10)/10;
   counted['speed'] = speed.toFixed(1) + ' ' +value;
   if (this._uploadFiles[fileid]['finished'] == 1) {
     var remaining = new Date(0);
   } else {
     var remaining = (this._uploadFiles[fileid]['totalsize'] * diference) / this._uploadFiles[fileid]['uploaded'];
     if ((remaining - diference) < 0) {
       remaining = new Date(0);  
     } else {
       remaining = new Date(remaining - diference);  
     }

   }
   counted['remaining'] = '';
   if (remaining.getHours()>1) counted['remaining'] += remaining.getHours()-1 + 'h ';
   if (remaining.getMinutes()>0) counted['remaining'] += remaining.getMinutes() + 'm ';
   counted['remaining'] += remaining.getSeconds() + 's ';


   var uploaded = this._uploadFiles[fileid]['uploaded'];
   var value = 'B';
   if (uploaded > 1024) {
     uploaded = uploaded/1024;
     value = 'kB';
   }
   if (uploaded > 1024) {
     uploaded = uploaded/1024;
     value = 'MB';
   }
   uploaded = Math.round(uploaded*10)/10;
   counted['size'] = uploaded.toFixed(1) + ' ' +value;
   var totalSize = this._uploadFiles[fileid]['totalsize'];
   var value = 'B';
   if (totalSize > 1024) {
     totalSize = totalSize/1024;
     value = 'kB';
   }
   if (totalSize > 1024) {
     totalSize = totalSize/1024;
     value = 'MB';
   }
   totalSize = Math.round(totalSize*10)/10;
   counted['size'] += '/'+totalSize.toFixed(1) + ' ' +value;


   return counted;
}

/* ************************************
 *
 *  Description: show file upload infos
 *
 * ************************************ */
TinyPopup.prototype.showFileInfo = function(fileid) {
  for (var fileidpom in this._uploadFiles) {
     if (document.getElementById('is_popup1_infobox'+fileidpom)) {
       var el = document.getElementById('is_popup1_infobox'+fileidpom);
       clearTimeout(this._fileInfoTimer[el.id]);
       el.style.display = "none";
       if (this._elementVisibility[el.id]) {
           el.style.opacity = this._elementVisibility[el.id]['visibility-opa'];
           el.style.filter = this._elementVisibility[el.id]['visibility-filter'];
       }
     }
  }
  var progressBox = document.getElementById('is_popup1_progresbox'+fileid);
  if (!document.getElementById('is_popup1_infobox'+fileid)) {
      var infoBox = document.createElement("div");
      infoBox.setAttribute('id','is_popup1_infobox'+fileid);
      infoBox.setAttribute((this.ie ? 'className' : 'class'),'progressinfobox');
      infoBox.innerHTML = "--";
      if (!this._elementVisibility[fileid]) {
        this._elementVisibility[fileid] = new Array();
      }
      this._elementVisibility[fileid]['visibility-opa'] = infoBox.style.opacity;
      this._elementVisibility[fileid]['visibility-filter'] = infoBox.style.filter;
      progressBox.appendChild(infoBox);
  } else {
    var infoBox = document.getElementById('is_popup1_infobox'+fileid);
  }
  if (!this._elementVisibility[infoBox.id]) {
      this._elementVisibility[infoBox.id] = new Array();
    }
    this._elementVisibility[infoBox.id]['visibility-opa'] = infoBox.style.opacity;
    this._elementVisibility[infoBox.id]['visibility-filter'] = infoBox.style.filter;
    this.elementAppear(infoBox, this._def_disappear_increase, 0, this._def_disappear_timeout, 90);
  //infoBox.style.display = "block";
}

/* ************************************
 *
 *  Description: hide file upload infos
 *
 * ************************************ */
TinyPopup.prototype.hideFileInfo = function(fileid) {
  for (var fileidpom in this._uploadFiles) {
     if (document.getElementById('is_popup1_infobox'+fileidpom)) {
       var el = document.getElementById('is_popup1_infobox'+fileidpom);
       clearTimeout(this._fileInfoTimer[el.id]);
       //el.style.display = "none";
       if (this._elementVisibility[el.id]) {
           el.style.opacity = this._elementVisibility[el.id]['visibility-opa'];
           el.style.filter = this._elementVisibility[el.id]['visibility-filter'];
       }
     }
  }
  var infoBox = document.getElementById('is_popup1_infobox'+fileid);
  if (infoBox && infoBox.style.display == "block") {
    if (!this._elementVisibility[infoBox.id]) {
      this._elementVisibility[infoBox.id] = new Array();
      this._elementVisibility[infoBox.id]['visibility-opa'] = infoBox.style.opacity;
      this._elementVisibility[infoBox.id]['visibility-filter'] = infoBox.style.filter;
    }
    
    var pomVis = 100;
    var pomId = this._id;
    var pomInc = this._def_disappear_increase;
    this._fileInfoTimer[infoBox.id] = setTimeout(function () {if (infoBox && popupObject[pomId]) popupObject[pomId].elementDisappear(infoBox,pomInc,pomVis); }, 300);
  }
}

/* ************************************
 *
 *  Description: hide element - disappear
 *
 * ************************************ */
TinyPopup.prototype.elementDisappear = function(el, increase, visibility, timeout) {
  if (this._def_popup_disappear_enable == 1) {
    if (!timeout) timeout = this._def_disappear_timeout;
    if (visibility>0 && el) {
      if (visibility>=increase) visibility = visibility - increase;
      el.style.opacity = visibility/100;
      el.style.filter = "alpha( opacity = "+visibility+")";
      var pomId = this._id;
      this._fileInfoTimer[el.id] = setTimeout(function () {if (el && visibility && popupObject[pomId]) popupObject[pomId].elementDisappear(el, increase, visibility, timeout);}, timeout);
    }
    if (visibility == 0) {
      el.style.display = "none";
      if (this._elementVisibility[el.id]) {
          el.style.opacity = this._elementVisibility[el.id]['visibility-opa'];
          el.style.filter = this._elementVisibility[el.id]['visibility-filter'];
      }
      clearTimeout(this._fileInfoTimer[el.id]);

    }
  } else {
     el.style.display = "none";
  }
}

/* ************************************
 *
 *  Description: show element - appear
 *
 * ************************************ */
TinyPopup.prototype.elementAppear = function(el, increase, visibility, timeout, max) {
  if (!max) max = 100;
  if (this._def_popup_disappear_enable == 1) {
    
    if (!timeout) timeout = this._def_disappear_timeout;
    if (visibility>max) visibility = max;
    if (visibility<max && el) {
      if (visibility<=(max-increase)) visibility = visibility + increase;
      el.style.opacity = visibility/100;
      el.style.filter = "alpha( opacity = "+visibility+")";
      el.style.display = "block";
      var pomId = this._id;
      this._fileInfoTimer[el.id] = setTimeout(function () {if (el && visibility && popupObject[pomId]) popupObject[pomId].elementAppear(el, increase, visibility, timeout, max);}, timeout);
    }
    if (visibility == max) {
      el.style.opacity = visibility/100;
      el.style.filter = "alpha( opacity = "+visibility+")";
      clearTimeout(this._fileInfoTimer[el.id]);
    }
  }
  else {
    el.style.display = "block";
    //el.style.opacity = max/100;
    //el.style.filter = "alpha( opacity = "+max+")";
    
    clearTimeout(this._fileInfoTimer[el.id]);
  }
  //el.style.display = "block";
}

/* ************************************
 *
 *  Description: refresh file upload infos
 *
 * ************************************ */
TinyPopup.prototype.refreshFileInfo = function(fileid) {
  if (document.getElementById('is_popup1_infobox'+fileid)) {
    var infoBox = document.getElementById('is_popup1_infobox'+fileid);
    var objFileName = document.getElementById('is_popup1_progresname'+fileid);
    var counted = this.countFileInfo(fileid);
    infoBox.innerHTML = popupTextElapsedTime + ': ' + counted['diference'] + '<br>' + popupTextRemainingTime + ': ' + counted['remaining'] + '<br>' + counted['size'] + ' (' + counted['speed'] + ')';
    if (this._uploadFiles[fileid]['name'].length > 25) {
      objFileName.innerHTML = this._uploadFiles[fileid]['name'].substring(0,13)+' ... '+this._uploadFiles[fileid]['name'].substring(this._uploadFiles[fileid]['name'].length-5);
    }
    else objFileName.innerHTML = this._uploadFiles[fileid]['name'];
    }
}

/* ************************************
 *
 *  Description: stop uploading current file
 *
 * ************************************ */
TinyPopup.prototype.stopFileUload = function(fileid) {
  var objFormDiv = document.getElementById('is_popup1_formdiv' + this._id + fileid);
  var objFrame = document.getElementById('form'+fileid+'_frame');
  var objForm = document.getElementById('form'+fileid);
  var newElFile = document.getElementById(fileid);
  var progressBox = document.getElementById('is_popup1_progresbox'+fileid);
  if (this._uploadFiles[fileid]['multiupload']==0) {
    var elFile = document.createElement("input");
    elFile.setAttribute('type','file');
    elFile.setAttribute('id', fileid);
    elFile.setAttribute('name', newElFile.name);
    if (this.ie) {
      if (newElFile.getAttribute('className') != null)  elFile.setAttribute('className', newElFile.getAttribute('className') );
    }else {
      if (newElFile.getAttribute('class') != null)  elFile.setAttribute('class', newElFile.getAttribute('class') );
    }
    var pomId = this._id;
    elFile.onchange = function() {popupObject[pomId].startFileUload(this.id)};
    progressBox.parentNode.insertBefore(elFile, progressBox);
  }  
  //objFormDiv.innerHTML = '';
  objFormDiv.parentNode.removeChild(objFormDiv);
  progressBox.parentNode.removeChild(progressBox);
  if (this._resizeOnUpload == 1) {
    this.forceAutosize();
  }  
  this.deleteFile(fileid);
}

/* ************************************
 *
 *  Description: get files upload progress
 *
 * ************************************ */
TinyPopup.prototype.checkFileUload = function() {
  var constParams = "";
  for (var fileid in this._uploadFiles) {
    if (this._uploadFiles[fileid]['finished'] != 1) {
        constParams = constParams+fileid+',';
    }
  }
  if (constParams != "") {
    constParams = '<param1>'+constParams.substring(0, constParams.length-1)+'</param1>';
    this.sendRequest('Pcb/Upload.php', 'Pcb_Upload', constParams, 'ajGetStatus', '');
    var pomIdUpload = this._id;
    var Timer = setTimeout(function () {if (popupObject[pomIdUpload]) popupObject[pomIdUpload].checkFileUload();}, this._file_upload_refresh_timeout);
  } else {
    this._sendingFiles = 0;
  }
   
}

/* ************************************
 *
 *  Description: set file upload finish
 *
 * ************************************ */
TinyPopup.prototype.fileUploadFinished = function(fileid) {
  var objInputHidden = document.getElementById('hidden_upload_'+fileid);
  objInputHidden.value = this._uploadFiles[fileid]['name'];
  var constParams = '<param1>'+fileid+'</param1>';
  var methParams = '<param1>'+this._uploadFiles[fileid]['name']+'</param1>';
  this.sendRequest('Pcb/Upload.php', 'Pcb_Upload', constParams, 'ajFinishUpload', methParams);
}


/* ************************************
 *
 *  Description: get form data
 *
 * ************************************ */
TinyPopup.prototype.getForm = function() {
  this._formData = "<formdata>";
  var objForm = document.getElementById('is_popup1_form'+this._id);
  var formData = objForm.elements;
  var newParam = Array();
  var poc = 0;
  
  if (formData.length>0) {
    
    for (var i=0; i < formData.length; i++) {
      //if (formData[i].name=='pobocka_id') alert(formData[i].name+' '+formData[i].disabled);
      if (formData[i].type == "checkbox") {
        if (formData[i].checked==1 && !formData[i].disabled) {
          this._formData += "<"+formData[i].name+">1</"+formData[i].name+">";
        }  
      }else 
      if (formData[i].type == "radio" && !formData[i].disabled) {
        if (formData[i].checked==1) {
          this._formData += "<"+formData[i].name+">"+this.urlencode(formData[i].value)+"</"+formData[i].name+">";
        }  
      }else 
      if (formData[i].tagName == "SELECT" && !formData[i].disabled) {
        this._formData += "<"+formData[i].name+">"+this.urlencode(formData[i].value)+"</"+formData[i].name+">";
      }else 
      if (formData[i].tagName == "TEXTAREA" && !formData[i].disabled) {
        this._formData += "<"+formData[i].name+"><![CDATA["+this.urlencode(formData[i].value)+"]]></"+formData[i].name+">";
      } else {
        if (!formData[i].disabled) {
          this._formData += "<"+formData[i].name+"><![CDATA["+this.urlencode(formData[i].value)+"]]></"+formData[i].name+">";
        }  
      }
      poc++;
    }
  }
  if (document.getElementById(this._formId)) {
    var objForm = document.getElementById(this._formId);
    var formData = objForm.elements;
    var newParam = Array();
    var poc = 0;
    if (typeof(formData) != 'undefined' && formData.length>0) {
      
      for (var i=0; i < formData.length; i++) {
        if (formData[i].type == "checkbox") {
          if (formData[i].checked==1 && !formData[i].disabled) {
            this._formData += "<"+formData[i].name+">1</"+formData[i].name+">";
          }  
        }else 
        if (formData[i].type == "radio") {
          if (formData[i].checked==1 && !formData[i].disabled) {
            this._formData += "<"+formData[i].name+">"+this.urlencode(formData[i].value)+"</"+formData[i].name+">";
          }  
        }else 
        if (formData[i].tagName == "SELECT" && !formData[i].disabled) {
          this._formData += "<"+formData[i].name+">"+this.urlencode(formData[i].value)+"</"+formData[i].name+">";
        }else 
        if (formData[i].tagName == "TEXTAREA" && !formData[i].disabled) {
          this._formData += "<"+formData[i].name+"><![CDATA["+this.urlencode(formData[i].value)+"]]></"+formData[i].name+">";
        } else {
          if (!formData[i].disabled) {
            this._formData += "<"+formData[i].name+"><![CDATA["+this.urlencode(formData[i].value)+"]]></"+formData[i].name+">";
          }  
        }
        poc++;
      }
    }
  }
  if (this._activeTab != 0) {
    this._formData += "<popupactivetab>"+this._activeTab+"</popupactivetab>";
  }
  this._formData += "</formdata>";
}

/* ************************************
 *
 *  Description: hide select
 *
 * ************************************ */
TinyPopup.prototype.hideSelects = function() {
  if (this.ie && !this.ie7 && this._type!=2) {
   var selects = this.doc.getElementsByTagName("SELECT");
    if (selects.length>0) {
      for (var i = 0; i < selects.length; i++) {
        selects[i].style.visibility = "hidden";
      }
    }
    var objForm = document.getElementById('is_popup1_form'+this._id);
    if (objForm) {
      var formData = objForm.elements;
      if (formData.length>0) {
        for (var i=0; i < formData.length; i++) {
          if (formData[i].tagName == "SELECT") {
            formData[i].style.visibility = "";
          }
        }
      } 
    } 
  }  
}

/* ************************************
 *
 *  Description: hide select
 *
 * ************************************ */
TinyPopup.prototype.showSelects = function() {
  if (this.ie && !this.ie7) {
    var selects = this.doc.getElementsByTagName("SELECT");
    if (selects.length>0) {
      for (var i = 0; i < selects.length; i++) {
        selects[i].style.visibility = "";
      }
    } 
  }   
}

/* ************************************
 *
 *  Description: change active tab
 *  
 *  Params: id - [integer] - specify tab index  
 *
 * ************************************ */
TinyPopup.prototype.changeTab = function(id, type) {
  if (!this._activeTab) {
    this._activeTab = 0;
  }  
  
  this._tabs[this._activeTab] = new Array();
  this._tabs[this._activeTab]['scrollx'] = document.getElementById('is_popup1_content'+this._id).scrollLeft;
  this._tabs[this._activeTab]['scrolly'] = document.getElementById('is_popup1_content'+this._id).scrollTop;
  for (var i in this._tabs) {

    if (i==id) {
      this._tabs[i]['active'] = "1";
      document.getElementById('is_popup1_tabli'+this._id+'_'+i).className = "aktivni";
      document.getElementById('is_popup1_taba'+this._id+'_'+i).blur();
      document.getElementById('is_popup1_tabdiv'+this._id+'_'+i).style.display = "";
      document.getElementById('is_popup1_content'+this._id).scrollLeft = this._tabs[i]['scrollx'];
      document.getElementById('is_popup1_content'+this._id).scrollTop = this._tabs[i]['scrolly'];
      this._activeTab = i;
      this._tabChange = 1;
    } else {
      this._tabs[i]['active'] = "0";
      document.getElementById('is_popup1_tabli'+this._id+'_'+i).className = "";
      document.getElementById('is_popup1_tabdiv'+this._id+'_'+i).style.display = "none";

    }
  } 
  if (!type || type != 1) {
    this.forceAutosize();
    this.forceCenter();
  }
}

/* ************************************
 *
 *  Description: decode XML result from server
 *  
 *  @param XMLHttpRequest http
 *
 * ************************************ */
TinyPopup.prototype.decodeRequest = function(http) {
  if (!this._errorHandling) this._lastResponse = http.responseText;

  if (this._debug_mode==1) {
    this.debug.addMessage('CALLED METHOD: TinyPopup.prototype.decodeRequest');
  } 
  try {
    if (this._debug_mode==1) {
      //alert('RETURNED XML: -'+http.responseText+'-');
      this.debug.addMessage('RETURNED XML: -'+http.responseText+'-');
    } 
    if (this._errorHandling) {
      this._errorHandling = false;
      return;
    }  
    if (this._isLoading==1) {
      clearTimeout(this.openTimer);
      this.hideResult();
      this._isLoading = 0;
      this._nonAnsfare = 0;
      if (!http.responseXML.getElementsByTagName('body')[0]) {
        //alert('RETURNED XML: -'+http.responseText+'-');
        if (this._debug_mode==1) {
          this.debug.addMessage("An exception occurred in the script.\nError number: #101 - Charset or XML error! Tag body not set!", 1);
        }  
        this.saveLog();
        alert("An exception occurred in the script.\nError number: #101 - Charset or XML error! Tag body not set!");
      } 
      // object params
      var objparamsBOX = http.responseXML.getElementsByTagName('objparams')[0];
      if (objparamsBOX) {
        var status = objparamsBOX.getElementsByTagName('status')[0].firstChild.nodeValue;

        if (objparamsBOX.getElementsByTagName('type')[0]) 
        var type = objparamsBOX.getElementsByTagName('type')[0].firstChild.nodeValue;
        else var type = 'static';
        if (type=='form' || type=='static' || type=='info') {
            if (objparamsBOX.getElementsByTagName('popupwidth')[0])
            this._width = parseInt(objparamsBOX.getElementsByTagName('popupwidth')[0].firstChild.nodeValue);
            if (objparamsBOX.getElementsByTagName('popupheight')[0])
            this._height = parseInt(objparamsBOX.getElementsByTagName('popupheight')[0].firstChild.nodeValue);
            if (objparamsBOX.getElementsByTagName('popupname')[0])
            this._nazev = objparamsBOX.getElementsByTagName('popupname')[0].firstChild.nodeValue;
            else this._nazev = this._def_nazev;
            if (objparamsBOX.getElementsByTagName('resizeable')[0]) this._setResize = 1;
            else this._setResize = 0;
            if (objparamsBOX.getElementsByTagName('minimal')[0]) this._allowMinimal = 1;
            else this._allowMinimal = 0;
            if (objparamsBOX.getElementsByTagName('maximal')[0]) this._allowMaximal = 1;
            else this._allowMaximal = 0;
            if (objparamsBOX.getElementsByTagName('popupicon')[0])
            this._icon = objparamsBOX.getElementsByTagName('popupicon')[0].firstChild.nodeValue;
            else this._icon = this._def_icon;
            if (objparamsBOX.getElementsByTagName('forcecenter')[0]) {
              this._forceCenter = 1;
              this._noFocus = 0;
            }  
            else this._forceCenter = 0;
            if (objparamsBOX.getElementsByTagName('onclose')[0]) 
            this._onclose = objparamsBOX.getElementsByTagName('onclose')[0].firstChild.nodeValue;
            else this._onclose = false;
            if (objparamsBOX.getElementsByTagName('fileexterror')[0])
            this._fileexterror = objparamsBOX.getElementsByTagName('fileexterror')[0].firstChild.nodeValue;
            else this._fileexterror = 'Denied extension!';
            if (objparamsBOX.getElementsByTagName('resizeonupload')[0])
            this._resizeOnUpload = objparamsBOX.getElementsByTagName('resizeonupload')[0].firstChild.nodeValue;
            if (objparamsBOX.getElementsByTagName('centeronupload')[0])
            this._centerOnUpload = objparamsBOX.getElementsByTagName('centeronupload')[0].firstChild.nodeValue;
            
        }
        if (objparamsBOX.getElementsByTagName('endmessage')[0]) {
          this._endMessage = objparamsBOX.getElementsByTagName('endmessage')[0].firstChild.nodeValue;
        } else this._endMessage = "";
        if (objparamsBOX.getElementsByTagName('sessionid')[0]) {
          this._sessionId = objparamsBOX.getElementsByTagName('sessionid')[0].firstChild.nodeValue;
        }

        // content
        var contentsBOX = http.responseXML.getElementsByTagName('contents')[0];
        if (contentsBOX) var content = contentsBOX.getElementsByTagName('content');

        /*if (this._endMessage!="") {
          this.showResult();
          var id = this._id;
          var Timer2 = setTimeout(function () {if (popupObject[id]) popupObject[id].hideResult();}, this._def_timeout);
        } */

      
        if (type=='form' || type=='static' || type=='info') {

            /*var otherContentsBOX = http.responseXML.getElementsByTagName('othercontents');
            if (otherContentsBOX[0]) {
              var otherContents = otherContentsBOX[0].getElementsByTagName('othercontent');
              for (var i = 0; i < otherContents.length; i++) {
                var elementid = otherContents[i].getElementsByTagName('elementid')[0].firstChild.nodeValue;
                var newhtml = otherContents[i].getElementsByTagName('newhtml')[0].firstChild.nodeValue;
                var el = document.getElementById(elementid);
                if (el) el.innerHTML = newhtml;
              }
            }*/



            if (this._type == 2) this._type = 1;
            var inPopup = document.getElementById('is_popup1_content'+this._id);
            var tabs = document.getElementById('is_popup1_tabs'+this._id);
            if (content) {
              if (content.length>1) {
                this._setTabs = 1;
                var pop_tabs = "";
                var pop_tabsobj = "";
                var tabactive = "aa";
                pop_tabs += '<ul class="popup_window_zalozky">';
                pop_tabsobj = '';
                for (var i = 0; i < content.length; i++) {
                  this._tabs[i] = new Array();
                  this._tabs[i]['active'] = 0;
                  if (content[i].getElementsByTagName('tabactive')[0] && tabactive=="aa") {
                    tabactive = i;
                  }
                  var tabClass="";
                  if (content[i].getElementsByTagName('highlight')[0]) {
                    if (content[i].getElementsByTagName('highlight')[0].firstChild) {
                      if (content[i].getElementsByTagName('highlight')[0].firstChild.nodeValue == 1) {
                        this._tabs[i]['highlight'] = 1;
                        tabClass = "highlight";
                      }
                      
                    }
                  }
                  pop_tabs += '<li id="is_popup1_tabli'+this._id+'_'+i+'" onclick="popupObject[\''+this._id+'\'].changeTab('+i+');"><a href="" id="is_popup1_taba'+this._id+'_'+i+'" class="'+tabClass+'" onclick="return false;">'+content[i].getElementsByTagName('tabname')[0].firstChild.nodeValue+'</a></li>';
                  //pop_tabs += '<span class="tab" id="is_popup1_tab'+this._id+'_'+i+'" onclick="popupObject[\''+this._id+'\'].changeTab('+i+');">'+content[i].getElementsByTagName('tabname')[0].firstChild.nodeValue+'</span>';
                  pop_tabsobj += '<div class="tab_obj" style="display: none;" id="is_popup1_tabdiv'+this._id+'_'+i+'">'+content[i].getElementsByTagName('popuphtml')[0].firstChild.nodeValue+'</div>'
                }
                pop_tabs += '</ul>';
                tabs.innerHTML = pop_tabs;
                inPopup.innerHTML = pop_tabsobj;
                if (tabactive=="aa") this.changeTab("0", 1);
                else this.changeTab(tabactive, 1);
              }
              else {
                tabs.innerHTML = '';
                this._setTabs = 0;
                inPopup.innerHTML = content[0].getElementsByTagName('popuphtml')[0].firstChild.nodeValue;
              }
              
              this.checkContent();
            }
          
          
        }
        
        // buttons
        if (type=='form' || type=='static' || type=='info') {
          if (this._type == 2) this._type = 1;
          var buttons = document.getElementById('is_popup1_buttons'+this._id);
          buttons.innerHTML = "";
          var popupButtonsBOX = http.responseXML.getElementsByTagName('popupbuttons')[0];
          if (popupButtonsBOX) {
            var popupButtons = popupButtonsBOX.getElementsByTagName('popupbutton');
            this._disabledIcon = new Array();
            for (var i = 0; i < popupButtons.length; i++) {
              var name = popupButtons[i].getElementsByTagName('name')[0].firstChild.nodeValue;
              var className = popupButtons[i].getElementsByTagName('class')[0].firstChild.nodeValue;
              var onclickFuncBOX = popupButtons[i].getElementsByTagName('onclick')[0];
              if (onclickFuncBOX) {
                onclickFunc = onclickFuncBOX.firstChild.nodeValue;
              } else onclickFunc = "";

              
              var newOnClick = "";
              var buttype = popupButtons[i].getElementsByTagName('buttype')[0];
              if (buttype) {
                // zpráva
                var paramsmessage = popupButtons[i].getElementsByTagName('message')[0];
                var onclickmessage = "";
                if (paramsmessage) {
                  onclickmessage = "popupObject['"+this._id+"'].setMessage('"+paramsmessage.firstChild.nodeValue+"');"; 
                }
                // tlacitka
                if (buttype.firstChild.nodeValue == "send") {
                  var newparamscript = null;
                  var newparamclassname = null;
                  var newparamconstructparams = null;
                  var newparammethod = null;
                  var newparammethodparams = null;
                  
                  var paramscript = popupButtons[i].getElementsByTagName('paramscript');
                  if (paramscript[0].firstChild) {
                    newparamscript = "'"+paramscript[0].firstChild.nodeValue+"'";
                  }
                  var paramclassname = popupButtons[i].getElementsByTagName('paramclassname');
                  if (paramclassname[0].firstChild) {
                    newparamclassname = "'"+paramclassname[0].firstChild.nodeValue+"'";
                  }
                  var paramconstructparams = popupButtons[i].getElementsByTagName('paramconstructparams');
                  if (paramconstructparams[0].firstChild) {
                    newparamconstructparams = "'"+paramconstructparams[0].firstChild.nodeValue+"'";
                  }
                  var parammethod = popupButtons[i].getElementsByTagName('parammethod');
                  if (parammethod[0].firstChild) {
                    newparammethod = "'"+parammethod[0].firstChild.nodeValue+"'";
                  }
                  var parammethodparams = popupButtons[i].getElementsByTagName('parammethodparams');
                  if (parammethodparams[0].firstChild) {
                    newparammethodparams = "'"+parammethodparams[0].firstChild.nodeValue+"'";
                  }
                  var newOnClick = onclickmessage+"popupObject['"+this._id+"'].sendRequest("+newparamscript+","+newparamclassname+","+newparamconstructparams+","+newparammethod+","+newparammethodparams+");";
                }
                if (buttype.firstChild.nodeValue == "close") {
                  var newOnClick = "popupObject['"+this._id+"'].hidePopup();";
                }
                
                
              }
              
              
              buttons.innerHTML += '<a href="" id="is_popup1_button'+i+this._id+'" class="'+className+'" onclick="'+newOnClick+onclickFunc+';return false;">'+name+'</a>';
              var disableIcon = popupButtons[i].getElementsByTagName('disableonupload')[0];
              if (disableIcon) {
                var butId = 'is_popup1_button'+i+this._id;
                this._disabledIcon[butId] = new Array();
                this._disabledIcon[butId]['id'] = butId;
                this._disabledIcon[butId]['onclick'] = newOnClick+onclickFunc+';return false;';
                this._disabledIcon[butId]['class'] = className;
                this._disabledIcon[butId]['href'] = "";
              }
            }
            this._setButtons = 1;
          } else this._setButtons = 0; 
          
          // other content
          
          var otherContentsBOX = http.responseXML.getElementsByTagName('othercontents');
          if (otherContentsBOX[0]) {
            var otherContents = otherContentsBOX[0].getElementsByTagName('othercontent');
            
            for (var i = 0; i < otherContents.length; i++) {
              var nid = otherContents[i].getElementsByTagName('elementid')[0].firstChild.nodeValue;
              if (document.getElementById(nid)) {
                if (otherContents[i].getElementsByTagName('newhtml')[0]) {
                  var newHtml= otherContents[i].getElementsByTagName('newhtml')[0].firstChild.nodeValue;
                  document.getElementById(nid).innerHTML = newHtml;
                }
                if (otherContents[i].getElementsByTagName('newclass')[0]) {
                  var newClass= otherContents[i].getElementsByTagName('newclass')[0].firstChild.nodeValue;
                  document.getElementById(nid).setAttribute((this.ie ? 'className' : 'class'), newClass);
                }
                if (otherContents[i].getElementsByTagName('propertyname')[0]) {
                  var newPropertyName = otherContents[i].getElementsByTagName('propertyname')[0].firstChild.nodeValue;
                  if (otherContents[i].getElementsByTagName('propertyvalue')[0]) {
                    var newPropertyValue = otherContents[i].getElementsByTagName('propertyname')[0].firstChild.nodeValue;
                    document.getElementById(nid).setAttribute(newPropertyName, newPropertyValue);
                  }  
                } 
              }  
                
            }
          }
        }
        
        // upload
        if (type=='uloadinfo') {
          var filesBOX = http.responseXML.getElementsByTagName('files');
          if (filesBOX[0]) {
            var oFiles = filesBOX[0].getElementsByTagName('file');
            for (var i = 0; i < oFiles.length; i++) {
              var fileOk = 1;
              if (oFiles[i].getElementsByTagName('fileid')[0]) {
                var fileid = oFiles[i].getElementsByTagName('fileid')[0].firstChild.nodeValue;
              } else fileOk = 0;
              if (oFiles[i].getElementsByTagName('totalsize')[0]) {
                var totalSize= oFiles[i].getElementsByTagName('totalsize')[0].firstChild.nodeValue;
              } else fileOk = 0;
              if (oFiles[i].getElementsByTagName('uploaded')[0]) {
                var uploadedSize= oFiles[i].getElementsByTagName('uploaded')[0].firstChild.nodeValue;
              } else fileOk = 0;
              if (fileOk == 1) this.updateFile(fileid, uploadedSize, totalSize);
            }
            //var refId = this._id;
            //var Timer3 = setTimeout(function () {if (popupObject[refId]) popupObject[refId].refreshUploadProgressBars();}, 1000);
            this.refreshUploadProgressBars();
          }
        }
          
          /*if (objparamsBOX.getElementsByTagName('run')[0])
          eval(objparamsBOX.getElementsByTagName('run')[0].firstChild.nodeValue);*/
          
          if (this._endMessage!="") {
            this.showResult();
            var id = this._id;
            this._isClosing = 1;
            this._setButtons = 0;
            this._setTabs = 0;
            var content = document.getElementById('is_popup1_content'+this._id);
            content.innerHTML = '';
            this.setSize();
            
            if (status=='finished') {
              var Timer = setTimeout(function () {if (popupObject[id]) popupObject[id].hidePopup();}, this._def_timeout);
            }
          }
          else if (status=='finished') popupObject[this._id].hidePopup();

          if (objparamsBOX.getElementsByTagName('run')[0]) {
            var toRun = objparamsBOX.getElementsByTagName('run')[0].firstChild.nodeValue;
            if (objparamsBOX.getElementsByTagName('runtimeout')[0]) {
              var TimerRun = setTimeout(function () {eval(toRun);}, objparamsBOX.getElementsByTagName('runtimeout')[0].firstChild.nodeValue);
            } else eval(toRun);
            
            

          }

      }
    }
    if (type!='uloadinfo') {
        this._firstLoad = 1;
        if (popupObject[this._id]) this.setSize();
        this._firstLoadData = 1;
    }
    if (document.getElementById('ajax_progress_bar')) {
      var objProgres = document.getElementById('ajax_progress_bar');
      objProgres.style.display = "none";
    }
    
  } catch (e) {
    if (this._debug_mode==1) {
      this.debug.addMessage("An exception occurred in the script.\nError number: #100 - XML Parse error\n>> " + e + " <<", 1);
    }  
    this.saveLog();
    alert("An exception occurred in the script.\nError number: #100 - XML Parse error\n>> " + e + " <<"); 
  }   
}

/* ************************************
 *
 *  Description: set loading message
 *  
 * ************************************ */
TinyPopup.prototype.setMessage = function(message) {
  this._endMessage = message;
}

/* ************************************
 *
 *  Description: set size and position of the popup window woth timeout
 *  
 * ************************************ */
TinyPopup.prototype.setSizeTimer = function() {
  this.setSize();
  var popup = document.getElementById(this._id);
  popup.style.display = "none";
  if (document.getElementById('ajax_progress_bar') && this._type == 2) {
    var objProgres = document.getElementById('ajax_progress_bar');
    objProgres.style.display = "none";
  } 
  
  if (document.getElementById('lbOverlay'+this._id)) {
    document.getElementById('lbOverlay'+this._id).style.display = 'none';
  }  
  var id = this._id;
  this._nonAnsfare = 1;
  this.openTimer = setTimeout(function () {if (popupObject[id]) popupObject[id].setSize();}, this._def_open_timeout);
  
}

/* ************************************
 *
 *  Description: set size of siditko
 *
 * ************************************ */
TinyPopup.prototype.setSiditkoSize = function() {
  var objSiditko = document.getElementById('lbSiditko'+popupObject[id]._id);
  objSiditko.style.display = 'block';
  objSiditko.style.width = this._width+'px';
  objSiditko.style.height = this._height+'px';
  objSiditko.style.top = this._top + 'px';
  objSiditko.style.left = this._left + 'px';
}

/* ************************************
 *
 *  Description: autosize window
 *  
 * ************************************ */
TinyPopup.prototype.forceAutosize = function() {
  this._autoSize = 1;
  /*this._width = 0;
  this._height = 0;*/
  //alert('aa');
  this._noFocus = 1;
  this.setSize();
}
/* ************************************
 *
 *  Description: force center
 *  
 * ************************************ */
TinyPopup.prototype.forceCenter = function() {
  this._forceCenter = 1;
  this._noFocus = 1;
  this.setSize();
}

/* ************************************
 *
 *  Description: set size and position of the popup window
 *  
 * ************************************ */
TinyPopup.prototype.setSize = function() {
  
  if (this._type!=2) {
    if (this.ie && !this.ie7) {
      var iefix = 1;
    } 
    else {
      var iefix = 0;
    } 
     
    var autoWidth = false;
    var autoHeight = false;
    if (this._autoSize == 1) {
      autoWidth = true;
      autoHeight = true;
    }
    if (this._width == 0) {
      autoWidth = true;
    }  
    if (this._height == 0) {
      autoHeight = true;
    }  
    if (this._icon!="") var pomIcon = '<img src="'+this._icon+'" \/>';
    else var pomIcon = "";
    var objNazev = document.getElementById('is_popup1_nazev'+this._id);
    objNazev.innerHTML = pomIcon+this._nazev;
    var popup = document.getElementById(this._id);
    var ramecek = document.getElementById('ramecek_'+this._id);
    var lista = document.getElementById('is_popup1_lista'+this._id);
    var box = document.getElementById('is_popup1_content_box'+this._id);
    var tabs = document.getElementById('is_popup1_tabs'+this._id);
    var content = document.getElementById('is_popup1_content'+this._id);
    var buttons = document.getElementById('is_popup1_buttons'+this._id);
    var resizebox = document.getElementById('is_popup1_resizebox'+this._id);
    var iconMinimal = document.getElementById('is_popup1_minimal'+this._id);
    var iconMaximal = document.getElementById('is_popup1_maximal'+this._id);
    var iconUnMaximal = document.getElementById('is_popup1_unmaximal'+this._id);
    var objHintBox = document.getElementById('is_popup1_hint_box'+this._id);
    var objHint = document.getElementById('is_popup1_hint'+this._id);
    
   
    if (popup.style.display == "block") var isVis = 1;
    else var isVis = 0;
    
    lista.style.display = "none";
    tabs.style.display = "none";
    buttons.style.display = "none";
    resizebox.style.display = "none";
   
    
    if (autoWidth) {
      popup.style.width = "";
      ramecek.style.width = "";
      box.style.width = "";
      content.style.width = "";
      lista.style.width = "";
      buttons.style.width = "";
      tabs.style.width = "";
      resizebox.style.width = "";
    }
    
    if (autoHeight) {
      popup.style.height = "";
      ramecek.style.height = "";
      box.style.height = "";
      content.style.height = "";
    }
    if (popup.style.display == "block") {
      var newAppear = 0;
    }
    else {
      var newAppear = 1;
    }
    
    // def setting
    this._but_height = 0;
    buttons.style.display = "none";
    
    this._tab_height = 0;
    this._top_border = 1;
    content.className = "popup_window_obsah2";
    tabs.style.display = "none";
    
    this._res_height = 0;
    this._bottom_border = this._def_inner_border;
    resizebox.style.display = "none";
    

    popup.style.display = "block";
    ramecek.style.margin = this._def_outer_border+"px";
    box.style.margin =  this._def_inner_border + "px";
    if (this._bottom_border) box.style.marginBottom = this._bottom_border + "px";
    
    if (autoWidth) {
      var pomWidth = popup.offsetWidth-2-(2*iefix);
      //var pomWidth = popup.offsetWidth + (2*this._def_outer_border) + (2*this._def_inner_border)+(2*iefix)-2;
      if (this._tabChange == 0 || (pomWidth+20)>=this._width) {
        this._width = pomWidth;
        if (this._width < this._minWidth) this._width  = this._minWidth;
        var docWidth = document.documentElement.clientWidth;
        if (this._width+2 > docWidth) {
          this._width  = docWidth-2;
        }  
      }
    }
    
    if (newAppear==1 && (this._firstLoad==1 || this._nonAnsfare==1)) {
       //if (this._nonAnsfare==1) this.showResult();
       this.elementAppear(popup, this._def_popup_disappear_increase, 0, this._def_popup_disappear_timeout);
    } else {
      var max = 100;
     //alert('open');
      this.elementAppear(popup, this._def_popup_disappear_increase, 0, this._def_popup_disappear_timeout);
    }
    lista.style.display = "block";
    if (this._type == 3) {
      lista.style.height = "0px";
      this._lista_height = 0;
      lista.style.display = "none";

      this._def_inner_border = 0;
    } else {
      this._lista_height = lista.offsetHeight;
    }
    if (this._setTabs == 1) {
      this._tab_height = this._def_tab_height;
      this._top_border = 0;
      content.className = "popup_window_obsah";
      tabs.style.display = "block";
    } else {
      this._tab_height = 0;
      this._top_border = 1;
      content.className = "popup_window_obsah2";
      tabs.style.display = "none";
    }  
    if (this._setButtons==1) {
      this._but_height = this._def_but_height;
      buttons.style.display = "block";
    } else {
      this._but_height = 0;
      buttons.style.display = "none";
    }  
    
    if (this._setResize==1) {
      this._res_height = this._def_resizebox_height;
      this._bottom_border = 0;
      resizebox.style.display = "block";
      
    } else {
      this._res_height = 0;
      if (this._type == 3) {
        this._bottom_border = this._def_inner_border;
      }
      else {
        this._bottom_border = this._def_inner_border;
      }  
      resizebox.style.display = "none";
    }  
    
    this._minHeight = 30 + (2*this._def_outer_border) + this._def_inner_border + this._bottom_border + this._top_border + this._lista_height + this._but_height + this._tab_height + this._res_height;
    if (autoHeight) {
      var pomHeight = content.offsetHeight + (2*this._def_outer_border) + this._lista_height + this._def_inner_border + this._tab_height + this._bottom_border + this._but_height + this._res_height;
      if (this._tabChange == 0 || pomHeight>this._height) {
        this._height = pomHeight
        if (this._height < this._minHeight) this._height = this._minHeight;
        var docHeight = document.documentElement.clientHeight;
        if (this._height+2 > docHeight) {
          this._height  = docHeight-2;
          this._width = this._width + 20;
        }
      }
      
    }
    //okno
    //this._width = this._width+;
    popup.style.width = this._width+'px';
    popup.style.height = this._height+'px';

    //lista
    lista.style.width = (this._width-(2*this._def_outer_border))+(2*iefix)+"px";
 
    //ramecek
    ramecek.style.width = this._width - (2*this._def_outer_border)+"px";
    ramecek.style.height = this._height - (2*this._def_outer_border)+"px";
    ramecek.style.margin = this._def_outer_border+"px";
    //alert('aa'+this._def_inner_border);
    // box
    box.style.height = this._height - (2*this._def_outer_border) - this._def_inner_border - this._bottom_border - this._res_height - this._lista_height + "px";
    box.style.width = this._width - (2*this._def_inner_border)-2+(2*iefix) + "px";
    box.style.margin =  this._def_inner_border + "px";
    box.style.marginBottom = this._bottom_border + "px";
    
    //content
    content.style.height = this._height - 1 - (2*this._def_outer_border) - this._def_inner_border - this._bottom_border - this._top_border - this._lista_height - this._but_height - this._tab_height - this._res_height +"px";
    content.style.width = this._width - (2*this._def_outer_border) - (2*this._def_inner_border)+(2*iefix)-2 + "px";
    
    //zalozky
    tabs.style.height = this._tab_height+"px";
    tabs.style.width = this._width - (2*this._def_outer_border) - (2*this._def_inner_border) + "px";
    //tlacitka
    buttons.style.height = this._but_height+"px";
    buttons.style.width = this._width - (2*this._def_outer_border) - (2*this._def_inner_border) + (2*iefix) + "px";
    
    //resize
    resizebox.style.height = this._res_height+"px";
    resizebox.style.width = this._width - (2*this._def_outer_border) + (2*iefix) + "px";
    
    //ikona minimalizovat
    if (this._allowMinimal) {
      iconMinimal.style.display = "inline";
    }
    else {
      iconMinimal.style.display = "none";
    }

    //ikona maximalizovat
    if (this._allowMaximal == 1) {
      iconMaximal.style.display = "inline";
    }
    else {
      iconMaximal.style.display = "none";
    }
    
    //ikona demaximalizovat
    if (this._allowUnMaximal == 1) {
      iconUnMaximal.style.display = "inline";
    }
    else {
      iconUnMaximal.style.display = "none";
    }
    //pozicovani
    if (((isVis==1 && this._firstLoadData==1) || this._position == 2) && this._left>=0 && this._top>=0) {
      this._top = parseInt(this._top);
      this._left = parseInt(this._left);
      this._width = parseInt(this._width);
      this._height = parseInt(this._height);
      var xy = this.getPageSizeWithScroll();
      var sxDocWidth = xy[0];//document.documentElement.clientWidth;
      var sxDocHeight = xy[1];//document.documentElement.clientHeight;
      var sxDocTop = 0;//document.documentElement.scrollTop;
      var sxDocLeft = 0;//document.documentElement.scrollLeft;
      if ((this._left + this._width) > (sxDocLeft+sxDocWidth)) {
        if ((this._left - this._width) < (sxDocLeft)) {
          if (this._width > sxDocWidth) this._width = sxDocWidth;
          if (this._firstLoadData==1) this._left = (sxDocWidth/2)-(this._width/2)+sxDocLeft;
        } else {
          if (this._firstLoadData==1) this._left = this._left - this._width;
        }
      } 
      if ((this._top + this._height) > (sxDocTop + sxDocHeight)) {
        if ((this._top - this._height) < (sxDocTop)) {
          if (this._height > sxDocHeight) this._height = sxDocHeight;
          if (this._firstLoadData==1) this._top = (sxDocHeight/2)-(this._height/2)+sxDocTop;
        } else {
          if (this._firstLoadData==1) this._top = this._top - this._height;
        }
      } 
      popup.style.top = this._top + 'px';
      popup.style.left = this._left + 'px';
    } else {
      this.centruj(this._id);
    }  
    
    if (this._forceCenter==1) {
      
      //alert('ee');
      this._forceCenter = 0;
      this.centruj(this._id);
    }
    
    this._left = popup.offsetLeft;
    this._top = popup.offsetTop;
    this._minHeight = 30 + (2*this._def_outer_border) + this._def_inner_border + this._bottom_border + this._top_border + this._lista_height + this._but_height + this._tab_height + this._res_height;
    var increment = 52;
    if (this._allowMinimal) increment += 25;
    if (this._allowMaximal) increment += 25;
    this._minWidth = objNazev.offsetWidth + increment;
    //if (this._firstLoad==1) this.focusPopup();
    if (this._noFocus != 1) {
      this.focusPopup();
      //alert('cc');
    } else {
      //alert('dd');
    }  
    this._noFocus = 0;
    this._tabChange = 0;
    this._autoSize = 0;
    if (objHint) {
      objHint.style.display = "block";
      objHint.style.left = this._left+(this._width/2)-(objHint.offsetWidth/2)+"px";
      objHint.style.top = this._top+((this._height-this._lista_height)/2)-(objHint.offsetHeight/2)+this._lista_height+"px";
      objHint.style.zIndex = "999999";
      
    }  

    if (objHintBox) {
      objHintBox.style.display = "block";
      objHintBox.style.height = this._height - this._lista_height - this._def_outer_border - this._top_border + "px";
      objHintBox.style.left = this._def_outer_border + "px";
      objHintBox.style.top = this._lista_height + this._top_border + "px";
      objHintBox.style.width = this._width-(2*this._def_outer_border)+"px";
    }
    

  }  
  else {
    if (document.getElementById('ajax_progress_bar') && this._type == 2) {
      var objProgres = document.getElementById('ajax_progress_bar');
      objProgres.style.display = "block";
    } 
  }
}

/* ************************************
 *
 *  Description: hide popup window
 *  
 * ************************************ */
TinyPopup.prototype.hidePopupIf = function(e) {
  
  var disableClose = 0;
  if (!this._id) {
    var id = pomId;
  } else {
    var id = this._id;
  }
  
  if (popupObject[id]) {
    if ((popupObject[id]._disableBackground == 2 || popupObject[id]._disableBackground == 4) && (e || event)) {
      
      if (popupObject[id].ie || popupObject[id].ie8) { // grab the x-y pos.s if browser is IE
        popupObject[id]._mouseX = event.clientX + document.documentElement.scrollLeft;
        popupObject[id]._mouseY = event.clientY + document.documentElement.scrollTop;
      } else {  // grab the x-y pos.s if browser is NS
        popupObject[id]._mouseX = e.pageX;
        popupObject[id]._mouseY = e.pageY;
      }  
      
      if (popupObject[id]._mouseX > popupObject[id]._left
          && popupObject[id]._mouseY > popupObject[id]._top
          && popupObject[id]._mouseX < popupObject[id]._left+popupObject[id]._width
          && popupObject[id]._mouseY < popupObject[id]._top+popupObject[id]._height) {
        disableClose = 1;
      }
    }
  
    if (disableClose == 0) {
      if (popupObject[id]._disableBackground == 2 || popupObject[id]._disableBackground == 4) {
        document.onmousedown = pomDocMouse;
      }  
      popupObject[id].hidePopupQuick();
    }
  }  
}

/* ************************************
 *
 *  Description: hide popup window
 *  
 * ************************************ */
TinyPopup.prototype.hidePopup = function(e) {
  if (typeof(tinyMCE) != "undefined") {
    //tinyMCE.triggerSave();
    tinyMCE.execCommand( 'mceRemoveControl', true, 'result/record/contents' );
  }
  
  if (!this._id) {
    var id = pomId;
  } else {
    var id = this._id;
  }
  if (this._onclose) {
    eval(this._onclose);
  }
  popupObject[id].hideResult();
  var objBody = document.getElementsByTagName("body").item(0);	
  if (document.getElementById(id)) {
    popup = document.getElementById(id);
    if (popup.style.display == "block") {
        this.elementDisappear(popup, this._def_popup_disappear_increase, 100, this._def_popup_disappear_timeout);
        if (document.getElementById('lbOverlay'+id)) {
           var lbOver = document.getElementById('lbOverlay'+id);
           if (lbOver.style.display == "block") this.elementDisappear(lbOver, this._def_popup_disappear_increase, 30, this._def_popup_disappear_timeout);
        }
        //popup.style.display = 'none';
        var Timer = setTimeout(function () {
            objBody.removeChild(document.getElementById(id));
            if (document.getElementById('lbSiditko'+id)) {
              objBody.removeChild(document.getElementById('lbSiditko'+id));
            }
            if (document.getElementById('lbOverlay'+id)) {
              document.getElementById('lbOverlay'+id).style.display = 'none';
              if (document.getElementById('lbOverlay'+id)) {
                objBody.removeChild(document.getElementById('lbOverlay'+id));
              }
            }
            popupObject[id]._isGenerated="0";
            var pomDel = popupObject[id];
            delete popupObject[id];
            pomDel.focusNextPopup();
         }, (2*this._def_popup_disappear_timeout*(100/this._def_popup_disappear_increase)+1));
    } else {
        if (document.getElementById('lbOverlay'+id)) {
           document.getElementById('lbOverlay'+id).style.display = 'none';
           if (document.getElementById('lbOverlay'+id)) {
             objBody.removeChild(document.getElementById('lbOverlay'+id));
           }
         }
         if (document.getElementById('lbSiditko'+id)) {
              objBody.removeChild(document.getElementById('lbSiditko'+id));
            }
        popup.style.display = 'none';
        objBody.removeChild(document.getElementById(id));

        popupObject[id]._isGenerated="0";
        var pomDel = popupObject[id];
        delete popupObject[id];
        pomDel.focusNextPopup();

    }
  } 

}

/* ************************************
 *
 *  Description: hide popup window - quick - without disappear
 *
 * ************************************ */
TinyPopup.prototype.hidePopupQuick = function(e) {


  if (!this._id) {
    var id = pomId;
  } else {
    var id = this._id;
  }
  if (this._onclose) {
    eval(this._onclose);
  }
  popupObject[id].hideResult();
  var objBody = document.getElementsByTagName("body").item(0);
  if (document.getElementById(id)) {
    popup = document.getElementById(id);
    if (document.getElementById('lbOverlay'+id)) {
       document.getElementById('lbOverlay'+id).style.display = 'none';
       if (document.getElementById('lbOverlay'+id)) {
         objBody.removeChild(document.getElementById('lbOverlay'+id));
       }
     }
    popup.style.display = 'none';
    objBody.removeChild(document.getElementById(id));

    popupObject[id]._isGenerated="0";
    var pomDel = popupObject[id];
    delete popupObject[id];
    pomDel.focusNextPopup();
  }
}


/* ************************************
 *
 *  Description: minimalize window
 *  
 * ************************************ */
TinyPopup.prototype.minimalizePopup = function() {
  if (document.getElementById('trybox')) {
    var popup = document.getElementById(this._id);
    popup.style.display = "none";
    if (document.getElementById('lbOverlay'+this._id)) {
      document.getElementById('lbOverlay'+this._id).style.display = 'none';
    } 
    var trybox = document.getElementById('trybox');
    var pomIcon = this._def_icon.split(".");
    pomIcon[pomIcon.length-2] += this._def_icon_big_postfix;
    var pomPostfix = pomIcon[pomIcon.length-1];
    var pomIconNew = new Array();
    for (var i=0;i<pomIcon.length-1;i++) {
      pomIconNew[i] = pomIcon[i];
    }
    pomIconNew[i] = pomPostfix;
    var pomIconFileNew = pomIconNew.join('.');
    
    trybox.innerHTML += '<a href="#" id="a_trybox_'+this._id+'" class="item" onclick="popupObject[\''+this._id+'\'].unminimalizePopup();" title="'+this._nazev+'" style="background-image: url('+pomIconFileNew+')"></a>';
    this._isMinimized = 1;
    this.focusNextPopup();
    
  }
}

/* ************************************
 *
 *  Description: open minimalized windows
 *  
 * ************************************ */
TinyPopup.prototype.unminimalizePopup = function() {
  var popup = document.getElementById(this._id);
  popup.style.display = "block";
  if (document.getElementById('lbOverlay'+this._id)) {
    document.getElementById('lbOverlay'+this._id).style.display = 'block';
    this.focusPopup();
  } 
  var trybox = document.getElementById('trybox');
  trybox.removeChild(document.getElementById('a_trybox_'+this._id));
  
  this._isMinimized = 0;
  this.focusPopup();
}

/* ************************************
 *
 *  Description: maximalize window
 *  
 * ************************************ */
TinyPopup.prototype.maximalizePopup = function() {
  var popup = document.getElementById(this._id);
  this._left = popup.offsetLeft;
  this._top = popup.offsetTop;
  this._def_width = this._width;
  this._def_height = this._height;
  this._def_left = this._left;
  this._def_top = this._top;
  this._def_setResize = this._setResize;
  
  this._top = document.documentElement.scrollTop;
  
  this._left = document.documentElement.scrollLeft;
  //var xy = this.getPageSizeWithScroll();
  var xy = new Array(document.documentElement.clientWidth,document.documentElement.clientHeight);
  this._width = xy[0]-2;
  this._height = xy[1]-2; 
  this._allowMaximal = 0;
  this._allowUnMaximal = 1;
  this._setResize = 0;
  
  if (document.getElementById('is_popup1_lista'+this._id)) {
    var lista = document.getElementById('is_popup1_lista'+this._id);
    lista.onmousedown = null;
    lista.style.cursor = "auto";
  }  
  
  this.setSize();
}

/* ************************************
 *
 *  Description: unmaximalize window
 *  
 * ************************************ */
TinyPopup.prototype.unmaximalizePopup = function() {
  this._width = this._def_width;
  this._height = this._def_height;
  this._left = this._def_left;
  this._top = this._def_top;
  this._setResize = this._def_setResize;

  this._allowMaximal = 1;
  this._allowUnMaximal = 0;
  if (document.getElementById('is_popup1_lista'+this._id)) {
    var lista = document.getElementById('is_popup1_lista'+this._id);
    lista.onmousedown = popupObject[this._id].startMove;
    lista.style.cursor = "move";
  }  
  this.setSize();
}

/* ************************************
 *
 *  Description: get resize position
 *  
 * ************************************ */
TinyPopup.prototype.getResizePosition = function() {
  ramecek = document.getElementById('ramecek_'+this._id);
  
}

/* ************************************
 *
 *  Description: focus popup window
 *
 * ************************************ */
TinyPopup.prototype.focusPopup = function() {
  var popup = "";
  if (document.getElementById('lbOverlay'+this._id)) {
      for (var i in popupObject)
      {
        if (popupObject[i].isGenerated() == 1) {
          if (this._id==i) {
            if (document.getElementById(i)) {
              document.getElementById(i).style.zIndex = 99999;
              document.getElementById('is_popup1_lista'+i).className = "popup_window_lista_active";
              if (document.getElementById('lbOverlay'+this._id)) {
                popup = document.getElementById(this._id);
                if (popup) {
                  if (popup.style.display == "block") {
                    var lbOver = document.getElementById('lbOverlay'+this._id);
                    //document.getElementById('lbOverlay'+this._id).style.display = "block";
                    if (lbOver.style.display == "none") {
                      this.elementAppear(lbOver, this._def_popup_disappear_increase, 0, this._def_popup_disappear_timeout, 30);
                    }
                  }
                }
              }
            }
          }
          else {
            if (document.getElementById(i)) {
              document.getElementById(i).style.zIndex = document.getElementById(i).style.zIndex-1;
              document.getElementById('is_popup1_lista'+i).className = "popup_window_lista";
              if (document.getElementById('lbOverlay'+i)) {
                //document.getElementById('lbOverlay'+i).style.display = "none";
                var lbOver = document.getElementById('lbOverlay'+i);
                if (lbOver.style.display == "block") {
                  this.elementDisappear(lbOver, this._def_popup_disappear_increase, 30, this._def_popup_disappear_timeout);
                }
              }
            }
          }
        }
      }
  }
  this.hideSelects(); 
}

/* ************************************
 *
 *  Description: focus next window
 *
 * ************************************ */
TinyPopup.prototype.focusNextPopup = function() {
  var maxI = "-1";
  var maxIndex = 0;
  for (var i in popupObject) {
    if (popupObject[i].isGenerated()==1 && popupObject[i]._isMinimized != 1) {
      if (maxIndex<document.getElementById(i).style.zIndex) {
        maxIndex = document.getElementById(i).style.zIndex;
        maxI = i;
      }  
    }  
  }
  if (maxI != "-1") popupObject[maxI].focusPopup();
  else {
    this.showSelects();
  }  
}

/* ************************************
 *
 *  Description: return array with document sizes
 *
 * ************************************ */
/*TinyPopup.prototype.getPageSizeWithScroll = function(){

	if (window.innerHeight != undefined && window.scrollMaxY  != undefined) {// Firefox
		yWithScroll = window.innerHeight + window.scrollMaxY;
		xWithScroll = window.innerWidth + window.scrollMaxX;
	}else if(window.innerHeight  && document.body.scrollHeight > document.body.offsetHeight){
		yWithScroll = (window.innerHeight >document.body.scrollHeight)?window.innerHeight:document.body.scrollHeight;
		xWithScroll = (window.innerWidth >document.body.scrollWidth)?window.innerWidth:document.body.scrollWidth;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		yWithScroll = document.body.scrollHeight;
		xWithScroll = document.body.scrollWidth;
	} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		yWithScroll = document.body.offsetHeight;
		xWithScroll = document.body.offsetWidth;
  	}
  	
	arrayPageSizeWithScroll = new Array(xWithScroll,yWithScroll);
	return arrayPageSizeWithScroll;
}*/

/* ************************************
 *
 *  Description: display progres bar
 *
 * ************************************ */
TinyPopup.prototype.startLoading = function() {
  this._isLoading = 1;
  this._setButtons = 0;
  this._setTabs = 0;
  var content = document.getElementById('is_popup1_content'+this._id);
  content.innerHTML = '<div class="loading"></div>';
  this.setSize();
}

/* ************************************
 *
 *  Description: display hint - result text
 *
 * ************************************ */
TinyPopup.prototype.showResult = function() {
  if (this._type != 2) {
    var objBody = this.doc.getElementsByTagName("body").item(0);
    
    var objHintBox = this.doc.createElement("div");
    objHintBox.setAttribute((this.ie ? 'className' : 'class'), 'popup_reshint_box');
    objHintBox.setAttribute('id','is_popup1_hint_box'+this._id);
    
    var objHint = this.doc.createElement("div");
    objHint.setAttribute((this.ie ? 'className' : 'class'), 'popup_reshint');
    objHint.setAttribute('id','is_popup1_hint'+this._id);
  
  
    var popup = document.getElementById(this._id);
    popup.appendChild(objHintBox); 
    objBody.appendChild(objHint); 
    
    var lista = document.getElementById('is_popup1_lista'+this._id);
    

    if (popup.style.display == "block") {
      objHint.style.display = "block";
      objHintBox.style.display = "block";
    } else {
      objHint.style.display = "none";
      objHintBox.style.display = "none";
    }    
    if (this._endMessage!="") {
      objHint.innerHTML = '<div class="message">'+this._endMessage+'</div>';
    }
    else objHint.innerHTML = '';

    objHint.style.left = this._left+(this._width/2)-(objHint.offsetWidth/2)+"px";
    objHint.style.top = this._top+((this._height-this._lista_height)/2)-(objHint.offsetHeight/2)+this._lista_height+"px";
    objHint.style.zIndex = "999999";

    objHintBox.style.height = this._height - this._lista_height - this._def_outer_border - this._top_border + "px";
    objHintBox.style.left = this._def_outer_border + "px";
    objHintBox.style.top = this._lista_height + this._top_border + "px";
    if (this.ie) objHintBox.style.width = this._width-(2*this._def_outer_border)+2+ "px";
    else objHintBox.style.width = this._width-(2*this._def_outer_border) + "px";
    this._endMessage = "";
  }  
}

/* ************************************
 *
 *  Description: hide hint - result text
 *
 * ************************************ */
TinyPopup.prototype.hideResult = function() {
  var objBox;
  var objBody = this.doc.getElementsByTagName("body").item(0);
  
  if (objBox = document.getElementById(this._id)) {
    if (document.getElementById('is_popup1_hint'+this._id)) {
      objBody.removeChild(document.getElementById('is_popup1_hint'+this._id));
    }
    if (document.getElementById('is_popup1_hint_box'+this._id)) {
      objBox.removeChild(document.getElementById('is_popup1_hint_box'+this._id));
    }
  }
}



/* ************************************
 *
 *  Description: get page size
 *
 * ************************************ */
TinyPopup.prototype.getPageSizeWithScroll = function() {
	if (window.innerHeight && window.scrollMaxY) {// Firefox
		yWithScroll = window.innerHeight + window.scrollMaxY;
		xWithScroll = window.innerWidth + window.scrollMaxX;
	} else if (document.documentElement.scrollHeight > document.documentElement.offsetHeight){ // all but Explorer Mac
		yWithScroll = document.documentElement.scrollHeight;
		xWithScroll = document.documentElement.scrollWidth;
	} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		yWithScroll = document.documentElement.offsetHeight;
		xWithScroll = document.documentElement.offsetWidth;
  	}
  //if (document.documentElement.clientHeight>yWithScroll) yWithScroll = document.documentElement.clientHeight;
  //if (document.documentElement.clientWidth>xWithScroll) xWithScroll = document.documentElement.clientWidth;	
	arrayPageSizeWithScroll = new Array(xWithScroll,yWithScroll);
	return arrayPageSizeWithScroll;
}

/* ************************************
 *
 *  Description: encode string
 *
 * ************************************ */
TinyPopup.prototype.urlencode = function( str ) {
  if (str) {                                
    var histogram = {}, histogram_r = {}, code = 0, tmp_arr = [];
    var ret = str.toString();
    
    var replacer = function(search, replace, str) {
        var tmp_arr = [];
        tmp_arr = str.split(search);
        return tmp_arr.join(replace);
    };
    
    // The histogram is identical to the one in urldecode.
    histogram['!']   = '%21';
    histogram['%20'] = '+';
    
    // Begin with encodeURIComponent, which most resembles PHP's encoding functions
    ret = encodeURIComponent(ret);
    
    for (search in histogram) {
        replace = histogram[search];
        ret = replacer(search, replace, ret) // Custom replace. No regexing
    }
    
    // Uppercase for full PHP compatibility
    return ret.replace(/(\%([a-z0-9]{2}))/g, function(full, m1, m2) {
        return "%"+m2.toUpperCase();
    });
    return ret;
  }
  else return "";
}

/* ************************************
 *
 *  Description: remove <![CDATA[ and ]]>
 *
 * ************************************ */
TinyPopup.prototype.prepareForSend = function(str) {
   if (str) { 
    var histogram = {}, histogram_r = {}, code = 0, str_tmp = [];
    var ret = str.toString();
    var replacer = function(search, replace, str) {
        var tmp_arr = [];
        tmp_arr = str.split(search);
        return tmp_arr.join(replace);
    };
    
    // The histogram is identical to the one in urlencode.
    histogram['6561d8b14cd91c2a631e23147c787dd4']   = '<![CDATA[';
    histogram['a493bdd4e51139679751c0dec7056de9'] = ']]>';
    for (replace in histogram) {
        search = histogram[replace]; // Switch order when decoding
        ret = replacer(search, replace, ret) // Custom replace. No regexing   
    }
    
    // End with decodeURIComponent, which most resembles PHP's encoding functions
    ret = decodeURIComponent(ret);

    return ret;
  }
  else return "";
}

/* ************************************
 *
 *  Description: decode string
 *
 * ************************************ */
TinyPopup.prototype.urldecode = function( str ) {
  if (str) { 
    var histogram = {}, histogram_r = {}, code = 0, str_tmp = [];
    var ret = str.toString();
    
    var replacer = function(search, replace, str) {
        var tmp_arr = [];
        tmp_arr = str.split(search);
        return tmp_arr.join(replace);
    };
    
    // The histogram is identical to the one in urlencode.
    histogram['!']   = '%21';
    histogram['%20'] = '+';
    
    for (replace in histogram) {
        search = histogram[replace]; // Switch order when decoding
        ret = replacer(search, replace, ret) // Custom replace. No regexing   
    }
    
    // End with decodeURIComponent, which most resembles PHP's encoding functions
    ret = decodeURIComponent(ret);

    return ret;
  }
  else return "";
}

/* ************************************
 *
 *  Description: start resize window
 *
 * ************************************ */
TinyPopup.prototype.startResize = function(e) {
  try {
    
    id = this.id.substring(16);
    
    popupObject[id]._mouseX = 0;
    popupObject[id]._mouseY = 0;
    firstMove = 0;
    /*if (!popupObject[id]._id) {
      popupObject[id]._id = id;
    }*/
    
    document.body.style.cursor="nw-resize";
    /*var objBody = document.getElementsByTagName("body").item(0);
    if (!document.getElementById('is_popup1_resize_overlay'+popupObject[id]._id)) {
    var objOver2 = document.createElement("div");
      objOver2.setAttribute((popupObject[id].ie ? 'className' : 'class'), 'popup_window_resize_overlay');
      objOver2.setAttribute('id','is_popup1_resize_overlay'+popupObject[id]._id);
      if ((popupObject[id].ie && !popupObject[id].ie7) || (popupObject[id].ie7 && document.compatMode == 'BackCompat')) {
  			objOver2.style.position = 'absolute';
  		}
      objOver2.style.display = "block";
      var pageSize = popupObject[id].getPageSizeWithScroll();
      objOver2.style.height = pageSize[1];
      objBody.appendChild(objOver2);	
    } else {
      objOver2 = document.getElementById('is_popup1_resize_overlay'+popupObject[id]._id);
      objOver2.style.display = "block";
    }*/
    // Set-up to use getMouseXY function onMouseMove
    
    
    
    var popup = document.getElementById(popupObject[id]._id);
    popupObject[id]._left = popup.offsetLeft;
    popupObject[id]._top = popup.offsetTop;
    popupObject[id]._startHeight = popupObject[id]._height;
    popupObject[id]._startWidth = popupObject[id]._width;
    popupObject[id]._startMouseX = popupObject[id]._mouseX;
    popupObject[id]._startMouseY = popupObject[id]._mouseY;
    
    var popup = document.getElementById(id);
    popupObject[id]._left = popup.offsetLeft;
    popupObject[id]._top = popup.offsetTop;
    
    if (popupObject[id].ie || popupObject[id].ie8) { // grab the x-y pos.s if browser is IE
      popupObject[id]._mouseX = event.clientX + document.documentElement.scrollLeft;
      popupObject[id]._mouseY = event.clientY + document.documentElement.scrollTop;
    } else {  // grab the x-y pos.s if browser is NS
      popupObject[id]._mouseX = e.pageX;
      popupObject[id]._mouseY = e.pageY;
    }  
    popupObject[id]._startMouseY = popupObject[id]._mouseY;
    popupObject[id]._startMouseX = popupObject[id]._mouseX;
    pomDocMove = document.onmousemove;
    document.onmousemove= popupObject[id].getMouseXYresize;
    document.onmouseup = popupObject[id].stopResize;
    document.body.focus(); 
    return false; 
  } catch (e) {
    alert("An exception occurred in the script.\nError number: #200 - Resize object not defined\n>> " + e + " <<");
  }
}

// Main function to retrieve mouse x-y pos.s
TinyPopup.prototype.getMouseXYresize = function(e) {
  document.body.style.cursor="nw-resize";
  if (popupObject[id].ie || popupObject[id].ie8) { // grab the x-y pos.s if browser is IE
    popupObject[id]._mouseX = event.clientX + document.documentElement.scrollLeft;
    popupObject[id]._mouseY = event.clientY + document.documentElement.scrollTop;
  } else {  // grab the x-y pos.s if browser is NS
    popupObject[id]._mouseX = e.pageX;
    popupObject[id]._mouseY = e.pageY;
  }  
  // catch possible negative values in NS4
  if (popupObject[id]._mouseX < 0){popupObject[id]._mouseX = 0};
  if (popupObject[id]._mouseY < 0){popupObject[id]._mouseY = 0};  
  var xy = new Array(document.documentElement.offsetWidth,document.documentElement.offsetHeight);
 
  if (((popupObject[id]._height + popupObject[id]._mouseY - popupObject[id]._startMouseY)>popupObject[id]._minHeight)
    && ((popupObject[id]._height + popupObject[id]._mouseY - popupObject[id]._startMouseY)<=(xy[1]-popupObject[id]._top-2))) {
    popupObject[id]._height = popupObject[id]._height + (popupObject[id]._mouseY - popupObject[id]._startMouseY);
    popupObject[id]._startMouseY = popupObject[id]._mouseY;
  } else {
    if ((popupObject[id]._height + popupObject[id]._mouseY - popupObject[id]._startMouseY)>(xy[1]-popupObject[id]._top-2)) {
      popupObject[id]._startMouseY = xy[1]-2;
      popupObject[id]._height = xy[1]-popupObject[id]._top-2;
    } else {
      popupObject[id]._startMouseY = popupObject[id]._startMouseY - (popupObject[id]._height - popupObject[id]._minHeight);
      popupObject[id]._height = popupObject[id]._minHeight;

    }
  }
  
  if (((popupObject[id]._width + popupObject[id]._mouseX - popupObject[id]._startMouseX)>popupObject[id]._minWidth)
    && ((popupObject[id]._width + popupObject[id]._mouseX - popupObject[id]._startMouseX)<=(xy[0]-popupObject[id]._left-2))) {
    popupObject[id]._width = popupObject[id]._width + (popupObject[id]._mouseX - popupObject[id]._startMouseX);
    popupObject[id]._startMouseX = popupObject[id]._mouseX;
  } else {
    if ((popupObject[id]._width + popupObject[id]._mouseX - popupObject[id]._startMouseX)>(xy[0]-popupObject[id]._left-2)) {
      popupObject[id]._startMouseX = xy[0]-2;
      popupObject[id]._width = xy[0]-popupObject[id]._left-2;
    } else {
      popupObject[id]._startMouseX = popupObject[id]._startMouseX - (popupObject[id]._width - popupObject[id]._minWidth);
      popupObject[id]._width = popupObject[id]._minWidth;
    }
  }
  if (popupObject[id]._def_full_move_allowed == 1) {
    popupObject[id].setSize();
  } else {
    popupObject[id].setSiditkoSize();
  }
  firstMove = 1;
  document.body.focus(); 
  return false; 
}


/* ************************************
 *
 *  Description: stop resize window
 *
 * ************************************ */
TinyPopup.prototype.stopResize = function() {
  var objSiditko = document.getElementById('lbSiditko'+popupObject[id]._id);
  objSiditko.style.display = 'none';
  popupObject[id].setSize();
  if (document.getElementById('is_popup1_resize_overlay'+id)) {
    var objBody = document.getElementsByTagName("body").item(0);
    var objOver2 = document.getElementById('is_popup1_resize_overlay'+id);
    objBody.removeChild(objOver2);
  }
  document.onmousemove = pomDocMove;
  document.onmouseup = null;
  
  objPopup = document.getElementById(id);
  if (objPopup) {
    objPopup.focus();
  }  
  document.body.style.cursor="auto";
  id = null;
  
}




/* ************************************
 *
 *  Description: start move window
 *
 * ************************************ */
TinyPopup.prototype.startMove = function(e) {
  
  try {
    
    id = this.id.substring(15);
    if (popupObject[id]._onIcon) return false;  
    popupObject[id]._mouseX = 0;
    popupObject[id]._mouseY = 0;
    firstMove = 0;

    document.body.style.cursor="move";

    
    var popup = document.getElementById(popupObject[id]._id);
    
    popupObject[id]._startMouseX = popupObject[id]._mouseX;
    popupObject[id]._startMouseY = popupObject[id]._mouseY;
    
    
    
    var popup = document.getElementById(id);
    
    if (popupObject[id].ie || popupObject[id].ie8) { // grab the x-y pos.s if browser is IE
      popupObject[id]._mouseX = event.clientX + document.documentElement.scrollLeft;
      popupObject[id]._mouseY = event.clientY + document.documentElement.scrollTop;
    } else {  // grab the x-y pos.s if browser is NS
      popupObject[id]._mouseX = e.pageX;
      popupObject[id]._mouseY = e.pageY;
    }  
    popupObject[id]._startMouseY = popupObject[id]._mouseY;
    popupObject[id]._startMouseX = popupObject[id]._mouseX;
    
    popupObject[id]._startMouseLeft = popupObject[id]._mouseX - popupObject[id]._left;
    popupObject[id]._startMouseTop = popupObject[id]._mouseY - popupObject[id]._top;
    
    pomDocMove = document.onmousemove;
    document.onmousemove= popupObject[id].getMouseXYmove;
    document.onmouseup = popupObject[id].stopMove;
    document.body.focus();
    popupObject[id]._left = popup.offsetLeft;
    popupObject[id]._top = popup.offsetTop;
    //alert(popupObject[id]._top);
    return false; 
  } catch (e) {
    alert("An exception occurred in the script.\nError number: #202 - Move object not defined\n>> " + e + " <<");
  }
}

// Main function to retrieve mouse x-y pos.s
TinyPopup.prototype.getMouseXYmove = function(e) {
  try {
    if (popupObject[id].ie || popupObject[id].ie8) { // grab the x-y pos.s if browser is IE
      popupObject[id]._mouseX = event.clientX + document.documentElement.scrollLeft;
      popupObject[id]._mouseY = event.clientY + document.documentElement.scrollTop;
    } else {  // grab the x-y pos.s if browser is NS
      popupObject[id]._mouseX = e.pageX;
      popupObject[id]._mouseY = e.pageY;
    }  
    // catch possible negative values in NS4
    if (popupObject[id]._mouseX < 0){popupObject[id]._mouseX = 0};
    if (popupObject[id]._mouseY < 0){popupObject[id]._mouseY = 0};  
    
    //var xy = popupObject[id].getPageSizeWithScroll();
    //var xy = new Array(document.documentElement.clientWidth,document.documentElement.clientHeight);
    var xy = new Array(document.documentElement.scrollWidth,document.documentElement.scrollHeight);
    
    var popup = document.getElementById(id);
    
    if ((popupObject[id]._top + popupObject[id]._mouseY - popupObject[id]._startMouseY)<=0) {
      popupObject[id]._top = 0;
      //popup.style["top"] = popupObject[id]._top+"px";
      popupObject[id]._startMouseY = popupObject[id]._startMouseTop;
    } else if ((popupObject[id]._top + popupObject[id]._height + 2 + popupObject[id]._mouseY - popupObject[id]._startMouseY)>=xy[1]) {
      popupObject[id]._top = xy[1] - popupObject[id]._height - 2;
      //popup.style["top"] = popupObject[id]._top+"px";
      popupObject[id]._startMouseY = popupObject[id]._top + popupObject[id]._startMouseTop;
    } else {
      popupObject[id]._top = popupObject[id]._top + popupObject[id]._mouseY - popupObject[id]._startMouseY;
      //popup.style["top"] = popupObject[id]._top+"px";
      popupObject[id]._startMouseY = popupObject[id]._mouseY;
    }
    
    if ((popupObject[id]._left + popupObject[id]._mouseX - popupObject[id]._startMouseX)<=0) {
      popupObject[id]._left = 0;
      //popup.style["left"] = popupObject[id]._left+"px";
      popupObject[id]._startMouseX = popupObject[id]._startMouseLeft;
    } else if ((popupObject[id]._left + popupObject[id]._width + 2 + popupObject[id]._mouseX - popupObject[id]._startMouseX)>=xy[0]) {
      popupObject[id]._left = xy[0] - popupObject[id]._width - 2;
      //popup.style["left"] = popupObject[id]._left+"px";
      popupObject[id]._startMouseX = popupObject[id]._left + popupObject[id]._startMouseLeft;
    } else {
      popupObject[id]._left = popupObject[id]._left + popupObject[id]._mouseX - popupObject[id]._startMouseX;
      //popup.style["left"] = popupObject[id]._left+"px";
      popupObject[id]._startMouseX = popupObject[id]._mouseX;
    }
    /*
    popupObject[id]._left = popupObject[id]._left + popupObject[id]._mouseX - popupObject[id]._startMouseX;
    popup.style["left"] = popupObject[id]._left+"px";
    popupObject[id]._startMouseX = popupObject[id]._mouseX;*/
    if (popupObject[id]._def_full_move_allowed == 1) {
      popup.style["top"] = popupObject[id]._top+"px";
      popup.style["left"] = popupObject[id]._left+"px";
    } else {
      popupObject[id].setSiditkoSize();
    }
    firstMove = 1;
    document.body.focus(); 
  }
  catch (err) {
  
  }
  return false;
}

/* ************************************
 *
 *  Description: stop resize window
 *
 * ************************************ */
TinyPopup.prototype.setActiveIcon = function(status) {
  this._onIcon = status;
  id = this._id;
  //document.onmouseup = function() {popupObject[id].setActiveIcon(false);}
}

/* ************************************
 *
 *  Description: stop resize window
 *
 * ************************************ */
TinyPopup.prototype.stopMove = function() {
  var objSiditko = document.getElementById('lbSiditko'+popupObject[id]._id);
  objSiditko.style.display = 'none';
  popupObject[id].setSize();
  if (document.getElementById('is_popup1_resize_overlay'+id)) {
    var objBody = document.getElementsByTagName("body").item(0);
    var objOver2 = document.getElementById('is_popup1_resize_overlay'+id);
    objBody.removeChild(objOver2);
  }
  document.onmousemove = pomDocMove;
  document.onmouseup = null;
  
  objPopup = document.getElementById(id);
  if (objPopup) {
    objPopup.focus();
  }  
  document.body.style.cursor="auto";
  id = null;
}

