/**
 *
 * 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    004 0005 20.07.2009 13:45
 * 
 * @todo prizpusobeni okna obsahu - bug
 * @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 = "";

// use in html code !!!!
setGlobalPopupParameters("","","Minimalizovat","Maximalizovat");
// end

//**********  slouzi k urceni pozice mysi
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) {
    PopupTempX = event.clientX + document.body.scrollLeft;
    PopupTempY = event.clientY + document.body.scrollTop;
  } 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 - remote call
 *
 *  see function (constructor) TinyPopup
 *
 * ************************************ */
function newRemCall(id, script, classname, constructParams, method, methodParams, formId) {
  
  if (popupObject) {
    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 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) {
  popupTextLoading = popupTextLoadingPom;
  popupTextClose = popupTextClosePom;
  popupTextMinimalize = popupTextMinimalizePom;
  popupTextMaximalize = popupTextMaximalizePom;
}

/**
 *
 * 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 = 0;
  
  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;
  
  /*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) {
      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) {
      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._sendingFiles = 0;
  
  // default values
  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._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._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;
  
  
  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,})");
  if (re.exec(ua) != null) {
    rv = parseFloat(RegExp.$1);
  }
  if (rv == 4) this.ie8 = true;
  else this.ie8 = 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;
}

/* ************************************
 *
 *  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);
    el.style.top = ((document.documentElement.clientHeight)/2)-(el.offsetHeight/2)+document.documentElement.scrollTop+"px";
    el.style.left = ((document.documentElement.clientWidth)/2)-(el.offsetWidth/2)+document.documentElement.scrollLeft+"px";
  }
}


/* ************************************
 *
 *  Description: generate popup windows objects
 *
 * ************************************ */
TinyPopup.prototype.generatePopup = function() {
  var objBody = this.doc.getElementsByTagName("body").item(0);
  
  if (this._disableBackground==0) {
  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);
	}	
	if (this._disableBackground==2) {
  	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" 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+'" 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+'" 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+'" onclick="popupObject[\''+this._id+'\'].minimalizePopup();return false;" title="'+this._def_minimal_message+'"></a>';
		objLista.onmousedown = popupObject[this._id].startMove;
    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) {
      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 (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._debug_mode==1) {
      alert('PARAMS TO SEND: '+this._new_param);
    }  
    var http = this.createXmlHttpRequestObject();
    var id = this._id;
    
    this._endMessage = this._def_loading_message;
    if (this._sendingFiles == 0) this.showResult();

    http.open("POST", 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);
          }  
        }
      }
    }
    http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

    http.send(this._new_param);
  }  
}

/* ************************************
 *
 *  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].type == "checkbox") {
        if (formData[i].checked==1) {
          this._formData += "<"+formData[i].name+">1</"+formData[i].name+">";
        }  
      }else 
      if (formData[i].type == "radio") {
        if (formData[i].checked==1) {
          this._formData += "<"+formData[i].name+">"+this.urlencode(formData[i].value)+"</"+formData[i].name+">";
        }  
      }else 
      if (formData[i].tagName == "SELECT") {
        this._formData += "<"+formData[i].name+">"+this.urlencode(formData[i].value)+"</"+formData[i].name+">";
      }else 
      if (formData[i].tagName == "TEXTAREA") {
        this._formData += "<"+formData[i].name+"><![CDATA["+this.urlencode(formData[i].value)+"]]></"+formData[i].name+">";
      } else {
        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 (formData.length>0) {
      
      for (var i=0; i < formData.length; i++) {
        if (formData[i].type == "checkbox") {
          if (formData[i].checked==1) {
            this._formData += "<"+formData[i].name+">1</"+formData[i].name+">";
          }  
        }else 
        if (formData[i].type == "radio") {
          if (formData[i].checked==1) {
            this._formData += "<"+formData[i].name+">"+this.urlencode(formData[i].value)+"</"+formData[i].name+">";
          }  
        }else 
        if (formData[i].tagName == "SELECT") {
          this._formData += "<"+formData[i].name+">"+this.urlencode(formData[i].value)+"</"+formData[i].name+">";
        }else 
        if (formData[i].tagName == "TEXTAREA") {
          this._formData += "<"+formData[i].name+"><![CDATA["+this.urlencode(formData[i].value)+"]]></"+formData[i].name+">";
        } else {
          this._formData += "<"+formData[i].name+"><![CDATA["+this.urlencode(formData[i].value)+"]]></"+formData[i].name+">";
        }
        poc++;
      }
    }
  }
  
  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) {
  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;
    } 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";

    }
  } 
}

/* ************************************
 *
 *  Description: decode XML result from server
 *  
 *  @param XMLHttpRequest http
 *
 * ************************************ */
TinyPopup.prototype.decodeRequest = function(http) {
  try {
    if (this._debug_mode==1) {
      alert('RETURNED XML: '+http.responseText);
    } 
    if (this._isLoading==1) {
      clearTimeout(this.openTimer);
      this.hideResult();
      this._isLoading = 0;
      if (!http.responseXML.getElementsByTagName('body')[0])
      alert("An exception occurred in the script.\nError number: #101 - Charset or XML error! Tag body not set!"); 
      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 (objparamsBOX.getElementsByTagName('popupwidth')[0])
        this._width = objparamsBOX.getElementsByTagName('popupwidth')[0].firstChild.nodeValue;
        if (objparamsBOX.getElementsByTagName('popupheight')[0])
        this._height = 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('endmessage')[0]) {
          this._endMessage = objparamsBOX.getElementsByTagName('endmessage')[0].firstChild.nodeValue;
        } else this._endMessage = "";
        
        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);
                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">';
                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;
                  }
                  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+'" 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");
                else this.changeTab(tabactive);
              }
              else {
  
                inPopup.innerHTML = content[0].getElementsByTagName('popuphtml')[0].firstChild.nodeValue;
              }
            }
          
          
        }
      

          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');
            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) {
                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 = "popupObject['"+this._id+"'].sendRequest("+newparamscript+","+newparamclassname+","+newparamconstructparams+","+newparammethod+","+newparammethodparams+");";
                }
                if (buttype.firstChild.nodeValue == "close") {
                  var newOnClick = "popupObject['"+this._id+"'].hidePopup();";
                }
                
              }
              
              
              buttons.innerHTML += '<a href="" class="'+className+'" onclick="'+newOnClick+onclickFunc+';return false;">'+name+'</a>';
            }
            this._setButtons = 1;
          } else this._setButtons = 0; 
          
          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;
              var newHtml= otherContents[i].getElementsByTagName('newhtml')[0].firstChild.nodeValue;
              if (document.getElementById(nid)) {
                document.getElementById(nid).innerHTML = newHtml;
              }
            }
          }
          
          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();
          
        
        this._firstLoadData = 1;
        
        
      }
    }
    if (popupObject[this._id]) this.setSize();
    if (document.getElementById('ajax_progress_bar')) {
      var objProgres = document.getElementById('ajax_progress_bar');
      objProgres.style.display = "none";
    } 
  } catch (e) {
    alert("An exception occurred in the script.\nError number: #100 - XML Parse error\n>> " + e + " <<"); 
  }   
}

/* ************************************
 *
 *  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.openTimer = setTimeout(function () {if (popupObject[id]) popupObject[id].setSize();}, this._def_open_timeout);
  this._firstLoad = 1;
}

/* ************************************
 *
 *  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._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 = "";
    }
      
    popup.style.display = "block";
    
    if (autoWidth) {
      this._width = popup.offsetWidth-2-(2*iefix);
      if (this._width < this._minWidth) this._width  = this._minWidth;
      var docWidth = document.documentElement.clientWidth;
      if (this._width+2 > docWidth) {
        this._width  = docWidth-2;
      }  
    }
  
    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";
    }  

    if (autoHeight) {
      this._height = 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._height < this._minHeight) this._height = this._minHeight;
      var docHeight = document.documentElement.clientHeight;
      if (this._height+2 > docHeight) this._height  = docHeight-2;
      
    }
    
    //okno
    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";
    
    // 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+(2*iefix) + "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 sxDocWidth = document.documentElement.clientWidth;
      var sxDocHeight = document.documentElement.clientHeight;
      var sxDocTop = document.documentElement.scrollTop;
      var sxDocLeft = 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);
    
    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 (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 && (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) {
        document.onmousedown = pomDocMouse;
      }  
      popupObject[id].hidePopup();
    }
  }  
}

/* ************************************
 *
 *  Description: hide popup window
 *  
 * ************************************ */
TinyPopup.prototype.hidePopup = function(e) {
  
  
  if (!this._id) {
    var id = pomId;
  } else {
    var id = this._id;
  }

  popupObject[id].hideResult();
  var objBody = document.getElementsByTagName("body").item(0);	
  if (document.getElementById(id)) {
    popup = document.getElementById(id);
    popup.style.display = 'none';
    if (document.getElementById('lbOverlay'+id)) {
      document.getElementById('lbOverlay'+id).style.display = 'none';
    	if (document.getElementById('lbOverlay'+id)) {
    		objBody.removeChild(document.getElementById('lbOverlay'+id));
    	}
    } 
    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 = "";
  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") { 
                document.getElementById('lbOverlay'+this._id).style.display = "block";
              }  
            }
          }
        }  
      }  
      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";
          }
        }  
      }  
    }  
  }
  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 style="margin:0 0 0 20px;">'+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";
    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: 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;
      alert('jop');
    } else {
      popupObject[id]._startMouseX = popupObject[id]._startMouseX - (popupObject[id]._width - popupObject[id]._minWidth);
      popupObject[id]._width = popupObject[id]._minWidth;
    }
  }

  popupObject[id].setSize();
  firstMove = 1;
  document.body.focus(); 
  return false; 
}


/* ************************************
 *
 *  Description: stop resize window
 *
 * ************************************ */
TinyPopup.prototype.stopResize = function() {
  
  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);
    popupObject[id]._mouseX = 0;
    popupObject[id]._mouseY = 0;
    firstMove = 0;
    /*if (!popupObject[id]._id) {
      popupObject[id]._id = id;
    }*/
    document.body.style.cursor="move";
    /*var objBody = document.getElementsByTagName("body").item(0);
    if (!document.getElementById('is_popup1_resize_overlay'+id)) {
    var objOver2 = document.createElement("div");
      objOver2.setAttribute((popupObject[id].ie ? 'className' : 'class'), 'popup_window_resize_overlay');
      objOver2.setAttribute('id','is_popup1_resize_overlay'+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]._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(); 
    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;*/
    //popupObject[id].setSize();
    firstMove = 1;
    document.body.focus(); 
  }
  catch (err) {
  
  }
  return false;
}


/* ************************************
 *
 *  Description: stop resize window
 *
 * ************************************ */
TinyPopup.prototype.stopMove = function() {
  
  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;
}


