 	//*************************************************************************
	//*************************************************************************

	//				 Deklarace trid a globalnich promennych

	//*************************************************************************
	//*************************************************************************

  var moz = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined');
  var ie = (typeof window.ActiveXObject != 'undefined'); 

	var FlagMove;
	var StartX;
	var StartY;
	var LastX;
	var LastY;
	var offsetX;
	var offsetY;
	var tmpLeft;
	var tmpTop;
	var tmpWidth;
	var tmpHeight;
	var MappixelLeft;
	var MappixelTop;
	var Winname;
	var MapAction;
	var PanX;
	var PanY;
	var MapScale;
	var MidpointX;
	var MidpointY;

	var btnActual;

	var zmena;

	//Mereni vzdalenosti
	var distanceAction;
	var distanceArrayX;
	var distanceArrayY;
	var distanceOffsetX;
	var distanceOffsetY;
	var distanceLastPoint;
	var distancePath;

	var jg_doc;
			
	var action = "";
	var navigation = "";

	var FlagMove = false;
	var tmpLeft;
	var tmpTop;
	var tmpWidth;
	var tmpHeight;
	var LastX;
	var LastY;

  var tmp_par = "";     //hnus, za vsechno muze mozilla, zlaty IE
  
	distanceAction = "";
	distanceLastPoint = 0;
	distancePath = "";

  var get_queries_xslt;
  var get_t_queries_xslt;
  var get_o_queries_xslt;
  var get_query_param_xslt;
  var get_query_result_xslt;

  var get_queries_xslt_path;
  var get_t_queries_xslt_path;
  var get_o_queries_xslt_path;
  var get_query_param_xslt_path;
  var get_query_result_xslt_path;
  
  var print_query_url;
  var print_map_url;
  var print_dialog_url;
  var param_dialog_url;
  var save_enviroment_url;
  
  var wms_enabled = 0;
  var wcs_enabled = 0;
  
  var proxy_enabled = 0;
  var proxy_url = "";
  
  var xmlQueries, xmlParam, xmlQueryResult;

  var nemerit = false;
  
  function TLayerManager()
  {

  	//QUERY
  	//Identifikace zda je viditelny dotaz
  	var myQuery = false;
  	var myQIndex = 0;
  	var myQParam = "";
  	var myQURL = "";
  	var myQHide = false;
  	var myQShow = false;
  	var myQHidded = false;
  	var myQShowed = false;
  	var myQMode = 0;
  	
  	//SELECT
  	//Identifikace zda je viditelny vyber
  	var mySelected = false;
  	var mySIndex = 0;
  	var mySParam = "";
  	var mySTooltip = "";
  	var mySURL = "";
  	var mySWMS = "";
  	var mySHide = false;
  	var mySShow = false;
  	var mySHidded = false;
  	var mySShowed = false;
  	//************************************************************************
  		
  	//verejne property TRIDY
  	
  	this.Query = myQuery;
  
  	this.QueryIndex = myQIndex;
  	
  	this.QueryParam = myQParam;
  
  	this.IsQHide = myQHide;
  
  	this.IsQShow = myQShow;
  
 		this.IsQHidded = myQHidded;
  
  	this.IsQShowed = myQShowed;
  
  	this.Mode = myQMode;

    //verejne METODY  
    this.ShowQuery = ShowQuery;
    
    function ShowQuery(index, sParam, URL, mode)
    {
  	
  		var Style;
  		var QColor;
  		var QBackgroundColor;

  		//SetScaleBox
  		
  		QColor = "0x" + document.getElementById("cmbQColor").options[document.getElementById("cmbQColor").selectedIndex].id.substr(1, document.getElementById("cmbQColor").options[document.getElementById("cmbQColor").selectedIndex].id.length-1);
  			
  		if(document.getElementById("cmbQBackgroundColor").options[document.getElementById("cmbQBackgroundColor").selectedIndex].id == "TRANSPARENT")
  		{
  			QBackgroundColor = -1;
  		}
  		else
  		{
  			QBackgroundColor = "0x" + document.getElementById("cmbQBackgroundColor").options[document.getElementById("cmbQBackgroundColor").selectedIndex].id.substr(1, document.getElementById("cmbQBackgroundColor").options[document.getElementById("cmbQBackgroundColor").selectedIndex].id.length-1);
  		}
  	
  		Style = "C:" + parseInt(QColor, 16) + ",FC:" + parseInt(QBackgroundColor,16) + ",S:" + document.getElementById("cmbQStyle").options[document.getElementById("cmbQStyle").selectedIndex].value + ",W:" + document.getElementById("txtQLineWidth").value + ",F:,TS:";

  		if(myQuery)
  		{
  			myQMode = mode;

  			myQURL = replace_string(myQURL, 'BBOX', map_list.maps.Item(map_list.map_id).bbox);
  			myQURL = replace_string(myQURL, 'SRS', map_list.maps.Item(map_list.map_id).srs);
  			myQURL = replace_string(myQURL, 'GM_STYLE', Style);
  			
        //document.getElementById("QueryMap").style.display = "";
  			
        if(moz)
        {
          document.getElementById("QueryMap").style.opacity = parseFloat(document.getElementById("txtQOpacity").value) / 100;
        }
        else
        {
          document.getElementById("QueryMap").style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=" + document.getElementById("txtQOpacity").value + ")";
        }
  
  			document.getElementById("QueryMap").src = myQURL;
  			myQHidded = false;
  			myQShowed = true;
  			
        if(myQShowed)
  			{
  				document.getElementById("btnShowQuery").src = "./DisplayStyle/queryd.gif";
  			}

  			document.getElementById("btnDisableQuery").src = "./DisplayStyle/disableup.gif";
  			
  		}
  		else
  		{

  			myQMode = mode;
  			myQIndex = index;
  			myQParam = sParam;

      	var re = /[?]/i;
      	var xml_req = "";
      	if(URL.search(re) != -1)
      	{
          //sloz XML request
          
          URL = URL + "&";
              
      	}
      	else
      	{
            //sloz XML request
          URL = URL + "?";
      	}
  			
  			if(myQMode == 0)
  			{
    			myQURL = URL + "REQUEST=GetMap&FORMAT=image/png&WIDTH=" + map_list.maps.Item(map_list.map_id).map_width + "&HEIGHT=" + map_list.maps.Item(map_list.map_id).map_height;
    			myQURL = myQURL + "&SRS=" + map_list.maps.Item(map_list.map_id).srs + "&BBOX=" + map_list.maps.Item(map_list.map_id).bbox + "&ID=" + myQIndex + "&FEATUREID=" + myQParam;
    			myQURL = myQURL + "&GM_STYLE=" + Style;
    		}
  			else
  			{
    			myQURL = URL + "REQUEST=GetMap&FORMAT=image/png&WIDTH=" + map_list.maps.Item(map_list.map_id).map_width + "&HEIGHT=" + map_list.maps.Item(map_list.map_id).map_height;
    			myQURL = myQURL + "&SRS=" + map_list.maps.Item(map_list.map_id).srs + "&BBOX=" + map_list.maps.Item(map_list.map_id).bbox + "&ID=" + myQIndex + "&FEATUREID=" + myQParam;
    			myQURL = myQURL + "&GM_STYLE=" + Style;
  			}
        //document.getElementById("QueryMap").style.display = "";
        
        if(moz)
        {
          document.getElementById("QueryMap").style.opacity = parseFloat(document.getElementById("txtQOpacity").value) / 100;
        }
        else
        {
          document.getElementById("QueryMap").style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=" + document.getElementById("txtQOpacity").value + ")";
        }
        document.getElementById("QueryMap").src = myQURL;

  			myQHidded = false;
  			myQShowed = true;

        if(myQShowed)
        {
  				document.getElementById("btnShowQuery").src = "./DisplayStyle/queryd.gif";
  			}
  			
  			document.getElementById("btnDisableQuery").src = "./DisplayStyle/disableup.gif";

  		}

  		myQuery = true;
  		myQHide = false;
  		myQShow = true;
  		
      this.Query = myQuery;
      this.QueryIndex = myQIndex;
      this.QueryParam = myQParam;
      this.IsQHide = myQHide;
      this.IsQShow = myQShow;
      this.IsQHidded = myQHidded;
      this.IsQShowed = myQShowed;
      this.Mode = myQMode;
  		
  	}
  	//************************************************************************
  	
  	this.HideQuery = HideQuery;
  	
    function HideQuery()
    {
  		if(myQuery)
  		{
  
  			document.getElementById("QueryMap").removeAttribute("src");
  			document.getElementById("QueryMap").style.display = "none";
  			document.getElementById("btnShowQuery").src = "./DisplayStyle/queryup.gif";
  			document.getElementById("btnDisableQuery").src = "./DisplayStyle/disableup.gif";
  			myQHide = true;
  			myQShow = false;

        this.Query = myQuery;
        this.QueryIndex = myQIndex;
        this.QueryParam = myQParam;
        this.IsQHide = myQHide;
        this.IsQShow = myQShow;
        this.IsQHidded = myQHidded;
        this.IsQShowed = myQShowed;
        this.Mode = myQMode;
  
  		}
  
  	}
  	//************************************************************************
  	
  	this.DeleteQuery = DeleteQuery;
  	
    function DeleteQuery()
    {
  
  		if(myQuery)
  		{
  
  			myQIndex = 0;
  			myQParam = "";
  			myQURL = "";
  
  			document.getElementById("QueryMap").removeAttribute("src");
  			document.getElementById("QueryMap").style.visibility = "hidden";
  			document.getElementById("QueryMap").style.display = "none";
  			document.getElementById("btnShowQuery").src = "./DisplayStyle/dquery.gif";
  			document.getElementById("btnDisableQuery").src = "./DisplayStyle/ddisable.gif";
  
  			myQuery = false;
  			myQHide = false;
  			myQShow = false;
  			myQHidded = false;
  			myQShowed = false;

        this.Query = myQuery;
        this.QueryIndex = myQIndex;
        this.QueryParam = myQParam;
        this.IsQHide = myQHide;
        this.IsQShow = myQShow;
        this.IsQHidded = myQHidded;
        this.IsQShowed = myQShowed;
        this.Mode = myQMode;

  		}
  		
  	}
  	//************************************************************************
  	
  /*
  	Public Sub ShowSelected(index, sParam, URL, tooltip)
  	
  		Dim Style
  		Dim SColor
  		Dim SBackgroundColor
  
  		SColor = CDbl("&H" + Mid(CStr(document.all.cmbSColor.options(document.all.cmbSColor.selectedIndex).id), 2, Len(CStr(document.all.cmbSColor.options(document.all.cmbSColor.selectedIndex).id)) - 1))
  			
  		If(UCase(document.all.cmbSBackgroundColor.options(document.all.cmbSBackgroundColor.selectedIndex).id) = "TRANSPARENT") Then
  			SBackgroundColor = -1
  		Else
  			SBackgroundColor = CDbl("&H" + Mid(CStr(document.all.cmbSBackgroundColor.options(document.all.cmbSBackgroundColor.selectedIndex).id), 2, Len(CStr(document.all.cmbSBackgroundColor.options(document.all.cmbSBackgroundColor.selectedIndex).id)) - 1))
  		End If
  	
  		Style = "C:" & CStr(SColor) & ",FC:" & CStr(SBackgroundColor) & ",S:" & CStr(document.all.cmbSStyle.options(document.all.cmbSStyle.selectedIndex).value) & ",W:" & CStr(document.all.txtSLineWidth.value) & ",F:,TS:"
  
  		mySIndex = index
  		mySParam = sParam
  		mySWMS = URL
  		mySTooltip = tooltip
  		mySURL = mySWMS & "?REQUEST=GetQueryMap&FORMAT=image/png&WIDTH=" & Cstr(document.all.Map.Width) + "&HEIGHT=" + Cstr(document.all.Map.Height)
  		mySURL = mySURL & "&SRS=EPSG:4818&BBOX=" & GetBBOX(document.all.Map.Src) & "&QUERYINDEX=" & mySIndex & "&" & Replace(mySParam, ",", "&")
  		mySURL = mySURL & "&QUERY_STYLE=" & Style
  		document.all.SelectMap.style.display = ""
  		' msgbox mySURL
  		document.all.SelectMap.src = mySURL
  		document.all.SelectMap.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=" & CStr(document.all.txtSOpacity.value) & ")"
  		document.all.btnShowSelected.src = "./DisplayStyle/selectd.gif"
  		document.all.btnDisableSelected.src = "./DisplayStyle/disableup.gif"
  		mySShowed = True
  		mySHidded = False
  		window.status = mySTooltip
  		mySelected = True
  		mySHide = False
  		mySShow = True
  
  	End Sub
  	'************************************************************************
  	
  	Public Sub HideSelected()
  	
  		If (mySelected = True) Then
  
  			document.all.SelectMap.removeAttribute "src"
  			'document.all.SelectMap.src = ""
  			document.all.SelectMap.style.display = "none"
  			document.all.btnShowSelected.src = "./DisplayStyle/selectup.gif"
  			document.all.btnDisableSelected.src = "./DisplayStyle/disableup.gif"
  			window.status = ""
  			mySHide = True
  			mySShow = False
  		End If
  
  	End Sub
  	'************************************************************************
  	
  	Public Sub DeleteSelected()
  
  		If (mySelected = True) Then
  			mySIndex = 0
  			mySParam = ""
  			mySURL = ""
  			mySWMS = ""
  
  			document.all.SelectMap.removeAttribute "src"
  			'document.all.SelectMap.src = mySURL
  			document.all.SelectMap.style.display = "none"
  			document.all.btnShowSelected.src = "./DisplayStyle/dselect.gif"
  			document.all.btnDisableSelected.src = "./DisplayStyle/ddisable.gif"
  			window.status = ""
  
  			mySelected = False
  			mySHide = False
  			mySShow = False
  			mySShowed = False
  			mySHidded = False
  		End If
  		
  	End Sub
  	'************************************************************************
  */
  	this.HideAll = HideAll;
  	
  	function HideAll()
  	{
  
  		//QUERY
  		if (this.Query)
  		{
  			HideQuery();
  		}
  
  		//SELECT
  		/*If (Selected = True) Then
  			HideSelected
  		End If*/
  		
  	}
  	//************************************************************************
  
  	this.ShowAll = ShowAll;
  	
  	function ShowAll()
  	{
  
  		//QUERY
  		if(this.Query && this.IsQShowed)
  		{
  			ShowQuery(this.QueryIndex, this.QueryParam, map_list.maps.Item(map_list.map_id).query_url, 0);
  		}
  
  		//SELECT
  		/*If ((Selected = True) And (IsSShowed = True)) Then
  			ShowSelected SelectedIndex, SelectedParam, WMS, Tooltip
  		End If*/
  		
  	}
  	//************************************************************************
		
  }

	var LayerManager = new TLayerManager();

  // Class Collection
  function Collection() {
       var lsize = 0;
  
       this.Add = _add;
       this.Remove = _remove;
       this.Item = _item;
       this.SetItem = _setItem;
       this.IsEmpty = _isEmpty;
       this.Length = _length;
       this.Clear = _clear;
       this.Clone = _clone;
  
       function _add(newItem) {
       /* --adds a new item to the collection-- */
            if (newItem == null) return;
  
            lsize++;
            this[(lsize - 1)] = newItem;
       }
  
       function _remove(index) {
       /* --removes the item at the specified index-- */
            if (index < 0 || index > this.length - 1) return;
            this[index] = null;
  
            /* --reindex collection-- */
            for (var i = index; i <= lsize; i++)
                 this[i] = this[i + 1];
  
            lsize--;
       }

       function _item(index) {
       /* --removes the item at the specified index-- */
            if (index < 0 || index > this.length - 1) return null;
            return this[index];
       }

       function _setItem(index, Item) {
       /* --removes the item at the specified index-- */
            if (index < 0 || index > this.length - 1) return null;

            if (Item == null) return;
  
            this[index] = Item;
       }
  
       function _isEmpty() { return lsize == 0 }     /* --returns boolean if collection is/isn't empty-- */
  
       function _length() { return lsize }     /* --returns the size of the collection-- */
  
       function _clear() {
       /* --clears the collection-- */
            for (var i = 0; i < lsize; i++)
                 this[i] = null;
  
            lsize = 0;
       }
  
       function _clone() {
       /* --returns a copy of the collection-- */
            var c = new Collection();
  
            for (var i = 0; i < lsize; i++)
                 c.add(this[i]);
  
            return c;
       }
  }
	// End of class Collection

	// Class CRS_Record
	function CRS_Record(code, name, unit, round, sign, axis_order, axis_horiz_desc, axis_vert_desc)
	{
		this.code = code;
		this.name = name;
		this.unit = unit;
		this.round = round;
		this.sign = sign;
		this.axis_order = axis_order;
		this.axis_horiz_desc = axis_horiz_desc;
		this.axis_vert_desc = axis_vert_desc;
	}
	// End of class CRS_Record

	// Class CRS_Info
	function CRS_Info()
	{
		this.crs_list = new Collection();

		this.Add_Crs = Add_Crs;
		
		function Add_Crs(crs)
		// Funkce pro pridani CRS_Record
		{
			this.crs_list.Add(crs);
		}
	}
	// End of class CRS_Info

	var crs_info = new CRS_Info();
	
	// Class Scale
	function Scale(title, value)
	{
		this.title = title;
		this.value = value;
	}
	// End of class Scale

	// Class Srs
	function Srs(value)
	{
		this.value = value;
	}
	// End of class Srs

	// Class Image_format
	function Image_format(value)
	{
		this.value = value;
	}
	// End of class Image_format

	// Class FI_format
	function FI_format(value)
	{
		this.value = value;
	}
	// End of class FI_format

	// Class WMS_layer
	function WMS_layer(id, title, name, scalemin, scalemax, queryable, checked, pic_width, pic_height, pic_url)
	{
		this.id = id;
		this.title = title;
		this.name = name;
		this.scalemin = scalemin;
		this.scalemax = scalemax;
		this.queryable = queryable;
		this.checked = checked;
		this.pic_width = pic_width;
		this.pic_height = pic_height;
		this.pic_url = pic_url;		
	}
	// End of class WMS_layer

	// Class CMS_layer
	function CMS_layer(id, title, name, scalemin, scalemax, selected)
	{
		this.id = id;
		this.title = title;
		this.name = name;
		this.scalemin = scalemin;
		this.scalemax = scalemax;
		this.selected = selected;
	}
	// End of class CMS_layer

	// Class Default_layer
	function Default_layer(name)
	{
		this.name = name;
	}
	// End of class Default_layer

	// Class WMS_group
	function WMS_group(id, title, expanded)
	{
		this.id = id;
		this.title = title;
		this.expanded = expanded;
		
		this.layer_list = new Collection();

		this.Add_Layer = Add_Layer;
		
		function Add_Layer(layer)
		// Funkce pro pridani vrstvy
		{
			this.layer_list.Add(layer);
		}

	}
	// End of class WMS_group

	// Class WMS_legend
	function WMS_legend(id)
	{
		this.id = id;

		// group_list
		this.group_list = new Collection();

		this.layer_list = new Collection();

		this.Add_Layer = Add_Layer;
		
		function Add_Layer(layer)
		// Funkce pro pridani vrstvy
		{
			this.layer_list.Add(layer);
		}
		
		this.Add_Group = Add_Group;
		
		function Add_Group(group)
		// Funkce pro pridani skupiny
		{
			this.group_list.Add(group);
		}

	}
	// End of class WMS_legend

	// Class WMS_server
	function WMS_server(id, url, opacity, selected, expanded, map_width, map_height, map_format, map_srs, map_bbox)
	{
    this.is_get_capabilities = false;
		this.expanded = expanded;
		this.id = id;
		this.version;
		this.name;
		this.title;
		this.url = url;
		this.opacity = opacity;
		this.selected = selected;
		
		this.width = map_width;
		this.height = map_height;
		this.image_format = map_format;
		this.srs = map_srs;
		this.bbox = map_bbox;
		
		//Kontaktni informace
		this.c_organization;
		this.c_contact_person;
		this.c_phone;
		this.c_email;
		this.c_address;
		this.c_city;
		this.c_post_code;
		this.c_country;
		
		//wms url
		this.wms_url;
		
    //feature info
    this.featureinfo_url;
		this.featureinfo = false;
		this.featureinfo_selected = false;
    this.fi_selected_value = "";
    
		this.legend = new WMS_legend(this.id);

		this.map_img = document.createElement("IMG");
		this.map_img.id = "map_" + this.id;
    this.map_img.useMap = "#Afeature";
		this.map_img.onload = imgMap_Load;
		this.map_img.style.position = "absolute";
		this.map_img.style.left = "0px";
		this.map_img.style.top = "0px";
		this.map_img.style.borderWidth = "0px";
		this.map_img.style.zIndex = "0";
    
    if(moz)
    {
      this.map_img.style.opacity = this.opacity / 100;
    }
    else
    {
      this.map_img.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=" + this.opacity + ")";
    }
    //this.map_img.style.filter = "alpha(opacity=" + this.opacity + ")";
     		
		if(this.selected)
		{
			this.map_img.style.display = "";
		}
		else
		{
			this.map_img.style.display = "none";
		}

		// CAST DEFAULT WMS LAYERS				
		this.default_list = new Collection();
		
		this.Add_Default_Layer = Add_Default_Layer;
		
		function Add_Default_Layer(default_layer)
		// Funkce pro pridani defaultni vrstvy
		{
			this.default_list.Add(default_layer);
		}
		//*******************************************************************************	
		
		// CAST SRS
		this.srs_list = new Collection();
		
		this.Add_Srs = Add_Srs;
		
		function Add_Srs(srs)
		// Funkce pro pridani SRS mapy
		{
			this.srs_list.Add(srs);
		}
		//*******************************************************************************	

		this.Write_Srs = Write_Srs;
		
		function Write_Srs(str_object)
		// Funkce vypise seznam Formatu do listboxu
		{
			var srs_string = "" //<textarea id='txtWMS_Properties_SRS' class='vyber' rows='4' readonly style='width:120px; border: 1px solid black;'>";
			
			/*if(map_list.maps.Item(map_list.map_id).wms_list.Length() > 1)
			{
				srs_string = "<select id='" + str_object + "' disabled class='vyber' style='width:120px'>";
			}
			else
			{
				srs_string = "<select id='" + str_object + "' class='vyber' style='width:120px'>";
			}*/

			for(var i = 0; i < this.srs_list.Length(); i++)
			{
				/*if(this.srs_list.Item(i).value == this.srs)
				{
					srs_string += "<option value='" + this.srs_list.Item(i).value + "' selected>" + this.srs_list.Item(i).value + "</option>";
				}
				else
				{*/
				srs_string += this.srs_list.Item(i).value + "</br>";
				
        //}
			}
			//srs_string += "</textarea>";
			
      document.getElementById(str_object).innerHTML = srs_string;			
		}
		//*******************************************************************************	

		// CAST IMAGE FORMAT
		this.img_format_list = new Collection();
		
		this.Add_Format = Add_Format;
		
		function Add_Format(image_format)
		// Funkce pro pridani Image format mapy
		{
			this.img_format_list.Add(image_format);
		}
		//*******************************************************************************	

		this.Write_Format = Write_Format;
		
		function Write_Format(str_object)
		// Funkce vypise seznam Formatu do listboxu
		{
			var format_string = "<select id='cmbWMS_Properties_ImageFormat' class='vyber' style='width:120px'>";

			for(var i = 0; i < this.img_format_list.Length(); i++)
			{
        if(this.image_format.toLowerCase() == this.img_format_list.Item(i).value.toLowerCase())
        {
          format_string += "<option selected value='" + this.img_format_list.Item(i).value + "'>" + this.img_format_list.Item(i).value + "</option>";
				}
				else
				{
          format_string += "<option value='" + this.img_format_list.Item(i).value + "'>" + this.img_format_list.Item(i).value + "</option>";
        }
			}
			format_string += "</select>";
			
			document.getElementById(str_object).innerHTML = format_string;			
		}
		//*******************************************************************************	

		// CAST FEATURE INFO FORMAT
		this.fi_format_list = new Collection();
		
		this.Add_FI_Format = Add_FI_Format;
		
		function Add_FI_Format(fi_format)
		// Funkce pro pridani feature info format
		{
			this.fi_format_list.Add(fi_format);
		}
		//*******************************************************************************	

		this.Write_FI_Format = Write_FI_Format;
		
		function Write_FI_Format(str_object)
		// Funkce vypise seznam FI Formatu do listboxu
		{
			var format_string = "<select id='cmbWMS_Feature_Info_Format' class='vyber' style='width:120px'>";

			for(var i = 0; i < this.fi_format_list.Length(); i++)
			{
				if(this.fi_selected_value == this.fi_format_list.Item(i).value)
				{
          format_string += "<option selected value='" + this.fi_format_list.Item(i).value + "'>" + this.fi_format_list.Item(i).value + "</option>";
        }
        else
        {
          format_string += "<option value='" + this.fi_format_list.Item(i).value + "'>" + this.fi_format_list.Item(i).value + "</option>";
        }
			}
			format_string += "</select>";
			
			document.getElementById(str_object).innerHTML = format_string;			
		}
		//*******************************************************************************	

		this.Get_Capabilities = Get_Capabilities;
		
		function Get_Capabilities(default_version)
		{

      if (!this.is_get_capabilities)
      {

        var response = '';
  
        var xml_req;
        
  			var xmlCap;
  
        var strSrs;
  
      	var re_version = /[.]/ig;
              
        var moz = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined');
        var ie = (typeof window.ActiveXObject != 'undefined'); 
  			
  			var re = /[?]/i;
  			if(this.url.search(re) != -1)
  			{
          //sloz XML request
          
          xml_req = this.url + "&REQUEST=GetCapabilities";
          
          if(get_string(xml_req, 'SERVICE') == '')
          {
            xml_req = replace_string(xml_req, 'SERVICE', 'WMS');
            
            if(get_string(xml_req, 'SERVICE') == '')
            {
              xml_req = xml_req + "&SERVICE=WMS";
            }
          }
  
          if(get_string(xml_req, 'VERSION') == '')
          {
            xml_req = replace_string(xml_req, 'VERSION', default_version);
            
            if(get_string(xml_req, 'VERSION') == '')
            {
              xml_req = xml_req + "&VERSION=" + default_version;
            }
          }
  
  			}
  			else
  			{
            //sloz XML request
          xml_req = this.url + "?REQUEST=GetCapabilities";
          
          if(get_string(xml_req, 'SERVICE') == '')
          {
            xml_req = replace_string(xml_req, 'SERVICE', 'WMS');
            
            if(get_string(xml_req, 'SERVICE') == '')
            {
              xml_req = xml_req + "&SERVICE=WMS";
            }
          }
          if(get_string(xml_req, 'VERSION') == '')
          {
            xml_req = replace_string(xml_req, 'VERSION', default_version);
            
            if(get_string(xml_req, 'VERSION') == '')
            {
              xml_req = xml_req + "&VERSION=" + default_version;
            }
          }
    		}

        xmlCap = AJAX(xml_req, proxy_enabled);

        if (moz)
        { 
          var xpathres;
          
          if(parseInt(get_string(xml_req, 'VERSION').replace(re_version,"")) >= 130)
          {
      			//Nacti version
            //xpathres = xmlCap.getElementsByTagName("WMS_Capabilities")[0];
            xpathres = xmlCap.evaluate("//WMS_Capabilities", xmlCap, null, 9, null); //getElementsByTagName("WMS_Capabilities")[0];
            this.version = (xpathres != null)?(xpathres.singleNodeValue != null)?xpathres.singleNodeValue.getAttribute("version"):"":"";
            //this.version = (xpathres != null)?xpathres.getAttribute("version"):"";
  
      			if(this.version == "")
      			{
        			//Nacti version
              xpathres = xmlCap.evaluate("//WMT_MS_Capabilities", xmlCap, null, 9, null);
              this.version = (xpathres != null)?xpathres.singleNodeValue.getAttribute("version"):"";
            }
          }
          else
          {
      			//Nacti version
            xpathres = xmlCap.evaluate("//WMT_MS_Capabilities", xmlCap, null, 9, null);
            this.version = (xpathres != null && xpathres.singleNodeValue != null)?xpathres.singleNodeValue.getAttribute("version"):"";
  
      			if(this.version == "")
      			{
        			//Nacti version
              //xpathres = xmlCap.getElementsByTagName("WMS_Capabilities")[0];
              xpathres = xmlCap.evaluate("//WMS_Capabilities", xmlCap, null, 9, null);
              //this.version = (xpathres != null)?xpathres.getAttribute("version"):"";
              //xpathres = xmlCap.evaluate("//WMS_Capabilities", xmlCap, null, 9, null); //getElementsByTagName("WMS_Capabilities")[0];
              this.version = (xpathres != null)?(xpathres.singleNodeValue != null)?xpathres.singleNodeValue.getAttribute("version"):"":"";
            
            }
  
          }
  
          if(parseInt(this.version.replace(re_version,"")) >= 130)
          {
            strSrs = "CRS";
          }
          else
          {
            strSrs = "SRS";
          }
          	
    			//Nacti name
          xpathres = xmlCap.evaluate("//Service/Name", xmlCap, null, 9, null);
    			this.name = (xpathres != null)?(xpathres.singleNodeValue.firstChild != null)?xpathres.singleNodeValue.firstChild.nodeValue:"":"";
  
    			//Nacti title
          xpathres = xmlCap.evaluate("//Service/Title", xmlCap, null, 9, null);
    			this.title = (xpathres != null)?xpathres.singleNodeValue.firstChild.nodeValue:"";
          
    			// Nacti contact info
          xpathres = xmlCap.evaluate("//ContactInformation/ContactPersonPrimary/ContactOrganization", xmlCap, null, 9, null);
    			try
    			{
      			this.c_organization = (xpathres != null)?(xpathres.singleNodeValue.firstChild != null)?xpathres.singleNodeValue.firstChild.nodeValue:"neuvedeno":"neuvedeno";
          }
          catch(e)
          {
            this.c_organization = "neuvedeno";
          }
    
          xpathres = xmlCap.evaluate("//ContactInformation/ContactPersonPrimary/ContactPerson", xmlCap, null, 9, null);
    			try
    			{
      			this.c_contact_person = (xpathres != null)?(xpathres.singleNodeValue.firstChild != null)?xpathres.singleNodeValue.firstChild.nodeValue:"neuvedeno":"neuvedeno";
          }
          catch(e)
          {
            this.c_contact_person = "neuvedeno";
          }
  
          xpathres = xmlCap.evaluate("//ContactInformation/ContactAddress/Address", xmlCap, null, 9, null);
    			try
    			{
            this.c_address = (xpathres != null)?(xpathres.singleNodeValue.firstChild != null)?xpathres.singleNodeValue.firstChild.nodeValue:"neuvedeno":"neuvedeno";
          }
          catch(e)
          {
            this.c_address = "neuvedeno";
          }
          
          xpathres = xmlCap.evaluate("//ContactInformation/ContactAddress/City", xmlCap, null, 9, null);
    			try
    			{
            this.c_city = (xpathres != null)?(xpathres.singleNodeValue.firstChild != null)?xpathres.singleNodeValue.firstChild.nodeValue:"neuvedeno":"neuvedeno";
          }
          catch(e)
          {
            this.c_city = "neuvedeno";
          }
          
          xpathres = xmlCap.evaluate("//ContactInformation/ContactAddress/PostCode", xmlCap, null, 9, null);
    			try
    			{
            this.c_post_code = (xpathres != null)?(xpathres.singleNodeValue.firstChild != null)?xpathres.singleNodeValue.firstChild.nodeValue:"neuvedeno":"neuvedeno";
          }
          catch(e)
          {
            this.c_post_code = "neuvedeno";
          }
          
          xpathres = xmlCap.evaluate("//ContactInformation/ContactAddress/Country", xmlCap, null, 9, null);
    			try
    			{
            this.c_country = (xpathres != null)?(xpathres.singleNodeValue.firstChild != null)?xpathres.singleNodeValue.firstChild.nodeValue:"neuvedeno":"neuvedeno";
          }
          catch(e)
          {
            this.c_country = "neuvedeno";
          }
          
          xpathres = xmlCap.evaluate("//ContactInformation/ContactVoiceTelephone", xmlCap, null, 9, null);
    			try
    			{
            this.c_phone = (xpathres != null)?(xpathres.singleNodeValue.firstChild != null)?xpathres.singleNodeValue.firstChild.nodeValue:"neuvedeno":"neuvedeno";
          }
          catch(e)
          {
            this.c_phone = "neuvedeno";
          }
          
          xpathres = xmlCap.evaluate("//ContactInformation/ContactElectronicMailAddress", xmlCap, null, 9, null);
    			try
    			{
            this.c_email = (xpathres != null)?(xpathres.singleNodeValue.firstChild != null)?xpathres.singleNodeValue.firstChild.nodeValue:"neuvedeno":"neuvedeno";
          }
          catch(e)
          {
            this.c_email = "neuvedeno";
          }
    			
          // nacti url adresy
          xpathres = xmlCap.evaluate("//GetMap/DCPType/HTTP/Get/OnlineResource", xmlCap, null, 9, null);
    			this.wms_url = (xpathres != null)?xpathres.singleNodeValue.getAttributeNS("http://www.w3.org/1999/xlink", "href"):"";
  
          xpathres = xmlCap.evaluate("//GetFeatureInfo/DCPType/HTTP/Get/OnlineResource", xmlCap, null, 9, null);
    			this.featureinfo_url = (xpathres != null)?xpathres.singleNodeValue.getAttributeNS("http://www.w3.org/1999/xlink", "href"):"";
  
          var fi_index = 0;
  
          if(this.featureinfo_url != '')
          {
            this.featureinfo = true;
            this.featureinfo_selected = true;
      			// nacti fi formaty
            xpathres = xmlCap.evaluate("//GetFeatureInfo/Format", xmlCap, null, 7, null);
      			for(var i = 0; i < xpathres.snapshotLength; i++)
      			{
              var format = new FI_format(xpathres.snapshotItem(i).firstChild.nodeValue);
      				
      				if(format.value == "text/html")
      				{
                fi_index = i;
              }
  
      				this.Add_FI_Format(format);
      			}
  
            if(fi_index > 0)
            {
              this.fi_selected_value = this.fi_format_list.Item(fi_index).value;
            }
            else
            {
              this.fi_selected_value = this.fi_format_list.Item(fi_index).value;
            }
          }
          
    			// nacti image formaty
          xpathres = xmlCap.evaluate("//GetMap/Format", xmlCap, null, 7, null);
    			for(var i = 0; i < xpathres.snapshotLength; i++)
    			{
            var format = new Image_format(xpathres.snapshotItem(i).firstChild.nodeValue);
    				
    				this.Add_Format(format);
    			}
  
    			// nacti srs
          xpathres = xmlCap.evaluate("//Capability/Layer/" + strSrs, xmlCap, null, 7, null);
    			switch(this.version)
    			{
            case "1.0.0":
    			  case "1.1.0":
    			  case "1.1.1":
            default:
             	var re_srs = new RegExp(" ", "i");
              
              for(var i = 0; i < xpathres.snapshotLength; i++)
              {
                var srs_a = xpathres.snapshotItem(i).firstChild.nodeValue.split(" ");
          			for(var j = 0; j < srs_a.length; j++)
          			{
          					if(srs_a[j].replace(re_srs, "") != '')
          					{
                      var srs = new Srs(srs_a[j]);
                      this.Add_Srs(srs);
                    }
          			}			   
              }
              break;
  /*           	var re_srs = new RegExp(" ", "i");
        			for(var i = 0; i < xpathres.snapshotLength; i++)
        			{
        					if(xpathres.snapshotItem(i).firstChild.nodeValue.replace(re_srs, "") != '')
        					{
          					var srs = new Srs(xpathres.snapshotItem(i).firstChild.nodeValue);
          					this.Add_Srs(srs);
          				}
        			}			   */
          }
          
    			//pokud toto neni prvni sever, zjisti jestli je v podporovanych souradnych systemech jiz zvoleny
    			var s_system = false;
    			for(var i = 0; i < this.srs_list.Length(); i++)
    			{
    				if(this.srs_list.Item(i).value.toLowerCase() == this.srs.toLowerCase())
    				{
    					s_system = true;
    				}
    			}
    			
    			if(!s_system)
    			{
    				alert(script_messages[1]);
    				return(false);
    			}
  
    			//nacti skupiny
          xmlNodes = xmlCap.evaluate("//Capability/Layer/Layer", xmlCap, null, 7, null);
    			
    			var groups = 0;
  
    			for (var i = 0; i < xmlNodes.snapshotLength; i++)
    			{
            var xmlFNodes = xmlCap.evaluate("./Layer", xmlNodes.snapshotItem(i), null, 7, null); //xpathres.snapshotItem(i).firstChild.nodeValue.getElementsByTagName("Layer");
    				// obsahuje podvrstvy, je to tedy skupina
    				if (xmlFNodes.snapshotLength > 0)
    				{
    					var title, name, queryable, min_scale, max_scale, legend_url;
    										
              var m_group = new WMS_group(groups, xmlNodes.snapshotItem(i).getElementsByTagName("Title")[0].firstChild.nodeValue,0);
    					
    					for(var j = 0; j < xmlFNodes.snapshotLength; j++)
    					{
                var xmlTitle = xmlFNodes.snapshotItem(j).getElementsByTagName("Title")[0].firstChild;
    						var xmlName = xmlFNodes.snapshotItem(j).getElementsByTagName("Name")[0].firstChild;
    						
    						title = xmlTitle.nodeValue;
    						name = xmlName.nodeValue;
    						
    						queryable = (xmlFNodes.snapshotItem(j).getAttribute("queryable") != null)?xmlFNodes.snapshotItem(j).getAttribute("queryable"):0;
    						
                if(parseInt(this.version.replace(re_version,"")) >= 130)
                {
      						var xmlScaleMin = xmlFNodes.snapshotItem(j).getElementsByTagName("MinScaleDenominator")[0].firstChild;
      
        					if(xmlScaleMin != null)
        					{	
               			min_scale = (xmlScaleMin != null)?xmlScaleMin.nodeValue:"";
          						
          					if (min_scale == "" )
          					{
          						min_scale = 0;
          					}
                  }
                  else
                  {
          						min_scale = 0;
                  }
  
      						var xmlScaleMax = xmlFNodes.snapshotItem(j).getElementsByTagName("MaxScaleDenominator")[0].firstChild;
      
        					if(xmlScaleMax != null)
        					{	
          					max_scale = (xmlScaleMax != null)?xmlScaleMax.nodeValue:"";
          						
          					if (max_scale == "" )
          					{
          						max_scale = 9999999999;
          					}
                  }
                  else
                  {
          						max_scale = 9999999999;
                  }
                }
                else
                {
      						/*var xmlScale = xmlFNodes.item(j).selectSingleNode("./ScaleHint");
      
        					if(xmlScale != null)
        					{	
               			min_scale = (xmlScale != null)?xmlScale.getAttribute("min"):"";
          					max_scale = (xmlScale != null)?xmlScale.getAttribute("max"):"";
          						
          					if (min_scale == "" )
          					{
          						min_scale = 0;
          					}
          						
          					if (max_scale == "" )
          					{
          						max_scale = 9999999999;
          					}
                  }
                  else
                  {
          						min_scale = 0;
          						max_scale = 9999999999;
                  }*/
      						min_scale = 0;
      						max_scale = 9999999999;                
                }
    
    						//Zobrazeni obrazku
    						var picwidth = 0;
    						var picheight = 0;
    						var picurl = "";
    						if(xmlFNodes.snapshotItem(j).getElementsByTagName("Style").length > 0)
    						{
                  var xmlLegendURL = xmlFNodes.snapshotItem(j).getElementsByTagName("Style")[0].getElementsByTagName("LegendURL")[0];
      						
      						if(xmlLegendURL != null)
      						{	
      							picwidth = parseInt(xmlLegendURL.getAttribute("width"));
      							picheight = parseInt(xmlLegendURL.getAttribute("height"));
      								
      							var xmlOnlineRes = xmlLegendURL.getElementsByTagName("OnlineResource")[0];
      							picurl = xmlOnlineRes.getAttributeNS("http://www.w3.org/1999/xlink", "href");
      						}
                }
    						
    						var checked = this.In_Default_Layers(name);
    						
    						var m_layer = new WMS_layer(j, title, name, min_scale, max_scale, queryable, checked, picwidth, picheight, picurl);
    
    						m_group.Add_Layer(m_layer);					
    					}	
    					
    					this.legend.Add_Group(m_group);
    					
    					groups++;
    
    				}
    			}
  
    			var l_index = 0;
    			for (var i = 0; i < xmlNodes.snapshotLength; i++)
    			{
    				var xmlFNodes = xmlCap.evaluate("./Layer", xmlNodes.snapshotItem(i), null, 7, null);
  
    				// neobsahuje podvrstvy, je to tedy vrstva
    				if (xmlFNodes.snapshotLength == 0)
    				{
    					var title, name, queryable, min_scale, max_scale;
    										
    					var xmlTitle = xmlNodes.snapshotItem(i).getElementsByTagName("Title")[0].firstChild;
    					var xmlName = xmlNodes.snapshotItem(i).getElementsByTagName("Name")[0].firstChild;
    						
    					title = xmlTitle.nodeValue;
    					name = xmlName.nodeValue;
   						queryable = (xmlNodes.snapshotItem(i).getAttribute("queryable") != null)?xmlNodes.snapshotItem(i).getAttribute("queryable"):0;
    						
              if(parseInt(this.version.replace(re_version,"")) >= 130)
              {
    						var xmlScaleMin = xmlFNodes.snapshotItem(j).getElementsByTagName("MinScaleDenominator")[0].firstChild;
    
      					if(xmlScaleMin != null)
      					{	
             			min_scale = (xmlScaleMin != null)?xmlScaleMin.nodeValue:"";
        						
        					if (min_scale == "" )
        					{
        						min_scale = 0;
        					}
                }
                else
                {
        						min_scale = 0;
                }
  
    						var xmlScaleMax = xmlFNodes.snapshotItem(j).getElementsByTagName("MaxScaleDenominator")[0].firstChild;
    
      					if(xmlScaleMax != null)
      					{	
        					max_scale = (xmlScaleMAx != null)?xmlScaleMax.nodeValue:"";
        						
        					if (max_scale == "" )
        					{
        						max_scale = 9999999999;
        					}
                }
                else
                {
        						max_scale = 9999999999;
                }
              }
              else
              {
       					/*var xmlScale = xmlNodes.item(i).selectSingleNode("./ScaleHint");
      
      					if(xmlScale != null)
      					{	
             			min_scale = (xmlScale != null)?xmlScale.getAttribute("min"):"";
        					max_scale = (xmlScale != null)?xmlScale.getAttribute("max"):"";
        						
        					if (min_scale == "" )
        					{
        						min_scale = 0;
        					}
        						
        					if (max_scale == "" )
        					{
        						max_scale = 9999999999;
        					}
                }
                else
                {
        						min_scale = 0;
        						max_scale = 9999999999;
                }*/
    						min_scale = 0;
    						max_scale = 9999999999;              
              }
              											
    					//Zobrazeni obrazku
    					var picwidth = 0;
    					var picheight = 0;
    					var picurl = "";
    					if(xmlNodes.snapshotItem(i).getElementsByTagName("Style")[0] != null)
    					{
                var xmlLegendURL = xmlNodes.snapshotItem(i).getElementsByTagName("Style")[0].getElementsByTagName("LegendURL")[0];
      						    						
      					if(xmlLegendURL != null)
      					{	
      						picwidth = parseInt(xmlLegendURL.getAttribute("width"));
      						picheight = parseInt(xmlLegendURL.getAttribute("height"));
      								
      						var xmlOnlineRes = xmlLegendURL.getElementsByTagName("OnlineResource")[0];
      						picurl = xmlOnlineRes.getAttributeNS("http://www.w3.org/1999/xlink", "href");
      					}
              }
    					
              var checked = this.In_Default_Layers(name);
    
    					var m_layer = new WMS_layer(l_index, title, name, min_scale, max_scale, queryable, checked, picwidth, picheight, picurl);
              
              l_index++;
              
    					this.legend.Add_Layer(m_layer);					
    				}	
    					
    			}
        }
        else if (ie) 
        { 
  
          if(xmlCap.xml == "")
          {
            alert(script_messages[0]);
            return(false);
          }
  
          var xmlNode;
          
          if(parseInt(get_string(xml_req, 'VERSION').replace(re_version,"")) >= 130)
          {
      			//Nacti version
      			xmlNode = xmlCap.selectSingleNode("//WMS_Capabilities");
      			this.version = (xmlNode != null)?xmlNode.getAttribute("version"):"";
      			
      			if(this.version == "")
      			{
        			//Nacti version
        			xmlNode = xmlCap.selectSingleNode("//WMT_MS_Capabilities");
        			this.version = (xmlNode != null)?xmlNode.getAttribute("version"):"";
            }
          }
          else
          {
      			//Nacti version
      			xmlNode = xmlCap.selectSingleNode("//WMT_MS_Capabilities");
      			this.version = (xmlNode != null)?xmlNode.getAttribute("version"):"";
  
      			if(this.version == "")
      			{
        			//Nacti version
        			xmlNode = xmlCap.selectSingleNode("//WMS_Capabilities");
        			this.version = (xmlNode != null)?xmlNode.getAttribute("version"):"";
            }
  
          }
  
          if(parseInt(this.version.replace(re_version,"")) >= 130)
          {
            strSrs = "CRS";
          }
          else
          {
            strSrs = "SRS";
          }
  
    			//Nacti name
    			xmlNode = xmlCap.selectSingleNode("//Service/Name");
    			this.name = (xmlNode != null)?xmlNode.text:"";
    
    			//Nacti title
    			xmlNode = xmlCap.selectSingleNode("//Service/Title");
    			this.title = (xmlNode != null)?xmlNode.text:"";
    			
    			// Nacti contact info
    			xmlNode = xmlCap.selectSingleNode("//ContactInformation/ContactPersonPrimary/ContactOrganization");
    			this.c_organization = (xmlNode != null)?xmlNode.text:"neuvedeno";
    
    			xmlNode = xmlCap.selectSingleNode("//ContactInformation/ContactPersonPrimary/ContactPerson");
    			this.c_contact_person = (xmlNode != null)?xmlNode.text:"neuvedeno";
    
    			xmlNode = xmlCap.selectSingleNode("//ContactInformation/ContactAddress/Address");
    			this.c_address = (xmlNode != null)?xmlNode.text:"neuvedeno";
    
    			xmlNode = xmlCap.selectSingleNode("//ContactInformation/ContactAddress/City");
    			this.c_city = (xmlNode != null)?xmlNode.text:"neuvedeno";
    
    			xmlNode = xmlCap.selectSingleNode("//ContactInformation/ContactAddress/PostCode");
    			this.c_post_code = (xmlNode != null)?xmlNode.text:"neuvedeno";
    
    			xmlNode = xmlCap.selectSingleNode("//ContactInformation/ContactAddress/Country");
    			this.c_country = (xmlNode != null)?xmlNode.text:"neuvedeno";
    
    			xmlNode = xmlCap.selectSingleNode("//ContactInformation/ContactVoiceTelephone");
    			this.c_phone = (xmlNode != null)?xmlNode.text:"neuvedeno";
    
    			xmlNode = xmlCap.selectSingleNode("//ContactInformation/ContactElectronicMailAddress");
    			this.c_email = (xmlNode != null)?xmlNode.text:"neuvedeno";
    
    			// nacti url adresy
    			xmlNode = xmlCap.selectSingleNode("//GetMap/DCPType/HTTP/Get/OnlineResource");
    			this.wms_url = (xmlNode != null)?xmlNode.getAttribute("xlink:href"):"";
    
    			xmlNode = xmlCap.selectSingleNode("//GetFeatureInfo/DCPType/HTTP/Get/OnlineResource");
    			this.featureinfo_url = (xmlNode != null)?xmlNode.getAttribute("xlink:href"):"";
  
          if(this.featureinfo_url != '')
          {
            this.featureinfo = true;
            this.featureinfo_selected = true;
  
      			// nacti fi formaty
      			var xmlNodes = xmlCap.selectNodes("//GetFeatureInfo/Format");
      			
            var fi_index = 0;
      			
      			for(var i = 0; i < xmlNodes.length; i++)
      			{
      				var format = new FI_format(xmlNodes.item(i).text);
      				
      				if(format.value == "text/html")
      				{
                fi_index = i;
              }
  
      				this.Add_FI_Format(format);
      			}
  
            if(fi_index > 0)
            {
              this.fi_selected_value = this.fi_format_list.Item(fi_index).value;
            }
            else
            {
              this.fi_selected_value = this.fi_format_list.Item(fi_index).value;
            }
  
          }
    			
    			// nacti image formaty
    			var xmlNodes = xmlCap.selectNodes("//GetMap/Format");
    			
    			for(var i = 0; i < xmlNodes.length; i++)
    			{
    				var format = new Image_format(xmlNodes.item(i).text);
    				
    				this.Add_Format(format);
    			}
    
    			// nacti srs
    			xmlNodes = xmlCap.selectNodes("//Capability/Layer/" + strSrs);
    			
    			switch(this.version)
    			{
            case "1.0.0":
    			  case "1.1.0":
    			  case "1.1.1":
            default:
        			for(var i = 0; i < xmlNodes.length; i++)
        			{
                var srs_a = xmlNodes.item(i).text.split(" ");
          			for(var j = 0; j < srs_a.length; j++)
          			{
          					var srs = new Srs(srs_a[j]);
          					this.Add_Srs(srs);
          			}			   
              }
              break;
          }
    
    			//pokud toto neni prvni sever, zjisti jestli je v podporovanych souradnych systemech jiz zvoleny
    			var s_system = false;
    			for(var i = 0; i < this.srs_list.Length(); i++)
    			{
    				if(this.srs_list.Item(i).value.toLowerCase() == this.srs.toLowerCase())
    				{
    					s_system = true;
    				}
    			}
    			
    			if(!s_system)
    			{
    				alert(script_messages[1]);
    				return(false);
    			}
    			
    			//nacti skupiny
    			var xmlNodes = xmlCap.selectNodes("//Capability/Layer/Layer");
    			
    			var groups = 0;
    			
    			for (var i = 0; i < xmlNodes.length; i++)
    			{
    				var xmlFNodes = xmlNodes.item(i).selectNodes("./Layer");
    		
    				// obsahuje podvrstvy, je to tedy skupina
    				if (xmlFNodes.length > 0)
    				{
    					var title, name, queryable, min_scale, max_scale, legend_url;
    										
    					var m_group = new WMS_group(groups, xmlNodes.item(i).selectSingleNode("./Title").text,0);
    					
    					for(var j = 0; j < xmlFNodes.length; j++)
    					{
    						var xmlTitle = xmlFNodes.item(j).selectSingleNode("./Title");
    						var xmlName = xmlFNodes.item(j).selectSingleNode("./Name");
    						
    						title = xmlTitle.text;
    						name = xmlName.text;
                queryable = (xmlFNodes.item(j).getAttribute("queryable") != null)?xmlFNodes.item(j).getAttribute("queryable"):0;
  
                if(parseInt(this.version.replace(re_version,"")) >= 130)
                {
      						var xmlScaleMin = xmlFNodes.item(j).selectSingleNode("./MinScaleDenominator");
      
        					if(xmlScaleMin != null)
        					{	
               			min_scale = (xmlScaleMin != null)?xmlScaleMin.text:"";
          						
          					if (min_scale == "" )
          					{
          						min_scale = 0;
          					}
                  }
                  else
                  {
          						min_scale = 0;
                  }
  
      						var xmlScaleMax = xmlFNodes.item(j).selectSingleNode("./MaxScaleDenominator");
      
        					if(xmlScaleMax != null)
        					{	
          					max_scale = (xmlScaleMax != null)?xmlScaleMax.text:"";
          						
          					if (max_scale == "" )
          					{
          						max_scale = 9999999999;
          					}
                  }
                  else
                  {
          						max_scale = 9999999999;
                  }
                }
                else
                {
      						/*var xmlScale = xmlFNodes.item(j).selectSingleNode("./ScaleHint");
      
        					if(xmlScale != null)
        					{	
               			min_scale = (xmlScale != null)?xmlScale.getAttribute("min"):"";
          					max_scale = (xmlScale != null)?xmlScale.getAttribute("max"):"";
          						
          					if (min_scale == "" )
          					{
          						min_scale = 0;
          					}
          						
          					if (max_scale == "" )
          					{
          						max_scale = 9999999999;
          					}
                  }
                  else
                  {
          						min_scale = 0;
          						max_scale = 9999999999;
                  }*/
      						min_scale = 0;
      						max_scale = 9999999999;                
                }
    
    						//Zobrazeni obrazku
    						var picwidth = 0;
    						var picheight = 0;
    						var picurl = "";
    						var xmlLegendURL = xmlFNodes.item(j).selectSingleNode("./Style/LegendURL");  						
    						if(xmlLegendURL != null)
    						{	
    							picwidth = parseInt(xmlLegendURL.getAttribute("width"));
    							picheight = parseInt(xmlLegendURL.getAttribute("height"));
    								
    							var xmlOnlineRes = xmlLegendURL.selectSingleNode("OnlineResource");
    							picurl = xmlOnlineRes.attributes.getNamedItem("xlink:href").text;
    						}
    						
    						var checked = this.In_Default_Layers(name);
    						
    						var m_layer = new WMS_layer(j, title, name, min_scale, max_scale, queryable, checked, picwidth, picheight, picurl);
    
    						m_group.Add_Layer(m_layer);					
    					}	
    					
    					this.legend.Add_Group(m_group);
    					
    					groups++;
    
    				}
    			}
    
    			var l_index = 0;
          for (var i = 0; i < xmlNodes.length; i++)
    			{
    				var xmlFNodes = xmlNodes.item(i).selectNodes("./Layer");
    		
    				// neobsahuje podvrstvy, je to tedy skupina
    				if (xmlFNodes.length == 0)
    				{
              var title, name, queryable, min_scale, max_scale;
    										
    					var xmlTitle = xmlNodes.item(i).selectSingleNode("./Title");
    					var xmlName = xmlNodes.item(i).selectSingleNode("./Name");
    						
    					title = xmlTitle.text;
    					name = xmlName.text;
              queryable = (xmlNodes.item(i).getAttribute("queryable") != null)?xmlNodes.item(i).getAttribute("queryable"):0;
    						
              if(parseInt(this.version.replace(re_version,"")) >= 130)
              {
    						var xmlScaleMin = xmlFNodes.item(j).selectSingleNode("./MinScaleDenominator");
    
      					if(xmlScaleMin != null)
      					{	
             			min_scale = (xmlScaleMin != null)?xmlScaleMin.text:"";
        						
        					if (min_scale == "" )
        					{
        						min_scale = 0;
        					}
                }
                else
                {
        						min_scale = 0;
                }
  
    						var xmlScaleMax = xmlFNodes.item(j).selectSingleNode("./MaxScaleDenominator");
    
      					if(xmlScaleMax != null)
      					{	
        					max_scale = (xmlScaleMAx != null)?xmlScaleMax.text:"";
        						
        					if (max_scale == "" )
        					{
        						max_scale = 9999999999;
        					}
                }
                else
                {
        						max_scale = 9999999999;
                }
              }
              else
              {
       					/*var xmlScale = xmlNodes.item(i).selectSingleNode("./ScaleHint");
      
      					if(xmlScale != null)
      					{	
             			min_scale = (xmlScale != null)?xmlScale.getAttribute("min"):"";
        					max_scale = (xmlScale != null)?xmlScale.getAttribute("max"):"";
        						
        					if (min_scale == "" )
        					{
        						min_scale = 0;
        					}
        						
        					if (max_scale == "" )
        					{
        						max_scale = 9999999999;
        					}
                }
                else
                {
        						min_scale = 0;
        						max_scale = 9999999999;
                }*/
    						min_scale = 0;
    						max_scale = 9999999999;              
              }
                          											
    					//Zobrazeni obrazku
    					var picwidth = 0;
    					var picheight = 0;
    					var picurl = "";
    					var xmlLegendURL = xmlNodes.item(i).selectSingleNode("./Style/LegendURL");  						
    					if(xmlLegendURL != null)
    					{	
    						picwidth = parseInt(xmlLegendURL.getAttribute("width"));
    						picheight = parseInt(xmlLegendURL.getAttribute("height"));
    								
    						var xmlOnlineRes = xmlLegendURL.selectSingleNode("OnlineResource");
    						picurl = xmlOnlineRes.attributes.getNamedItem("xlink:href").text;
    					}
    
    					var checked = this.In_Default_Layers(name);
    
    					var m_layer = new WMS_layer(l_index, title, name, min_scale, max_scale, queryable, checked, picwidth, picheight, picurl);
  
     					l_index++;
  
    					this.legend.Add_Layer(m_layer);					
    				}	
    					
    			}
        }//end if IE
        
  			if(this.wms_url.search(re) != -1)
  			{
          if(this.wms_url.charAt(this.wms_url.length-1) == "&")
          {
      			this.wms_url = this.wms_url + "request=GetMap&SERVICE=WMS&VERSION=" + this.version + "&FORMAT=" + this.image_format + "&" + strSrs + "=" + this.srs + "&BBOX=" + this.bbox + "&WIDTH=" + this.width + "&HEIGHT=" + this.height + "&TRANSPARENT=True";
          }
          else
          {
      			this.wms_url = this.wms_url + "&request=GetMap&SERVICE=WMS&VERSION=" + this.version + "&FORMAT=" + this.image_format + "&" + strSrs + "=" + this.srs + "&BBOX=" + this.bbox + "&WIDTH=" + this.width + "&HEIGHT=" + this.height + "&TRANSPARENT=True";
          }
  			}
  			else
  			{
     			this.wms_url = this.wms_url + "?request=GetMap&SERVICE=WMS&VERSION=" + this.version + "&FORMAT=" + this.image_format + "&" + strSrs + "=" + this.srs + "&BBOX=" + this.bbox + "&WIDTH=" + this.width + "&HEIGHT=" + this.height + "&TRANSPARENT=True";
  			}
  		
  			var layers = "";
  			var styles = "";
  			for(var i = 0; i < this.default_list.Length(); i++)
  			{
  				layers += this.default_list.Item(i).name + ",";
  				styles += ","
  			}
  			layers = layers.substr(0, layers.length - 1);
  			styles = styles.substr(0, styles.length - 1);
  			
  			this.wms_url += "&LAYERS=" + layers + "&STYLES=" + styles;
  			
  			this.is_get_capabilities = true;
  			
  			//this.map_img.src = this.wms_url;
  			//prompt("",this.map_img.src);
  			
  			return(true);
      }			
		}
		//*******************************************************************************
		
		this.GetMap = GetMap;
		
		function GetMap()
		{
      this.map_img.src = this.wms_url;
    }
		//*******************************************************************************	
    
		this.Write_Legend = Write_Legend;
		
		function Write_Legend(str_object)
		{
			var BBoxArray = new Array();
			
			BBoxArray = map_list.maps.Item(map_list.map_id).bbox.split(',');
			
			var world_width = BBoxArray[2] - BBoxArray[0];
			var s_actual = ((((world_width * map_list.maps.Item(map_list.map_id).projection_to_scale) / this.width) * 100) * (280/10));
      var str_legend = "<table id='tblWMS_Legend" + this.id + "' width='100%' border='0' cellspacing='3' cellpadding='0'>";
			
			//delej pro jednotliva temata (skupiny)
			for(var i = 0; i < this.legend.group_list.Length(); i++)
			{
				str_legend += "<tr>";

				if(this.legend.group_list.Item(i).expanded)
				{
					str_legend += "<td><img alt='" + script_messages[23] +"' id='imgFGroup_" + this.id + "_" + this.legend.group_list.Item(i).id + "' onClick='imgFGroup_Click(" + this.id + "," + this.legend.group_list.Item(i).id + ")' src='./DisplayStyle/minus.gif' style='border: 0px; cursor:hand'/><img alt='" + script_messages[25] + "' id='imgFGroupSAll_" + this.id + "_" + this.legend.group_list.Item(i).id + "' onClick='imgFGroupSAll_Click(" + this.id + "," + this.legend.group_list.Item(i).id + ")' src='./DisplayStyle/sall.gif' style='border: 0px; cursor:hand; margin-left:1px;'/><img alt='" + script_messages[26] + "' id='imgFGroupDSAll_" + this.id + "_" + this.legend.group_list.Item(i).id + "' onClick='imgFGroupDSAll_Click(" + this.id + "," + this.legend.group_list.Item(i).id + ")' src='./DisplayStyle/dsall.gif' style='border: 0px; cursor:hand; margin-left:1px;'/></td>";
				}
				else
				{
					str_legend += "<td><img alt='" + script_messages[24] + "' id='imgFGroup_" + this.id + "_" + this.legend.group_list.Item(i).id + "' onClick='imgFGroup_Click(" + this.id + "," + this.legend.group_list.Item(i).id + ")' src='./DisplayStyle/plus.gif' style='border: 0px; cursor:hand'/><img alt='" + script_messages[25] + "' id='imgFGroupSAll_" + this.id + "_" + this.legend.group_list.Item(i).id + "' onClick='imgFGroupSAll_Click(" + this.id + "," + this.legend.group_list.Item(i).id + ")' src='./DisplayStyle/sall.gif' style='border: 0px; cursor:hand; margin-left:1px;'/><img alt='" + script_messages[26] + "' id='imgFGroupDSAll_" + this.id + "_" + this.legend.group_list.Item(i).id + "' onClick='imgFGroupDSAll_Click(" + this.id + "," + this.legend.group_list.Item(i).id + ")' src='./DisplayStyle/dsall.gif' style='border: 0px; cursor:hand; margin-left:1px;'/></td>";
				}

				str_legend += "<td colspan='2' align='left' width='100%'><span class='footerbold'>" + this.legend.group_list.Item(i).title + "</span></td>";
				
				str_legend += "</tr>";

				if(this.legend.group_list.Item(i).expanded)
				{
					str_legend += "<tr id='trFGroup_" + this.id + "_" + this.legend.group_list.Item(i).id + "'><td></td><td colspan='3'>";
				}
				else
				{
					str_legend += "<tr id='trFGroup_" + this.id + "_" + this.legend.group_list.Item(i).id + "' style='display:none'><td></td><td colspan='3'>";
				}

				str_legend += "<table width='100%' border='0' cellspacing='0' cellpadding='0'>";
				
				//delej pro vrstrvy v dane skupine
				for(var j = 0; j < this.legend.group_list.Item(i).layer_list.Length(); j++)
				{
					str_legend += "<tr id='trLayer_" + this.legend.group_list.Item(i).id + "_" + this.legend.group_list.Item(i).layer_list.Item(j).name + "'>"
					
					if(this.legend.group_list.Item(i).layer_list.Item(j).checked)
					{
						if((/*world_width*/ s_actual >= this.legend.group_list.Item(i).layer_list.Item(j).scalemin) && (/*world_width*/ s_actual < this.legend.group_list.Item(i).layer_list.Item(j).scalemax))
						{
							str_legend += "<td><input id='chbFeature_" + this.id + this.legend.group_list.Item(i).id + this.legend.group_list.Item(i).layer_list.Item(j).name + "' type='checkbox' title='" + script_messages[27] + "' value='" + this.id + "|" + this.legend.group_list.Item(i).id + "|" + this.legend.group_list.Item(i).layer_list.Item(j).id + "' checked onClick='chbFeature_Click(this)'></td>";
						}
						else
						{
							str_legend += "<td><input id='chbFeature_" + this.id + this.legend.group_list.Item(i).id + this.legend.group_list.Item(i).layer_list.Item(j).name + "' type='checkbox' title='" + script_messages[27] + "' value='" + this.id + "|" + this.legend.group_list.Item(i).id + "|" + this.legend.group_list.Item(i).layer_list.Item(j).id + "' checked disabled='true'></td>";
						}
					}
					else
					{
						if((/*world_width*/ s_actual >= this.legend.group_list.Item(i).layer_list.Item(j).scalemin) && (/*world_width*/ s_actual < this.legend.group_list.Item(i).layer_list.Item(j).scalemax))
						{
							str_legend += "<td><input id='chbFeature_" + this.id + this.legend.group_list.Item(i).id + this.legend.group_list.Item(i).layer_list.Item(j).name + "' type='checkbox' title='" + script_messages[27] + "' value='" + this.id + "|" + this.legend.group_list.Item(i).id + "|" + this.legend.group_list.Item(i).layer_list.Item(j).id + "' onClick='chbFeature_Click(this)'></td>";
						}
						else
						{
							str_legend += "<td><input id='chbFeature_" + this.id + this.legend.group_list.Item(i).id + this.legend.group_list.Item(i).layer_list.Item(j).name + "' type='checkbox' title='" + script_messages[27] + "' value='" + this.id + "|" + this.legend.group_list.Item(i).id + "|" + this.legend.group_list.Item(i).layer_list.Item(j).id + "' disabled='true'></td>";
						}
					}
										
					if(this.legend.group_list.Item(i).layer_list.Item(j).pic_url != "")
					{
						if((/*world_width*/ s_actual >= this.legend.group_list.Item(i).layer_list.Item(j).scalemin) && (/*world_width*/ s_actual < this.legend.group_list.Item(i).layer_list.Item(j).scalemax))
						{
							str_legend += "<td><img id='imgFeature_" + this.id + this.legend.group_list.Item(i).id + this.legend.group_list.Item(i).layer_list.Item(j).name + "' width='" + this.legend.group_list.Item(i).layer_list.Item(j).pic_width + "' height='" + this.legend.group_list.Item(i).layer_list.Item(j).pic_height + "' src='" + this.legend.group_list.Item(i).layer_list.Item(j).pic_url + "'/></td>";
						}
						else
						{
							str_legend += "<td><img id='imgFeature_" + this.id + this.legend.group_list.Item(i).id + this.legend.group_list.Item(i).layer_list.Item(j).name + "' width='" + this.legend.group_list.Item(i).layer_list.Item(j).pic_width + "' height='" + this.legend.group_list.Item(i).layer_list.Item(j).pic_height + "' src='" + this.legend.group_list.Item(i).layer_list.Item(j).pic_url + "' disabled='true'/></td>";
						}
					}
					else
					{
						str_legend += "<td></td>";
					}
					
					if((/*world_width*/ s_actual >= this.legend.group_list.Item(i).layer_list.Item(j).scalemin) && (/*world_width*/ s_actual < this.legend.group_list.Item(i).layer_list.Item(j).scalemax))
					{
						str_legend += "<td width='100%'><span id='spnFeature_" + this.id + this.legend.group_list.Item(i).id + this.legend.group_list.Item(i).layer_list.Item(j).name + "' class='footernorm' style='margin-left:1px;'>" + this.legend.group_list.Item(i).layer_list.Item(j).title + "</span></td></tr>";
					}
					else
					{
						str_legend += "<td width='100%'><span id='spnFeature_" + this.id + this.legend.group_list.Item(i).id + this.legend.group_list.Item(i).layer_list.Item(j).name + "' class='footernorm' style='margin-left:1px;' disabled='true'>" + this.legend.group_list.Item(i).layer_list.Item(j).title + "</span></td></tr>";
					}
				}
				
				str_legend += "</table>";
						
				str_legend += "</td></tr>";

			}
			
			if(this.legend.layer_list.Length() > 0)
			{
				str_legend += "<tr><td colspan='3'><table width='100%' border='0' cellspacing='0' cellpadding='0'>";
				// delej pro vrstvy co nejsou v zadne skupine
				for(var i = 0; i < this.legend.layer_list.Length(); i++)
				{
					str_legend += "<tr id='trLayer__" + this.legend.layer_list.Item(i).name + "'>"
					
					if(this.legend.layer_list.Item(i).checked)
					{
						if((/*world_width*/ s_actual >= this.legend.layer_list.Item(i).scalemin) && (/*world_width*/ s_actual < this.legend.layer_list.Item(i).scalemax))
						{
							str_legend += "<td><input id='chbFeature_" + this.id + this.legend.layer_list.Item(i).name + "' type='checkbox' title='" + script_messages[27] + "' value='" + this.id + "|-1|" + this.legend.layer_list.Item(i).id + "' checked onClick='chbFeature_Click(this)'></td>";
						}
						else
						{
							str_legend += "<td><input id='chbFeature_" + this.id + this.legend.layer_list.Item(i).name + "' type='checkbox' title='" + script_messages[27] + "' value='" + this.id + "|-1|" + this.legend.layer_list.Item(i).id + "' checked disabled='true'></td>";
						}
					}
					else
					{
						if((/*world_width*/ s_actual >= this.legend.layer_list.Item(i).scalemin) && (/*world_width*/ s_actual < this.legend.layer_list.Item(i).scalemax))
						{
							str_legend += "<td><input id='chbFeature_" + this.id + this.legend.layer_list.Item(i).name + "' type='checkbox' title='" + script_messages[27] + "' value='" + this.id + "|-1|" + this.legend.layer_list.Item(i).id + "' onClick='chbFeature_Click(this)'></td>";
						}
						else
						{
							str_legend += "<td><input id='chbFeature_" + this.id + this.legend.layer_list.Item(i).name + "' type='checkbox' title='" + script_messages[27] + "' value='" + this.id + "|-1|" + this.legend.layer_list.Item(i).id + "' disabled='true'></td>";
						}
					}
						
					if(this.legend.layer_list.Item(i).pic_url != "")
					{
						if((/*world_width*/ s_actual >= this.legend.layer_list.Item(i).scalemin) && (/*world_width*/ s_actual < this.legend.layer_list.Item(i).scalemax))
						{
							str_legend += "<td><img id='imgFeature_" + this.id + this.legend.layer_list.Item(i).name + "' width='" + this.legend.layer_list.Item(i).pic_width + "' height='" + this.legend.layer_list.Item(i).pic_height + "' src='" + this.legend.layer_list.Item(i).pic_url + "'/></td>";
						}
						else
						{
							str_legend += "<td><img id='imgFeature_" + this.id + this.legend.layer_list.Item(i).name + "' width='" + this.legend.layer_list.Item(i).pic_width + "' height='" + this.legend.layer_list.Item(i).pic_height + "' src='" + this.legend.layer_list.Item(i).pic_url + "' disabled='true'/></td>";
						}
					}
					else
					{
						str_legend += "<td></td>";
					}
					
					if((/*world_width*/ s_actual >= this.legend.layer_list.Item(i).scalemin) && (/*world_width*/ s_actual < this.legend.layer_list.Item(i).scalemax))
					{
						str_legend += "<td width='100%'><span id='spnFeature_" + this.id + this.legend.layer_list.Item(i).name + "' class='footernorm' style='margin-left:1px;'>" + this.legend.layer_list.Item(i).title + "</span></td></tr>";
					}
					else
					{
						str_legend += "<td width='100%'><span id='spnFeature_" + this.id + this.legend.layer_list.Item(i).name + "' class='footernorm' style='margin-left:1px;' disabled='true'>" + this.legend.layer_list.Item(i).title + "</span></td></tr>";
					}
				}

				str_legend += "</table></td></tr>";
			}
			
			str_legend += "</table>";
			
			document.getElementById(str_object).innerHTML = str_legend;
		}
		//*******************************************************************************	
		
		this.Check_Defautl_Layers = Check_Defautl_Layers;
		
		function Check_Defautl_Layers()
		{
			for(var i = 0; i < this.default_list.Length(); i++)
			{
				for(var j = 0; j < this.group_list.Length(); j++)
				{
					for(var k = 0; k < this.group_list.Item(j).layer_list.Length(); k++)
					{
					}
				}
			}
		}
		//*******************************************************************************	
		
		this.In_Default_Layers = In_Default_Layers;
		
		function In_Default_Layers(name)
		{
			for(var i = 0; i < this.default_list.Length(); i++)
			{
				if(name == this.default_list.Item(i).name)
				{
					return true;
				}
			}
			return false;
		}
		//*******************************************************************************	

		this.Actualize_LAYERS = Actualize_LAYERS;
		
		function Actualize_LAYERS()
		{
			var layers = "";
			var styles = "";
		
			for(var i = 0; i < this.legend.group_list.Length(); i++)
			{
				for(var j = 0; j < this.legend.group_list.Item(i).layer_list.Length(); j++)
				{
					if(this.legend.group_list.Item(i).layer_list.Item(j).checked)
					{
						layers += this.legend.group_list.Item(i).layer_list.Item(j).name + ",";
						styles += ",";
					}
				}
			}

			for(var i = 0; i < this.legend.layer_list.Length(); i++)
			{
				if(this.legend.layer_list.Item(i).checked)
				{
					layers += this.legend.layer_list.Item(i).name + ",";
					styles += ",";
				}
			}

			layers = layers.substr(0, layers.length - 1);
			styles = styles.substr(0, styles.length - 1);

			this.wms_url = replace_string(this.wms_url, "LAYERS", layers); //ReplaceLAYERS(this.wms_url, layers);
			this.wms_url = replace_string(this.wms_url + "&", "STYLES", styles);
			this.wms_url = this.wms_url.substr(0, this.wms_url.length - 1);
		}
		//*******************************************************************************	

		this.Actualize_DIMENSIONS = Actualize_DIMENSIONS;
		
		function Actualize_DIMENSIONS(width, height)
		{
			this.wms_url = replace_string(this.wms_url, "WIDTH", width);
			this.wms_url = replace_string(this.wms_url, "HEIGHT", height);
			//this.wms_url = this.wms_url.substr(0, this.wms_url.length - 1);
      //this.map_img.src = this.wms_url;
		}
		//*******************************************************************************	

		this.SetOpacity = SetOpacity;
		
		function SetOpacity(o)
		{
			this.opacity = o;

      if(moz)
      {
        this.map_img.style.opacity = this.opacity / 100;
      }
      else
      {
        this.map_img.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=" + this.opacity + ")";
      }

/*      this.map_img.style.filter = "alpha(opacity=" + this.opacity + ")";
      this.map_img.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=" + this.opacity + ")";
      this.map_img.style.MozOpacity = this.opacity / 100;

			this.map_img.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=" + this.opacity + ")";*/
		}
		//*******************************************************************************	

		this.SetImageFormat = SetImageFormat;
		
		function SetImageFormat(image_format)
		{
			this.image_format = image_format;

			this.wms_url = replace_string(this.wms_url + "&", "FORMAT", this.image_format); 

		}
		//*******************************************************************************	

    this.Get_FI_Layers = Get_FI_Layers;
    
    function Get_FI_Layers()
    {
			var layers = "";
		
			for(var i = 0; i < this.legend.group_list.Length(); i++)
			{
				for(var j = 0; j < this.legend.group_list.Item(i).layer_list.Length(); j++)
				{
					if(this.legend.group_list.Item(i).layer_list.Item(j).checked && this.legend.group_list.Item(i).layer_list.Item(j).queryable == 1 )
					{
						layers += this.legend.group_list.Item(i).layer_list.Item(j).name + ",";
					}
				}
			}

			for(var i = 0; i < this.legend.layer_list.Length(); i++)
			{
				if(this.legend.layer_list.Item(i).checked && this.legend.layer_list.Item(i).queryable == 1)
				{
					layers += this.legend.layer_list.Item(i).name + ",";
				}
			}

			layers = layers.substr(0, layers.length - 1);

      return (layers);
    }
		//*******************************************************************************	
    
		this.Get_FeatureInfo = Get_FeatureInfo;
		
		function Get_FeatureInfo(startx, starty)
		{
      if(this.featureinfo && this.featureinfo_selected)
      {
        var url = this.featureinfo_url;

  			var re = /[?]/i;
  			if(url.search(re) != -1)
  			{
          url = url + "&REQUEST=GetFeatureInfo&INFO_FORMAT=" + this.fi_selected_value + "&VERSION=" + this.version + "&X=" + startx + "&Y=" + starty + "&BBOX=" + this.bbox + "&SRS=" + this.srs + "&WIDTH=" + this.width + "&HEIGHT=" + this.height + "&QUERY_LAYERS=" + get_string(this.wms_url, 'LAYERS')
        }
        else
        {
          url = url + "?REQUEST=GetFeatureInfo&INFO_FORMAT=" + this.fi_selected_value + "&VERSION=" + this.version + "&X=" + startx + "&Y=" + starty + "&BBOX=" + this.bbox + "&SRS=" + this.srs + "&WIDTH=" + this.width + "&HEIGHT=" + this.height + "&QUERY_LAYERS=" + get_string(this.wms_url, 'LAYERS')
        }

        var xmlFInfo = AJAX(url, proxy_enabled);
        
      }
    }
		//*******************************************************************************	

	}
	// End of class WMS_server

	// Class WCS_coverage
	function WCS_coverage(id, name, label, description, graphics)
	{
		this.id = id;
		this.name = name;
		this.label = label;
		this.description = description;
		this.graphics = graphics
	}
	// End of class WCS_coverage

	// Class WCS_server
	function WCS_server(id, title, url, opacity, map_width, map_height, map_format, map_srs, map_bbox)
	{
		this.id = id;
		this.version;
		this.title = title;
		this.label;
		this.name;
		this.description;
		this.url = url;
		this.opacity = opacity;
		
		this.width = map_width;
		this.height = map_height;
		this.image_format = map_format;
		this.srs = map_srs;
		this.bbox = map_bbox;
		
		//Kontaktni informace
		this.c_i_name;
		this.c_organization;
		this.c_phone;
		this.c_email;
		this.c_address;
		this.c_city;
		this.c_post_code;
		this.c_country;
		
		//dc url
		this.dc_url;

		//gc url
		this.gc_url;
		
		/*this.map_img = document.createElement("IMG");
		this.map_img.id = "wcs_" + this.id;
    this.map_img.useMap = "#Afeature";
		this.map_img.onload = imgWCS_Load;
		this.map_img.style.position = "absolute";
		this.map_img.style.left = "0px";
		this.map_img.style.top = "0px";
		this.map_img.style.borderWidth = "0px";
		this.map_img.style.zIndex = "0";
    
    if(moz)
    {
      this.map_img.style.opacity = this.opacity / 100;
    }
    else
    {
      this.map_img.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=" + this.opacity + ")";
    }
     		
		this.map_img.style.display = "none";*/

		this.Get_Capabilities = Get_Capabilities;
		
		function Get_Capabilities(default_version)
		{
      var response = '';

      var xml_req;
      
			var xmlCap;
      
      var moz = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined');
      var ie = (typeof window.ActiveXObject != 'undefined'); 
			
			var re = /[?]/i;
			if(this.url.search(re) != -1)
			{
        //sloz XML request
        
        xml_req = this.url + "&REQUEST=GetCapabilities";
        
        if(get_string(xml_req, 'SERVICE') == '')
        {
          xml_req = replace_string(xml_req, 'SERVICE', 'WCS');
          
          if(get_string(xml_req, 'SERVICE') == '')
          {
            xml_req = xml_req + "&SERVICE=WCS";
          }
        }

        if(get_string(xml_req, 'VERSION') == '')
        {
          xml_req = replace_string(xml_req, 'VERSION', default_version);
          
          if(get_string(xml_req, 'VERSION') == '')
          {
            xml_req = xml_req + "&VERSION=" + default_version;
          }
        }

			}
			else
			{
          //sloz XML request
        xml_req = this.url + "?REQUEST=GetCapabilities";
        
        if(get_string(xml_req, 'SERVICE') == '')
        {
          xml_req = replace_string(xml_req, 'SERVICE', 'WCS');
          
          if(get_string(xml_req, 'SERVICE') == '')
          {
            xml_req = xml_req + "&SERVICE=WCS";
          }
        }
        if(get_string(xml_req, 'VERSION') == '')
        {
          xml_req = replace_string(xml_req, 'VERSION', default_version);
          
          if(get_string(xml_req, 'VERSION') == '')
          {
            xml_req = xml_req + "&VERSION=" + default_version;
          }
        }
  		}

      xmlCap = AJAX(xml_req, proxy_enabled);
      
      if (moz)
      { 
  			//Nacti version
        var xpathres = xmlCap.getElementsByTagName("WCS_Capabilities")[0];
        //var xpathres = xmlCap.evaluate("//WCS_Capabilities", xmlCap, null, 9, null);

        this.version = (xpathres != null)?xpathres.getAttribute("version"):"";
        //this.version = (xpathres != null)?xpathres.singleNodeValue.getAttribute("version"):"";

  			//Nacti description
        xpathres = xmlCap.getElementsByTagName("WCS_Capabilities")[0].getElementsByTagName("Service")[0].getElementsByTagName("description")[0];
        this.description = (xpathres != null)?(xpathres.firstChild != null)?xpathres.firstChild.nodeValue:"":"";
        //xpathres = xmlCap.evaluate("//WCS_Capabilities/Service/description", xmlCap, null, 9, null);
  			//this.description = (xpathres != null)?(xpathres.singleNodeValue.firstChild != null)?xpathres.singleNodeValue.firstChild.nodeValue:"":"";

  			//Nacti name
        xpathres = xmlCap.getElementsByTagName("WCS_Capabilities")[0].getElementsByTagName("Service")[0].getElementsByTagName("name")[0];
  			this.name = (xpathres != null)?(xpathres.firstChild != null)?xpathres.firstChild.nodeValue:"":"";
        //xpathres = xmlCap.evaluate("//WCS_Capabilities/Service/name", xmlCap, null, 9, null);
  			//this.name = (xpathres != null)?(xpathres.singleNodeValue.firstChild != null)?xpathres.singleNodeValue.firstChild.nodeValue:"":"";

  			//Nacti label
        xpathres = xmlCap.getElementsByTagName("WCS_Capabilities")[0].getElementsByTagName("Service")[0].getElementsByTagName("label")[0];
  			this.label = (xpathres != null)?(xpathres.firstChild != null)?xpathres.firstChild.nodeValue:"":"";
        //xpathres = xmlCap.evaluate("//WCS_Capabilities/Service/label", xmlCap, null, 9, null);
  			//this.label = (xpathres != null)?(xpathres.singleNodeValue.firstChild != null)?xpathres.singleNodeValue.firstChild.nodeValue:"":"";
        
  			// Nacti contact info
        xpathres = xmlCap.getElementsByTagName("responsibleParty")[0].getElementsByTagName("individualName")[0];
  			this.c_i_name = (xpathres != null)?(xpathres.firstChild != null)?xpathres.firstChild.nodeValue:"":"";
        //xpathres = xmlCap.evaluate("//responsibleParty/individualName", xmlCap, null, 9, null);
  			//this.c_i_name = (xpathres != null)?(xpathres.singleNodeValue.firstChild != null)?xpathres.singleNodeValue.firstChild.nodeValue:"":"";

        xpathres = xmlCap.getElementsByTagName("responsibleParty")[0].getElementsByTagName("organisationName")[0];
  			this.c_organization = (xpathres != null)?(xpathres.firstChild != null)?xpathres.firstChild.nodeValue:"neuvedeno":"neuvedeno";
        //xpathres = xmlCap.evaluate("//responsibleParty/organisationName", xmlCap, null, 9, null);
  			//this.c_organization = (xpathres != null)?(xpathres.singleNodeValue.firstChild != null)?xpathres.singleNodeValue.firstChild.nodeValue:"neuvedeno":"neuvedeno";
  
        xpathres = xmlCap.getElementsByTagName("responsibleParty")[0].getElementsByTagName("contactInfo")[0].getElementsByTagName("address")[0].getElementsByTagName("deliveryPoint")[0];
        //xpathres = xmlCap.evaluate("//responsibleParty/contactInfo/address/deliveryPoint", xmlCap, null, 9, null);
  			try
  			{
          this.c_address = (xpathres != null)?(xpathres.firstChild != null)?xpathres.firstChild.nodeValue:"neuvedeno":"neuvedeno";
          //this.c_address = (xpathres != null)?(xpathres.singleNodeValue.firstChild != null)?xpathres.singleNodeValue.firstChild.nodeValue:"neuvedeno":"neuvedeno";
        }
        catch(e)
        {
          this.c_address = "neuvedeno";
        }
        
        xpathres = xmlCap.getElementsByTagName("responsibleParty")[0].getElementsByTagName("contactInfo")[0].getElementsByTagName("address")[0].getElementsByTagName("city")[0];
        //xpathres = xmlCap.evaluate("//responsibleParty/contactInfo/address/city", xmlCap, null, 9, null);
  			try
  			{
          this.c_city = (xpathres != null)?(xpathres.firstChild != null)?xpathres.firstChild.nodeValue:"neuvedeno":"neuvedeno";
          //this.c_city = (xpathres != null)?(xpathres.singleNodeValue.firstChild != null)?xpathres.singleNodeValue.firstChild.nodeValue:"neuvedeno":"neuvedeno";
        }
        catch(e)
        {
          this.c_city = "neuvedeno";
        }
        
        xpathres = xmlCap.getElementsByTagName("responsibleParty")[0].getElementsByTagName("contactInfo")[0].getElementsByTagName("address")[0].getElementsByTagName("postalCode")[0];
        //xpathres = xmlCap.evaluate("//responsibleParty/contactInfo/address/postalCode", xmlCap, null, 9, null);
  			try
  			{
          this.c_post_code = (xpathres != null)?(xpathres.firstChild != null)?xpathres.firstChild.nodeValue:"neuvedeno":"neuvedeno";
          //this.c_post_code = (xpathres != null)?(xpathres.singleNodeValue.firstChild != null)?xpathres.singleNodeValue.firstChild.nodeValue:"neuvedeno":"neuvedeno";
        }
        catch(e)
        {
          this.c_post_code = "neuvedeno";
        }
        
        xpathres = xmlCap.getElementsByTagName("responsibleParty")[0].getElementsByTagName("contactInfo")[0].getElementsByTagName("address")[0].getElementsByTagName("country")[0];
        //xpathres = xmlCap.evaluate("//responsibleParty/contactInfo/address/country", xmlCap, null, 9, null);
  			try
  			{
          this.c_country = (xpathres != null)?(xpathres.firstChild != null)?xpathres.firstChild.nodeValue:"neuvedeno":"neuvedeno";
          //this.c_country = (xpathres != null)?(xpathres.singleNodeValue.firstChild != null)?xpathres.singleNodeValue.firstChild.nodeValue:"neuvedeno":"neuvedeno";
        }
        catch(e)
        {
          this.c_country = "neuvedeno";
        }
        
        xpathres = xmlCap.getElementsByTagName("responsibleParty")[0].getElementsByTagName("contactInfo")[0].getElementsByTagName("phone")[0].getElementsByTagName("voice")[0];
        //xpathres = xmlCap.evaluate("//responsibleParty/contactInfo/phone/voice", xmlCap, null, 9, null);
  			try
  			{
          this.c_phone = (xpathres != null)?(xpathres.firstChild != null)?xpathres.firstChild.nodeValue:"neuvedeno":"neuvedeno";
          //this.c_phone = (xpathres != null)?(xpathres.singleNodeValue.firstChild != null)?xpathres.singleNodeValue.firstChild.nodeValue:"neuvedeno":"neuvedeno";
        }
        catch(e)
        {
          this.c_phone = "neuvedeno";
        }
        
        xpathres = xmlCap.getElementsByTagName("responsibleParty")[0].getElementsByTagName("contactInfo")[0].getElementsByTagName("address")[0].getElementsByTagName("electronicMailAddress")[0];
        //xpathres = xmlCap.evaluate("//responsibleParty/contactInfo/address/electronicMailAddress", xmlCap, null, 9, null);
  			try
  			{
          this.c_email = (xpathres != null)?(xpathres.firstChild != null)?xpathres.firstChild.nodeValue:"neuvedeno":"neuvedeno";
          //this.c_email = (xpathres != null)?(xpathres.singleNodeValue.firstChild != null)?xpathres.singleNodeValue.firstChild.nodeValue:"neuvedeno":"neuvedeno";
        }
        catch(e)
        {
          this.c_email = "neuvedeno";
        }

        // nacti url adresy
        xpathres = xmlCap.getElementsByTagName("GetCoverage")[0].getElementsByTagName("DCPType")[0].getElementsByTagName("HTTP")[0].getElementsByTagName("Get")[0].getElementsByTagName("OnlineResource")[0];
        //xpathres = xmlCap.evaluate("//GetCoverage/DCPType/HTTP/Get/OnlineResource", xmlCap, null, 9, null);
  			this.gc_url = (xpathres != null)?xpathres.getAttributeNS("http://www.w3.org/1999/xlink", "href"):"";
  			//this.gc_url = (xpathres != null)?xpathres.singleNodeValue.getAttributeNS("http://www.w3.org/1999/xlink", "href"):"";

        xpathres = xmlCap.getElementsByTagName("DescribeCoverage")[0].getElementsByTagName("DCPType")[0].getElementsByTagName("HTTP")[0].getElementsByTagName("Get")[0].getElementsByTagName("OnlineResource")[0];
        //xpathres = xmlCap.evaluate("//DescribeCoverage/DCPType/HTTP/Get/OnlineResource", xmlCap, null, 9, null);
  			this.dc_url = (xpathres != null)?xpathres.getAttributeNS("http://www.w3.org/1999/xlink", "href"):"";
  			//this.dc_url = (xpathres != null)?xpathres.singleNodeValue.getAttributeNS("http://www.w3.org/1999/xlink", "href"):"";

  			// nacti coverages
        xpathres = xmlCap.getElementsByTagName("ContentMetadata")[0].getElementsByTagName("CoverageOfferingBrief");
        //xpathres = xmlCap.evaluate("//ContentMetadata/CoverageOfferingBrief", xmlCap, null, 7, null);
  			for(var i = 0; i < xpathres.length; i++)
  			{
  				/*var xmlName = xpathres.snapshotItem(i).getElementsByTagName("name")[0].firstChild;
  				var xmlLabel = xmlNodes.snapshotItem(i).getElementsByTagName("label")[0].firstChild;
  				var xmlDescription = xmlNodes.snapshotItem(i).getElementsByTagName("description")[0].firstChild;*/
  						
  				var name = xpathres[i].getElementsByTagName("name")[0].firstChild.nodeValue;
  				var label = xpathres[i].getElementsByTagName("label")[0].firstChild.nodeValue;
  				var description = xpathres[i].getElementsByTagName("description")[0].firstChild.nodeValue;
  				var xmlGraphics = xpathres[i].getElementsByTagName("legendLink")[0].firstChild;

  				var graphics;
  				
  				if(xmlGraphics != null)
  				{
            graphics = xmlGraphics.nodeValue;
          }
          else
          {
            graphics = "";
          }
          var m_coverage = new WCS_coverage(i, name, label, description, graphics);
  				
  				this.Add_Coverage(m_coverage);
  			}

      }
      else if (ie) 
      { 
  			//Nacti version
  			var xmlNode = xmlCap.selectSingleNode("//WCS_Capabilities");
  			this.version = (xmlNode != null)?xmlNode.getAttribute("version"):"";
  
  			//Nacti description
  			xmlNode = xmlCap.selectSingleNode("//WCS_Capabilities/Service/description");
  			this.description = (xmlNode != null)?xmlNode.text:"";

  			//Nacti name
  			xmlNode = xmlCap.selectSingleNode("//WCS_Capabilities/Service/name");
  			this.name = (xmlNode != null)?xmlNode.text:"";
  
  			//Nacti label
  			xmlNode = xmlCap.selectSingleNode("//WCS_Capabilities/Service/label");
  			this.label = (xmlNode != null)?xmlNode.text:"";
  			
  			// Nacti contact info
  			xmlNode = xmlCap.selectSingleNode("//responsibleParty/individualName");
  			this.c_i_name = (xmlNode != null)?xmlNode.text:"";

  			xmlNode = xmlCap.selectSingleNode("//responsibleParty/organisationName");
  			this.c_organization = (xmlNode != null)?xmlNode.text:"neuvedeno";
  
  			xmlNode = xmlCap.selectSingleNode("//responsibleParty/contactInfo/address/deliveryPoint");
  			this.c_address = (xmlNode != null)?xmlNode.text:"neuvedeno";
  
  			xmlNode = xmlCap.selectSingleNode("//responsibleParty/contactInfo/address/city");
  			this.c_city = (xmlNode != null)?xmlNode.text:"neuvedeno";
  
  			xmlNode = xmlCap.selectSingleNode("//responsibleParty/contactInfo/address/postalCode");
  			this.c_post_code = (xmlNode != null)?xmlNode.text:"neuvedeno";
  
  			xmlNode = xmlCap.selectSingleNode("//responsibleParty/contactInfo/address/country");
  			this.c_country = (xmlNode != null)?xmlNode.text:"neuvedeno";
  
  			xmlNode = xmlCap.selectSingleNode("//responsibleParty/contactInfo/phone/voice");
  			this.c_phone = (xmlNode != null)?xmlNode.text:"neuvedeno";
  
  			xmlNode = xmlCap.selectSingleNode("//responsibleParty/contactInfo/address/electronicMailAddress");
  			this.c_email = (xmlNode != null)?xmlNode.text:"neuvedeno";
  
  			// nacti url adresy
  			xmlNode = xmlCap.selectSingleNode("//GetCoverage/DCPType/HTTP/Get/OnlineResource");
  			this.gc_url = (xmlNode != null)?xmlNode.getAttribute("xlink:href"):"";
  
  			xmlNode = xmlCap.selectSingleNode("//DescribeCoverage/DCPType/HTTP/Get/OnlineResource");
  			this.dc_url = (xmlNode != null)?xmlNode.getAttribute("xlink:href"):"";

  			// nacti coverages
        var xmlNodes = xmlCap.selectNodes("//ContentMetadata/CoverageOfferingBrief");
  			for(var i = 0; i < xmlNodes.length; i++)
  			{
  				var xmlName = xmlNodes.item(i).selectSingleNode("./name");
  				var xmlLabel = xmlNodes.item(i).selectSingleNode("./label");
  				var xmlDescription = xmlNodes.item(i).selectSingleNode("./description");
  				var xmlGraphics = xmlNodes.item(i).selectSingleNode("./legendLink");
  						
  				var	name = xmlName.text;
  				var	label = xmlLabel.text;
  				var	description = xmlDescription.text;
  				var	graphics;
          
          if(xmlGraphics != null)
          {
            graphics = xmlGraphics.text;
          }
          else
          {
            graphics = "";
          }

          var m_coverage = new WCS_coverage(i, name, label, description, graphics);
  				
  				this.Add_Coverage(m_coverage);
  			}

      }//end if IE
      
			return(true);
			
		}
		//*******************************************************************************	

		// CAST COVERAGE
		this.coverage_list = new Collection();
		
		this.Add_Coverage = Add_Coverage;
		
		function Add_Coverage(coverage)
		// Funkce pro pridani COVERAGE
		{
			this.coverage_list.Add(coverage);
		}
		//*******************************************************************************	

		this.Write_Coverages = Write_Coverages;
		
		function Write_Coverages(str_object)
		// Funkce vypise seznam Formatu do listboxu
		{
			
			var c_string = ""
			
      if(this.coverage_list.Length() > 0)
			{
  			c_string = "<SELECT id='cmbWCS_Coverages' class='vyber' style='width:300px;'>";
  			
        for(var i = 0; i < this.coverage_list.Length(); i++)
  			{
  				if(i == 0)
  				{
  					c_string += "<option value='" + this.coverage_list.Item(i).id + "' selected>" + this.coverage_list.Item(i).name + "</option>";
  				}
  				else
  				{
  					c_string += "<option value='" + this.coverage_list.Item(i).id + "'>" + this.coverage_list.Item(i).name + "</option>";
          }
  			}
  			c_string += "</SELECT>";
      }
      else
      {
        c_string = "<SELECT id='cmbWCS_Coverages' class='vyber' style='width:300px;'><OPTION>Nejsou k dispozici zadna pokryti</OPTION></SELECT>";
      }
      
      document.getElementById(str_object).innerHTML = c_string;			
		}
		//*******************************************************************************	

	}
	// End of class WCS_server

	// Class CMS_server (ClickMap)
	function CMS_server(id, url, layer, selected, expanded, map_width, map_height, map_srs, map_bbox)
	{
		this.expanded = expanded;
		this.id = id;
		this.version;
		this.name;
		this.title;
		this.url = url;
		this.selected = selected;
		
		this.width = map_width;
		this.height = map_height;
		this.srs = map_srs;
		this.bbox = map_bbox;
		
		//cms url
		this.cms_url;
		this.cms_layer = layer;
		
		this.legend = new WMS_legend(this.id);

		//this.clmap = document.getElementById("ClickMap");
    
		// CAST DEFAULT CMS LAYERS				
		this.default_list = new Collection();
		
		this.Add_Default_Layer = Add_Default_Layer;
		
		function Add_Default_Layer(default_layer)
		// Funkce pro pridani defaultni vrstvy
		{
			this.default_list.Add(default_layer);
		}
		//*******************************************************************************	
		
		// CAST SRS
		this.srs_list = new Collection();
		
		this.Add_Srs = Add_Srs;
		
		function Add_Srs(srs)
		// Funkce pro pridani SRS mapy
		{
			this.srs_list.Add(srs);
		}
		//*******************************************************************************	

		this.Get_Capabilities = Get_Capabilities;
		
		function Get_Capabilities(default_version)
		{
      var response = '';

      var xml_req;
      
			var xmlCap;
      
      var moz = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined');
      var ie = (typeof window.ActiveXObject != 'undefined'); 
			
			var re = /[?]/i;
		
    	if(this.url.search(re) != -1)
			{
        //sloz XML request
        
        xml_req = this.url + "&REQUEST=GetCapabilities";
        
        if(get_string(xml_req, 'VERSION') == '')
        {
          xml_req = replace_string(xml_req, 'VERSION', default_version);
          
          if(get_string(xml_req, 'VERSION') == '')
          {
            xml_req = xml_req + "&VERSION=" + default_version;
          }
        }

			}
			else
			{
          //sloz XML request
        xml_req = this.url + "?REQUEST=GetCapabilities";
        
        if(get_string(xml_req, 'VERSION') == '')
        {
          xml_req = replace_string(xml_req, 'VERSION', default_version);
          
          if(get_string(xml_req, 'VERSION') == '')
          {
            xml_req = xml_req + "&VERSION=" + default_version;
          }
        }
  		}

      xmlCap = AJAX(xml_req, proxy_enabled);

      if (moz)
      { 
  			//Nacti version
        var xpathres = xmlCap.evaluate("//CMS_Capabilities", xmlCap, null, 9, null);

        this.version = (xpathres != null)?xpathres.singleNodeValue.getAttribute("version"):"";

  			//Nacti name
        xpathres = xmlCap.evaluate("//CMS_Capabilities/Service/Name", xmlCap, null, 9, null);
  			this.name = (xpathres != null)?(xpathres.singleNodeValue.firstChild != null)?xpathres.singleNodeValue.firstChild.nodeValue:"":"";

  			//Nacti title
        xpathres = xmlCap.evaluate("//CMS_Capabilities/Service/Title", xmlCap, null, 9, null);
  			this.title = (xpathres != null)?xpathres.singleNodeValue.firstChild.nodeValue:"";
        
        // nacti url adresy
        xpathres = xmlCap.evaluate("//GetClickMap/DCPType/HTTP/Get/OnlineResource", xmlCap, null, 9, null);
  			this.cms_url = (xpathres != null)?xpathres.singleNodeValue.getAttributeNS("http://www.w3.org/1999/xlink", "href"):"";

  			// nacti srs
        xpathres = xmlCap.evaluate("//Layer/SRS", xmlCap, null, 7, null);
       	var re_srs = new RegExp(" ", "i");
        
        for(var i = 0; i < xpathres.snapshotLength; i++)
        {
          var srs_a = xpathres.snapshotItem(i).firstChild.nodeValue.split(" ");
    			for(var j = 0; j < srs_a.length; j++)
    			{
    					if(srs_a[j].replace(re_srs, "") != '')
    					{
                var srs = new Srs(srs_a[j]);
                this.Add_Srs(srs);
              }
    			}			   
        }
        
  			//pokud toto neni prvni sever, zjisti jestli je v podporovanych souradnych systemech jiz zvoleny
  			var s_system = false;
  			for(var i = 0; i < this.srs_list.Length(); i++)
  			{
  				if(this.srs_list.Item(i).value.toLowerCase() == this.srs.toLowerCase())
  				{
  					s_system = true;
  				}
  			}
  			
  			if(!s_system)
  			{
  				alert(script_messages[2]);
  				return(false);
  			}

  			//nacti skupiny
        xmlNodes = xmlCap.evaluate("/CMS_Capabilities/Capability/Layer/Layer", xmlCap, null, 7, null);
  			
  			var groups = 0;

  			for (var i = 0; i < xmlNodes.snapshotLength; i++)
  			{
          var xmlFNodes = xmlCap.evaluate("./Layer", xmlNodes.snapshotItem(i), null, 7, null); //xpathres.snapshotItem(i).firstChild.nodeValue.getElementsByTagName("Layer");
  				// obsahuje podvrstvy, je to tedy skupina
  				if (xmlFNodes.snapshotLength > 0)
  				{
  					var title, name, min_scale, max_scale;
  										
            var m_group = new WMS_group(groups, xmlNodes.snapshotItem(i).getElementsByTagName("Title")[0].firstChild.nodeValue,0);
  					
  					for(var j = 0; j < xmlFNodes.snapshotLength; j++)
  					{
              var xmlTitle = xmlFNodes.snapshotItem(j).getElementsByTagName("Title")[0].firstChild;
  						var xmlName = xmlFNodes.snapshotItem(j).getElementsByTagName("Name")[0].firstChild;
  						
  						title = xmlTitle.nodeValue;
  						name = xmlName.nodeValue;
  						
  						var xmlScale = xmlFNodes.snapshotItem(j).getElementsByTagName("ScaleHint")[0];
  
    					if(xmlScale != null)
    					{	
           			min_scale = (xmlScale != null)?xmlScale.getAttribute("min"):"";
      					max_scale = (xmlScale != null)?xmlScale.getAttribute("max"):"";
      						
      					if (min_scale == "" )
      					{
      						min_scale = 0;
      					}
      						
      					if (max_scale == "" )
      					{
      						max_scale = 9999999999;
      					}
              }
              else
              {
      						min_scale = 0;
      						max_scale = 9999999999;
              }
  
  						var selected = this.In_Default_Layers(name);
  						
  						var m_layer = new CMS_layer(j, title, name, min_scale, max_scale, selected);
  
  						m_group.Add_Layer(m_layer);					
  					}	
  					
  					this.legend.Add_Group(m_group);
  					
  					groups++;
  
  				}
  			}

  			for (var i = 0; i < xmlNodes.snapshotLength; i++)
  			{
  				var xmlFNodes = xmlCap.evaluate("./Layer", xmlNodes.snapshotItem(i), null, 7, null);

  				// neobsahuje podvrstvy, je to tedy vrstva
  				if (xmlFNodes.snapshotLength == 0)
  				{
  					var title, name, min_scale, max_scale;
  										
  					var xmlTitle = xmlNodes.snapshotItem(i).getElementsByTagName("Title")[0].firstChild;
  					var xmlName = xmlNodes.snapshotItem(i).getElementsByTagName("Name")[0].firstChild;
  						
  					title = xmlTitle.nodeValue;
  					name = xmlName.nodeValue;
  						
  					var xmlScale = xmlNodes.snapshotItem(i).getElementsByTagName("ScaleHint")[0];
  
  					if(xmlScale != null)
  					{	
         			min_scale = (xmlScale != null)?xmlScale.getAttribute("min"):"";
    					max_scale = (xmlScale != null)?xmlScale.getAttribute("max"):"";
    						
    					if (min_scale == "" )
    					{
    						min_scale = 0;
    					}
    						
    					if (max_scale == "" )
    					{
    						max_scale = 9999999999;
    					}
            }
            else
            {
    						min_scale = 0;
    						max_scale = 9999999999;
            }
            											
            var selected = this.In_Default_Layers(name);
  
  					var m_layer = new CMS_layer(i, title, name, min_scale, max_scale, selected);
  
  					this.legend.Add_Layer(m_layer);					
  				}	
  					
  			}
      }
      else if (ie) 
      { 
  			//Nacti version
  			var xmlNode = xmlCap.selectSingleNode("//CMS_Capabilities");
  			this.version = (xmlNode != null)?xmlNode.getAttribute("version"):"";
  
  			//Nacti name
  			xmlNode = xmlCap.selectSingleNode("//CMS_Capabilities/Service/Name");
  			this.name = (xmlNode != null)?xmlNode.text:"";
  
  			//Nacti title
  			xmlNode = xmlCap.selectSingleNode("//CMS_Capabilities/Service/Title");
  			this.title = (xmlNode != null)?xmlNode.text:"";
  			
  			// nacti url adresy
  			xmlNode = xmlCap.selectSingleNode("//GetClickMap/DCPType/HTTP/Get/OnlineResource");
  			this.cms_url = (xmlNode != null)?xmlNode.getAttribute("xlink:href"):"";
  
  			// nacti srs
  			xmlNodes = xmlCap.selectNodes("//Layer/SRS");
  			
  			for(var i = 0; i < xmlNodes.length; i++)
  			{
          var srs_a = xmlNodes.item(i).text.split(" ");
    			for(var j = 0; j < srs_a.length; j++)
    			{
    					var srs = new Srs(srs_a[j]);
    					this.Add_Srs(srs);
    			}			   
        }
  
  			//pokud toto neni prvni sever, zjisti jestli je v podporovanych souradnych systemech jiz zvoleny
  			var s_system = false;
  			for(var i = 0; i < this.srs_list.Length(); i++)
  			{
  				if(this.srs_list.Item(i).value.toLowerCase() == this.srs.toLowerCase())
  				{
  					s_system = true;
  				}
  			}
  			
  			if(!s_system)
  			{
  				alert(script_messages[2]);
  				return(false);
  			}
  			
  			//nacti skupiny
  			var xmlNodes = xmlCap.selectNodes("/CMS_Capabilities/Capability/Layer/Layer");
  			
  			var groups = 0;
  			
  			for (var i = 0; i < xmlNodes.length; i++)
  			{
  				var xmlFNodes = xmlNodes.item(i).selectNodes("./Layer");
  		
  				// obsahuje podvrstvy, je to tedy skupina
  				if (xmlFNodes.length > 0)
  				{
  					var title, name, min_scale, max_scale;
  										
  					var m_group = new WMS_group(groups, xmlNodes.item(i).selectSingleNode("./Title").text,0);
  					
  					for(var j = 0; j < xmlFNodes.length; j++)
  					{
  						var xmlTitle = xmlFNodes.item(j).selectSingleNode("./Title");
  						var xmlName = xmlFNodes.item(j).selectSingleNode("./Name");
  						
  						title = xmlTitle.text;
  						name = xmlName.text;
  						
  						var xmlScale = xmlFNodes.item(j).selectSingleNode("./ScaleHint");
  
    					if(xmlScale != null)
    					{	
           			min_scale = (xmlScale != null)?xmlScale.getAttribute("min"):"";
      					max_scale = (xmlScale != null)?xmlScale.getAttribute("max"):"";
      						
      					if (min_scale == "" )
      					{
      						min_scale = 0;
      					}
      						
      					if (max_scale == "" )
      					{
      						max_scale = 9999999999;
      					}
              }
              else
              {
      						min_scale = 0;
      						max_scale = 9999999999;
              }
  
  						var selected = this.In_Default_Layers(name);
  						
  						var m_layer = new CMS_layer(j, title, name, min_scale, max_scale, selected);
  
  						m_group.Add_Layer(m_layer);					
  					}	
  					
  					this.legend.Add_Group(m_group);
  					
  					groups++;
  
  				}
  			}
  
  			for (var i = 0; i < xmlNodes.length; i++)
  			{
  				var xmlFNodes = xmlNodes.item(i).selectNodes("./Layer");
  		
  				// obsahuje podvrstvy, je to tedy skupina
  				if (xmlFNodes.length == 0)
  				{
  					var title, name, min_scale, max_scale;
  										
  					var xmlTitle = xmlNodes.item(i).selectSingleNode("./Title");
  					var xmlName = xmlNodes.item(i).selectSingleNode("./Name");
  						
  					title = xmlTitle.text;
  					name = xmlName.text;
  						
  					var xmlScale = xmlNodes.item(i).selectSingleNode("./ScaleHint");
  
  					if(xmlScale != null)
  					{	
         			min_scale = (xmlScale != null)?xmlScale.getAttribute("min"):"";
    					max_scale = (xmlScale != null)?xmlScale.getAttribute("max"):"";
    						
    					if (min_scale == "" )
    					{
    						min_scale = 0;
    					}
    						
    					if (max_scale == "" )
    					{
    						max_scale = 9999999999;
    					}
            }
            else
            {
    						min_scale = 0;
    						max_scale = 9999999999;
            }
            											
  					var selected = this.In_Default_Layers(name);
  
  					var m_layer = new CMS_layer(i, title, name, min_scale, max_scale);
  
  					this.legend.Add_Layer(m_layer);					
  				}	
  					
  			}
      }//end if IE
      
			if(this.cms_url.search(re) != -1)
			{
        if(this.cms_url.charAt(this.cms_url.length-1) == "&")
        {
    			this.cms_url = this.cms_url + "REQUEST=GetClickMap&VERSION=" + this.version + "&FORMAT=text/xml&SRS=" + this.srs + "&BBOX=" + this.bbox + "&WIDTH=" + this.width + "&HEIGHT=" + this.height;
        }
        else
        {
    			this.cms_url = this.cms_url + "&REQUEST=GetClickMap&VERSION=" + this.version + "&FORMAT=text/xml&SRS=" + this.srs + "&BBOX=" + this.bbox + "&WIDTH=" + this.width + "&HEIGHT=" + this.height;
        }
			}
			else
			{
   			this.cms_url = this.cms_url + "?REQUEST=GetClickMap&VERSION=" + this.version + "&FORMAT=text/xml&SRS=" + this.srs + "&BBOX=" + this.bbox + "&WIDTH=" + this.width + "&HEIGHT=" + this.height;
			}
		
			var layers = "";
			for(var i = 0; i < this.default_list.Length(); i++)
			{
				layers += this.default_list.Item(i).name + ",";
			}
			layers = layers.substr(0, layers.length - 1);
			
			this.cms_url += "&LAYERS=" + layers;
			
			//this.map_img.src = this.wms_url;
			//prompt("",this.cms_url);
			
			return(true);
			
		}
		//*******************************************************************************	
		
		this.Write_Legend = Write_Legend;
		
		function Write_Legend(str_object)
		{
			var BBoxArray = new Array();
			
			BBoxArray = map_list.maps.Item(map_list.map_id).bbox.split(',');
			
			var world_width = BBoxArray[2] - BBoxArray[0];
			var s_actual = ((((world_width * map_list.maps.Item(map_list.map_id).projection_to_scale) / this.width) * 100) * (280/10));
			var str_legend = "<table id='tblCMS_Legend" + this.id + "' width='100%' border='0' cellspacing='3' cellpadding='0'>";
			
			//delej pro jednotliva temata (skupiny)
			for(var i = 0; i < this.legend.group_list.Length(); i++)
			{
				str_legend += "<tr>";

				if(this.legend.group_list.Item(i).expanded)
				{
					str_legend += "<td><img id='imgCFGroup_" + this.id + "_" + this.legend.group_list.Item(i).id + "' onClick='imgCFGroup_Click(" + this.id + "," + this.legend.group_list.Item(i).id + ")' src='./DisplayStyle/minus.gif' style='border: 0px; cursor:hand'/></td>";
				}
				else
				{
					str_legend += "<td><img id='imgCFGroup_" + this.id + "_" + this.legend.group_list.Item(i).id + "' onClick='imgCFGroup_Click(" + this.id + "," + this.legend.group_list.Item(i).id + ")' src='./DisplayStyle/plus.gif' style='border: 0px; cursor:hand'/></td>";
				}

				str_legend += "<td colspan='2' align='left' width='100%'><span class='footerbold'>" + this.legend.group_list.Item(i).title + "</span></td>";
				
				str_legend += "</tr>";

				if(this.legend.group_list.Item(i).expanded)
				{
					str_legend += "<tr id='trCFGroup_" + this.id + "_" + this.legend.group_list.Item(i).id + "'><td></td><td colspan='2'>";
				}
				else
				{
					str_legend += "<tr id='trCFGroup_" + this.id + "_" + this.legend.group_list.Item(i).id + "' style='display:none'><td></td><td colspan='3'>";
				}

				str_legend += "<table width='100%' border='0' cellspacing='0' cellpadding='0'>";
				
				//delej pro vrstrvy v dane skupine
				for(var j = 0; j < this.legend.group_list.Item(i).layer_list.Length(); j++)
				{
					str_legend += "<tr id='trCLayer_" + this.legend.group_list.Item(i).id + "_" + this.legend.group_list.Item(i).layer_list.Item(j).name + "'>"
					
					if(this.legend.group_list.Item(i).layer_list.Item(j).name == this.cms_layer)
					{
						if((s_actual >= this.legend.group_list.Item(i).layer_list.Item(j).scalemin) && (s_actual < this.legend.group_list.Item(i).layer_list.Item(j).scalemax))
						{
							str_legend += "<td><input name='rdbClickMap' id='rdbCFeature_" + this.id + this.legend.group_list.Item(i).id + this.legend.group_list.Item(i).layer_list.Item(j).name + "' type='radio' title='" + script_messages[27] + "' value='" + this.id + "|" + this.legend.group_list.Item(i).id + "|" + this.legend.group_list.Item(i).layer_list.Item(j).id + "' checked onClick='rdbCFeature_Click(this)'></td>";
						}
						else
						{
							str_legend += "<td><input name='rdbClickMap' id='rdbCFeature_" + this.id + this.legend.group_list.Item(i).id + this.legend.group_list.Item(i).layer_list.Item(j).name + "' type='radio' title='" + script_messages[27] + "' value='" + this.id + "|" + this.legend.group_list.Item(i).id + "|" + this.legend.group_list.Item(i).layer_list.Item(j).id + "' checked disabled='true'></td>";
						}
					}
					else
					{
						if((s_actual >= this.legend.group_list.Item(i).layer_list.Item(j).scalemin) && (s_actual < this.legend.group_list.Item(i).layer_list.Item(j).scalemax))
						{
							str_legend += "<td><input name='rdbClickMap' id='rdbCFeature_" + this.id + this.legend.group_list.Item(i).id + this.legend.group_list.Item(i).layer_list.Item(j).name + "' type='radio' title='" + script_messages[27] + "' value='" + this.id + "|" + this.legend.group_list.Item(i).id + "|" + this.legend.group_list.Item(i).layer_list.Item(j).id + "' onClick='rdbCFeature_Click(this)'></td>";
						}
						else
						{
							str_legend += "<td><input name='rdbClickMap' id='rdbCFeature_" + this.id + this.legend.group_list.Item(i).id + this.legend.group_list.Item(i).layer_list.Item(j).name + "' type='radio' title='" + script_messages[27] + "' value='" + this.id + "|" + this.legend.group_list.Item(i).id + "|" + this.legend.group_list.Item(i).layer_list.Item(j).id + "' disabled='true'></td>";
						}
					}
										
					if((s_actual >= this.legend.group_list.Item(i).layer_list.Item(j).scalemin) && (s_actual < this.legend.group_list.Item(i).layer_list.Item(j).scalemax))
					{
						str_legend += "<td width='100%'><span id='spnCFeature_" + this.id + this.legend.group_list.Item(i).id + this.legend.group_list.Item(i).layer_list.Item(j).name + "' class='footernorm' style='margin-left:1px;'>" + this.legend.group_list.Item(i).layer_list.Item(j).title + "</span></td></tr>";
					}
					else
					{
						str_legend += "<td width='100%'><span id='spnCFeature_" + this.id + this.legend.group_list.Item(i).id + this.legend.group_list.Item(i).layer_list.Item(j).name + "' class='footernorm' style='margin-left:1px;' disabled='true'>" + this.legend.group_list.Item(i).layer_list.Item(j).title + "</span></td></tr>";
					}
				}
				
				str_legend += "</table>";
						
				str_legend += "</td></tr>";

			}
			
			if(this.legend.layer_list.Length() > 0)
			{
				str_legend += "<tr><td colspan='2'><table width='100%' border='0' cellspacing='0' cellpadding='0'>";
				// delej pro vrstvy co nejsou v zadne skupine
				for(var i = 0; i < this.legend.layer_list.Length(); i++)
				{
					str_legend += "<tr id='trCLayer__" + this.legend.layer_list.Item(i).name + "'>"
					if(this.legend.layer_list.Item(i).name == this.cms_layer)
					{
						if((s_actual >= this.legend.layer_list.Item(i).scalemin) && (s_actual < this.legend.layer_list.Item(i).scalemax))
						{
							str_legend += "<td><input name='rdbClickMap' id='rdbCFeature_" + this.id + this.legend.layer_list.Item(i).name + "' type='radio' title='" + script_messages[27] + "' value='" + this.id + "|-1|" + this.legend.layer_list.Item(i).id + "' checked onClick='rdbCFeature_Click(this)'></td>";
						}
						else
						{
							str_legend += "<td><input name='rdbClickMap' id='rdbCFeature_" + this.id + this.legend.layer_list.Item(i).name + "' type='radio' title='" + script_messages[27] + "' value='" + this.id + "|-1|" + this.legend.layer_list.Item(i).id + "' checked disabled='true'></td>";
						}
					}
					else
					{
						if((s_actual >= this.legend.layer_list.Item(i).scalemin) && (s_actual < this.legend.layer_list.Item(i).scalemax))
						{
							str_legend += "<td><input name='rdbClickMap' id='rdbCFeature_" + this.id + this.legend.layer_list.Item(i).name + "' type='radio' title='" + script_messages[27] + "' value='" + this.id + "|-1|" + this.legend.layer_list.Item(i).id + "' onClick='rdbCFeature_Click(this)'></td>";
						}
						else
						{
							str_legend += "<td><input name='rdbClickMap' id='rdbCFeature_" + this.id + this.legend.layer_list.Item(i).name + "' type='radio' title='" + script_messages[27] + "' value='" + this.id + "|-1|" + this.legend.layer_list.Item(i).id + "' disabled='true'></td>";
						}
					}
						
					if((s_actual >= this.legend.layer_list.Item(i).scalemin) && (s_actual < this.legend.layer_list.Item(i).scalemax))
					{
						str_legend += "<td width='100%'><span id='spnCFeature_" + this.id + this.legend.layer_list.Item(i).name + "' class='footernorm' style='margin-left:1px;'>" + this.legend.layer_list.Item(i).title + "</span></td></tr>";
					}
					else
					{
						str_legend += "<td width='100%'><span id='spnCFeature_" + this.id + this.legend.layer_list.Item(i).name + "' class='footernorm' style='margin-left:1px;' disabled='true'>" + this.legend.layer_list.Item(i).title + "</span></td></tr>";
					}
				}

				str_legend += "</table></td></tr>";
			}
			
			str_legend += "</table>";
			
			document.getElementById(str_object).innerHTML = str_legend;
		}
		//*******************************************************************************	
		
		this.Check_Defautl_Layers = Check_Defautl_Layers;
		
		function Check_Defautl_Layers()
		{
			for(var i = 0; i < this.default_list.Length(); i++)
			{
				for(var j = 0; j < this.group_list.Length(); j++)
				{
					for(var k = 0; k < this.group_list.Item(j).layer_list.Length(); k++)
					{
					}
				}
			}
		}
		//*******************************************************************************	
		
		this.In_Default_Layers = In_Default_Layers;
		
		function In_Default_Layers(name)
		{
			for(var i = 0; i < this.default_list.Length(); i++)
			{
				if(name == this.default_list.Item(i).name)
				{
					return true;
				}
			}
			return false;
		}
		//*******************************************************************************	

		this.Actualize_LAYERS = Actualize_LAYERS;
		
		function Actualize_LAYERS()
		{
			this.cms_url = replace_string(this.cms_url + "&", "LAYERS", this.cms_layer); //ReplaceLAYERS(this.wms_url, layers);
			this.cms_url = this.cms_url.substr(0, this.cms_url.length - 1);
		}
		//*******************************************************************************	

		this.Actualize_DIMENSIONS = Actualize_DIMENSIONS;
		
		function Actualize_DIMENSIONS(width, height)
		{
			this.cms_url = replace_string(this.cms_url, "WIDTH", width);
			this.cms_url = replace_string(this.cms_url, "HEIGHT", height);
		}
		//*******************************************************************************	

		this.GetClickMap = GetClickMap;
		
		function GetClickMap()
		{
      
      document.getElementById("divWait").style.display = "";
      var xmlResponse = AJAX(this.cms_url, proxy_enabled);

      document.getElementById("divClickMap").innerHTML = "";
			/*for(var i = document.getElementById("divClickMap").childNodes.length-1; i >= 0; i--)
			{
        document.getElementById("divClickMap").removeChild(document.getElementById("divClickMap").childNodes.item(i));
			}*/

      if(moz)
      {
        var xmlNode = xmlResponse.evaluate("//MAP", xmlResponse, null, 9, null);

    		if (xmlNode != null)
    		{
          var s = new XMLSerializer();
//alert(s.serializeToString(xmlNode.singleNodeValue));
          //document.getElementById("ClickMap").outerHTML = s.serializeToString(xmlNode.singleNodeValue);
          //document.getElementById("divClickMap").innerHTML = s.serializeToString(xmlNode.singleNodeValue);
          document.getElementById("divClickMap").innerHTML = s.serializeToString(xmlNode.singleNodeValue);
        }
      }
      else
      {
        var xmlNode = xmlResponse.selectSingleNode("MAP");
    	
    		if (xmlNode != null)
    		{
          document.getElementById("divClickMap").innerHTML = xmlNode.xml;
    		}
    	}      

      document.getElementById("divWait").style.display = "none";

    }
		//*******************************************************************************	

	}
	// End of class CMS_server
	
		// Class Map
	function Map(id, title, srs, bbox, projection_to_scale, image_format, default_version, map_width, map_height, c_url, c_layer, q_url, prw_url, pos_url, cst_url)
	{
		this.loaded = false;
		this.id = id;
		this.title = title;
		this.srs = srs;
		this.default_bbox = bbox;
		this.bbox = bbox;
    this.projection_to_scale = projection_to_scale;
		this.image_format = image_format;
		this.default_version = default_version;
		this.map_width = map_width;
		this.map_height = map_height;
		
		this.clickmap_url = c_url;
		this.clickmap_layer = c_layer;
    this.query_url = q_url;
		this.preview_url = prw_url;
		this.position_url = pos_url;
    this.cst_url = cst_url;

    this.wms_list_url = "";
        
    this.query_param_string = "";
    this.query_index = "";
    this.query_page = 1
    this.query_items = 50;
    
		this.load_counter = 0;
		
		/* CAST PREDNASTOAVENYCH MERITEK MAPY */
		this.scale_list = new Collection();
		
		this.Add_Scale = Add_Scale;
		
		function Add_Scale(scale)
		// Funkce pro pridani meritka mapy
		{
			this.scale_list.Add(scale);
		}
		/* KONEC CASTI PREDNASTAVENYCH MERITEK MAPY */

		/* CAST CMS SERVERU */
		this.cms_list = new Collection();

		this.Add_CMS = Add_CMS;
		
		function Add_CMS(cms_server)
		// Funkce pro pridani serveru
		{
			this.cms_list.Add(cms_server);
		}

		this.Write_CMS = Write_CMS;
		
		function Write_CMS(str_object)
		{

      if(this.clickmap_url != '')
      {
  			for(var i = 0; i < this.cms_list.Length(); i++)
  			{
          this.cms_list.Item(0).Write_Legend("pAFeatures");
        }
      }
		}

		/* CAST WMS SERVERU */
		this.wms_list = new Collection();
		
		this.Get_Id = Get_Id;

		function Get_Id(id)
		// Funkce pro ziskani id wms_serveru
		{
			var wms_id = -1;
			
			for(var i = 0; i < this.wms_list.Length(); i++)
			{
				if(this.wms_list.Item(i).id == id)
				{
					wms_id = i;
				}
			}
			
			return wms_id;
		}		
		
		this.Add_WMS = Add_WMS;
		
		function Add_WMS(wms_server)
		// Funkce pro pridani wms serveru
		{
			this.wms_list.Add(wms_server);
		}
		
		this.WMS_PriorityUp = WMS_PriorityUp;

		function WMS_PriorityUp(id)
		// Funkce prehodi poradi wms serveru smerem nahoru
		{
			var id1 = this.Get_Id(id) + 1;
			var id2 = this.Get_Id(id);
			
			var pom_wms = this.wms_list.Item(id1);
			
			this.wms_list.SetItem(id1, this.wms_list.Item(id2));
			
			this.wms_list.SetItem(id2, pom_wms);
		}
		
		this.WMS_PriorityDown = WMS_PriorityDown;

		function WMS_PriorityDown(id)
		// Funkce prehodi poradi wms serveru smerem dolu
		{
			var id1 = this.Get_Id(id) - 1;
			var id2 = this.Get_Id(id);
			
			var pom_wms = this.wms_list.Item(id1);
			
			this.wms_list.SetItem(id1, this.wms_list.Item(id2));
			
			this.wms_list.SetItem(id2, pom_wms);
		}

		this.Write_WMS = Write_WMS;
		
		function Write_WMS(str_object, id)
		// Funkce vypise seznam WMS serveru do listboxu
		{
			for(var i = document.getElementById("Mapa").childNodes.length-1; i >= 0; i--)
			{
				//document.removeChild(document.getElementById("Mapa").children(i));
				//alert(document.getElementById("Mapa").childNodes[i].nodeName);
        document.getElementById("Mapa").removeChild(document.getElementById("Mapa").childNodes.item(i));
			}

//			var wms_string = "<select id='" + str_object + "' size='7' style='width:300px' class='vyber' onClick='" + str_object + "_Click()'>";

			var wms_string = "</select>";
			
			//var wms_list_string = "<table id='tblWMS_Servers' border='0' cellpadding='0' cellspacing='0'>";
			var wms_list_string = "</table>";
			
			for(var i = 0; i < this.wms_list.Length(); i++)
			{
        //wms_list_string += "<tr>";
        wms_list_string = "</tr>" + wms_list_string;
				
				if(this.wms_list.Item(i).id == id)
				{
//					wms_string += "<option value='" + this.wms_list.Item(i).id + "' selected>" + this.wms_list.Item(i).title + "</option>";
					wms_string = "<option value='" + this.wms_list.Item(i).id + "' selected>" + this.wms_list.Item(i).title + "</option>" + wms_string;
				}
				else
				{
//					wms_string += "<option value='" + this.wms_list.Item(i).id + "'>" + this.wms_list.Item(i).title + "</option>";
					wms_string = "<option value='" + this.wms_list.Item(i).id + "'>" + this.wms_list.Item(i).title + "</option>" + wms_string;
				}

				if(this.wms_list.Item(i).expanded)
				{
//					wms_list_string += "<tr id='trWMS_Server_" + this.wms_list.Item(i).id + "'><td></td><td id='tdWMS_Server_" + this.wms_list.Item(i).id + "' colspan='4'></td></tr>"
					wms_list_string = "<tr id='trWMS_Server_" + this.wms_list.Item(i).id + "'><td></td><td id='tdWMS_Server_" + this.wms_list.Item(i).id + "' colspan='4'></td></tr>" + wms_list_string;
				}
				else
				{
//					wms_list_string += "<tr id='trWMS_Server_" + this.wms_list.Item(i).id + "' style='display:none'><td></td><td id='tdWMS_Server_" + this.wms_list.Item(i).id + "' colspan='4'></td></tr>"
					wms_list_string = "<tr id='trWMS_Server_" + this.wms_list.Item(i).id + "' style='display:none'><td></td><td id='tdWMS_Server_" + this.wms_list.Item(i).id + "' colspan='4'></td></tr>" + wms_list_string;
				}
								
//				wms_list_string += "<td colspan='3' align='left' width='100%'><span class='footerboldbig'>" + this.wms_list.Item(i).title + "</span></td>";
				wms_list_string = "<td colspan='3' align='left' width='100%'><span class='footerboldbig'>" + this.wms_list.Item(i).title + "</span></td>" + wms_list_string;

				if(this.wms_list.Item(i).selected)
				{
//					wms_list_string += "<td><input id='chbWMS_Server_" + this.wms_list.Item(i).id + "' type='checkbox' title='Zapnout/Vypnout zobrazení' value='" + this.wms_list.Item(i).id + "' onClick='chbWMS_Server_Click(this)' checked></td>"
					wms_list_string = "<td><input id='chbWMS_Server_" + this.wms_list.Item(i).id + "' type='checkbox' title='" + script_messages[28] + "' value='" + this.wms_list.Item(i).id + "' onClick='chbWMS_Server_Click(this)' checked></td>" + wms_list_string;
				}
				else
				{
//					wms_list_string += "<td><input id='chbWMS_Server_" + this.wms_list.Item(i).id + "' type='checkbox' title='Zapnout/Vypnout zobrazení' value='" + this.wms_list.Item(i).id + "' onClick='chbWMS_Server_Click(this)'></td>"
					wms_list_string = "<td><input id='chbWMS_Server_" + this.wms_list.Item(i).id + "' type='checkbox' title='" + script_messages[28] + "' value='" + this.wms_list.Item(i).id + "' onClick='chbWMS_Server_Click(this)'></td>" + wms_list_string;
				}

				if(this.wms_list.Item(i).expanded)
				{
//					wms_list_string += "<td><img id='imgWMS_Server_" + this.wms_list.Item(i).id + "' onClick='imgWMS_Server_Click(" + this.wms_list.Item(i).id + ")' src='./DisplayStyle/minus.gif' style='border: 0px; cursor:hand'/></td>"
					wms_list_string = "<td><img id='imgWMS_Server_" + this.wms_list.Item(i).id + "' onClick='imgWMS_Server_Click(" + this.wms_list.Item(i).id + ")' src='./DisplayStyle/minus.gif' style='border: 0px; cursor:hand'/></td>" + wms_list_string;
				}
				else
				{
//					wms_list_string += "<td><img id='imgWMS_Server_" + this.wms_list.Item(i).id + "' onClick='imgWMS_Server_Click(" + this.wms_list.Item(i).id + ")' src='./DisplayStyle/plus.gif' style='border: 0px; cursor:hand'/></td>"
					wms_list_string = "<td><img id='imgWMS_Server_" + this.wms_list.Item(i).id + "' onClick='imgWMS_Server_Click(" + this.wms_list.Item(i).id + ")' src='./DisplayStyle/plus.gif' style='border: 0px; cursor:hand'/></td>" + wms_list_string;
				}

				//wms_list_string += "</tr>"
				wms_list_string = "<tr>" + wms_list_string;

        //Aktualizace spolecnych souradnych systemu
        if(i == 0)
        {
          for (var srs_id = this.common_srs_list.Length() - 1; srs_id >= 0; srs_id--)
    			{
            this.common_srs_list.Remove(srs_id);
    			}

          for (var srs_id = 0; srs_id < this.wms_list.Item(i).srs_list.Length(); srs_id++)
    			{
            this.Add_Common_Srs(new Srs(this.wms_list.Item(i).srs_list.Item(srs_id).value));
    			}
        }
        else
        {
          for (var srs_id = 0; srs_id < this.wms_list.Item(i).srs_list.Length(); srs_id++)
    			{
            this.Compare_SRS(new Srs(this.wms_list.Item(i).srs_list.Item(srs_id).value));
    			}        

          for (var srs_id = this.common_srs_list.Length() - 1; srs_id >= 0; srs_id--)
    			{
            this.common_srs_list.Remove(srs_id);
    			}

    			for (var srs_id = 0; srs_id < map_list.maps.Item(map_list.map_id).common_srs_list_tmp.Length(); srs_id++)
    			{
            this.Add_Common_Srs(new Srs(this.common_srs_list_tmp.Item(srs_id).value));
    			}        

          for (var srs_id = this.common_srs_list_tmp.Length() - 1; srs_id >= 0; srs_id--)
    			{
            this.common_srs_list_tmp.Remove(srs_id);
    			}

        }

			}
//			wms_string += "</select>";
			wms_string = "<select id='cmbWMS_Servers' size='10' style='width:300px' class='vyber' onClick='cmbWMS_Servers_Click()'>" + wms_string;
			
			//wms_list_string += "</table>"
			wms_list_string = "<table id='tblWMS_Servers' border='0' cellpadding='0' cellspacing='0'>" + wms_list_string;
			

			document.getElementById(str_object).innerHTML = wms_string;
			document.getElementById("pFeatures").innerHTML = wms_list_string;

			this.Write_Common_SRS("spnCRS_List", 0);
			
			for(var i = 0; i < this.wms_list.Length(); i++)
			{
        document.getElementById("Mapa").appendChild(this.wms_list.Item(i).map_img);	
				this.wms_list.Item(i).Write_Legend("tdWMS_Server_" + this.wms_list.Item(i).id);
			}
			
			cmbWMS_Servers_Click();
		}
		/* KONEC CASTI WMS SERVERU */

		/* CAST WCS SERVERU */
		this.wcs_list = new Collection();
		
		this.Get_WCS_Id = Get_WCS_Id;

		function Get_WCS_Id(id)
		// Funkce pro ziskani id wms_serveru
		{
			var wcs_id = -1;
			
			for(var i = 0; i < this.wcs_list.Length(); i++)
			{
				if(this.wcs_list.Item(i).id == id)
				{
					wcs_id = i;
				}
			}
			
			return wcs_id;
		}		
		
		this.Add_WCS = Add_WCS;
		
		function Add_WCS(wcs_server)
		// Funkce pro pridani wcs serveru
		{
			this.wcs_list.Add(wcs_server);
		}
		
		this.Write_WCS = Write_WCS;
		
		function Write_WCS(str_object, id)
		// Funkce vypise seznam WCS serveru do listboxu
		{

			var wcs_string = "<select id='cmbWCS_Servers' style='width:300px' class='vyber' onClick='cmbWCS_Servers_Change()'>";

			for(var i = 0; i < this.wcs_list.Length(); i++)
			{
				if(this.wcs_list.Item(i).id == id)
				{
					wcs_string += "<option value='" + this.wcs_list.Item(i).id + "' selected>" + this.wcs_list.Item(i).title + "</option>";
				}
				else
				{
					wcs_string += "<option value='" + this.wcs_list.Item(i).id + "'>" + this.wcs_list.Item(i).title + "</option>";
				}

			}
			wcs_string += "</select>";
			
			document.getElementById(str_object).innerHTML = wcs_string;
			
			cmbWCS_Servers_Change();

		}
		/* KONEC CASTI WCS SERVERU */

		this.Actualize_BBOX = Actualize_BBOX;
		
		function Actualize_BBOX()
		{
      if(this.wms_list.Length() > 0)
      {
        document.getElementById("divWait").style.display = "";
      }
      
      //Aktualizace mapy
			for(var i = 0; i < this.wms_list.Length(); i++)
			{
				this.wms_list.Item(i).wms_url = replace_string(this.wms_list.Item(i).wms_url, "BBOX", this.bbox);
	      this.wms_list.Item(i).bbox = this.bbox; 
  			if(this.wms_list.Item(i).selected) this.wms_list.Item(i).GetMap();
			}

      if(document.getElementById("imgWCS").style.display == "")
      {
        var c_url = document.getElementById("imgWCS").src;
        c_url = replace_string(c_url, "BBOX", this.bbox + ",0,0");
        
        document.getElementById("imgWCS").src = c_url;
      }
      
      if(this.cms_list.Length() > 0)
      {
        //Aktualizace mapy
  			for(var i = 0; i < this.cms_list.Length(); i++)
  			{
  				this.cms_list.Item(i).cms_url = replace_string(this.cms_list.Item(i).cms_url, "BBOX", this.bbox);
	        this.cms_list.Item(i).bbox = this.bbox; 
  				this.cms_list.Item(i).GetClickMap();
  			}      
      }
		}

		this.Actualize_SRS = Actualize_SRS;
		
		function Actualize_SRS()
		{

      if(this.wms_list.Length() > 0)
      {
        document.getElementById("divWait").style.display = "";
      }

      var strSrs;

    	var re_version = /[.]/ig;

			//Aktualizace mapy
			for(var i = 0; i < this.wms_list.Length(); i++)
			{
        if(parseInt(this.wms_list.Item(i).version.replace(re_version,"")) >= 130)
        {
          strSrs = "CRS";
        }
        else
        {
          strSrs = "SRS";
        }

        this.wms_list.Item(i).wms_url = replace_string(this.wms_list.Item(i).wms_url, strSrs, this.srs);
				this.wms_list.Item(i).wms_url = replace_string(this.wms_list.Item(i).wms_url, "BBOX", this.bbox);

        if(this.wms_list.Item(i).selected) this.wms_list.Item(i).GetMap();

			}

      if(document.getElementById("imgWCS").style.display == "")
      {
        var c_url = document.getElementById("imgWCS").src;
        c_url = replace_string(c_url, "CRS", this.srs);
        c_url = replace_string(c_url, "BBOX", this.bbox + ",0,0");
        document.getElementById("imgWCS").src = c_url;
      }

      if(this.cms_list.Length() > 0)
      {
        //Aktualizace klikaci mapy
  			for(var i = 0; i < this.cms_list.Length(); i++)
  			{
  				this.cms_list.Item(i).cms_url = replace_string(this.cms_list.Item(i).cms_url, "SRS", this.srs);
  				this.cms_list.Item(i).cms_url = replace_string(this.cms_list.Item(i).cms_url, "BBOX", this.bbox);
  				this.cms_list.Item(i).GetClickMap();
  			}      
      }

		}

		this.Actualize_LAYERS = Actualize_LAYERS;
		
		function Actualize_LAYERS()
		{

      if(this.wms_list.Length() > 0)
      {
        document.getElementById("divWait").style.display = "";
      }

			//Aktualizace vrstev jednotlivych wms
			for(var i = 0; i < this.wms_list.Length(); i++)
			{
        this.wms_list.Item(i).Actualize_LAYERS();
  			if(this.wms_list.Item(i).selected) this.wms_list.Item(i).GetMap();
			}
		}

		this.Actualize_CLAYERS = Actualize_CLAYERS;
		
		function Actualize_CLAYERS()
		{

			//Aktualizace vrstev jednotlivych cms
			for(var i = 0; i < this.cms_list.Length(); i++)
			{
				this.cms_list.Item(i).cms_layer = this.clickmap_layer;
        this.cms_list.Item(i).Actualize_LAYERS();
				this.cms_list.Item(i).GetClickMap();
			}
		}

		this.Actualize_DIMENSIONS = Actualize_DIMENSIONS;
		
		function Actualize_DIMENSIONS(width, height)
		{
      
      this.map_width = width;
      this.map_height = height;

      var BBoxArray = ParseBBox(this.bbox);
    
    	BBoxArray = TransformBBox(BBoxArray, this.map_width, this.map_height);

      this.bbox = dbl2StrEN(BBoxArray[0].toString()) + "," + dbl2StrEN(BBoxArray[1].toString()) + "," + dbl2StrEN(BBoxArray[2].toString()) + "," + dbl2StrEN(BBoxArray[3].toString());      
      
      if(this.wms_list.Length() > 0)
      {
        document.getElementById("divWait").style.display = "";
      }

			//Aktualizace vrstev jednotlivych wms
			for(var i = 0; i < this.wms_list.Length(); i++)
			{
				this.wms_list.Item(i).Actualize_DIMENSIONS(this.map_width, this.map_height);
				this.wms_list.Item(i).wms_url = replace_string(this.wms_list.Item(i).wms_url, "BBOX", this.bbox);
				this.wms_list.Item(i).map_img.width = width;
				this.wms_list.Item(i).map_img.height = height;

				if(this.wms_list.Item(i).selected) this.wms_list.Item(i).GetMap();
			}

			//Aktualizace vrstev jednotlivych cms
			for(var i = 0; i < this.cms_list.Length(); i++)
			{
				this.cms_list.Item(i).width = this.map_width;
				this.cms_list.Item(i).height = this.map_height;
        this.cms_list.Item(i).Actualize_DIMENSIONS(this.map_width, this.map_height);
				this.wms_list.Item(i).cms_url = replace_string(this.cms_list.Item(i).cms_url, "BBOX", this.bbox);
        this.cms_list.Item(i).GetClickMap();
			}

		}

		// CAST spolecnych SRS
		this.common_srs_list = new Collection();
		this.common_srs_list_tmp = new Collection();
		
		this.Add_Common_Srs = Add_Common_Srs;
		
		function Add_Common_Srs(srs)
		// Funkce pro pridani SRS mapy
		{
      this.common_srs_list.Add(srs);
		}

		this.Add_Common_Tmp_Srs = Add_Common_Tmp_Srs;
		
		function Add_Common_Tmp_Srs(srs)
		// Funkce pro pridani SRS mapy
		{
      this.common_srs_list_tmp.Add(srs);
		}
		
		this.Compare_SRS = Compare_SRS;
		
    function Compare_SRS(srs)
    {
      for(var i = 0; i < this.common_srs_list.Length(); i++)
      {
        if(this.common_srs_list.Item(i).value.toLowerCase() == srs.value.toLowerCase())
        {
          this.Add_Common_Tmp_Srs(new Srs(srs.value));
        }
      }
    }

		this.Write_Common_SRS = Write_Common_SRS;
		
		function Write_Common_SRS(str_object, id)
		// Funkce vypise seznam SRS do listboxu
		{
			var srs_string;
			var crs_name = "";
			
			srs_string = "<select id='cmbCRS_List' class='vyber' style='width:300px'>";
			//alert (this.common_srs_list.Length());
			for(var i = 0; i < this.common_srs_list.Length(); i++)
			{
				crs_name = "";

        if(crs_info.crs_list.Length() > 0)
        {
          for (var crs_record = 0; crs_record < crs_info.crs_list.Length(); crs_record++)
      		{
				    if(crs_info.crs_list.Item(crs_record).code.toLowerCase() == this.common_srs_list.Item(i).value.toLowerCase())
            {
              crs_name = crs_info.crs_list.Item(crs_record).name;
              break;
            } 
          }
        }         
        //alert(this.common_srs_list.Item(i).value);
        if(this.common_srs_list.Item(i).value.toLowerCase() == this.srs.toLowerCase())
				{
          if(crs_name != "")
          {
            srs_string += "<option value='" + this.common_srs_list.Item(i).value + "' selected>" + this.common_srs_list.Item(i).value + " - " + crs_name + "</option>";
				  }
				  else
				  {
            srs_string += "<option value='" + this.common_srs_list.Item(i).value + "' selected>" + this.common_srs_list.Item(i).value + "</option>";
          }
        }
				else
				{
          if(crs_name != "")
          {
  					srs_string += "<option value='" + this.common_srs_list.Item(i).value + "'>" + this.common_srs_list.Item(i).value + " - " + crs_name + "</option>";
	        }
	        else
	        {
  					srs_string += "<option value='" + this.common_srs_list.Item(i).value + "'>" + this.common_srs_list.Item(i).value + "</option>";
          }
  			}
			}
			srs_string += "</select>";
			
			document.getElementById(str_object).innerHTML = srs_string;			
    }
		//*******************************************************************************	

		this.Get_FeatureInfo = Get_FeatureInfo;
		
		function Get_FeatureInfo(startx, starty)
		// Funkce pro vypis feature info pripojenych wms serveru
		{
      
      var wms_list_string = "</table>";
			
			var window_height = parseInt(document.getElementById('divFIPanel').style.height) - 20;
			var show = false;
			
      //Delej pro vsechny WMS servery
			for(var i = 0; i < this.wms_list.Length(); i++)
			{
				if(this.wms_list.Item(i).selected && this.wms_list.Item(i).featureinfo && this.wms_list.Item(i).featureinfo_selected)
				{
          show = true;
          
          /*var url = this.wms_list.Item(i).featureinfo_url;
  
    			var re = /[?]/i;
    			if(url.search(re) != -1)
    			{
            url = url + "&REQUEST=GetFeatureInfo&INFO_FORMAT=" + this.wms_list.Item(i).fi_selected_value + "&VERSION=" + this.wms_list.Item(i).version + "&X=" + startx + "&Y=" + starty + "&BBOX=" + this.wms_list.Item(i).bbox + "&SRS=" + this.wms_list.Item(i).srs + "&WIDTH=" + this.wms_list.Item(i).width + "&HEIGHT=" + this.wms_list.Item(i).height + "&QUERY_LAYERS=" + get_string(this.wms_list.Item(i).wms_url, 'LAYERS');
          }
          else
          {
            url = url + "?REQUEST=GetFeatureInfo&INFO_FORMAT=" + this.wms_list.Item(i).fi_selected_value + "&VERSION=" + this.wms_list.Item(i).version + "&X=" + startx + "&Y=" + starty + "&BBOX=" + this.wms_list.Item(i).bbox + "&SRS=" + this.wms_list.Item(i).srs + "&WIDTH=" + this.wms_list.Item(i).width + "&HEIGHT=" + this.wms_list.Item(i).height + "&QUERY_LAYERS=" + get_string(this.wms_list.Item(i).wms_url, 'LAYERS');
          }*/
          wms_list_string = "</tr>" + wms_list_string;
				
					wms_list_string = "<tr id='trFI_Server_" + this.wms_list.Item(i).id + "' style='display:none'><td></td><td height='" + window_height + "' id='tdFI_Server_" + this.wms_list.Item(i).id + "' colspan='4'></td></tr>" + wms_list_string;
								
  				wms_list_string = "<td colspan='3' align='left' width='100%'><span class='footerboldbig'>" + this.wms_list.Item(i).title + "</span></td>" + wms_list_string;

					wms_list_string = "<td><img id='imgFI_Server_" + this.wms_list.Item(i).id + "' onClick='imgFI_Server_Click(" + this.wms_list.Item(i).id + ")' src='./DisplayStyle/plus.gif' style='border: 0px; cursor:hand'/></td>" + wms_list_string;

  				wms_list_string = "<tr height='20'>" + wms_list_string;

          wms_list_string = "<table id='tblFI' width='100%' border='0' cellpadding='0' cellspacing='0'>" + wms_list_string;
        }
			}
			
			if(show)
			{
        document.getElementById("divFIPanel").innerHTML = wms_list_string;
        
        //Delej pro vsechny WMS servery
  			for(var i = 0; i < this.wms_list.Length(); i++)
  			{
  				if(this.wms_list.Item(i).selected && this.wms_list.Item(i).featureinfo && this.wms_list.Item(i).featureinfo_selected)
  				{
            var url = this.wms_list.Item(i).featureinfo_url;
            
            var fi_layers = this.wms_list.Item(i).Get_FI_Layers();
            
            if(fi_layers == '')
            {
              document.getElementById("tdFI_Server_" + this.wms_list.Item(i).id).innerHTML = "Žádná ze zobrazených mapových vrstev tohoto WMS serveru nemá příznak 'QUERYABLE'";          
              continue;          
            }
            
            var strX = "X";
            var strY = "Y";
            var strSrs = "SRS";
            var re_version = /[.]/ig;
            if(parseInt(this.wms_list.Item(i).version.replace(re_version,"")) >= 130)
            {
              strX = "I";
              strY = "J";
              strSrs = "CRS";
            }
            
      			var re = /[?]/i;
      			if(url.search(re) != -1)
      			{
        			if(url.substr(url.length - 1, url.length) != '&')
        			{
                url = url + "&REQUEST=GetFeatureInfo&INFO_FORMAT=" + this.wms_list.Item(i).fi_selected_value + "&VERSION=" + this.wms_list.Item(i).version + "&" + strX + "=" + startx + "&" + strY + "=" + starty + "&BBOX=" + this.wms_list.Item(i).bbox + "&" + strSrs + "=" + this.wms_list.Item(i).srs + "&WIDTH=" + this.wms_list.Item(i).width + "&HEIGHT=" + this.wms_list.Item(i).height + "&QUERY_LAYERS=" + fi_layers;
              }
              else
              {
                url = url + "REQUEST=GetFeatureInfo&INFO_FORMAT=" + this.wms_list.Item(i).fi_selected_value + "&VERSION=" + this.wms_list.Item(i).version + "&" + strX + "=" + startx + "&" + strY + "=" + starty + "&BBOX=" + this.wms_list.Item(i).bbox + "&" + strSrs + "=" + this.wms_list.Item(i).srs + "&WIDTH=" + this.wms_list.Item(i).width + "&HEIGHT=" + this.wms_list.Item(i).height + "&QUERY_LAYERS=" + fi_layers;
              }
            }
            else
            {
              url = url + "?REQUEST=GetFeatureInfo&INFO_FORMAT=" + this.wms_list.Item(i).fi_selected_value + "&VERSION=" + this.wms_list.Item(i).version + "&" + strX + "=" + startx + "&" + strY + "=" + starty + "&BBOX=" + this.wms_list.Item(i).bbox + "&" + strSrs + "=" + this.wms_list.Item(i).srs + "&WIDTH=" + this.wms_list.Item(i).width + "&HEIGHT=" + this.wms_list.Item(i).height + "&QUERY_LAYERS=" + fi_layers;
            }

            var fi_string = "<table cellspacing='0' cellpadding='0' border='0' width='100%' height='100%'><tr><td width='100%' height='100%'><iframe id='frmFI_" + i + "' src='" + url + "' width='100%' height='100%'></iframe></td></tr></table>" 
  
            document.getElementById("tdFI_Server_" + this.wms_list.Item(i).id).innerHTML = fi_string;          
            //this.wms_list.Item(i).Get_FeatureInfo(startx, starty);
  
          }
  			}
  
        document.getElementById("zalozkaFI").style.display = "";
        ViewSwitch('OknoFI');
      }
      else
      {
        alert(script_messages[3]);
      }
		}
		//*******************************************************************************	
		
	}
	// End of class Map

	// Class Map_list
	function Map_list()
	{
		this.default_map_id;		
		this.map_id;
		
		this.maps = new Collection();	
		
		this.Add = Add;
		
		function Add(map)
		// Pridani mapy do kolekce map
		{
			this.maps.Add(map);
		}

		this.Load_Map = Load_Map;
				
		function Load_Map(id)
		{			
			this.map_id = id;

			//PREHLEDKA
			this.maps.Item(id).preview_url = replace_string(this.maps.Item(id).preview_url, "WIDTH", parseInt(document.getElementById('imgPrehledka').style.width));
			this.maps.Item(id).preview_url = replace_string(this.maps.Item(id).preview_url, "HEIGHT", parseInt(document.getElementById('imgPrehledka').style.height));
      document.getElementById('imgPrehledka').src = this.maps.Item(id).preview_url;

			this.maps.Item(id).position_url = replace_string(this.maps.Item(id).position_url, "WIDTH", parseInt(document.getElementById('imgPrehledka').style.width));
			this.maps.Item(id).position_url = replace_string(this.maps.Item(id).position_url, "HEIGHT", parseInt(document.getElementById('imgPrehledka').style.height));
			document.getElementById('imgPosition').src = this.maps.Item(id).position_url;

			//DOTAZY
      document.getElementById("pQueryResult").innerHTML = "";
      
      if(this.maps.Item(id).query_url != "")
      {
  			var re = /[?]/i;
  			var xml_req = "";
  			if(this.maps.Item(id).query_url.search(re) != -1)
  			{
          //sloz XML request
          
          xml_req = this.maps.Item(id).query_url + "&REQUEST=GetCapabilities";
              
  			}
  			else
  			{
            //sloz XML request
          xml_req = this.maps.Item(id).query_url + "?REQUEST=GetCapabilities";
    		}

        //xmlQueries = AJAX(this.maps.Item(id).query_url + "?request=getqueries", false);
        xmlQueries = AJAX(xml_req, false);
        SetQueriesSourceIQS();
      }
      else
      {
      //dotazy nejsou
        document.getElementById("zalozkaVyhledat").style.display = "none";
        document.getElementById("btnShowQuery").style.display = "none";
        document.getElementById("btnDisableQuery").style.display = "none";
        document.getElementById("dividerQuery").style.display = "none";
      }
			//document.getElementById("QueriesSrc").src = this.maps.Item(id).query_url + "?request=getqueries";

			//MAPOVE MERITKA
			var scale_string = "<option value=''></option>";

			for(s = 0; s < this.maps.Item(id).scale_list.Length(); s++)
			{
				scale_string += "<option value='" + this.maps.Item(id).scale_list.Item(s).value + "'>" + this.maps.Item(id).scale_list.Item(s).title + "</option>"
			}
			document.getElementById("spnCmbScale").innerHTML = "<select id='cmbScale' class='vyber' onChange='cmbScale_Change()' style='margin-left:1px;'>" + scale_string + "</select>";

  		for(var i = 0; i < this.maps.Item(id).wms_list.Length(); i++)
  		{

        if(this.maps.Item(id).wms_list.Item(i).selected)
        {
          this.maps.Item(id).wms_list.Item(i).GetMap();
        }
      }
      
      //napln seznam wms serveru pokud jsou
      if(this.maps.Item(id).wms_list_url != "")
      {
        var xmlWms_list = AJAX(this.maps.Item(id).wms_list_url, false);

        var wms_html_string = "";
       	var re_space = new RegExp(" ", "i");
        
        if (moz)
        { 
          var xpathres = xmlWms_list.evaluate("//wms", xmlWms_list, null, 7, null);
          
          for(var i = 0; i < xpathres.snapshotLength; i++)
          {
            wms_html_string += "<OPTION value='" + xpathres.snapshotItem(i).getElementsByTagName("url")[0].firstChild.nodeValue.replace(re_space, "") + "?VERSION=" + xpathres.snapshotItem(i).getElementsByTagName("version")[0].firstChild.nodeValue.replace(re_space, "") + "'>" + xpathres.snapshotItem(i).getElementsByTagName("name")[0].firstChild.nodeValue + "</OPTION>";
          }
        }
        else if (ie) 
        { 
    			var xmlNodes = xmlWms_list.selectNodes("//wms");
    			
    			for(var i = 0; i < xmlNodes.length; i++)
    			{
            wms_html_string += "<OPTION value='" + xmlNodes.item(i).selectSingleNode("url").text.replace(re_space, "") + "?VERSION=" + xmlNodes.item(i).selectSingleNode("version").text.replace(re_space, "") + "'>" + xmlNodes.item(i).selectSingleNode("name").text + "</OPTION>";            
          }
        }        
        document.getElementById("spnWMS_URL").innerHTML = "<SELECT id='cmbWMS_URL' class='vyber' style='width:400px;'>" + wms_html_string + "</SELECT>";
        
        document.getElementById("trWMS_List").style.display = "";
      }
      else
      {
        document.getElementById("trWMS_List").style.display = "none";
      }
      
			this.maps.Item(id).Write_WMS("tdWMS_Servers", this.maps.Item(id).wms_list.Length()-1);

      if(this.maps.Item(id).wcs_list.Length() > 0)
      {
  			this.maps.Item(id).Write_WCS("tdWCS_Servers", this.maps.Item(id).wcs_list.Length()-1);
      }
      else
      {
        document.getElementById("zalozkaWCS").style.display = "none";
      }
      
      if(this.maps.Item(id).clickmap_url != '')
      {
        this.maps.Item(id).Actualize_CLAYERS();
        this.maps.Item(id).Write_CMS();
        document.getElementById("tdActiveLayers").style.display = "";
      }
      else
      {
        document.getElementById("divClickMap").innerHTML = "";
        document.getElementById("tdActiveLayers").style.display = "none"
      }

      var BBoxArray = ParseBBox(this.maps.Item(id).bbox);
      
      if ((BBoxArray[0] > -180) && (BBoxArray[0] < 180))
      {
        //nemerit
        nemerit = true;
      }
      else
      {
        nemerit = false;
      }

      SetMeasure();

      //vyplneni/nevyplneni informaci o zvolenem CRS
      document.getElementById("crsInfo").innerHTML = "";
      for(var c = 0; c < crs_info.crs_list.Length(); c++)
      {
        if(crs_info.crs_list.Item(c).code.toLowerCase() == this.maps.Item(id).srs.toLowerCase())
        {
          document.getElementById("crsInfo").innerHTML = crs_info.crs_list.Item(c).name + " (" + crs_info.crs_list.Item(c).unit + ")";
          break;
        }
      }
      
      this.maps.Item(id).loaded = true;

      ViewSwitch('OknoMapa');
		}	

		this.Save_MapEnviroment = Save_MapEnviroment;

		function Save_MapEnviroment(id)
		// Funkce ulozi aktualni hodnoty do XML souboru
		{
      var d_map = this.maps.Item(id);
      var xmlDoc;

      var xmlhttp;
      
      if (moz)
      {
        xmlDoc = document.implementation.createDocument("", "", null);
        
        xmlhttp = new XMLHttpRequest();
        
      }
      else
      {
        xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); 
        xmlDoc.async = false;

        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

      }

      var configurationElem = xmlDoc.createElement("CONFIGURATION");
      
      var constElem = xmlDoc.createElement("CONST");

      var xslElem = xmlDoc.createElement("XSL_URL");
      xslElem.setAttribute("q_style_url", get_queries_xslt_path);
      xslElem.setAttribute("tq_style_url", get_t_queries_xslt_path);
      xslElem.setAttribute("oq_style_url", get_o_queries_xslt_path);
      xslElem.setAttribute("qp_style_url", get_query_param_xslt_path);
      xslElem.setAttribute("qr_style_url", get_query_result_xslt_path);

      constElem.appendChild(xslElem);

      var service_urlElem = xmlDoc.createElement("SERVICE_URL");
      service_urlElem.setAttribute("print_map_url", print_map_url);
      service_urlElem.setAttribute("print_query_url", print_query_url);
      service_urlElem.setAttribute("print_dialog_url", print_dialog_url);
      service_urlElem.setAttribute("param_dialog_url", param_dialog_url);
      service_urlElem.setAttribute("save_enviroment_url", save_enviroment_url);

      constElem.appendChild(service_urlElem);
      
      configurationElem.appendChild(constElem);

      var proxyElem = xmlDoc.createElement("PROXY");
      proxyElem.setAttribute("Enabled", proxy_enabled);
      proxyElem.setAttribute("Url", proxy_url);

      var print_configElem = xmlDoc.createElement("PRINT_CONFIG");

      var print_mapElem = xmlDoc.createElement("PRINT_MAP");
      
      for(var page=0; page < document.getElementById("cmbPrint_page_setting").length; page++)
      {
        var ppageElem = xmlDoc.createElement("PPAGE");

        ppageElem.setAttribute("Title", document.getElementById("cmbPrint_page_setting").options[page].text);
        ppageElem.setAttribute("Width", document.getElementById("cmbPrint_page_setting").options[page].value.split("|")[0]);
        ppageElem.setAttribute("Height", document.getElementById("cmbPrint_page_setting").options[page].value.split("|")[1]);
        print_mapElem.appendChild(ppageElem);
      }
      
      print_configElem.appendChild(print_mapElem);

      var qfElem = xmlDoc.createElement("QUALITY_FACTOR");
      
      for(var qf=0; qf < document.getElementById("cmbPrint_quality_factor").length; qf++)
      {
        var qfactorElem = xmlDoc.createElement("QFACTOR");

        qfactorElem.setAttribute("Title", document.getElementById("cmbPrint_quality_factor").options[qf].text);
        qfactorElem.setAttribute("Value", document.getElementById("cmbPrint_quality_factor").options[qf].value);
        qfElem.appendChild(qfactorElem);
      }
      
      print_configElem.appendChild(qfElem);

      var print_scalesElem = xmlDoc.createElement("PRINT_SCALES");
      
      for(var ps=0; ps < document.getElementById("cmbPrint_scales").length; ps++)
      {
        var pscaleElem = xmlDoc.createElement("PSCALE");

        pscaleElem.setAttribute("Title", document.getElementById("cmbPrint_scales").options[ps].text);
        pscaleElem.setAttribute("Value", document.getElementById("cmbPrint_scales").options[ps].value);
        print_scalesElem.appendChild(pscaleElem);
      }
      
      print_configElem.appendChild(print_scalesElem);
      
      configurationElem.appendChild(print_configElem);

      configurationElem.appendChild(proxyElem);

      if(crs_info.crs_list.Length() > 0)
      {
        var crs_infoElem = xmlDoc.createElement("CRS_INFO");

        for (var crs_record = 0; crs_record < crs_info.crs_list.Length(); crs_record++)
    		{
          var crs_recordElem = xmlDoc.createElement("CRS_RECORD")

          crs_recordElem.setAttribute("Code", crs_info.crs_list.Item(crs_record).code);
          crs_recordElem.setAttribute("Name", crs_info.crs_list.Item(crs_record).name);
          crs_recordElem.setAttribute("Unit", crs_info.crs_list.Item(crs_record).unit);
          crs_recordElem.setAttribute("Round", crs_info.crs_list.Item(crs_record).round);
          if(crs_info.crs_list.Item(crs_record).sign == 1)
          {
            crs_recordElem.setAttribute("Sign", "normal");
          }
          else
          {
            crs_recordElem.setAttribute("Sign", "inverse");
          }
          
          if(crs_info.crs_list.Item(crs_record).axis_order == 1)
          {
            crs_recordElem.setAttribute("AxisOrder", "normal");
          }
          else
          {
            crs_recordElem.setAttribute("AxisOrder", "inverse");
          }
          crs_recordElem.setAttribute("AxisHorizDesc", crs_info.crs_list.Item(crs_record).axis_horiz_desc);
          crs_recordElem.setAttribute("AxisVertDesc", crs_info.crs_list.Item(crs_record).axis_vert_desc);
          crs_infoElem.appendChild(crs_recordElem);
        }
        configurationElem.appendChild(crs_infoElem);        
      }
      
      var applicationElem = xmlDoc.createElement("APPLICATION");
      applicationElem.setAttribute("Title", document.title);
      applicationElem.setAttribute("Default_map_id", d_map.id);
      applicationElem.setAttribute("Wms_enabled", wms_enabled);
      applicationElem.setAttribute("Wcs_enabled", wcs_enabled);
      
      var mapsElem = xmlDoc.createElement("MAP_COMPOSITIONS");
	
	for(var m = 0; m < this.maps.Length(); m++)
{      
      var map = this.maps.Item(m);
      var mapElem = xmlDoc.createElement("MAP");
      mapElem.setAttribute("Id", map.id);
      mapElem.setAttribute("Title", map.title);
      mapElem.setAttribute("Srs", map.srs);
      mapElem.setAttribute("Bbox", map.bbox);
      mapElem.setAttribute("Projection_to_scale", map.projection_to_scale);
      mapElem.setAttribute("Image_format", map.image_format);
      mapElem.setAttribute("Default_version", map.default_version);

      var wms_serversElem = xmlDoc.createElement("WMS_SERVERS");
      
      wms_serversElem.setAttribute("List_url", map.wms_list_url);
      
      //delej pro vsechny WMS servery
  		for(var i = 0; i < map.wms_list.Length(); i++)
  		{
        var serverElem = xmlDoc.createElement("SERVER");
        serverElem.setAttribute("Url", map.wms_list.Item(i).url);
        serverElem.setAttribute("Opacity", map.wms_list.Item(i).opacity);
        
        if(map.wms_list.Item(i).selected)
        {
          serverElem.setAttribute("Selected", "1");
        }
        else
        {
          serverElem.setAttribute("Selected", "0");
        }

        //uloz zapnute mapove vrstvy
        
        // pokud jiz byla mapa nactena, vezmi vrstvy z url
        var map_layers, map_layer_array;
        
        if(map.loaded)
        {
          map_layers = get_string(map.wms_list.Item(i).wms_url, 'LAYERS')
          map_layer_array = map_layers.split(",");
        }
        else // uloz puvodni defaultni vrstvy
        {
      		var default_layer_string = "";
          for(var l = 0; l < map.wms_list.Item(i).default_list.Length(); l++)
      		{
            if(l = map.wms_list.Item(i).default_list.Length()-1)
            {
              default_layer_string += map.wms_list.Item(i).default_list.Item(l).name;
            }
            else
            {
              default_layer_string += map.wms_list.Item(i).default_list.Item(l).name + ",";
            }
            map_layer_array = default_layer_string.split(",");          
          }        
        }
        
        var layersElem = xmlDoc.createElement("LAYERS");

    		for(var j = 0; j < map_layer_array.length; j++)
    		{
          var layerElem = xmlDoc.createElement("LAYER");
          layerElem.setAttribute('Name', map_layer_array[j]);
          layersElem.appendChild(layerElem);
        }
        
        serverElem.appendChild(layersElem);
                  
        wms_serversElem.appendChild(serverElem);
  		}
      
      mapElem.appendChild(wms_serversElem);

      //ulozeni wcs serveru, zatim neimplementovano, ulozi se prazdny seznam !!!!
      var wcs_serversElem = xmlDoc.createElement("WCS_SERVERS");
      mapElem.appendChild(wcs_serversElem);

      //ulozeni url na click
	    var clickElem = xmlDoc.createElement("CLICKMAP");
      clickElem.setAttribute('Url', map.clickmap_url);
      clickElem.setAttribute('Layer', map.clickmap_layer);
      mapElem.appendChild(clickElem);

      //ulozeni url na dotazy
	    var queriesElem = xmlDoc.createElement("QUERIES");
      queriesElem.setAttribute('Url', map.query_url);
      mapElem.appendChild(queriesElem);
      
      //ulozeni url na prehledku
	    var previewElem = xmlDoc.createElement("PREVIEW");
      previewElem.setAttribute('Wms', map.preview_url);
      previewElem.setAttribute('Position', map.position_url);
      mapElem.appendChild(previewElem);

      //ulozeni url na transformacni CST sluzbu
	    var cstElem = xmlDoc.createElement("CST");
      cstElem.setAttribute('Url', map.cst_url);
      mapElem.appendChild(cstElem);

      //ulozeni meritek
	    var scalesElem = xmlDoc.createElement("SCALES");

  		for(var i = 0; i < map.scale_list.Length(); i++)
  		{
        var scaleElem = xmlDoc.createElement("SCALE");
        scaleElem.setAttribute("Title", map.scale_list.Item(i).title);
        scaleElem.setAttribute("Value", map.scale_list.Item(i).value);
        scalesElem.appendChild(scaleElem);
      }
      
      mapElem.appendChild(scalesElem);
      
      mapsElem.appendChild(mapElem);
	}
      
      applicationElem.appendChild(mapsElem);

      configurationElem.appendChild(applicationElem);
              
      xmlDoc.appendChild(configurationElem);

      if (xmlhttp != null)
      {
        xmlhttp.open("POST", save_enviroment_url + "?REQUEST=GetSaveEnviromentPath", false);
      }
      else 
      {
        alert(script_messages[4]);
        return(false);
      }
		
      xmlhttp.send(xmlDoc);

  		//vracen error ze serveru
  		if(xmlhttp.status != 200)
  		{
  			alert(script_messages[5] + xmlhttp.statusText);
  			return(false);
  			
  		}

  		//zkontroluj vracenou hlavicku kvuli metode nacteni
  		if(xmlhttp.getResponseHeader("Content-Type") == "text/xml")
  		{
        if (moz)
        { 
          var parser = new DOMParser(); 
          xml_return_dom = parser.parseFromString(xmlhttp.responseText, "text/xml"); 
        }
        else if (ie) 
        { 
          xml_return_dom = new ActiveXObject("Microsoft.XMLDOM"); 
          xml_return_dom.async = false; 
    			xml_return_dom.validateOnParse = false;
    			xml_return_dom.loadXML(xmlhttp.responseXML.xml);
        } 
  		}
  		else
  		{
        if (moz)
        { 
          var parser = new DOMParser(); 
          xml_return_dom = parser.parseFromString(xmlhttp.responseText, "text/xml"); 
        }
        else if (ie) 
        { 
          xml_return_dom = new ActiveXObject("Microsoft.XMLDOM"); 
          xml_return_dom.async = false; 
    			xml_return_dom.validateOnParse = false;
  		  	xml_return_dom.loadXML(xmlhttp.responseText);
        } 
  		}

      if(moz)
      {
  			//Nacti version
        var xpathres = xml_return_dom.evaluate("//SaveEnviromentPath", xml_return_dom, null, 9, null);
  			var xml_path = (xpathres != null)?xpathres.singleNodeValue.getAttribute("url"):"";

				if(xml_path != "")
				{
          window.open(xml_path);
        }
        else
        {
          alert(script_messages[6]);
        }  		
      }
      else
      {
    		//nacti url na xml soubor
  			var xmlRoot = xml_return_dom.selectSingleNode("//SaveEnviromentPath");
  				
  			if(xmlRoot != null)
  			{	
  				var xml_path = xmlRoot.getAttribute("url");
  				
  				if(xml_path != "")
  				{
            window.open(xml_path);
          }
          else
          {
            alert(script_messages[6]);
          }  		
        }
        else
        {
          alert(script_messages[6]);
        }  		
      }
    }
	}
	// End of class Map_list
	
	var map_list = new Map_list();

/*************************************************************************
 *************************************************************************

								Funkce skriptu

 *************************************************************************
 *************************************************************************/

function GenerateException(chyba)
{
/*
 * Procedura, ktera zobrazi vystrazny dialog s pozadovanym textem.
 */

	alert(chyba);

}
//****************************************************************************

function dbl2StrEN(hodn)
{
/*
 * Funkce, ktera prevadi znaky carka v retezci na znaky tecka v retezci.
 */

	var re = new RegExp(",", "i");
	
	hodn = new String(hodn);
  hodn.replace(re, ".");
  return hodn;
}
//****************************************************************************

function app_initialize(map_width, map_height)
/*
 * Funkce se vola po nacteni HTML obsahu aplikace, provede inicializaci
 * podle konfiguracniho souboru.
 */
{
    var xmlhttp = null;

		//var xmlHttp = new ActiveXObject("Msxml2.XMLHTTP.4.0");
		var xmlConfig;
    var moz = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined');
    var ie = (typeof window.ActiveXObject != 'undefined'); 

/*		
    // code for Mozilla, etc.
    if (window.XMLHttpRequest)
    {
      xmlhttp = new XMLHttpRequest();
    }
    // code for IE
    else if (window.ActiveXObject)
    {
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
          
    if (xmlhttp != null)
    {
      xmlhttp.open("GET", 'http://booksize/jmk/config.xml', false);
    }
    else 
    {
      alert("Your browser does not support XMLHTTP!");
    }
		
    xmlhttp.send(null);

		//vracen error ze serveru
		if(xmlhttp.status != 200)
		{
			alert("Chyba komunikace se serverem: " + xmlhttp.statusText);
			return(false);			
		}
		
		//zkontroluj vracenou hlavicku kvuli metode nacteni
		if(xmlhttp.getResponseHeader("Content-Type") == "text/xml")
		{
      if (moz)
      { 
        var parser = new DOMParser(); 
        xmlConfig = parser.parseFromString(xmlhttp.responseText, "text/xml"); 
      }
      else if (ie) 
      { 
        xmlConfig = new ActiveXObject("Microsoft.XMLDOM"); 
        xmlConfig.async = false; 
  			xmlConfig.validateOnParse = false;
  			xmlConfig.loadXML(xmlhttp.responseXML.xml);
      } 
		}
		else
		{
      if (moz)
      { 
        var parser = new DOMParser(); 
        xmlConfig = parser.parseFromString(xmlhttp.responseText, "text/xml"); 
      }
      else if (ie) 
      { 
        xmlConfig = new ActiveXObject("Microsoft.XMLDOM"); 
        xmlConfig.async = false; 
  			xmlConfig.validateOnParse = false;
		  	xmlConfig.loadXML(xmlhttp.responseText);
      } 
		}
  */  

  xmlConfig = AJAX(document.getElementById("txtConfigPath").value, proxy_enabled);
  
  if(moz)
	{
    document.title = xmlConfig.getElementsByTagName("APPLICATION")[0].getAttribute("Title");

    //nacti xslt sablony
  	get_queries_xslt_path = xmlConfig.getElementsByTagName("CONST")[0].getElementsByTagName("XSL_URL")[0].getAttribute("q_style_url");
  	get_t_queries_xslt_path = xmlConfig.getElementsByTagName("CONST")[0].getElementsByTagName("XSL_URL")[0].getAttribute("tq_style_url");
  	get_o_queries_xslt_path = xmlConfig.getElementsByTagName("CONST")[0].getElementsByTagName("XSL_URL")[0].getAttribute("oq_style_url");
  	get_query_param_xslt_path = xmlConfig.getElementsByTagName("CONST")[0].getElementsByTagName("XSL_URL")[0].getAttribute("qp_style_url");
  	get_query_result_xslt_path = xmlConfig.getElementsByTagName("CONST")[0].getElementsByTagName("XSL_URL")[0].getAttribute("qr_style_url");

  	get_queries_xslt = AJAX(get_queries_xslt_path, proxy_enabled);
  	get_t_queries_xslt = AJAX(get_t_queries_xslt_path, proxy_enabled);
  	get_o_queries_xslt = AJAX(get_o_queries_xslt_path, proxy_enabled);
  	get_query_param_xslt = AJAX(get_query_param_xslt_path, proxy_enabled);
  	get_query_result_xslt = AJAX(get_query_result_xslt_path, proxy_enabled);

    print_map_url = xmlConfig.getElementsByTagName("CONST")[0].getElementsByTagName("SERVICE_URL")[0].getAttribute("print_map_url");
    print_query_url = xmlConfig.getElementsByTagName("CONST")[0].getElementsByTagName("SERVICE_URL")[0].getAttribute("print_query_url");
    print_dialog_url = xmlConfig.getElementsByTagName("CONST")[0].getElementsByTagName("SERVICE_URL")[0].getAttribute("print_dialog_url");
    param_dialog_url = xmlConfig.getElementsByTagName("CONST")[0].getElementsByTagName("SERVICE_URL")[0].getAttribute("param_dialog_url");
    save_enviroment_url = xmlConfig.getElementsByTagName("CONST")[0].getElementsByTagName("SERVICE_URL")[0].getAttribute("save_enviroment_url");
    kn_query_result_url = xmlConfig.getElementsByTagName("CONST")[0].getElementsByTagName("SERVICE_URL")[0].getAttribute("kn_query_result_url");
    
  	map_list.default_map_id = xmlConfig.getElementsByTagName("APPLICATION")[0].getAttribute("Default_map_id");
    //map_list.map_id = map_list.default_map_id;

    wms_enabled = (xmlConfig.getElementsByTagName("APPLICATION")[0].getAttribute("Wms_enabled") != null)?parseInt(xmlConfig.getElementsByTagName("APPLICATION")[0].getAttribute("Wms_enabled")):0;

    if(wms_enabled != 0)
    {
      document.getElementById("zalozkaWMS").style.display = "";
    }
    else
    {
      document.getElementById("zalozkaWMS").style.display = "none";
    }

    wcs_enabled = (xmlConfig.getElementsByTagName("APPLICATION")[0].getAttribute("Wcs_enabled") != null)?parseInt(xmlConfig.getElementsByTagName("APPLICATION")[0].getAttribute("Wcs_enabled")):0;

    if(wcs_enabled != 0)
    {
      document.getElementById("zalozkaWCS").style.display = "";
    }
    else
    {
      document.getElementById("zalozkaWCS").style.display = "none";
    }
    
 		proxy_enabled = parseInt(xmlConfig.getElementsByTagName("PROXY")[0].getAttribute("Enabled"));
 		proxy_url = xmlConfig.getElementsByTagName("PROXY")[0].getAttribute("Url");
    
    //naplneni panelu pro nastaveni tisku
  	var xmlPages = xmlConfig.getElementsByTagName("PRINT_CONFIG")[0].getElementsByTagName("PRINT_MAP")[0].getElementsByTagName("PPAGE");
    
    var print_page_string = "";
    
		for (var page = 0; page < xmlPages.length; page++)
		{
			var page_title = xmlPages[page].getAttribute("Title");
			var page_width = xmlPages[page].getAttribute("Width");
			var page_height = xmlPages[page].getAttribute("Height");
		  
      print_page_string = print_page_string	+ "<OPTION Value='" + page_width + "|" + page_height + "'>" + page_title + "</OPTION>";
		}
		
    document.getElementById("spnPrintPageSetting").innerHTML = "<SELECT id='cmbPrint_page_setting' class='vyber' style='width:175px' onChange='cmbPrintPageSetting_Change()'>" + print_page_string + "</SELECT>";

  	cmbPrintPageSetting_Change();

  	var xmlQFactor = xmlConfig.getElementsByTagName("PRINT_CONFIG")[0].getElementsByTagName("QUALITY_FACTOR")[0].getElementsByTagName("QFACTOR");
    
    var print_qfactor_string = "";
    
		for (var qfactor = 0; qfactor < xmlQFactor.length; qfactor++)
		{
			var qfactor_title = xmlQFactor[qfactor].getAttribute("Title");
			var qfactor_value = xmlQFactor[qfactor].getAttribute("Value");
		  
      print_qfactor_string = print_qfactor_string	+ "<OPTION Value='" + qfactor_value + "'>" + qfactor_title + "</OPTION>";
		}
		
    document.getElementById("spnPrintQualityFactor").innerHTML = "<SELECT id='cmbPrint_quality_factor' class='vyber' style='width:175px' onChange='notifyQ(this)'>" + print_qfactor_string + "</SELECT>";

  	var xmlPScales = xmlConfig.getElementsByTagName("PRINT_CONFIG")[0].getElementsByTagName("PRINT_SCALES")[0].getElementsByTagName("PSCALE");
    
    var print_scales_string = "";
    
		for (var pscale = 0; pscale < xmlPScales.length; pscale++)
		{
			var pscale_title = xmlPScales[pscale].getAttribute("Title");
			var pscale_value = xmlPScales[pscale].getAttribute("Value");
		  
      print_scales_string = print_scales_string	+ "<OPTION Value='" + pscale_value + "'>" + pscale_title + "</OPTION>";
		}
		
    document.getElementById("spnPrintScales").innerHTML = "<SELECT id='cmbPrint_scales' class='vyber' style='width:175px'>" + print_scales_string + "</SELECT>";

    //nacteni CRS info
    var xmlCRS_Records = xmlConfig.getElementsByTagName("CRS_INFO")[0].getElementsByTagName("CRS_RECORD");

    if(xmlCRS_Records != null)
    {
  		for (var crs_record = 0; crs_record < xmlCRS_Records.length; crs_record++)
  		{
  			var code = xmlCRS_Records[crs_record].getAttribute("Code");
  			var name = xmlCRS_Records[crs_record].getAttribute("Name");
  			var unit = xmlCRS_Records[crs_record].getAttribute("Unit");
  			var round = xmlCRS_Records[crs_record].getAttribute("Round");
  		  var sign = xmlCRS_Records[crs_record].getAttribute("Sign");
  		  var axis_order = xmlCRS_Records[crs_record].getAttribute("AxisOrder");
  		  var axis_horiz_desc = xmlCRS_Records[crs_record].getAttribute("AxisHorizDesc");
  		  var axis_vert_desc = xmlCRS_Records[crs_record].getAttribute("AxisVertDesc");
  		  var n_sign = 1;
  		  var n_axis_order = 1;
  		  
  		  if(sign == "inverse")
  		  {
          n_sign = -1;
        }

  		  if(axis_order == "inverse")
  		  {
          n_axis_order = -1;
        }
        
  		  var crs = new CRS_Record(code, name, unit, round, n_sign, n_axis_order, axis_horiz_desc, axis_vert_desc);
        crs_info.Add_Crs(crs);
  		}
    }

  	var xmlMaps = xmlConfig.getElementsByTagName("MAP");
  	var map_string = "";
  		
  	for (var i = 0; i < xmlMaps.length; i++)
  	{
      var id = xmlMaps[i].getAttribute("Id");
  		var title = xmlMaps[i].getAttribute("Title");
  		var srs = xmlMaps[i].getAttribute("Srs");
  		var bbox = xmlMaps[i].getAttribute("Bbox");
  		var projection_to_scale = (xmlMaps[i].getAttribute("Projection_to_scale") != null)?parseFloat(xmlMaps[i].getAttribute("Projection_to_scale")):1;
  		var image_format = xmlMaps[i].getAttribute("Image_format");
  		var default_version = xmlMaps[i].getAttribute("Default_version");
      	
  		var query_url = xmlMaps[i].getElementsByTagName("QUERIES")[0].getAttribute("Url");
  		var click_url = xmlMaps[i].getElementsByTagName("CLICKMAP")[0].getAttribute("Url");
  		var click_layer = xmlMaps[i].getElementsByTagName("CLICKMAP")[0].getAttribute("Layer");
      var prw_url = xmlMaps[i].getElementsByTagName("PREVIEW")[0].getAttribute("Wms");
  		var pos_url = xmlMaps[i].getElementsByTagName("PREVIEW")[0].getAttribute("Position");
  		var cst_url = xmlMaps[i].getElementsByTagName("CST")[0].getAttribute("Url");

    	var BBoxArray = ParseBBox(bbox);
			BBoxArray = TransformBBox(BBoxArray, map_width, map_height);
      bbox = dbl2StrEN(BBoxArray[0].toString()) + "," + dbl2StrEN(BBoxArray[1].toString()) + "," + dbl2StrEN(BBoxArray[2].toString()) + "," + dbl2StrEN(BBoxArray[3].toString());

  		var m_map = new Map(id, title, srs, bbox, projection_to_scale, image_format, default_version, map_width, map_height, click_url, click_layer, query_url, prw_url, pos_url, cst_url);
            
  		// Nacteni meritek mapy
  		var xmlScales = xmlMaps[i].getElementsByTagName("SCALE");
  		
  		for (var j = 0; j < xmlScales.length; j++)
  		{
  			var title = xmlScales[j].getAttribute("Title");
  			var value = xmlScales[j].getAttribute("Value");
  				
  			var m_scale = new Scale(title, value);
  				
  			m_map.Add_Scale(m_scale);
  		}

  		// Nacteni wms_serveru mapy
      var xmlWMS = xmlMaps[i].getElementsByTagName("WMS_SERVERS")[0].getElementsByTagName("SERVER");

      m_map.wms_list_url = xmlMaps[i].getElementsByTagName("WMS_SERVERS")[0].getAttribute("List_url");
      
  		for (var j = 0; j < xmlWMS.length; j++)
  		{
  			var id = j;
  			var url = xmlWMS[j].getAttribute("Url");
  			var opacity = xmlWMS[j].getAttribute("Opacity");
  			var selected = parseInt(xmlWMS[j].getAttribute("Selected"));
  			
  			var b_sel = (selected == 0)?false:true;
  
  			var m_wms = new WMS_server(id, url, opacity, b_sel, false, map_width, map_height, m_map.image_format, m_map.srs, m_map.bbox);
  				
  			//nacteni defaultnich vrstev
  			var xmlDefault_Layers = xmlWMS[j].getElementsByTagName("LAYERS")[0].getElementsByTagName("LAYER");
  		
  			for (var k = 0; k < xmlDefault_Layers.length; k++)
  			{
  				var name = xmlDefault_Layers[k].getAttribute("Name");
  				var m_default_layer = new Default_layer(name);
  					
  				m_wms.Add_Default_Layer(m_default_layer);
  			}
  			//nacteni capabilities serveru
  			//m_wms.Get_Capabilities(m_map.default_version);

  			m_map.Add_WMS(m_wms);
  			
  			/*if(m_wms.selected)
  			{
          m_wms.GetMap();
        }*/
  		}

  		// Nacteni wcs_serveru mapy
      var xmlWCS = xmlMaps[i].getElementsByTagName("WCS_SERVERS")[0].getElementsByTagName("SERVER");

  		for (var j = 0; j < xmlWCS.length; j++)
  		{
  			var id = j;
  			var title = xmlWCS[j].getAttribute("Title");
  			var url = xmlWCS[j].getAttribute("Url");
  			var opacity = xmlWCS[j].getAttribute("Opacity");
  			var image_format = xmlWCS[j].getAttribute("Image_format");
  			
  			var m_wcs = new WCS_server(id, title, url, opacity, map_width, map_height, image_format, m_map.srs, m_map.bbox);
  				
  			//nacteni capabilities serveru
  			//m_wms.Get_Capabilities("1.0.0");

  			m_map.Add_WCS(m_wcs);
  			
  		}

		  //Pridani CMS serveru pokud je
		  if(m_map.clickmap_url != '')
		  {
        var m_cms = new CMS_server(0, m_map.clickmap_url, m_map.clickmap_layer, 1, 1, map_width, map_height, m_map.srs, m_map.bbox)

 				var m_default_layer = new Default_layer(m_map.clickmap_layer);
  					
 				m_cms.Add_Default_Layer(m_default_layer);

  			//nacteni capabilities serveru
  			m_cms.Get_Capabilities('1.0.0');
        
  			m_map.Add_CMS(m_cms);

      }

      // Pridani mapy do seznamu preddefinovanych mapovych kompozic
  		map_list.Add(m_map);
  			
  		// Naplneni komboboxu s preddefinovanymi mapovymi kompozicemi
  		map_string += "<option value='" + m_map.id + "'>" + m_map.title + "</option>"
  		
  	}    
  }
  else
  {
    document.title = xmlConfig.selectSingleNode("//APPLICATION").getAttribute("Title");

    //nacti xslt sablony
  	get_queries_xslt_path = xmlConfig.selectSingleNode("//CONST/XSL_URL").getAttribute("q_style_url");
  	get_t_queries_xslt_path = xmlConfig.selectSingleNode("//CONST/XSL_URL").getAttribute("tq_style_url");
  	get_o_queries_xslt_path = xmlConfig.selectSingleNode("//CONST/XSL_URL").getAttribute("oq_style_url");
  	get_query_param_xslt_path = xmlConfig.selectSingleNode("//CONST/XSL_URL").getAttribute("qp_style_url");
  	get_query_result_xslt_path = xmlConfig.selectSingleNode("//CONST/XSL_URL").getAttribute("qr_style_url");

  	get_queries_xslt = AJAX(get_queries_xslt_path, proxy_enabled);
  	get_t_queries_xslt = AJAX(get_t_queries_xslt_path, proxy_enabled);
  	get_o_queries_xslt = AJAX(get_o_queries_xslt_path, proxy_enabled);
  	get_query_param_xslt = AJAX(get_query_param_xslt_path, proxy_enabled);
  	get_query_result_xslt = AJAX(get_query_result_xslt_path, proxy_enabled);

    print_map_url = xmlConfig.selectSingleNode("//SERVICE_URL").getAttribute("print_map_url");
    print_query_url = xmlConfig.selectSingleNode("//SERVICE_URL").getAttribute("print_query_url");
    print_dialog_url = xmlConfig.selectSingleNode("//SERVICE_URL").getAttribute("print_dialog_url");
    param_dialog_url = xmlConfig.selectSingleNode("//SERVICE_URL").getAttribute("param_dialog_url");
    save_enviroment_url = xmlConfig.selectSingleNode("//SERVICE_URL").getAttribute("save_enviroment_url");
    kn_query_result_url = xmlConfig.selectSingleNode("//SERVICE_URL").getAttribute("kn_query_result_url");
  		
  	map_list.default_map_id = xmlConfig.selectSingleNode("//APPLICATION").getAttribute("Default_map_id");
    //map_list.map_id = map_list.default_map_id;

  	wms_enabled = (xmlConfig.selectSingleNode("//APPLICATION").getAttribute("Wms_enabled") != null)?parseInt(xmlConfig.selectSingleNode("//APPLICATION").getAttribute("Wms_enabled")):0;

    if(wms_enabled != 0)
    {
      document.getElementById("zalozkaWMS").style.display = "";
    }
    else
    {
      document.getElementById("zalozkaWMS").style.display = "none";
    }

  	wcs_enabled = (xmlConfig.selectSingleNode("//APPLICATION").getAttribute("Wcs_enabled") != null)?parseInt(xmlConfig.selectSingleNode("//APPLICATION").getAttribute("Wcs_enabled")):0;

    if(wcs_enabled != 0)
    {
      document.getElementById("zalozkaWCS").style.display = "";
    }
    else
    {
      document.getElementById("zalozkaWCS").style.display = "none";
    }
        
    proxy_enabled = parseInt(xmlConfig.selectSingleNode("//PROXY").getAttribute("Enabled"));
    proxy_url = xmlConfig.selectSingleNode("//PROXY").getAttribute("Url");

    //naplneni panelu pro nastaveni tisku
  	var xmlPages = xmlConfig.selectNodes("//PPAGE");
    
    var print_page_string = "";
    
		for (var page = 0; page < xmlPages.length; page++)
		{
			var page_title = xmlPages.item(page).getAttribute("Title");
			var page_width = xmlPages.item(page).getAttribute("Width");
			var page_height = xmlPages.item(page).getAttribute("Height");
		  
      print_page_string = print_page_string	+ "<OPTION Value='" + page_width + "|" + page_height + "'>" + page_title + "</OPTION>";
		}
		
    document.getElementById("spnPrintPageSetting").innerHTML = "<SELECT id='cmbPrint_page_setting' class='vyber' style='width:175px' onChange='cmbPrintPageSetting_Change()'>" + print_page_string + "</SELECT>";

  	cmbPrintPageSetting_Change();

  	var xmlQFactor = xmlConfig.selectNodes("//QFACTOR");
    
    var print_qfactor_string = "";
    
		for (var qfactor = 0; qfactor < xmlQFactor.length; qfactor++)
		{
			var qfactor_title = xmlQFactor.item(qfactor).getAttribute("Title");
			var qfactor_value = xmlQFactor.item(qfactor).getAttribute("Value");
		  
      print_qfactor_string = print_qfactor_string	+ "<OPTION Value='" + qfactor_value + "'>" + qfactor_title + "</OPTION>";
		}
		
    document.getElementById("spnPrintQualityFactor").innerHTML = "<SELECT id='cmbPrint_quality_factor' class='vyber' style='width:175px' onChange='notifyQ(this)'>" + print_qfactor_string + "</SELECT>";

  	var xmlPScales = xmlConfig.selectNodes("//PSCALE");
    
    var print_scales_string = "";
    
		for (var pscale = 0; pscale < xmlPScales.length; pscale++)
		{
			var pscale_title = xmlPScales.item(pscale).getAttribute("Title");
			var pscale_value = xmlPScales.item(pscale).getAttribute("Value");
		  
      print_scales_string = print_scales_string	+ "<OPTION Value='" + pscale_value + "'>" + pscale_title + "</OPTION>";
		}
		
    document.getElementById("spnPrintScales").innerHTML = "<SELECT id='cmbPrint_scales' class='vyber' style='width:175px'>" + print_scales_string + "</SELECT>";

    //nacteni CRS info
    var xmlCRS_Records = xmlConfig.selectNodes("//CRS_RECORD");

		if(xmlCRS_Records != null)
		{
      for (var crs_record = 0; crs_record < xmlCRS_Records.length; crs_record++)
  		{
  			var code = xmlCRS_Records.item(crs_record).getAttribute("Code");
  			var name = xmlCRS_Records.item(crs_record).getAttribute("Name");
  			var unit = xmlCRS_Records.item(crs_record).getAttribute("Unit");
  			var round = xmlCRS_Records.item(crs_record).getAttribute("Round");
  		  var sign = xmlCRS_Records.item(crs_record).getAttribute("Sign");
  		  var axis_order = xmlCRS_Records.item(crs_record).getAttribute("AxisOrder");
  		  var axis_horiz_desc = xmlCRS_Records.item(crs_record).getAttribute("AxisHorizDesc");
  		  var axis_vert_desc = xmlCRS_Records.item(crs_record).getAttribute("AxisVertDesc");
  		  var n_sign = 1;
  		  var n_axis_order = 1;

  		  if(sign == "inverse")
  		  {
          n_sign = -1;
        }

  		  if(axis_order == "inverse")
  		  {
          n_axis_order = -1;
        }
        
        var crs = new CRS_Record(code, name, unit, round, n_sign, n_axis_order, axis_horiz_desc, axis_vert_desc);
        crs_info.Add_Crs(crs);
  		}
    }
  		
  	var xmlMaps = xmlConfig.selectNodes("//MAP");
  	var map_string = "";
  		
  	for (var i = 0; i < xmlMaps.length; i++)
  	{
  		var id = xmlMaps.item(i).getAttribute("Id");
  		var title = xmlMaps.item(i).getAttribute("Title");
  		var srs = xmlMaps.item(i).getAttribute("Srs");
  		var bbox = xmlMaps.item(i).getAttribute("Bbox");
  		var projection_to_scale = (xmlMaps.item(i).getAttribute("Projection_to_scale") != null)?parseFloat(xmlMaps.item(i).getAttribute("Projection_to_scale")):1;
  		var image_format = xmlMaps.item(i).getAttribute("Image_format");
  		var default_version = xmlMaps.item(i).getAttribute("Default_version");
      	
  		var query_url = xmlMaps.item(i).selectSingleNode("QUERIES").getAttribute("Url");
  		var click_url = xmlMaps.item(i).selectSingleNode("CLICKMAP").getAttribute("Url");
  		var click_layer = xmlMaps.item(i).selectSingleNode("CLICKMAP").getAttribute("Layer");
  		var prw_url = xmlMaps.item(i).selectSingleNode("PREVIEW").getAttribute("Wms");
  		var pos_url = xmlMaps.item(i).selectSingleNode("PREVIEW").getAttribute("Position");
  		var cst_url = xmlMaps.item(i).selectSingleNode("CST").getAttribute("Url");

    	var BBoxArray = ParseBBox(bbox);
			BBoxArray = TransformBBox(BBoxArray, map_width, map_height);
      bbox = dbl2StrEN(BBoxArray[0].toString()) + "," + dbl2StrEN(BBoxArray[1].toString()) + "," + dbl2StrEN(BBoxArray[2].toString()) + "," + dbl2StrEN(BBoxArray[3].toString());
  
  		var m_map = new Map(id, title, srs, bbox, projection_to_scale, image_format, default_version, map_width, map_height, click_url, click_layer, query_url, prw_url, pos_url, cst_url);
  
  		// Nacteni meritek mapy
  		var xmlScales = xmlMaps.item(i).selectNodes("SCALES/SCALE");
  		
  		for (var j = 0; j < xmlScales.length; j++)
  		{
  			var title = xmlScales.item(j).getAttribute("Title");
  			var value = xmlScales.item(j).getAttribute("Value");
  				
  			var m_scale = new Scale(title, value);
  				
  			m_map.Add_Scale(m_scale);
  		}
  
  		// Nacteni wms_serveru mapy
  		var xmlWMS = xmlMaps.item(i).selectNodes("WMS_SERVERS/SERVER");

      m_map.wms_list_url = xmlMaps.item(i).selectSingleNode("WMS_SERVERS").getAttribute("List_url");
  		
  		for (var j = 0; j < xmlWMS.length; j++)
  		{
  			var id = j;
  			var url = xmlWMS.item(j).getAttribute("Url");
  			var opacity = xmlWMS.item(j).getAttribute("Opacity");
  			var selected = parseInt(xmlWMS.item(j).getAttribute("Selected"));
  			
  			var b_sel = (selected == 0)?false:true;
  
  			var m_wms = new WMS_server(id, url, opacity, b_sel, false, map_width, map_height, m_map.image_format, m_map.srs, m_map.bbox);
  				
  			//nacteni defaultnich vrstev
  			var xmlDefault_Layers = xmlWMS.item(j).selectNodes("./LAYERS/LAYER");
  		
  			for (var k = 0; k < xmlDefault_Layers.length; k++)
  			{
  				var name = xmlDefault_Layers.item(k).getAttribute("Name");
  					
  				var m_default_layer = new Default_layer(name);
  					
  				m_wms.Add_Default_Layer(m_default_layer);
  			}
  				
  			//nacteni capabilities serveru
  			//m_wms.Get_Capabilities(m_map.default_version);
        
  			m_map.Add_WMS(m_wms);

  			/*if(m_wms.selected)
  			{
          m_wms.GetMap();
        }*/

  		}

  		// Nacteni wcs_serveru mapy
  		var xmlWCS = xmlMaps.item(i).selectNodes("WCS_SERVERS/SERVER");

  		for (var j = 0; j < xmlWCS.length; j++)
  		{
  			var id = j;
  			var title = xmlWCS.item(j).getAttribute("Title");
  			var url = xmlWCS.item(j).getAttribute("Url");
  			var opacity = xmlWCS.item(j).getAttribute("Opacity");
  			var image_format = xmlWCS.item(j).getAttribute("Image_format");
  			
  			var m_wcs = new WCS_server(id, title, url, opacity, map_width, map_height, image_format, m_map.srs, m_map.bbox);
  				
  			//nacteni capabilities serveru
  			m_wcs.Get_Capabilities("1.0.0");

  			m_map.Add_WCS(m_wcs);
  			
  		}
		
		  //Pridani CMS serveru pokud je
		  if(m_map.clickmap_url != '')
		  {
        var m_cms = new CMS_server(0, m_map.clickmap_url, m_map.clickmap_layer, 1, 1, map_width, map_height, m_map.srs, m_map.bbox)

 				var m_default_layer = new Default_layer(m_map.clickmap_layer);
  					
 				m_cms.Add_Default_Layer(m_default_layer);

  			//nacteni capabilities serveru
  			m_cms.Get_Capabilities('1.0.0');
        
  			m_map.Add_CMS(m_cms);

      }
		  
      // Pridani mapy do seznamu preddefinovanych mapovych kompozic
  		map_list.Add(m_map);
  			
  		// Naplneni komboboxu s preddefinovanymi mapovymi kompozicemi
  		map_string += "<option value='" + m_map.id + "'>" + m_map.title + "</option>"
  	}
	}	
	
  if(document.getElementById("txtMapID").value != "")
  {
    var map_id = parseInt(document.getElementById("txtMapID").value);
    
    if(map_id >=0 && map_id < map_list.maps.Length())
    {
      map_list.default_map_id = map_id;
    }
  }

	// Nastaveni defaultni mapy v kombo boxu
	document.getElementById("spnTMapa").innerHTML = "<select id='cmbTMapa' class='vyber' onChange='btnTMapaOK_Click();' style='margin-left: 20px; width: 160px'>" + map_string + "</select>"
	document.getElementById("cmbTMapa").selectedIndex = map_list.default_map_id;

	for(var i = 0; i < map_list.maps.Item(map_list.default_map_id).wms_list.Length(); i++)
	{

		//nacteni capabilities serveru
		map_list.maps.Item(map_list.default_map_id).wms_list.Item(i).Get_Capabilities(map_list.maps.Item(map_list.default_map_id).default_version);
  }
		
	// Zobrazeni preddefinovane mapy
	map_list.Load_Map(map_list.default_map_id);
	
	SetPosition();
	
	if(document.getElementById("txtNewWMS").value != '')
	{
    if(wms_enabled == 1)
    {
      ViewSwitch('OknoWMS');
    }
  }
}
//*******************************************************************************

function AJAX(url, proxy_enabled)
{
    var moz = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined');
    var ie = (typeof window.ActiveXObject != 'undefined'); 
		
		var xmlhttp;
		
		var return_xml_dom;

    // code for Mozilla, etc.
    if (window.XMLHttpRequest)
    {
      xmlhttp = new XMLHttpRequest();
    }
    // code for IE
    else if (window.ActiveXObject)
    {
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
          
    if (xmlhttp != null)
    {
      if (proxy_enabled)
      {
  			var re = /[?]/i;
		
	      url = proxy_url + "?URL=" + url.replace(re, "&");

      }
      xmlhttp.open("GET", url, false);
    }
    else 
    {
      alert(script_messages[4]);
      return(false);
    }
    try {
      xmlhttp.send(null);
    }
    catch(e)
    {
      alert("error");
    }

		//vracen error ze serveru
		if(xmlhttp.status != 200)
		{
			alert(script_messages[5] + xmlhttp.statusText);
			return(false);
			
		}

		//zkontroluj vracenou hlavicku kvuli metode nacteni
		if(xmlhttp.getResponseHeader("Content-Type") == "text/xml")
		{
      if (moz)
      { 
        var parser = new DOMParser(); 
        xml_return_dom = parser.parseFromString(xmlhttp.responseText, "text/xml");
      }
      else if (ie) 
      { 
        xml_return_dom = new ActiveXObject("Microsoft.XMLDOM"); 
        xml_return_dom.async = false; 
  			xml_return_dom.validateOnParse = false;
  			xml_return_dom.loadXML(xmlhttp.responseXML.xml);
      } 
		}
		else
		{
      if (moz)
      { 
        var parser = new DOMParser(); 
        xml_return_dom = parser.parseFromString(xmlhttp.responseText, "text/xml"); 
      }
      else if (ie) 
      { 
        xml_return_dom = new ActiveXObject("Microsoft.XMLDOM"); 
        xml_return_dom.async = false; 
  			xml_return_dom.validateOnParse = false;
		  	xml_return_dom.loadXML(xmlhttp.responseText);
      } 
		}
    //alert(xml_return_dom.xml);
    return (xml_return_dom);
}

function ViewSwitch(name)
{
/*
 * Procedura realizuji prepnuti na pozadovanou zalozku.
 */

	switch(name.toLowerCase())
	{
		case "oknomapa" :
			HideMapLayers();
			document.getElementById("divOknoZakladni").style.display = "";
			document.getElementById("zalozkaVrstvy").className = "zalozkaN";
			document.getElementById("OknoVyhledat").style.display = "none";
			document.getElementById("zalozkaVyhledat").className = "zalozkaN";
			document.getElementById("OknoNastaveni").style.display = "none";
			document.getElementById("zalozkaNastaveni").className = "zalozkaN";
			document.getElementById("OknoNapoveda").style.display = "none";
			document.getElementById("zalozkaNapoveda").className = "zalozkaN";
			document.getElementById("Main").style.display = "";
			document.getElementById("zalozkaMapa").className = "zalozkaA";
			document.getElementById("OknoWMS").style.display = "none";
			document.getElementById("zalozkaWMS").className = "zalozkaN";
			document.getElementById("OknoWCS").style.display = "none";
			document.getElementById("zalozkaWCS").className = "zalozkaN";
			document.getElementById("OknoFI").style.display = "none";
			document.getElementById("zalozkaFI").className = "zalozkaN";
      break;
		case "oknovrstvy" :
			document.getElementById("divOknoZakladni").style.display = "";
			document.getElementById("zalozkaVrstvy").className = "zalozkaA";
			document.getElementById("OknoVyhledat").style.display = "none";
			document.getElementById("zalozkaVyhledat").className = "zalozkaN";
			document.getElementById("Main").style.display = "";
			document.getElementById("zalozkaMapa").className = "zalozkaN";
			document.getElementById("OknoNastaveni").style.display = "none";
			document.getElementById("zalozkaNastaveni").className = "zalozkaN";
			document.getElementById("OknoNapoveda").style.display = "none";
			document.getElementById("zalozkaNapoveda").className = "zalozkaN";
			document.getElementById("OknoWMS").style.display = "none";
			document.getElementById("zalozkaWMS").className = "zalozkaN";
			document.getElementById("OknoWCS").style.display = "none";
			document.getElementById("zalozkaWCS").className = "zalozkaN";
			document.getElementById("OknoFI").style.display = "none";
			document.getElementById("zalozkaFI").className = "zalozkaN";
			ShowMapLayers();
			break;
		case "oknoaktiv" :
			document.getElementById("divOknoZakladni").style.display = "";
			document.getElementById("zalozkaAktiv").className = "zalozkaA";
			document.getElementById("OknoVyhledat").style.display = "none";
			document.getElementById("zalozkaVyhledat").className = "zalozkaN";
			document.getElementById("Main").style.display = "";
			document.getElementById("zalozkaMapa").className = "zalozkaN";
			document.getElementById("OknoNastaveni").style.display = "none";
			document.getElementById("zalozkaNastaveni").className = "zalozkaN";
			document.getElementById("OknoNapoveda").style.display = "none";
			document.getElementById("zalozkaNapoveda").className = "zalozkaN";
			document.getElementById("OknoWMS").style.display = "none";
			document.getElementById("zalozkaWMS").className = "zalozkaN";
			document.getElementById("OknoWCS").style.display = "none";
			document.getElementById("zalozkaWCS").className = "zalozkaN";
			document.getElementById("OknoFI").style.display = "none";
			document.getElementById("zalozkaFI").className = "zalozkaN";
			ShowAktivLayers();
			break;
		case "oknofi" :
      HideMapLayers();
      if(document.getElementById("zalozkaFI").style.display == "none")
      {
        ViewSwitch('OknoMapa');  
      }
      else
      {
  			document.getElementById("divOknoZakladni").style.display = "";
  			document.getElementById("zalozkaVrstvy").className = "zalozkaN";
  			document.getElementById("OknoFI").style.display = "";
  			document.getElementById("zalozkaFI").className = "zalozkaA";
  			document.getElementById("OknoVyhledat").style.display = "none";
  			document.getElementById("zalozkaVyhledat").className = "zalozkaN";
  			document.getElementById("Main").style.display = "none";
  			document.getElementById("zalozkaMapa").className = "zalozkaN";
  			document.getElementById("OknoNastaveni").style.display = "none";
  			document.getElementById("zalozkaNastaveni").className = "zalozkaN";
  			document.getElementById("OknoNapoveda").style.display = "none";
  			document.getElementById("zalozkaNapoveda").className = "zalozkaN";
  			document.getElementById("OknoWMS").style.display = "none";
  			document.getElementById("zalozkaWMS").className = "zalozkaN";
  			document.getElementById("OknoWCS").style.display = "none";
	   		document.getElementById("zalozkaWCS").className = "zalozkaN";
      }
			break;
		case "oknovyhledat" :
      HideMapLayers();
			document.getElementById("divOknoZakladni").style.display = "";
			document.getElementById("zalozkaVrstvy").className = "zalozkaN";
			document.getElementById("OknoVyhledat").style.display = "";
			document.getElementById("zalozkaVyhledat").className = "zalozkaA";
			document.getElementById("Main").style.display = "none";
			document.getElementById("zalozkaMapa").className = "zalozkaN";
			document.getElementById("OknoNastaveni").style.display = "none";
			document.getElementById("zalozkaNastaveni").className = "zalozkaN";
			document.getElementById("OknoNapoveda").style.display = "none";
			document.getElementById("zalozkaNapoveda").className = "zalozkaN";
			document.getElementById("OknoWMS").style.display = "none";
			document.getElementById("zalozkaWMS").className = "zalozkaN";
			document.getElementById("OknoWCS").style.display = "none";
			document.getElementById("zalozkaWCS").className = "zalozkaN";
			document.getElementById("OknoFI").style.display = "none";
			document.getElementById("zalozkaFI").className = "zalozkaN";
			break;
		case "oknowms" :
      HideMapLayers();
			document.getElementById("divOknoZakladni").style.display = "";
			document.getElementById("zalozkaVrstvy").className = "zalozkaN";
			document.getElementById("OknoVyhledat").style.display = "none";
			document.getElementById("zalozkaVyhledat").className = "zalozkaN";
			document.getElementById("Main").style.display = "none";
			document.getElementById("zalozkaMapa").className = "zalozkaN";
			document.getElementById("OknoWMS").style.display = "";
			document.getElementById("zalozkaWMS").className = "zalozkaA";
			document.getElementById("OknoWCS").style.display = "none";
			document.getElementById("zalozkaWCS").className = "zalozkaN";
			document.getElementById("OknoNastaveni").style.display = "none";
			document.getElementById("zalozkaNastaveni").className = "zalozkaN";
			document.getElementById("OknoNapoveda").style.display = "none";
			document.getElementById("zalozkaNapoveda").className = "zalozkaN";
			document.getElementById("OknoFI").style.display = "none";
			document.getElementById("zalozkaFI").className = "zalozkaN";
			break;
		case "oknowcs" :
      HideMapLayers();
			document.getElementById("divOknoZakladni").style.display = "";
			document.getElementById("zalozkaVrstvy").className = "zalozkaN";
			document.getElementById("OknoVyhledat").style.display = "none";
			document.getElementById("zalozkaVyhledat").className = "zalozkaN";
			document.getElementById("Main").style.display = "none";
			document.getElementById("zalozkaMapa").className = "zalozkaN";
			document.getElementById("OknoWMS").style.display = "none";
			document.getElementById("zalozkaWMS").className = "zalozkaN";
			document.getElementById("OknoWCS").style.display = "";
			document.getElementById("zalozkaWCS").className = "zalozkaA";
			document.getElementById("OknoNastaveni").style.display = "none";
			document.getElementById("zalozkaNastaveni").className = "zalozkaN";
			document.getElementById("OknoNapoveda").style.display = "none";
			document.getElementById("zalozkaNapoveda").className = "zalozkaN";
			document.getElementById("OknoFI").style.display = "none";
			document.getElementById("zalozkaFI").className = "zalozkaN";
			break;
		case "oknonastaveni" :
      HideMapLayers();
			document.getElementById("divOknoZakladni").style.display = "";
			document.getElementById("zalozkaVrstvy").className = "zalozkaN";
			document.getElementById("OknoVyhledat").style.display = "none";
			document.getElementById("zalozkaVyhledat").className = "zalozkaN";
			document.getElementById("OknoNastaveni").style.display = "";
			document.getElementById("zalozkaNastaveni").className = "zalozkaA";
			document.getElementById("Main").style.display = "none";
			document.getElementById("zalozkaMapa").className = "zalozkaN";
			document.getElementById("OknoNapoveda").style.display = "none";
			document.getElementById("zalozkaNapoveda").className = "zalozkaN";
			document.getElementById("OknoWMS").style.display = "none";
			document.getElementById("zalozkaWMS").className = "zalozkaN";
			document.getElementById("OknoWCS").style.display = "none";
			document.getElementById("zalozkaWCS").className = "zalozkaN";
			document.getElementById("OknoFI").style.display = "none";
			document.getElementById("zalozkaFI").className = "zalozkaN";
			break;
		case "oknonapoveda" :
      HideMapLayers();
			document.getElementById("divOknoZakladni").style.display = "";
			document.getElementById("zalozkaVrstvy").className = "zalozkaN";
			document.getElementById("OknoNapoveda").style.display = "";
			document.getElementById("zalozkaNapoveda").className = "zalozkaA";
			document.getElementById("OknoVyhledat").style.display = "none";
			document.getElementById("zalozkaVyhledat").className = "zalozkaN";
			document.getElementById("OknoNastaveni").style.display = "none";
			document.getElementById("zalozkaNastaveni").className = "zalozkaN";
			document.getElementById("Main").style.display = "none";
			document.getElementById("zalozkaMapa").className = "zalozkaN";
			document.getElementById("OknoWMS").style.display = "none";
			document.getElementById("zalozkaWMS").className = "zalozkaN";
			document.getElementById("OknoWCS").style.display = "none";
			document.getElementById("zalozkaWCS").className = "zalozkaN";
			document.getElementById("OknoFI").style.display = "none";
			document.getElementById("zalozkaFI").className = "zalozkaN";
			break;
	}
}
//****************************************************************************

function replace_string(str, str1, value)
{
		//Pomocne promenne
		var re = new RegExp(str1 + "=([^&]*)&","ig");
		
		var r_str = str.replace(re, str1 + "=" + value + "&");
		
		return r_str;
}
//*******************************************************************************

function get_string(str, value)
{
		//Pomocne promenne
		var start_re = new RegExp(value + "=","ig");
		var end_re = new RegExp("&","ig");
		var start_pos, end_pos;
		var sub_str;
		
    start_pos = str.search(start_re);
		
		if(start_pos > -1)
		{
      sub_str = str.substr(start_pos + value.length + 1);
      end_pos = sub_str.search(end_re);

      if(end_pos > -1)
      {
        str = sub_str.substr(0, end_pos);
      }
      else
      {
        str = sub_str.substr(0, sub_str.length);
      }
    }
    else
    {
		  str = "";
		}

    return str;
}
//*******************************************************************************

function imgPrehledka_onLoad()
{
	document.getElementById("imgPrehledka").style.display = "";
}
//*******************************************************************************

function imgPosition_onLoad()
{
	document.getElementById("imgPosition").style.display = "";
}
//*******************************************************************************
	
/********************************************************************************
*							Funkce pro obsluhu udalosti GUI						*
********************************************************************************/

function btnWMS_Add_Click()
{
	var wms_url = document.getElementById("txtWMS_URL").value;

	if(wms_url != "")
	{
			var id = map_list.maps.Item(map_list.map_id).wms_list.Length();
			var opacity = 100;
				
			var m_wms = new WMS_server(id, wms_url, opacity, false, false, map_list.maps.Item(map_list.map_id).map_width, map_list.maps.Item(map_list.map_id).map_height, map_list.maps.Item(map_list.map_id).image_format, map_list.maps.Item(map_list.map_id).srs, map_list.maps.Item(map_list.map_id).bbox);

			//nacteni capabilities serveru
			var stav = m_wms.Get_Capabilities(map_list.maps.Item(map_list.map_id).default_version);
			
			if(stav)
			{
				map_list.maps.Item(map_list.map_id).Add_WMS(m_wms);
			
				map_list.maps.Item(map_list.map_id).Write_WMS("tdWMS_Servers", document.getElementById("cmbWMS_Servers").length);
			
				//cmbWMS_Servers_Click();
			}
			else
			{
				m_wms = null;
			}	
	}
	else
	{
		alert(script_messages[7]);
	}
}
//********************************************************************************

function btnWMS_Add_From_List_Click()
{
  if(document.getElementById("cmbWMS_URL").options.selectedIndex >= 0)
  {
    document.getElementById("txtWMS_URL").value = document.getElementById("cmbWMS_URL").options[document.getElementById("cmbWMS_URL").selectedIndex].value;
  }
}
//*******************************************************************************	

function btnWMS_Remove_Click()
{
	if(document.getElementById("cmbWMS_Servers").selectedIndex >= 0)
	{
		var wms_id = document.getElementById("cmbWMS_Servers").options[document.getElementById("cmbWMS_Servers").selectedIndex].value;
		var id = map_list.maps.Item(map_list.map_id).Get_Id(wms_id);
		
		map_list.maps.Item(map_list.map_id).wms_list.Remove(id);
		map_list.maps.Item(map_list.map_id).Write_WMS("tdWMS_Servers", map_list.maps.Item(map_list.map_id).wms_list.Length()-1);

    document.getElementById("cmbWMS_Servers").selectedIndex = 0;
	}
	else
	{
		alert(script_messages[8]);
	}
}
//*******************************************************************************	

function btnWMS_Properties_OK_Click()
{
	if(document.getElementById("cmbWMS_Servers").selectedIndex >= 0)
	{
		var wms_id = document.getElementById("cmbWMS_Servers").options[document.getElementById("cmbWMS_Servers").selectedIndex].value;
		var id = map_list.maps.Item(map_list.map_id).Get_Id(wms_id);
		
		map_list.maps.Item(map_list.map_id).wms_list.Item(id).SetOpacity(document.getElementById("txtWMS_Properties_Opacity").value);


  	if (document.getElementById("chbWMS_Feature_Info").checked)
  	{
  		map_list.maps.Item(map_list.map_id).wms_list.Item(id).featureinfo_selected = true;
  	}
  	else
  	{
  		map_list.maps.Item(map_list.map_id).wms_list.Item(id).featureinfo_selected = false;
  		//map_list.maps.Item(map_list.map_id).wms_list.Item(wms_id).map_img.style.display = "none";
  	}	

    map_list.maps.Item(map_list.map_id).wms_list.Item(id).fi_selected_value = document.getElementById("cmbWMS_Feature_Info_Format").options[document.getElementById("cmbWMS_Feature_Info_Format").selectedIndex].value;

		var image_format = document.getElementById("cmbWMS_Properties_ImageFormat").options[document.getElementById("cmbWMS_Properties_ImageFormat").selectedIndex].value;

    if(image_format.toLowerCase() != map_list.maps.Item(map_list.map_id).wms_list.Item(id).image_format.toLowerCase())
    {
      map_list.maps.Item(map_list.map_id).wms_list.Item(id).SetImageFormat(image_format);
      map_list.maps.Item(map_list.map_id).wms_list.Item(id).GetMap();
    }
  }
}
//****************************************************************************

function cmbWMS_Servers_Click()
{
	if(document.getElementById("cmbWMS_Servers").selectedIndex >= 0)
	{
		var wms_id = document.getElementById("cmbWMS_Servers").options[document.getElementById("cmbWMS_Servers").selectedIndex].value;
		var id = map_list.maps.Item(map_list.map_id).Get_Id(wms_id);
		
		map_list.maps.Item(map_list.map_id).wms_list.Item(id).Write_Format("spnWMS_Properties_ImageFormat");
		map_list.maps.Item(map_list.map_id).wms_list.Item(id).Write_Srs("divWMS_Properties_SRS");
		map_list.maps.Item(map_list.map_id).wms_list.Item(id).Write_FI_Format("spnWMS_Feature_Info_Format");
    
    if(map_list.maps.Item(map_list.map_id).wms_list.Item(id).featureinfo)
    {
      if(map_list.maps.Item(map_list.map_id).wms_list.Item(id).featureinfo_selected)
      {
        document.getElementById("chbWMS_Feature_Info").checked = true;
      }
      else
      {
        document.getElementById("chbWMS_Feature_Info").checked = false;
      }
    }
    
		document.getElementById("txtWMS_Properties_Title").value = map_list.maps.Item(map_list.map_id).wms_list.Item(id).title;
		document.getElementById("txtWMS_Properties_Opacity").value = map_list.maps.Item(map_list.map_id).wms_list.Item(id).opacity;

		document.getElementById("spnWMS_Info_Url").innerHTML = map_list.maps.Item(map_list.map_id).wms_list.Item(id).url;
		document.getElementById("spnWMS_Info_Organization").innerHTML = map_list.maps.Item(map_list.map_id).wms_list.Item(id).c_organization;
		document.getElementById("spnWMS_Info_ContactPerson").innerHTML = map_list.maps.Item(map_list.map_id).wms_list.Item(id).c_contact_person;
		document.getElementById("spnWMS_Info_Phone").innerHTML = map_list.maps.Item(map_list.map_id).wms_list.Item(id).c_phone;
		document.getElementById("spnWMS_Info_Email").innerHTML = "<a href='mailto:" + map_list.maps.Item(map_list.map_id).wms_list.Item(id).c_email + "'>" + map_list.maps.Item(map_list.map_id).wms_list.Item(wms_id).c_email + "</a>";
		document.getElementById("spnWMS_Info_Address").innerHTML = map_list.maps.Item(map_list.map_id).wms_list.Item(id).c_address + ", " + map_list.maps.Item(map_list.map_id).wms_list.Item(id).c_city + ", " + map_list.maps.Item(map_list.map_id).wms_list.Item(id).c_post_code + ", " + map_list.maps.Item(map_list.map_id).wms_list.Item(id).c_country;
		//document.getElementById("spnWMS_Info_City").innerText = map_list.maps.Item(map_list.map_id).wms_list.Item(id).c_city + ", " + ;
		//document.getElementById("spnWMS_Info_PostCode").innerText = map_list.maps.Item(map_list.map_id).wms_list.Item(id).c_post_code;
		//document.getElementById("spnWMS_Info_Country").innerText = map_list.maps.Item(map_list.map_id).wms_list.Item(id).c_country;

    if(map_list.maps.Item(map_list.map_id).wms_list.Item(id).featureinfo)
    {
      document.getElementById("trFI_UnAvailable").style.display = "none";
      document.getElementById("trFI_Available").style.display = "";
    }
    else
    {
      document.getElementById("trFI_UnAvailable").style.display = "";
      document.getElementById("trFI_Available").style.display = "none";
    }
	}
	else
	{
		alert(script_messages[8]);
	}
}
//*******************************************************************************	

function btnWMS_PriorityUp_Click()
{
	// Zjisti jeslti je vybran prvek
	if(document.getElementById("cmbWMS_Servers").selectedIndex >= 0)
	{
		// Prvek je vybran, zjisti jeslti neni vybran prvni prvek
		if(document.getElementById("cmbWMS_Servers").selectedIndex > 0)
		{
			var wms_id = document.getElementById("cmbWMS_Servers").options[document.getElementById("cmbWMS_Servers").selectedIndex].value;
			map_list.maps.Item(map_list.map_id).WMS_PriorityUp(wms_id);
			map_list.maps.Item(map_list.map_id).Write_WMS("tdWMS_Servers", wms_id);
		}
	}
}
//*******************************************************************************	

function btnWMS_PriorityDown_Click()
{
	// Zjisti jeslti je vybran prvek
	if(document.getElementById("cmbWMS_Servers").selectedIndex >= 0)
	{
		// Prvek je vybran, zjisti jeslti neni vybran posledni prvek
		if(document.getElementById("cmbWMS_Servers").selectedIndex != document.getElementById("cmbWMS_Servers").length - 1)
		{
			var wms_id = document.getElementById("cmbWMS_Servers").options[document.getElementById("cmbWMS_Servers").selectedIndex].value;
			map_list.maps.Item(map_list.map_id).WMS_PriorityDown(wms_id);
			map_list.maps.Item(map_list.map_id).Write_WMS("tdWMS_Servers", wms_id);
		}
	}
}
//*******************************************************************************	

function btnCRS_Change_Click()
{

		//var xmlHttp = new ActiveXObject("Msxml2.XMLHTTP.4.0");
		//var xmlResponse = new ActiveXObject("Msxml2.DOMDocument.4.0");
    var xmlResponse;
    var url;
    var xmlNode;
    var bbox;
    var default_bbox;
    var new_default_bbox;
 		var re = /[?]/i;
    var new_srs;
    var new_default_srs;
    var source_srs, target_srs;
    var new_projection_to_scale;
        	
    //Zkontroluj neni-li pozadovan jiz nastaveny souradny system
    new_srs = document.getElementById("cmbCRS_List").options[document.getElementById("cmbCRS_List").selectedIndex].value;	
		
    if(new_srs == map_list.maps.Item(map_list.map_id).srs)
    {
      alert(script_messages[9]);
    }
    else
    {
      source_srs = map_list.maps.Item(map_list.map_id).srs;
      target_srs = new_srs;
      
      //transformuj aktualni bbox
      bbox = map_list.maps.Item(map_list.map_id).bbox;
  		
  		if(map_list.maps.Item(map_list.map_id).cst_url.search(re) != -1)
  		{
  			//prompt("", this.url + "&request=getcapabilities" )
  			url = map_list.maps.Item(map_list.map_id).cst_url + "request=getcstrans&SOURCESRS=" + source_srs + "&TARGETSRS=" + target_srs + "&BBOX=" + bbox;
  		}
  		else
  		{
  			url = map_list.maps.Item(map_list.map_id).cst_url + "?request=getcstrans&SOURCESRS=" + source_srs + "&TARGETSRS=" + target_srs + "&BBOX=" + bbox;
  		}
  		
      xmlResponse = AJAX(url, proxy_enabled);
        
  		if(moz)
  		{
        xmlNode = xmlResponse.evaluate("//CSTResponse/TargetBBOX", xmlResponse, null, 9, null);
  			new_bbox = (xmlNode != null)?xmlNode.singleNodeValue.getAttribute("value"):"";
        xmlNode = xmlResponse.evaluate("//CSTResponse/ProjectionToScale", xmlResponse, null, 9, null);
  			new_projection_to_scale = (xmlNode != null)?parseFloat(xmlNode.singleNodeValue.getAttribute("value")):1;
      }
      else
      {
        xmlNode = xmlResponse.selectSingleNode("//CSTResponse/TargetBBOX");
    		new_bbox = (xmlNode != null)?xmlNode.getAttribute("value"):"";
        xmlNode = xmlResponse.selectSingleNode("//CSTResponse/ProjectionToScale");
    		new_projection_to_scale = (xmlNode != null)?parseFloat(xmlNode.getAttribute("value")):1;
    	}

    	var BBoxArray;
    	var WrldWidth;
    	var wrldhalfx;
    	var wrldhalfy;
    	var Unit;
    	
    	BBoxArray = ParseBBox(new_bbox);

			//Transformace zobrazeni BBOXu
			BBoxArray = TransformBBox(BBoxArray,map_list.maps.Item(map_list.map_id).map_width,map_list.maps.Item(map_list.map_id).map_height);

			WrldWidth = BBoxArray[2] - BBoxArray[0];

			MapScale = Math.round(((((WrldWidth * new_projection_to_scale) / map_list.maps.Item(map_list.map_id).map_width) * 100) * (280/10)));
			
      if(parseInt(document.getElementById("selMaxScale").options[document.getElementById("selMaxScale").selectedIndex].value) > parseInt(MapScale))
			{
				MapScale = parseInt(document.getElementById("selMaxScale").options[document.getElementById("selMaxScale").selectedIndex].value);
				
        wrldhalfx = BBoxArray[0] + ((BBoxArray[2] - BBoxArray[0]) / 2);
				wrldhalfy = BBoxArray[1] + ((BBoxArray[3] - BBoxArray[1]) / 2);
				BBoxArray[0] = wrldhalfx - (((map_list.maps.Item(map_list.map_id).map_width / 2)/(280/100)) / 1000 * MapScale / new_projection_to_scale);
				BBoxArray[2] = wrldhalfx + (((map_list.maps.Item(map_list.map_id).map_width / 2)/(280/100)) / 1000 * MapScale / new_projection_to_scale);
				BBoxArray[1] = wrldhalfy - (((map_list.maps.Item(map_list.map_id).map_height / 2)/(280/100)) / 1000 * MapScale / new_projection_to_scale);
				BBoxArray[3] = wrldhalfy + (((map_list.maps.Item(map_list.map_id).map_height / 2)/(280/100)) / 1000 * MapScale / new_projection_to_scale);
			}
    
      new_bbox = dbl2StrEN(BBoxArray[0].toString()) + "," + dbl2StrEN(BBoxArray[1].toString()) + "," + dbl2StrEN(BBoxArray[2].toString()) + "," + dbl2StrEN(BBoxArray[3].toString());
      
      map_list.maps.Item(map_list.map_id).srs = new_srs;
      map_list.maps.Item(map_list.map_id).bbox = new_bbox;
      map_list.maps.Item(map_list.map_id).projection_to_scale = new_projection_to_scale;

      //transformuj defaultni bbox
      default_bbox = map_list.maps.Item(map_list.map_id).default_bbox;
  		
  		if(map_list.maps.Item(map_list.map_id).cst_url.search(re) != -1)
  		{
  			//prompt("", this.url + "&request=getcapabilities" )
  			url = map_list.maps.Item(map_list.map_id).cst_url + "request=getcstrans&SOURCESRS=" + source_srs + "&TARGETSRS=" + target_srs + "&BBOX=" + default_bbox;
  		}
  		else
  		{
  			url = map_list.maps.Item(map_list.map_id).cst_url + "?request=getcstrans&SOURCESRS=" + source_srs + "&TARGETSRS=" + target_srs + "&BBOX=" + default_bbox;
  		}
  		
  		xmlResponse = AJAX(url, proxy_enabled);
  		
      if(moz)
      {
        xmlNode = xmlResponse.evaluate("//CSTResponse/TargetBBOX", xmlResponse, null, 9, null);
  			new_default_bbox = (xmlNode != null)?xmlNode.singleNodeValue.getAttribute("value"):"";
      }
      else
      {
    		xmlNode = xmlResponse.selectSingleNode("//CSTResponse/TargetBBOX");
    		new_default_bbox = (xmlNode != null)?xmlNode.getAttribute("value"):"";
    	}

      map_list.maps.Item(map_list.map_id).default_bbox = new_default_bbox;

      //transformuj prehledku
  		if(map_list.maps.Item(map_list.map_id).cst_url.search(re) != -1)
  		{
  			url = map_list.maps.Item(map_list.map_id).cst_url + "request=getcstrans&SOURCESRS=" + source_srs + "&TARGETSRS=" + target_srs + "&BBOX=" + get_string(map_list.maps.Item(map_list.map_id).position_url, "BBOX");
  		}
  		else
  		{
  			url = map_list.maps.Item(map_list.map_id).cst_url + "?request=getcstrans&SOURCESRS=" + source_srs + "&TARGETSRS=" + target_srs + "&BBOX=" + get_string(map_list.maps.Item(map_list.map_id).position_url, "BBOX");
  		}
  		
  		xmlResponse = AJAX(url, proxy_enabled);
  		
      if(moz)
      {
        xmlNode = xmlResponse.evaluate("//CSTResponse/TargetBBOX", xmlResponse, null, 9, null);
  			new_default_bbox = (xmlNode != null)?xmlNode.singleNodeValue.getAttribute("value"):"";
      }
      else
      {
    		xmlNode = xmlResponse.selectSingleNode("//CSTResponse/TargetBBOX");
    		new_default_bbox = (xmlNode != null)?xmlNode.getAttribute("value"):"";
    	}

      //Aktualizace prehledky
			map_list.maps.Item(map_list.map_id).preview_url = replace_string(map_list.maps.Item(map_list.map_id).preview_url, "SRS", map_list.maps.Item(map_list.map_id).srs);
			map_list.maps.Item(map_list.map_id).preview_url = replace_string(map_list.maps.Item(map_list.map_id).preview_url, "BBOX", new_default_bbox);
			document.getElementById("imgPrehledka").src = map_list.maps.Item(map_list.map_id).preview_url;

			map_list.maps.Item(map_list.map_id).position_url = replace_string(map_list.maps.Item(map_list.map_id).position_url, "SRS", map_list.maps.Item(map_list.map_id).srs);
			map_list.maps.Item(map_list.map_id).position_url = replace_string(map_list.maps.Item(map_list.map_id).position_url, "BBOX", new_default_bbox);

      var BBoxArray = ParseBBox(get_string(map_list.maps.Item(map_list.map_id).position_url, "BBOX"));
      	
      var MidpointX = BBoxArray[0] + ((BBoxArray[2] - BBoxArray[0]) / 2);
      var MidpointY = BBoxArray[1] + ((BBoxArray[3] - BBoxArray[1]) / 2);
      
      map_list.maps.Item(map_list.map_id).position_url = replace_string(map_list.maps.Item(map_list.map_id).position_url, "XCOORD", dbl2StrEN(MidpointX));
      map_list.maps.Item(map_list.map_id).position_url = replace_string(map_list.maps.Item(map_list.map_id).position_url, "YCOORD", dbl2StrEN(MidpointY));
      document.getElementById("imgPosition").src = map_list.maps.Item(map_list.map_id).position_url;

      LayerManager.HideAll();
      
      map_list.maps.Item(map_list.map_id).Actualize_SRS(); 
      
      LayerManager.ShowAll();

      BBoxArray = ParseBBox(map_list.maps.Item(map_list.map_id).bbox);
      
      if ((BBoxArray[0] > -180) && (BBoxArray[0] < 180))
      {
        //nemerit
        nemerit = true;
      }
      else
      {
        nemerit = false;
      }

      SetMeasure();

      SetPosition();

      //vyplneni/nevyplneni informaci o zvolenem CRS
      document.getElementById("crsInfo").innerHTML = "";
      for(var c = 0; c < crs_info.crs_list.Length(); c++)
      {
        if(crs_info.crs_list.Item(c).code.toLowerCase() == map_list.maps.Item(map_list.map_id).srs.toLowerCase())
        {
          document.getElementById("crsInfo").innerHTML = crs_info.crs_list.Item(c).name + " (" + crs_info.crs_list.Item(c).unit + ")";
          break;
        }
      }

    }
}
//*******************************************************************************	

function imgWMS_Server_Click(id)
{
	var wms_id = map_list.maps.Item(map_list.map_id).Get_Id(id);

  var	row_name = "imgWMS_Server_" + id;
	var	tr_name = "trWMS_Server_" + id;
	
	if(document.getElementById(tr_name).style.display == "none")
	{
		document.getElementById(tr_name).style.display = "";
		document.getElementById(row_name).src = "./DisplayStyle/minus.gif";
		map_list.maps.Item(map_list.map_id).wms_list.Item(wms_id).expanded = true;
		//aFGroups(group_index(UBound(group_index)))(0) = 1
	}
	else
	{
		document.getElementById(tr_name).style.display = "none";
		document.getElementById(row_name).src = "./DisplayStyle/plus.gif";
		map_list.maps.Item(map_list.map_id).wms_list.Item(wms_id).expanded = false;
		//aFGroups(group_index(UBound(group_index)))(0) = 0
	}
}		
//*******************************************************************************	

function imgFI_Server_Click(id)
{
  var	row_name = "imgFI_Server_" + id;
	var	tr_name = "trFI_Server_" + id;
	
	if(document.getElementById(tr_name).style.display == "none")
	{
		document.getElementById(tr_name).style.display = "";
		document.getElementById(row_name).src = "./DisplayStyle/minus.gif";
	}
	else
	{
		document.getElementById(tr_name).style.display = "none";
		document.getElementById(row_name).src = "./DisplayStyle/plus.gif";
	}
}		
//*******************************************************************************	

function imgFGroup_Click(wms_id, group_id)
{	
	var tr_name = "trFGroup_" + wms_id + "_" + group_id;
	var img_name = "imgFGroup_" + wms_id + "_" + group_id;
	
	wms_id = map_list.maps.Item(map_list.map_id).Get_Id(wms_id);

	if (document.getElementById(tr_name).style.display == "none")
	{
		document.getElementById(tr_name).style.display = "";
		document.getElementById(img_name).alt = script_messages[23];
		document.getElementById(img_name).src = "./DisplayStyle/minus.gif";
		map_list.maps.Item(map_list.map_id).wms_list.Item(wms_id).legend.group_list.Item(group_id).expanded = true;
		//aFGroups(group_index(UBound(group_index)))(0) = 1
	}
	else
	{
		document.getElementById(tr_name).style.display = "none";
		document.getElementById(img_name).alt = script_messages[24];
		document.getElementById(img_name).src = "./DisplayStyle/plus.gif";
		map_list.maps.Item(map_list.map_id).wms_list.Item(wms_id).legend.group_list.Item(group_id).expanded = false;
		//aFGroups(group_index(UBound(group_index)))(0) = 0
	}	
}
//*******************************************************************************	

function imgFGroupSAll_Click(wms_id, group_id)
{	
	var element_id = wms_id;
	var wms_id = map_list.maps.Item(map_list.map_id).Get_Id(wms_id);
  var wms_s = map_list.maps.Item(map_list.map_id).wms_list.Item(wms_id);
  var feature_name = "";
  
  for (var i = 0; i < wms_s.legend.group_list.Item(group_id).layer_list.Length(); i++)
  {
  	feature_name = "chbFeature_" + element_id + wms_s.legend.group_list.Item(group_id).id + wms_s.legend.group_list.Item(group_id).layer_list.Item(i).name;
    wms_s.legend.group_list.Item(group_id).layer_list.Item(i).checked = true;
  	document.getElementById(feature_name).checked = true;
  }
}
//*******************************************************************************	

function imgFGroupDSAll_Click(wms_id, group_id)
{	
	var element_id = wms_id;
  var wms_id = map_list.maps.Item(map_list.map_id).Get_Id(wms_id);
  var wms_s = map_list.maps.Item(map_list.map_id).wms_list.Item(wms_id);
  var feature_name = "";

  for (var i = 0; i < wms_s.legend.group_list.Item(group_id).layer_list.Length(); i++)
  {
  	feature_name = "chbFeature_" + element_id + wms_s.legend.group_list.Item(group_id).id + wms_s.legend.group_list.Item(group_id).layer_list.Item(i).name;
    wms_s.legend.group_list.Item(group_id).layer_list.Item(i).checked = false;
  	document.getElementById(feature_name).checked = false;
  }
}
//*******************************************************************************	

function imgCFGroup_Click(cms_id, group_id)
{	
	var tr_name = "trCFGroup_" + cms_id + "_" + group_id;
	var img_name = "imgCFGroup_" + cms_id + "_" + group_id;
	
	//cms_id = map_list.maps.Item(map_list.map_id).Get_Id(wms_id);

	if (document.getElementById(tr_name).style.display == "none")
	{
		document.getElementById(tr_name).style.display = "";
		document.getElementById(img_name).src = "./DisplayStyle/minus.gif";
		map_list.maps.Item(map_list.map_id).cms_list.Item(cms_id).legend.group_list.Item(group_id).expanded = true;
		//aFGroups(group_index(UBound(group_index)))(0) = 1
	}
	else
	{
		document.getElementById(tr_name).style.display = "none";
		document.getElementById(img_name).src = "./DisplayStyle/plus.gif";
		map_list.maps.Item(map_list.map_id).cms_list.Item(cms_id).legend.group_list.Item(group_id).expanded = false;
		//aFGroups(group_index(UBound(group_index)))(0) = 0
	}	
}
//*******************************************************************************	

function chbWMS_Server_Click(o)
{
	var wms_id = map_list.maps.Item(map_list.map_id).Get_Id(o.value);

  var wms_s = map_list.maps.Item(map_list.map_id).wms_list.Item(wms_id);

	if (document.getElementById(o.id).checked)
	{
    //projdi vsechny mapove vrstvy jestli je aspon jedna vybrana
    var selected = false;
    
    for (var i = 0; i < wms_s.legend.group_list.Length(); i++)
    {
      for (var j = 0; j < wms_s.legend.group_list.Item(i).layer_list.Length(); j++)
      {
        if (wms_s.legend.group_list.Item(i).layer_list.Item(j).checked)
        {
          selected = true;
          break;
        }
      }
    }

    if (!selected)
    {
      for (var i = 0; i < wms_s.legend.layer_list.Length(); i++)
      {
        if (wms_s.legend.layer_list.Item(i).checked)
        {
          selected = true;
          break;
        }
      }
    }

    if (selected)
    {
  		wms_s.selected = true;
			wms_s.Actualize_LAYERS();
			wms_s.GetMap();
  		wms_s.map_img.style.display = "";
    }
    else
    {
      document.getElementById(o.id).checked = false;
      wms_s.selected = false;
      alert(wms_s.title + script_messages[10]);
    }
	}
	else
	{
		wms_s.selected = false;
		wms_s.map_img.src = "";
		wms_s.map_img.style.display = "none";
	}	
}
//*******************************************************************************	

function chbFeature_Click(o)
{
	var param_array = o.value.split("|");
	//alert(o.value)
	var wms_id = parseInt(param_array[0]);
	var g_id = parseInt(param_array[1]);
	var l_id = parseInt(param_array[2]);

  wms_id = map_list.maps.Item(map_list.map_id).Get_Id(wms_id);
	if (document.getElementById(o.id).checked)
	{
		if(g_id != -1)
		{
      map_list.maps.Item(map_list.map_id).wms_list.Item(wms_id).legend.group_list.Item(g_id).layer_list.Item(l_id).checked = true;
    }
    else
    {
      map_list.maps.Item(map_list.map_id).wms_list.Item(wms_id).legend.layer_list.Item(l_id).checked = true;
    }
	}
	else
	{
		if(g_id != -1)
		{
  		map_list.maps.Item(map_list.map_id).wms_list.Item(wms_id).legend.group_list.Item(g_id).layer_list.Item(l_id).checked = false;
  	}
  	else
  	{
  		map_list.maps.Item(map_list.map_id).wms_list.Item(wms_id).legend.layer_list.Item(l_id).checked = false;
    }
	}	
}
//*******************************************************************************	

function rdbCFeature_Click(o)
{
	var param_array = o.value.split("|");
	//alert(o.value)
	var cms_id = param_array[0];
	var g_id = param_array[1];
	var l_id = param_array[2];

	if (document.getElementById(o.id).checked)
	{
		if(g_id != -1)
		{
      map_list.maps.Item(map_list.map_id).cms_list.Item(cms_id).cms_layer = map_list.maps.Item(map_list.map_id).cms_list.Item(cms_id).legend.group_list.Item(g_id).layer_list.Item(l_id).name;
      //map_list.maps.Item(map_list.map_id).cms_list.Item(cms_id).legend.group_list.Item(g_id).layer_list.Item(l_id).checked = true;
    }
    else
    {
      map_list.maps.Item(map_list.map_id).cms_list.Item(cms_id).cms_layer = map_list.maps.Item(map_list.map_id).cms_list.Item(cms_id).legend.layer_list.Item(l_id).name;
    }
	}
	else
	{
		if(g_id != -1)
		{
  		map_list.maps.Item(map_list.map_id).cms_list.Item(cms_id).cms_layer = map_list.maps.Item(map_list.map_id).cms_list.Item(cms_id).legend.group_list.Item(g_id).layer_list.Item(l_id).name;
  	}
  	else
  	{
  		map_list.maps.Item(map_list.map_id).cms_list.Item(cms_id).cms_layer = map_list.maps.Item(map_list.map_id).cms_list.Item(cms_id).legend.layer_list.Item(l_id).name;
    }
	}	
  map_list.maps.Item(map_list.map_id).cms_list.Item(cms_id).Actualize_LAYERS();
  map_list.maps.Item(map_list.map_id).cms_list.Item(cms_id).GetClickMap();
}
//*******************************************************************************	

function ParseBBox(wms_bbox)
{
/*
 * Funkce zjisti jednotlive souradnice vyrezu a ulozi je do pole, ktere vraci
 * jako navratovou hodnotu funkce, v pripade spatneho fomratu BBOX generuje 
 * vyjimku.
 */
	
	//Deklarace lokalnich promennych
	var BBoxArray = new Array(3);  //Pole pro ulozeni jednotlivych souradnic vyrezu
	var start_pos, end_pos, sub_str, s;
  var dec_str = new String(1/2);
  var re = new RegExp(",","i");  
	var re_dec = /[.]/i;
//  var re_dec = new RegExp(".","i");  

  //XMIN
  start_pos = 0;
  sub_str = wms_bbox.substr(start_pos, wms_bbox.length);
  end_pos = sub_str.search(re);
		
	if (end_pos > -1)
	{
    s = sub_str.substr(0, end_pos);
    s.replace(re_dec, dec_str.substr(1,1));
    if (isNaN(parseFloat(s)))
    {
			GenerateException("Invalid BBOX1");
    }
    else
    {
      BBoxArray[0] = parseFloat(s);
    }
  }
  else
  {
			GenerateException("Invalid BBOX2");
  }

	//YMIN
  start_pos = end_pos + 1;
  sub_str = sub_str.substr(start_pos, sub_str.length - start_pos);
  end_pos = sub_str.search(re);
		
	if (end_pos > -1)
	{
    s = sub_str.substr(0, end_pos);
    s.replace(re_dec, dec_str.substr(1,1));
    if (isNaN(parseFloat(s)))
    {
			GenerateException("Invalid BBOX3");
    }
    else
    {
      BBoxArray[1] = parseFloat(s);
    }
  }
  else
  {
			GenerateException("Invalid BBOX4");
  }

	//XMAX
	start_pos = end_pos + 1;

  sub_str = sub_str.substr(start_pos, sub_str.length - start_pos);
  end_pos = sub_str.search(re);
		
	if (end_pos > -1)
	{
    s = sub_str.substr(0, end_pos);
    s.replace(re_dec, dec_str.substr(1,1));
    if (isNaN(parseFloat(s)))
    {
			GenerateException("Invalid BBOX5");
    }
    else
    {
      BBoxArray[2] = parseFloat(s);
    }
  }
  else
  {
			GenerateException("Invalid BBOX6");
  }

	//YMAX
	start_pos = end_pos + 1;

  if (start_pos > wms_bbox.length)
  {
		GenerateException("Invalid BBOX7");
  }
  else
  {
    s = sub_str.substr(start_pos, wms_bbox.length - start_pos);
    s.replace(re_dec, dec_str.substr(1,1));
    if (isNaN(parseFloat(s)))
    {
			GenerateException("Invalid BBOX8");
    }
    else
    {
      BBoxArray[3] = parseFloat(s);
    }
  }

	//Kontrola pripadneho chybneho zadani jednotlivych souradnic
  if ((parseFloat(BBoxArray[0]) >= parseFloat(BBoxArray[2])) || (parseFloat(BBoxArray[1]) >= parseFloat(BBoxArray[3])))
	{
		GenerateException("Invalid BBOX9");
	}

	return BBoxArray;
}
//****************************************************************************

function FitBBox(WMS_BBOX, ACTION)
{
/*
 * Funkce, ktera nastavi souradnice BBOX podle toho, co byla zvolena za akce.
 */
	
	var BBoxArray;
	var WrldWidth;
	var WrldHeight;
	var wrldhalfx;
	var wrldhalfy;
	var Unit;
	
	//FitBBox = WMS_BBOX;
	
	//var a = new VBArray(ParseBBOX(WMS_BBOX));

	BBoxArray = ParseBBox(WMS_BBOX);

	WrldWidth = BBoxArray[2] - BBoxArray[0];
	WrldHeight = BBoxArray[3] - BBoxArray[1];

	switch (ACTION.toLowerCase())
	{
		case "pannw" :
			if ((parseInt(document.getElementById("txtPrekryv").value) > 0) && (parseInt(document.getElementById("txtPrekryv").value) <= 100))
			{
				/*If (Err <> 0) Then
				  Err.Clear
				  alert "Nesprávně zadaná hodnota překryvu při posunu mapy."
				  Exit Function
				End If
		
				On Error GoTo 0
				*/
				
				BBoxArray[0] = BBoxArray[0] - WrldWidth / (100 / parseInt(document.getElementById("txtPrekryv").value));
				BBoxArray[2] = BBoxArray[2] - WrldWidth / (100 / parseInt(document.getElementById("txtPrekryv").value));
				BBoxArray[1] = BBoxArray[1] + WrldHeight / (100 / parseInt(document.getElementById("txtPrekryv").value));
				BBoxArray[3] = BBoxArray[3] + WrldHeight / (100 / parseInt(document.getElementById("txtPrekryv").value));
			}	
			else
			{
				alert(script_messages[11]);
				return;
			}
			break;
		case "pann" :
			if((parseInt(document.getElementById("txtPrekryv").value) > 0) && (parseInt(document.getElementById("txtPrekryv").value) <= 100))
			{
				/*If (Err <> 0) Then
				  Err.Clear
				  alert "Nesprávně zadaná hodnota překryvu při posunu mapy."
				  Exit Function
				End If
				*/
				BBoxArray[1] = BBoxArray[1] + WrldHeight / (100 / parseInt(document.getElementById("txtPrekryv").value));
				BBoxArray[3] = BBoxArray[3] + WrldHeight / (100 / parseInt(document.getElementById("txtPrekryv").value));
			}	
			else
			{
				alert(script_messages[11]);
				return
			}
			break;
		case "panne" :
			if((parseInt(document.getElementById("txtPrekryv").value) > 0) && (parseInt(document.getElementById("txtPrekryv").value) <= 100))
			{
				/*If (Err <> 0) Then
				  Err.Clear
				  alert "Nesprávně zadaná hodnota překryvu při posunu mapy."
				  Exit Function
				End If
				*/		
				BBoxArray[0] = BBoxArray[0] + WrldWidth / (100 / parseInt(document.getElementById("txtPrekryv").value));
				BBoxArray[2] = BBoxArray[2] + WrldWidth / (100 / parseInt(document.getElementById("txtPrekryv").value));
				BBoxArray[1] = BBoxArray[1] + WrldHeight / (100 / parseInt(document.getElementById("txtPrekryv").value));
				BBoxArray[3] = BBoxArray[3] + WrldHeight / (100 / parseInt(document.getElementById("txtPrekryv").value));
			}
			else
			{
				alert(script_messages[11]);
				return
			}
			break;
		case "panw" :
			if((parseInt(document.getElementById("txtPrekryv").value) > 0) && (parseInt(document.getElementById("txtPrekryv").value) <= 100))
			{
				/*If (Err <> 0) Then
				  Err.Clear
				  alert "Nesprávně zadaná hodnota překryvu při posunu mapy."
				  Exit Function
				End If
				*/		
				BBoxArray[0] = BBoxArray[0] - WrldWidth / (100 / parseInt(document.getElementById("txtPrekryv").value));
				BBoxArray[2] = BBoxArray[2] - WrldWidth / (100 / parseInt(document.getElementById("txtPrekryv").value));
			}
			else
			{
				alert(script_messages[11]);
				return
			}
			break;
		case "pane" :
			if((parseInt(document.getElementById("txtPrekryv").value) > 0) && (parseInt(document.getElementById("txtPrekryv").value) <= 100))
			{
				/*If (Err <> 0) Then
				  Err.Clear
				  alert "Nesprávně zadaná hodnota překryvu při posunu mapy."
				  Exit Function
				End If
				*/
				BBoxArray[0] = BBoxArray[0] + WrldWidth / (100 / parseInt(document.getElementById("txtPrekryv").value));
				BBoxArray[2] = BBoxArray[2] + WrldWidth / (100 / parseInt(document.getElementById("txtPrekryv").value));
			}
			else
			{
				alert(script_messages[11]);
				return
			}
			break;
		case "pansw" :
			if((parseInt(document.getElementById("txtPrekryv").value) > 0) && (parseInt(document.getElementById("txtPrekryv").value) <= 100))
			{
				/*If (Err <> 0) Then
				  Err.Clear
				  alert "Nesprávně zadaná hodnota překryvu při posunu mapy."
				  Exit Function
				End If
				*/
				BBoxArray[0] = BBoxArray[0] - WrldWidth / (100 / parseInt(document.getElementById("txtPrekryv").value));
				BBoxArray[2] = BBoxArray[2] - WrldWidth / (100 / parseInt(document.getElementById("txtPrekryv").value));
				BBoxArray[1] = BBoxArray[1] - WrldHeight / (100 / parseInt(document.getElementById("txtPrekryv").value));
				BBoxArray[3] = BBoxArray[3] - WrldHeight / (100 / parseInt(document.getElementById("txtPrekryv").value));
			}
			else
			{
				alert(script_messages[11]);
				return
			}
			break;
		case "pans" :
			if((parseInt(document.getElementById("txtPrekryv").value) > 0) && (parseInt(document.getElementById("txtPrekryv").value) <= 100))
			{
				/*If (Err <> 0) Then
				  Err.Clear
				  alert "Nesprávně zadaná hodnota překryvu při posunu mapy."
				  Exit Function
				End If
				*/
				BBoxArray[1] = BBoxArray[1] - WrldHeight / (100 / parseInt(document.getElementById("txtPrekryv").value));
				BBoxArray[3] = BBoxArray[3] - WrldHeight / (100 / parseInt(document.getElementById("txtPrekryv").value));
			}
			else
			{
				alert(script_messages[11]);
				return
			}
			break;
		case "panse" :
			if((parseInt(document.getElementById("txtPrekryv").value) > 0) && (parseInt(document.getElementById("txtPrekryv").value) <= 100))
			{
				/*If (Err <> 0) Then
				  Err.Clear
				  alert "Nesprávně zadaná hodnota překryvu při posunu mapy."
				  Exit Function
				End If
				*/
				
				BBoxArray[0] = BBoxArray[0] + WrldWidth / (100 / parseInt(document.getElementById("txtPrekryv").value));
				BBoxArray[2] = BBoxArray[2] + WrldWidth / (100 / parseInt(document.getElementById("txtPrekryv").value));
				BBoxArray[1] = BBoxArray[1] - WrldHeight / (100 / parseInt(document.getElementById("txtPrekryv").value));
				BBoxArray[3] = BBoxArray[3] - WrldHeight / (100 / parseInt(document.getElementById("txtPrekryv").value));
			}
			else
			{
				alert(script_messages[11]);
				return
			}
			break;
		case "zoomin" :
			/*For i = 0 To Ubound(aWMSLayers)
				If (aWMSLayers(i)(1) = 1) Then
					If (document.all.item("chbFeature_" & aWMSLayers(i)(0)).checked = True) Then
						aWMSLayers(i)(2) = 1
					Else
						aWMSLayers(i)(2) = 0
					End If
				End If
			Next*/

			Unit = WrldWidth/ map_list.maps.Item(map_list.map_id).map_width;
			StartX = ((map_list.maps.Item(map_list.map_id).map_width / 2) - StartX);
					
			StartY = ((map_list.maps.Item(map_list.map_id).map_height / 2)- StartY);

			BBoxArray[0] = (BBoxArray[0] - (StartX * Unit));
			BBoxArray[2] = (BBoxArray[2] - (StartX * Unit));
			BBoxArray[1] = (BBoxArray[1] + (StartY * Unit));
			BBoxArray[3] = (BBoxArray[3] + (StartY * Unit));

			//Unit = parseFloat(document.getElementById("txtScaleFactor").value);
			/*If (Err <> 0) Then
				Err.Clear
				alert "Hodnota faktoru změny měřítka je zadána ve špatném formátu."
				Exit Function
			End If*/
		
			BBoxArray[0] = BBoxArray[0] + (WrldWidth / 2) - (WrldWidth / (2*parseFloat(document.getElementById("txtScaleFactor").value)));
			BBoxArray[2] = BBoxArray[2] - (WrldWidth / 2) + (WrldWidth / (2*parseFloat(document.getElementById("txtScaleFactor").value)));
			BBoxArray[1] = BBoxArray[1] + (WrldHeight / 2) - (WrldHeight / (2*parseFloat(document.getElementById("txtScaleFactor").value)));
			BBoxArray[3] = BBoxArray[3] - (WrldHeight / 2) + (WrldHeight / (2*parseFloat(document.getElementById("txtScaleFactor").value)));

			WrldWidth = BBoxArray[2] - BBoxArray[0];

			MapScale = Math.round(((((WrldWidth * map_list.maps.Item(map_list.map_id).projection_to_scale) / map_list.maps.Item(map_list.map_id).map_width) * 100) * (280/10)));

			if(parseInt(document.getElementById("selMaxScale").options[document.getElementById("selMaxScale").selectedIndex].value) > parseInt(MapScale))
			{
				MapScale = parseInt(document.getElementById("selMaxScale").options[document.getElementById("selMaxScale").selectedIndex].value);
				wrldhalfx = BBoxArray[0] + ((BBoxArray[2] - BBoxArray[0]) / 2);
				wrldhalfy = BBoxArray[1] + ((BBoxArray[3] - BBoxArray[1]) / 2);
				BBoxArray[0] = wrldhalfx - (((map_list.maps.Item(map_list.map_id).map_width / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
				BBoxArray[2] = wrldhalfx + (((map_list.maps.Item(map_list.map_id).map_width / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
				BBoxArray[1] = wrldhalfy - (((map_list.maps.Item(map_list.map_id).map_height / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
				BBoxArray[3] = wrldhalfy + (((map_list.maps.Item(map_list.map_id).map_height / 2)/(280/100)) / 1000 * MapScale) / map_list.maps.Item(map_list.map_id).projection_to_scale;
			}

			SetScaleBox();
			break;
		case "zoomout" :
			/*For i = 0 To Ubound(aWMSLayers)
				If (aWMSLayers(i)(1) = 1) Then
					If (document.all.item("chbFeature_" & aWMSLayers(i)(0)).checked = True) Then
						aWMSLayers(i)(2) = 1
					Else
						aWMSLayers(i)(2) = 0
					End If
				End If
			Next*/

			Unit = WrldWidth / map_list.maps.Item(map_list.map_id).map_width;

			StartX = ((map_list.maps.Item(map_list.map_id).map_width / 2) - StartX);
					
			StartY = ((map_list.maps.Item(map_list.map_id).map_height / 2)- StartY);

			BBoxArray[0] = (BBoxArray[0] - (StartX * Unit));
			BBoxArray[2] = (BBoxArray[2] - (StartX * Unit));
			BBoxArray[1] = (BBoxArray[1] + (StartY * Unit));
			BBoxArray[3] = (BBoxArray[3] + (StartY * Unit));

			//Unit = parseFloat(document.getElementById("txtScaleFactor").value);
			/*If (Err <> 0) Then
				Err.Clear
				alert "Hodnota faktoru změny měřítka je zadána ve špatném formátu."
				Exit Function
			End If*/
		

			BBoxArray[0] = BBoxArray[0] - ((WrldWidth / 2) * parseFloat(document.getElementById("txtScaleFactor").value)) + (WrldWidth / 2);
			BBoxArray[2] = BBoxArray[2] + ((WrldWidth / 2) * parseFloat(document.getElementById("txtScaleFactor").value)) - (WrldWidth / 2);
			BBoxArray[1] = BBoxArray[1] - ((WrldHeight / 2) * parseFloat(document.getElementById("txtScaleFactor").value)) + (WrldHeight / 2);
			BBoxArray[3] = BBoxArray[3] + ((WrldHeight / 2) * parseFloat(document.getElementById("txtScaleFactor").value)) - (WrldHeight / 2);
			
			SetScaleBox();
			break;
		case "zoomarea" :

			/*For i = 0 To Ubound(aWMSLayers)
				If (aWMSLayers(i)(1) = 1) Then
					If (document.all.item("chbFeature_" & aWMSLayers(i)(0)).checked = True) Then
						aWMSLayers(i)(2) = 1
					Else
						aWMSLayers(i)(2) = 0
					End If
				End If
			Next*/
      
			Unit = WrldWidth / map_list.maps.Item(map_list.map_id).map_width;
			BBoxArray[0] = (BBoxArray[0] + (StartX * Unit));
			BBoxArray[2] = (BBoxArray[2] - ((map_list.maps.Item(map_list.map_id).map_width - LastX) * Unit));
			BBoxArray[1] = (BBoxArray[1] + ((map_list.maps.Item(map_list.map_id).map_height - LastY) * Unit));
			BBoxArray[3] = (BBoxArray[3] - (StartY * Unit));
			
			//Transformace zobrazeni BBOXu
			BBoxArray = TransformBBox(BBoxArray,map_list.maps.Item(map_list.map_id).map_width,map_list.maps.Item(map_list.map_id).map_height);

			WrldWidth = BBoxArray[2] - BBoxArray[0];

			MapScale = Math.round(((((WrldWidth * map_list.maps.Item(map_list.map_id).projection_to_scale) / map_list.maps.Item(map_list.map_id).map_width) * 100) * (280/10)));
			
      if(parseInt(document.getElementById("selMaxScale").options[document.getElementById("selMaxScale").selectedIndex].value) > parseInt(MapScale))
			{
				MapScale = parseInt(document.getElementById("selMaxScale").options[document.getElementById("selMaxScale").selectedIndex].value);
				
        wrldhalfx = BBoxArray[0] + ((BBoxArray[2] - BBoxArray[0]) / 2);
				wrldhalfy = BBoxArray[1] + ((BBoxArray[3] - BBoxArray[1]) / 2);
				BBoxArray[0] = wrldhalfx - (((map_list.maps.Item(map_list.map_id).map_width / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
				BBoxArray[2] = wrldhalfx + (((map_list.maps.Item(map_list.map_id).map_width / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
				BBoxArray[1] = wrldhalfy - (((map_list.maps.Item(map_list.map_id).map_height / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
				BBoxArray[3] = wrldhalfy + (((map_list.maps.Item(map_list.map_id).map_height / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
			}
			
			SetScaleBox();
			break;
		case "pan" :

			Unit = WrldWidth / map_list.maps.Item(map_list.map_id).map_width;
					
      var PosX = (map_list.maps.Item(map_list.map_id).map_width/2) - StartX;
      var PosY = (map_list.maps.Item(map_list.map_id).map_height/2) - StartY;
					
			BBoxArray[0] = (BBoxArray[0] - (PosX * Unit));
			BBoxArray[2] = (BBoxArray[2] - (PosX * Unit));
			BBoxArray[1] = (BBoxArray[1] + (PosY * Unit));
			BBoxArray[3] = (BBoxArray[3] + (PosY * Unit));

			break;
		case "changescale" :
			
			if(parseInt(document.getElementById("selMaxScale").options[document.getElementById("selMaxScale").selectedIndex].value) > parseInt(MapScale))
			{
				MapScale = parseInt(document.getElementById("selMaxScale").options[document.getElementById("selMaxScale").selectedIndex].value);
			}
			
			wrldhalfx = BBoxArray[0] + ((BBoxArray[2] - BBoxArray[0]) / 2);
			wrldhalfy = BBoxArray[1] + ((BBoxArray[3] - BBoxArray[1]) / 2);
			BBoxArray[0] = wrldhalfx - (((map_list.maps.Item(map_list.map_id).map_width / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
			BBoxArray[2] = wrldhalfx + (((map_list.maps.Item(map_list.map_id).map_width / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
			BBoxArray[1] = wrldhalfy - (((map_list.maps.Item(map_list.map_id).map_height / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
			BBoxArray[3] = wrldhalfy + (((map_list.maps.Item(map_list.map_id).map_height / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
			break;

		case "changeposition" :
			var pixhalfx;
			var pixhalfy;
				
			pixhalfx = map_list.maps.Item(map_list.map_id).map_width / 2;
			pixhalfy = map_list.maps.Item(map_list.map_id).map_height / 2;
			
			Unit = WrldWidth / map_list.maps.Item(map_list.map_id).map_width;
				
			BBoxArray[0] = MidpointX - (pixhalfx * Unit);
			BBoxArray[2] = MidpointX + (pixhalfx * Unit);
			BBoxArray[1] = MidpointY - (pixhalfy * Unit);
			BBoxArray[3] = MidpointY + (pixhalfy * Unit);
			break;
		}
	
	WMS_BBOX = dbl2StrEN(BBoxArray[0].toString()) + "," + dbl2StrEN(BBoxArray[1].toString()) + "," + dbl2StrEN(BBoxArray[2].toString()) + "," + dbl2StrEN(BBoxArray[3].toString());
	return WMS_BBOX

}
//****************************************************************************

function MoveMap(ACTION)
{
/*
 * Procedura realizujici posun mapy podle zvolene akce.
 */
	
	//Promenne WMS
	var MAP_URL;
	var WMS_BBOX;

	if(document.getElementById("divWait").style.display == "none")
	{

		document.getElementById("divWait").style.display = "";	
		
		LayerManager.HideAll();

		map_list.maps.Item(map_list.map_id).bbox = FitBBox(map_list.maps.Item(map_list.map_id).bbox, ACTION);
		map_list.maps.Item(map_list.map_id).Actualize_BBOX();

		//document.getElementById("divWait").style.display = "none";	

		/*Aktualizace klikaci mapy
		MAP_URL = document.all.ClickMapSrc.src
		MAP_URL = ReplaceLAYERS(MAP_URL, document.all.varActiveFeature.value)
		MAP_URL = ReplaceBBOX(MAP_URL, WMS_BBOX)
		document.all.ClickMapSrc.src = MAP_URL
		*/
		
    LayerManager.ShowAll();

    SetPosition();
		//MapHistory.Add "Mapový výřez", document.all.map.src , document.all.ClickMapSrc.src, document.all.varActiveFeature.value, document.all.QueryMap.src, document.all.SelectMap.src, window.status
		//UpdateHistory
	}
}
//****************************************************************************

function TransformBBox(BBoxArray, MapWidth, MapHeight)
{
/*
 * Funkce transformuje BBOX tak aby mel stejny pomer stran jako pozadovana
 * mapa, generovana WebMap serverem.
 */

	var WrldWidth;
	var WrldHeight;
	var ScaleX;
	var ScaleY;
	var TmpScale;
	var OldWrldWidth;
	var OldWrldHeight;
			
	WrldWidth = BBoxArray[2] - BBoxArray[0]; //currently meter
	WrldHeight = BBoxArray[3] - BBoxArray[1]; //currently meter
	ScaleX = Math.abs(WrldWidth / MapWidth);
	ScaleY = Math.abs(WrldHeight / MapHeight);
	
	if(ScaleX >= ScaleY)
	{
		TmpScale = ScaleX;
	}
	else
	{
		TmpScale = ScaleY;
	}

	OldWrldWidth = WrldWidth;
	OldWrldHeight = WrldHeight;
	
	WrldWidth = parseFloat(MapWidth * TmpScale);
	WrldHeight = parseFloat(MapHeight * TmpScale);
	
	BBoxArray[0] = parseFloat(BBoxArray[0] + ((OldWrldWidth - WrldWidth) / 2));
	BBoxArray[3] = parseFloat(BBoxArray[3] - ((OldWrldHeight - WrldHeight) / 2));
	BBoxArray[2] = parseFloat(BBoxArray[0] + WrldWidth);
	BBoxArray[1] = parseFloat(BBoxArray[3] - WrldHeight);

	return BBoxArray
		
}
//************************************************************************

function SetScale(WrldWidth, WrldHeight)
{
/*
 * Procedura slouzici k nastaveni zobrazovane hodnoty meritka a useku na mape.
 */

    var MapScale;
  	
  	MapScale = Math.round(((((WrldWidth * map_list.maps.Item(map_list.map_id).projection_to_scale) / map_list.maps.Item(map_list.map_id).map_width) * 100) * (280/10)));
  	
  	document.getElementById("spnScale").innerHTML = "1 : " + MapScale;
  	document.getElementById("spnDistance").innerHTML = Math.round((MapScale * 3) / 100) + "m";
}
//****************************************************************************

function SetScaleBox()
{
/*
 * Procedura nastavi hodnotu v cmbScale na prazdnou hodnotu.
 */

	document.getElementById("cmbScale").options[0].selected = true;
}
//****************************************************************************

function SetPosition()
{
/*
 * Procedura aktualizuje VIEW_URL pro mapovy vyrez zobrazeny uzivateli.
 */

	var BBoxArray;
	var gBBoxArray;
  var MidpointX;
	var MidpointY;

	var x;
	var y;
	var width;
	var height;
	var unitx,unity;

	//var a = new VBArray(ParseBBox(map_list.maps.Item(map_list.map_id).bbox));
	//var global_a = new VBArray(ParseBBox(GetBBox(map_list.maps.Item(map_list.map_id).preview_url)));

	BBoxArray = ParseBBox(map_list.maps.Item(map_list.map_id).bbox);
	gBBoxArray = ParseBBox(get_string(map_list.maps.Item(map_list.map_id).preview_url, "BBOX"));
  	
	MidpointX = BBoxArray[0] + ((BBoxArray[2] - BBoxArray[0]) / 2);
	MidpointY = BBoxArray[1] + ((BBoxArray[3] - BBoxArray[1]) / 2);
	
	map_list.maps.Item(map_list.map_id).position_url = replace_string(map_list.maps.Item(map_list.map_id).position_url, "XCOORD", dbl2StrEN(MidpointX));
	map_list.maps.Item(map_list.map_id).position_url = replace_string(map_list.maps.Item(map_list.map_id).position_url, "YCOORD", dbl2StrEN(MidpointY));

	document.getElementById('imgPosition').src = map_list.maps.Item(map_list.map_id).position_url;

  var cssStyle = getStyleObjectFromSelector('.divPrehledka');
  var cssBorder = 0;
  var cssMargin = 0;
  
  if(cssStyle)
  {
    cssBorder = parseInt(cssStyle.borderLeftWidth);
    cssMargin = parseInt(cssStyle.marginLeft);
  }

	unitx = (gBBoxArray[2] - gBBoxArray[0]) / (parseInt(document.getElementById("divPrehledka").style.width) - (cssBorder*2));
  unity = (gBBoxArray[3] - gBBoxArray[1]) / (parseInt(document.getElementById("divPrehledka").style.height) - (cssBorder*2));
  
	if(BBoxArray[0] < gBBoxArray[0])
	{
		BBoxArray[0] = gBBoxArray[0];
	}
	
	if(BBoxArray[2] > gBBoxArray[2])
	{
		BBoxArray[2] = gBBoxArray[2];
	}

	if(BBoxArray[1] < gBBoxArray[1])
	{
		BBoxArray[1] = gBBoxArray[1];
	}

	if(BBoxArray[3] > gBBoxArray[3])
	{
		BBoxArray[3] = gBBoxArray[3];
	}
	
	x = (Math.abs(gBBoxArray[0] - BBoxArray[0])/unitx);
	y = (Math.abs(gBBoxArray[3] - BBoxArray[3])/unity);
	width = Math.abs(BBoxArray[2] - BBoxArray[0])/unitx;
	height = Math.abs(BBoxArray[3] - BBoxArray[1])/unity;

	if(width <= 5)
	{
		x = (Math.abs(gBBoxArray[0] - MidpointX)/unitx) - 2;
		width = 5;
	}
	
	if(height <= 5)
	{
		y = (Math.abs(gBBoxArray[3] - MidpointY)/unity) - 2;
		height = 5;
	}
  document.getElementById("viewfence").style.visibility = "visible";
	document.getElementById("viewfence").style.left = cssMargin + cssBorder + x;
	document.getElementById("viewfence").style.top = 27 + y;
	document.getElementById("viewfence").style.width = width;
	document.getElementById("viewfence").style.height = height;
}
//****************************************************************************

function imgPosition_Click()
{
/*
 * Procedura obsluhujici udalost kliknuti na objekt imgPosition.
 */
  var cssStyle = getStyleObjectFromSelector('.divPrehledka');
  var cssBorder = 0;
  var cssMargin = 0;
  
  if(cssStyle)
  {
    cssBorder = parseInt(cssStyle.borderLeftWidth);
    cssMargin = parseInt(cssStyle.marginLeft);
  }


	if(document.getElementById("divWait").style.display == "none")
	{

		var BBoxArray;
		var WrldWidth;
		var WrldHeight;
		var UnitX;
		var UnitY;
		var tmpX;
		var tmpY;
		
    
		//Zjisti souradnice bodu v pixelech od leveho horniho okraje imgPosition
		if(moz)
		{
      tmpX = window.event.clientX - cssBorder - cssMargin; //14
    }
    else
    {
      tmpX = window.event.clientX - cssBorder - cssMargin - 2; //14
    }
	
    
  	tmpY = window.event.clientY - 27;//129

    if(document.getElementById("divNavLista"))
    {
      tmpY = tmpY - parseInt(document.getElementById("divNavLista").style.height);
    }
    
		//Zjisti BBOX
		//var a = new VBArray(ParseBBox(GetBBOX(map_list.maps.Item(map_list.map_id).position_url)));
	
		BBoxArray = ParseBBox(get_string(map_list.maps.Item(map_list.map_id).position_url, "BBOX"));

		WrldWidth = BBoxArray[2] - BBoxArray[0];
		WrldHeight = BBoxArray[3] - BBoxArray[1];

		//Vypocitej jednotku pro prepocet na svetove souradnice
		UnitX = WrldWidth / document.getElementById("imgPosition").width;
		UnitY = WrldHeight / document.getElementById("imgPosition").height;
		
		//Vypocti souradnice bodu ve svetovych souradnicich
		MidpointX = (BBoxArray[0] + (tmpX * UnitX));
		MidpointY = (BBoxArray[3] - (tmpY * UnitY));

		//Posun mapovy vyrez
		MoveMap("changeposition");
		
		//Prepnuti na zalozku mapa
		ViewSwitch("OknoMapa");
	}
}
//****************************************************************************

function imgMap_Load()
{
/*
 * Procedura obsluhujici udalost nacteni dat na objektu imgMap.
 */

  //navyseni counteru
	map_list.maps.Item(map_list.map_id).load_counter++;
	
	var wms_count = 0;
	
	for (var i = 0; i < map_list.maps.Item(map_list.map_id).wms_list.Length(); i++)
	{
    if(map_list.maps.Item(map_list.map_id).wms_list.Item(i).selected) wms_count++;
  }
	
	if(map_list.maps.Item(map_list.map_id).load_counter >= wms_count)
	{
		map_list.maps.Item(map_list.map_id).load_counter = 0;

		var BBoxArray;
		var WrldWidth;
		var WrldHeight;
	
		//Obnoveni pozice objektu Mapa po jejim posunu.	
		/*if(MapAction == "pan")
		{
			document.getElementById("Mapa").style.left = 0;
			document.getElementById("Mapa").style.top = 0;
		}*/

		//var a = new VBArray(ParseBBox(map_list.maps.Item(map_list.map_id).bbox));
	
		BBoxArray = ParseBBox(map_list.maps.Item(map_list.map_id).bbox);
			
		WrldWidth = BBoxArray[2] - BBoxArray[0];
		WrldHeight = BBoxArray[3] - BBoxArray[1];
	
		SetScale(WrldWidth, WrldHeight);

		//SetPosition();

		for(var i = 0; i < map_list.maps.Item(map_list.map_id).wms_list.Length(); i++)
		{
			//document.getElementById("Mapa").appendChild(this.wms_list.Item(i).map_img);				
			map_list.maps.Item(map_list.map_id).wms_list.Item(i).Write_Legend("tdWMS_Server_" + map_list.maps.Item(map_list.map_id).wms_list.Item(i).id);
		}

    if(map_list.maps.Item(map_list.map_id).clickmap_url != '')
    {
      map_list.maps.Item(map_list.map_id).cms_list.Item(0).Write_Legend("pAFeatures");
    }
		
    document.getElementById("divWait").style.display = "none";

		//ShowFeatures

		if(MapAction == "select")
		{
			btnSelect_Click();
		}
		else
		{
			SetMapAction(MapAction);
		}
	}
}
//****************************************************************************

function OknoMapa_Click()
{
/*
 * Procedura obsluhujici udalost stisku tlacitka mysi nad objektem OknoMapa.
 */
	
	switch (MapAction)
	{
		case "coordinates" :
      var crs_name = "";
      var crs_unit = "";
      var crs_round = "-1";
      
      var x = "";
      var y = "";
      //informace o CRS
      for(var c = 0; c < crs_info.crs_list.Length(); c++)
      {
        if(crs_info.crs_list.Item(c).code.toLowerCase() == map_list.maps.Item(map_list.map_id).srs.toLowerCase())
        {
          crs_name = crs_info.crs_list.Item(c).name;
          crs_unit = " (" + crs_info.crs_list.Item(c).unit + ")";
          crs_round = crs_info.crs_list.Item(c).round;
          break;
        }
      }
    
    	var BBoxArray = ParseBBox(map_list.maps.Item(map_list.map_id).bbox);
    	
    	var tmpX = window.event.clientX - document.getElementById("OknoMapa").offsetLeft - parseInt(document.getElementById("divNavOkno").style.width);
    	var tmpY = window.event.clientY - document.getElementById("OknoMapa").offsetTop - parseInt(document.getElementById("divNavLista").style.height) - parseInt(document.getElementById("divMapToolbar").style.height);
    
    	var WrldWidth = BBoxArray[2] - BBoxArray[0];
    	var WrldHeight = BBoxArray[3] - BBoxArray[1];
    
    	var UnitX = WrldWidth / map_list.maps.Item(map_list.map_id).map_width;
    	var UnitY = WrldHeight / map_list.maps.Item(map_list.map_id).map_height;
    
      if(crs_round == "-1")
      {
        x = (BBoxArray[0] + (tmpX * UnitX)).toString();
        y = (BBoxArray[3] - (tmpY * UnitY)).toString();
      }
      else
      {
        x = (Math.round((BBoxArray[0] + (tmpX * UnitX))*(Math.round(Math.exp(parseInt(crs_round) * Math.log(10)))))/(Math.round(Math.exp(parseInt(crs_round) * Math.log(10))))).toString();
        y = (Math.round((BBoxArray[3] - (tmpY * UnitY))*(Math.round(Math.exp(parseInt(crs_round) * Math.log(10)))))/(Math.round(Math.exp(parseInt(crs_round) * Math.log(10))))).toString();
      }
    
			prompt(crs_name + crs_unit,"X=" + x + ";Y=" + y);
			break;
		case "select" :
			LastX = window.event.clientX;
			LastY = window.event.clientY;
			StartX = LastX - document.getElementById("OknoMapa").offsetLeft - parseInt(document.getElementById("divNavOkno").style.width) - 1;
			StartY = LastY - document.getElementById("OknoMapa").offsetTop - parseInt(document.getElementById("divNavLista").style.height) - 2;//+ parseInt(document.getElementById("divMapToolbar").style.height);
      map_list.maps.Item(map_list.map_id).Get_FeatureInfo(StartX, StartY);
			break;
		case "zoomin" :
			LastX = window.event.clientX;
			LastY = window.event.clientY;
			StartX = LastX - document.getElementById("OknoMapa").offsetLeft - parseInt(document.getElementById("divNavOkno").style.width);
			StartY = LastY - document.getElementById("OknoMapa").offsetTop - parseInt(document.getElementById("divNavLista").style.height) - parseInt(document.getElementById("divMapToolbar").style.height);
			MoveMap(MapAction);
			break;
		case "zoomout" :
			LastX = window.event.clientX;
			LastY = window.event.clientY;
			StartX = LastX - document.getElementById("OknoMapa").offsetLeft - parseInt(document.getElementById("divNavOkno").style.width);
			StartY = LastY - document.getElementById("OknoMapa").offsetTop - parseInt(document.getElementById("divNavLista").style.height) - parseInt(document.getElementById("divMapToolbar").style.height);
			MoveMap(MapAction);
			break;
		case "pan" :
			LastX = window.event.clientX;
			LastY = window.event.clientY;
			StartX = LastX - document.getElementById("OknoMapa").offsetLeft - parseInt(document.getElementById("divNavOkno").style.width);
			StartY = LastY - document.getElementById("OknoMapa").offsetTop - parseInt(document.getElementById("divNavLista").style.height) - parseInt(document.getElementById("divMapToolbar").style.height);
			MoveMap(MapAction);
			break;
	}
}
//****************************************************************************

function OknoMapa_MouseDown()
{
/*
 * Procedura obsluhujici udalost stisku tlacitka mysi nad objektem OknoMapa.
 */
 
  //Pro danou akci delej
	switch (MapAction)
	{
		case "zoomarea" :
			if(window.event.button == 1 || !window.event.button)
			{
				if(FlagMove == false)
				{
					FlagMove = true;

  				tmpLeft = parseInt(document.getElementById("fence").style.left);
  				tmpTop = parseInt(document.getElementById("fence").style.top);
  				tmpWidth = parseInt(document.getElementById("fence").style.width);
  				tmpHeight = parseInt(document.getElementById("fence").style.height);

  				LastX = window.event.clientX;
  				LastY = window.event.clientY;
  				StartX = LastX - document.getElementById("OknoMapa").offsetLeft - parseInt(document.getElementById("divNavOkno").style.width);
  				StartY = LastY - document.getElementById("OknoMapa").offsetTop - parseInt(document.getElementById("divNavLista").style.height) + parseInt(document.getElementById("divMapToolbar").style.height);
  				document.getElementById("fence").style.left = StartX;
  				document.getElementById("fence").style.top = StartY;
  				document.getElementById("fence").style.width = 0;
  				document.getElementById("fence").style.height = 0;
  				document.getElementById("fence").style.visibility = "visible";
				}
				else
				{
					FlagMove = false;
					document.getElementById("fence").style.visibility = "hidden";
					tmpLastX = window.event.clientX;
					tmpLastY = window.event.clientY;
					offsetX = tmpLastX - document.getElementById("OknoMapa").offsetLeft - parseInt(document.getElementById("divNavOkno").style.width);
					offsetY = tmpLastY - document.getElementById("OknoMapa").offsetTop - parseInt(document.getElementById("divNavLista").style.height) + parseInt(document.getElementById("divMapToolbar").style.height);

					//Jestlize je vybrana oblast nulova - kliknuti do mapy, proved normalni zoom
					if((Math.abs(offsetX - StartX) < 1) || (Math.abs(offsetY - StartY) < 1))
					{
						StartY = StartY - parseInt(document.getElementById("divMapToolbar").style.height);
						MoveMap("zoomin");
					}
					else
					{
						StartX = parseInt(document.getElementById("fence").style.left);
						StartY = parseInt(document.getElementById("fence").style.top) - parseInt(document.getElementById("divMapToolbar").style.height);
						LastX = parseInt(document.getElementById("fence").style.left) + parseInt(document.getElementById("fence").style.width);
						LastY = parseInt(document.getElementById("fence").style.top) + parseInt(document.getElementById("fence").style.height) - parseInt(document.getElementById("divMapToolbar").style.height);
						MoveMap(MapAction);
					}
				}
			}
			else
			{
				if(FlagMove)
				{
					FlagMove = false;
					document.getElementById("fence").style.visibility = 'hidden';
					return false;
				}
			}
			break;
		case "distance" :
      if(window.event.button == 1 || !window.event.button)
      {
				distanceOffsetX = window.event.clientX - document.getElementById("Mapa").offsetLeft - parseInt(document.getElementById("divNavOkno").style.width);
				distanceOffsetY = window.event.clientY - document.getElementById("Mapa").offsetTop - parseInt(document.getElementById("divNavLista").style.height) - parseInt(document.getElementById("divMapToolbar").style.height);
				if(distanceLastPoint == 0)
				{
					distanceArrayX = new Array();
					distanceArrayY = new Array();
					distanceArrayX[distanceLastPoint] = distanceOffsetX;
					distanceArrayY[distanceLastPoint] = distanceOffsetY;
					distanceLastPoint = distanceLastPoint + 1;
					distanceAction = "process";
				}
				else
				{
					distanceArrayX[distanceLastPoint] = distanceOffsetX;
					distanceArrayY[distanceLastPoint] = distanceOffsetY;
					distanceLastPoint = distanceLastPoint + 1;
  				jg_doc.clear();
  				jg_doc.drawPolyLine(distanceArrayX, distanceArrayY);
  				jg_doc.paint();

					//document.getElementById("vmlShape").path = ArrayToPath();
				}
      }
      else
      {
				distanceAction = "";
				if(distanceLastPoint > 0)
				{
					alert(script_messages[12] + Math.round(ComputeLenght()) + script_messages[32]);
          jg_doc.clear();
				}
				distanceLastPoint = 0;
      }
			break;
		case "surface" :
      if(window.event.button == 1 || !window.event.button)
      {
				distanceOffsetX = window.event.clientX - document.getElementById("Mapa").offsetLeft - parseInt(document.getElementById("divNavOkno").style.width);
				distanceOffsetY = window.event.clientY - document.getElementById("Mapa").offsetTop - parseInt(document.getElementById("divNavLista").style.height) - parseInt(document.getElementById("divMapToolbar").style.height);
				if(distanceLastPoint == 0)
				{
					distanceArrayX = new Array();
					distanceArrayY = new Array();
					distanceArrayX[distanceLastPoint] = distanceOffsetX;
					distanceArrayY[distanceLastPoint] = distanceOffsetY;
					distanceLastPoint = distanceLastPoint + 1;
					distanceAction = "process";
				}
				else
				{
					distanceArrayX[distanceLastPoint] = distanceOffsetX;
					distanceArrayY[distanceLastPoint] = distanceOffsetY;
					distanceLastPoint = distanceLastPoint + 1;
          jg_doc.clear();
  				jg_doc.drawPolygon(distanceArrayX, distanceArrayY);
  				jg_doc.paint();
				}
      }
      else
      {
				distanceAction = "";
				if(distanceLastPoint > 0)
				{
					alert(script_messages[13] + ComputeSurface() + " " + script_messages[30] + "; " + script_messages[31] + Math.round(ComputePerimeter()) + script_messages[32]);
          jg_doc.clear();
  			}
				distanceLastPoint = 0;
  		}
			break;
	}
}
//****************************************************************************

function OknoMapa_MouseMove()
{
/*
 * Procedura obsluhujici udalost pohybu mysi nad objektem OknoMapa.
 */

	var tmpX;
	var tmpY;
  var WrldWidth, WrldHeight, UnitX, UnitY;

  var crs_name = "";
  var crs_unit = "";
  var crs_round = "-1";
  var crs_sign = 1;
  var crs_axis_order = 1;
  var crs_axis_horiz_desc = "X";
  var crs_axis_vert_desc = "Y";
  
  var x = "";
  var y = "";
    
	//window.event.returnValue = true;

  //informace o CRS
  for(var c = 0; c < crs_info.crs_list.Length(); c++)
  {
    if(crs_info.crs_list.Item(c).code.toLowerCase() == map_list.maps.Item(map_list.map_id).srs.toLowerCase())
    {
      crs_name = crs_info.crs_list.Item(c).name;
      crs_unit = crs_info.crs_list.Item(c).unit;
      crs_round = crs_info.crs_list.Item(c).round;
      crs_sign = parseInt(crs_info.crs_list.Item(c).sign);
      crs_axis_order = parseInt(crs_info.crs_list.Item(c).axis_order);
      crs_axis_horiz_desc = crs_info.crs_list.Item(c).axis_horiz_desc;
      crs_axis_vert_desc = crs_info.crs_list.Item(c).axis_vert_desc;
      break;
    }
  }

	var BBoxArray = ParseBBox(map_list.maps.Item(map_list.map_id).bbox);
	
	tmpX = window.event.clientX - document.getElementById("OknoMapa").offsetLeft - parseInt(document.getElementById("divNavOkno").style.width);
	tmpY = window.event.clientY - document.getElementById("OknoMapa").offsetTop - parseInt(document.getElementById("divNavLista").style.height) - parseInt(document.getElementById("divMapToolbar").style.height);

	WrldWidth = BBoxArray[2] - BBoxArray[0];
	WrldHeight = BBoxArray[3] - BBoxArray[1];

	UnitX = WrldWidth / map_list.maps.Item(map_list.map_id).map_width;
	UnitY = WrldHeight / map_list.maps.Item(map_list.map_id).map_height;

  if(crs_round == "-1")
  {
    x = ((BBoxArray[0] + (tmpX * UnitX)) * crs_sign).toString();
    y = ((BBoxArray[3] - (tmpY * UnitY)) * crs_sign).toString();
  }
  else
  {
    x = ((Math.round((BBoxArray[0] + (tmpX * UnitX))*(Math.round(Math.exp(parseInt(crs_round) * Math.log(10)))))/(Math.round(Math.exp(parseInt(crs_round) * Math.log(10))))) * crs_sign).toString();
    y = ((Math.round((BBoxArray[3] - (tmpY * UnitY))*(Math.round(Math.exp(parseInt(crs_round) * Math.log(10)))))/(Math.round(Math.exp(parseInt(crs_round) * Math.log(10))))) * crs_sign).toString();
  }

  if(crs_axis_order == -1)
  {
  	document.getElementById("posY").innerHTML = crs_axis_horiz_desc + ": " + x;
  	document.getElementById("posX").innerHTML = crs_axis_vert_desc + ": " + y;
  }
  else
  {
  	document.getElementById("posX").innerHTML = crs_axis_horiz_desc + ": " + x;
  	document.getElementById("posY").innerHTML = crs_axis_vert_desc + ": " + y;
  }
  
	//Pro danou akci delej
	switch (MapAction)
	{
		case "pan" :
			if (FlagMove)
			{
				offsetX = window.event.clientX - LastX;
				offsetY = window.event.clientY - LastY;
				LastX = window.event.clientX;
				LastY = window.event.clientY;
				document.getElementById("Mapa").style.left = parseInt(document.getElementById("Mapa").style.left) + offsetX;
				document.getElementById("Mapa").style.top = parseInt(document.getElementById("Mapa").style.top) + offsetY;
			}
			break;
		case "zoomarea" :
			if (FlagMove)
			{
				LastX = window.event.clientX;
				LastY = window.event.clientY;
				offsetX = LastX - document.getElementById("OknoMapa").offsetLeft - parseInt(document.getElementById("divNavOkno").style.width) - StartX;
				offsetY = LastY - document.getElementById("OknoMapa").offsetTop - parseInt(document.getElementById("divNavLista").style.height) + parseInt(document.getElementById("divMapToolbar").style.height) - StartY;
			
				if (offsetX < 0 )
				{
					document.getElementById("fence").style.left = LastX - document.getElementById("OknoMapa").offsetLeft - parseInt(document.getElementById("divNavOkno").style.width);
					document.getElementById("fence").style.width = - offsetX;
				}
				else
				{
					document.getElementById("fence").style.width = offsetX;
				}
		
				if (offsetY < 0 )
				{
					document.getElementById("fence").style.top = LastY - document.getElementById("OknoMapa").offsetTop - parseInt(document.getElementById("divNavLista").style.height) + parseInt(document.getElementById("divMapToolbar").style.height);
					document.getElementById("fence").style.height = - offsetY;
				}
				else
				{
					document.getElementById("fence").style.height = offsetY;
				}
			}
			break;
		case "distance" :
			distanceOffsetX = window.event.clientX - document.getElementById("Mapa").offsetLeft - parseInt(document.getElementById("divNavOkno").style.width);
			distanceOffsetY = window.event.clientY - document.getElementById("Mapa").offsetTop - parseInt(document.getElementById("divNavLista").style.height) - parseInt(document.getElementById("divMapToolbar").style.height);
			if(distanceAction == "process")
			{
				distanceArrayX[distanceLastPoint] = distanceOffsetX;
				distanceArrayY[distanceLastPoint] = distanceOffsetY;
  				jg_doc.clear();
  				jg_doc.drawPolyLine(distanceArrayX, distanceArrayY);
  				jg_doc.paint();
				//document.getElementById("vmlShape").path = ArrayToPath();
			}
			break;
		case "surface" :
			distanceOffsetX = window.event.clientX - document.getElementById("Mapa").offsetLeft - parseInt(document.getElementById("divNavOkno").style.width);
			distanceOffsetY = window.event.clientY - document.getElementById("Mapa").offsetTop - parseInt(document.getElementById("divNavLista").style.height) - parseInt(document.getElementById("divMapToolbar").style.height);
			if(distanceAction == "process")
			{
				distanceArrayX[distanceLastPoint] = distanceOffsetX;
				distanceArrayY[distanceLastPoint] = distanceOffsetY;
				jg_doc.clear();
				jg_doc.drawPolygon(distanceArrayX, distanceArrayY);
				jg_doc.paint();
				//document.getElementById("vmlShape").path = ArrayToSPath();
			}
			break;
	}
}
//****************************************************************************

function Redline_onRightClick()
{

  window.event.cancelBubble = true;
	window.event.returnValue = false;
	
	distanceLastPoint = 0;
	distanceAction = "";
	jg_doc.clear();
	/*document.getElementById("vmlShape").path = "m";
	document.getElementById("distanceLength").style.display = "none";*/
}
//****************************************************************************

function ArrayToPath()
{
	var tpath;
	var i;
	
	tpath = "m";
	
	for(i = 0; i < distanceArray.length; i+=2)
	{
		switch(i)
		{
			case 0 :
				tpath = tpath + distanceArray[i] + "," + distanceArray[i+1] + "l";
				break; 
			case 2 :
				tpath = tpath + distanceArray[i] + "," + distanceArray[i+1];
				break;
			default :
				tpath = tpath + "," + distanceArray[i] + "," + distanceArray[i+1];
				break;
		}
	}
	
	return tpath + "e"
}
//****************************************************************************

function ArrayToSPath()
{
	var tpath;
	var i;
	
	tpath = "m";
	
	for(i = 0; i < distanceArray.length; i+=2)
	{
		switch(i)
		{
			case 0 :
				tpath = tpath + distanceArray[i] + "," + distanceArray[i+1] + "l";
				break;
			case 2 :
				tpath = tpath + distanceArray[i] + "," + distanceArray[i+1];
				break;
			default :
				tpath = tpath + "," + distanceArray[i] + "," + distanceArray[i+1];
				break
		}
	}
	return tpath + "," + distanceArray[0] + "," + distanceArray[1] + "e"
}
//****************************************************************************

function ComputeLenght()
{
	var lnght;
	var i;
	var prevX;
	var prevY;
	var currX;
	var currY;
	
	var WrldWidth;
	var unit;
	var BBoxArray;
		
	lnght = 0;

	//var a = new VBArray(ParseBBox(map_list.maps.Item(map_list.map_id).bbox));
	
	BBoxArray = ParseBBox(map_list.maps.Item(map_list.map_id).bbox);

	WrldWidth = BBoxArray[2] - BBoxArray[0];
	unit = WrldWidth / map_list.maps.Item(map_list.map_id).map_width;

	if(distanceArrayX.length > 1)
	{
		prevX = distanceArrayX[0];
		prevY = distanceArrayY[0];
		for(i = 1; i < distanceArrayX.length; i++)
		{
			currX = distanceArrayX[i];
			currY = distanceArrayY[i];
			lnght = lnght + Math.sqrt(((currX - prevX) * (currX - prevX)) + ((currY - prevY) * (currY - prevY)));
			prevX = currX;
			prevY = currY;
		}
	}

	return Math.round((lnght * unit)/1)
}
//****************************************************************************

function ComputePerimeter()
{
	var lnght;
	var i;
	var prevX;
	var prevY;
	var currX;
	var currY;
	
	var WrldWidth;
	var unit;
	var BBoxArray;

	lnght = 0;

	//var a = new VBArray(ParseBBox(map_list.maps.Item(map_list.map_id).bbox));
	
	BBoxArray = ParseBBox(map_list.maps.Item(map_list.map_id).bbox);

	WrldWidth = BBoxArray[2] - BBoxArray[0];
	unit = WrldWidth / map_list.maps.Item(map_list.map_id).map_width;

	if(distanceArrayX.length > 1)
	{
		prevX = distanceArrayX[0];
		prevY = distanceArrayY[0];
		for(i = 1; i < distanceArrayX.length; i++)
		{
			currX = distanceArrayX[i];
			currY = distanceArrayY[i];
			lnght = lnght + Math.sqrt(((currX - prevX) * (currX - prevX)) + ((currY - prevY) * (currY - prevY)));
			prevX = currX;
			prevY = currY;
		}

		currX = distanceArrayX[0];
		currY = distanceArrayY[0];
		lnght = lnght + Math.sqrt(((currX - prevX) * (currX - prevX)) + ((currY - prevY) * (currY - prevY)));
	}

	return Math.round((lnght * unit)/1)
	
}
//****************************************************************************

function ComputeSurface()
{

	var surface;
	var i;
	var prevX;
	var prevY;
	var currX;
	var currY;
	
	var WrldWidth;
	var unit;
	var BBoxArray;
		
	surface = 0;

	//var a = new VBArray(ParseBBox(map_list.maps.Item(map_list.map_id).bbox));
	
	BBoxArray = ParseBBox(map_list.maps.Item(map_list.map_id).bbox);

	WrldWidth = BBoxArray[2] - BBoxArray[0];
	unit = WrldWidth / map_list.maps.Item(map_list.map_id).map_width;

	if(distanceArrayX.length > 1)
	{
		prevX = distanceArrayX[0];
		prevY = distanceArrayY[0];
		for(i = 1; i < distanceArrayX.length; i++)
		{
			currX = distanceArrayX[i];
			currY = distanceArrayY[i];
			surface = surface + (((currX - prevX) * (currY + prevY))/2);
			prevX = currX;
			prevY = currY;
		}

		currX = distanceArrayX[0];
		currY = distanceArrayY[0];
		surface = surface + (((currX - prevX) * (currY + prevY))/2);
	}

	surface = Math.round((surface * unit * unit)/1);
	
	return Math.abs(surface)
}
//****************************************************************************

function SetMapAction(a)
{

	var btnNew;
	
	if(btnActual != null)
	{
		btnActual.style.backgroundColor = "transparent";
		btnActual.style.border = "1px solid #C7D5F0";
	}

	switch(a)
	{
		case "select" :
			MapAction = a;
			btnNew = "imgSelect";
			break;
		case "zoomarea" :
			MapAction = a;
			btnNew = "imgZoomArea";
			break;
		case "zoomin" :
			MapAction = a;
			btnNew = "imgZoomIn";
			break;
		case "zoomout" :
			MapAction = a;
			btnNew = "imgZoomOut";
			break;
		case "pan" :
			MapAction = a;
			btnNew = "imgPan";
			break;
		case "fitall" :
			MapAction = a;
			btnNew = "imgFitAll";
			break;
		case "setscale" :
			MapAction = a;
			btnNew = "imgSetScale";
			break;
		case "distance" :
			MapAction = a;
			btnNew = "imgDistance";
			break;
		case "surface" :
			MapAction = a;
			btnNew = "imgSurface";
			break;
		case "coordinates" :
			MapAction = a;
			btnNew = "imgCoordinates";
			break;
		case "reload" :
			MapAction = a;
			btnNew = "imgReload";
			break;
	}
	
	document.getElementById(btnNew).style.backgroundColor = "3656A3";
	document.getElementById(btnNew).style.border = "1px solid blue";
	
	btnActual = document.getElementById(btnNew);
}
//****************************************************************************

function imgButton_Enter(btn, id)
{
	btn.style.border = "1px solid blue";
}
//****************************************************************************

function imgButton_Leave(btn, id)
{
	if(btnActual != null)
	{
		if(btnActual.id != btn.id)
		{
			btn.style.backgroundColor = "transparent";
			btn.style.border = "1px solid #C7D5F0";
		}
		else
		{
			btn.style.backgroundColor = "6699CC";
			btn.style.border = "1px solid blue";
		}
	}
	else
	{
		btn.style.backgroundColor = "transparent";
		btn.style.border = "1px solid #C7D5F0";
	}
}
//****************************************************************************

function btnSelect_Click()
{
/*
 * Procedura obsluhujici udalost kliknuti na tlacitko Select.
 */

	if(document.getElementById("divWait").style.display == "none")
	{
		//Zastav probublavani udalosti dale
		window.event.cancelBubble = true;

		//Nastaveni pozadovane akce
		SetMapAction("select");
		
		//Nastaveni stylu kurzoru na posun
		document.getElementById("OknoMapa").style.cursor = "default";
		
		document.getElementById("imgSelect").style.border = "1px solid blue";
		document.getElementById("imgSelect").style.backgroundColor = "6699CC";
	}	
}
//****************************************************************************

function btnZoomArea_Click()
{
/*
 * Procedura obsluhujici udalost kliknuti na tlacitko ZoomArea.
 */

	if(document.getElementById("divWait").style.display == "none")
	{
		//Zastav probublavani udalosti dale
		window.event.cancelBubble = true;

		//Nastaveni pozadovane akce
		SetMapAction("zoomarea");
		
		//Nastaveni stylu kurzoru na kriz
		document.getElementById("OknoMapa").style.cursor = "crosshair";
	}
}
//****************************************************************************

function btnZoomIn_Click()
{
/*
 * Procedura obsluhujici udalost kliknuti na tlacitko Select.
 */
	if(document.getElementById("divWait").style.display == "none")
	{
		//Zastav probublavani udalosti dale
		window.event.cancelBubble = true;

		SetMapAction("zoomin");

		//'MoveMap("ZoomIn")
		
		//Nastaveni pozadovane akce
		//MapAction = "zoomin"
		
		//Nastaveni stylu kurzoru na posun
		document.getElementById("OknoMapa").style.cursor = "crosshair";
	}
}
//****************************************************************************

function btnZoomOut_Click()
{
/*
 * Procedura obsluhujici udalost kliknuti na tlacitko Select.
 */
	
	if(document.getElementById("divWait").style.display == "none")
	{
		//Zastav probublavani udalosti dale
		window.event.cancelBubble = true;

		SetMapAction("zoomout");

		//'MoveMap("ZoomOut")
		
		//Nastaveni pozadovane akce
		//MapAction = "select"
		
		//Nastaveni stylu kurzoru na posun
		document.getElementById("OknoMapa").style.cursor = "crosshair";
	}	
}
//****************************************************************************

function btnPan_Click()
{
/*
 * Procedura obsluhujici udalost kliknuti na tlacitko Pan.
 */

	if(document.getElementById("divWait").style.display == "none")
	{
		//Zastav probublavani udalosti dale
		window.event.cancelBubble = true;
		
		SetMapAction("pan");
		
		//Nastaveni pozadovane akce
		//MapAction = "pan"
		
		//Nastaveni stylu kurzoru na posun
		document.getElementById("OknoMapa").style.cursor = "crosshair";
	}
}
//****************************************************************************

function btnCoordinates_Click()
{
/*
 * Procedura obsluhujici udalost kliknuti na tlacitko Pan.
 */
	if(document.getElementById("divWait").style.display == "none")
	{
		//Zastav probublavani udalosti dale
		window.event.cancelBubble = true;
		
		SetMapAction("coordinates");

		//Nastaveni stylu kurzoru na posun
		document.getElementById("OknoMapa").style.cursor = "crosshair";
	}
}
//****************************************************************************

function btnFitAll_Click()
{
/*
 * Procedura obsluhujici udalost FitAll.
 */

	if(document.getElementById("divWait").style.display == "none")
	{
		SetMapAction("fitall");
		MapAction = "select";
		
		document.getElementById("divWait").style.display = "";

		LayerManager.HideAll();
			
		//Aktualizace map
		map_list.maps.Item(map_list.map_id).bbox = map_list.maps.Item(map_list.map_id).default_bbox;
		map_list.maps.Item(map_list.map_id).Actualize_BBOX();

		/*'Klikaci mapa
		MAP_URL = document.all.ClickMapSrc.src
		MAP_URL = ReplaceBBOX(MAP_URL, "-925000,-1240000,-425000,-920000")
		document.all.ClickMapSrc.src = MAP_URL
		
		
		TMapaArray = Split(document.all.cmbTMapa.options(document.all.cmbTMapa.selectedIndex).value,"|")
		
		'Nastav aktivni vrstvu
		document.all.varActiveFeature.value = TMapaArray(7)
		
		CheckAFeature document.all.varActiveFeature.value
		
		btnAVrstvaOK_Click
*/
		LayerManager.ShowAll();
		
		SetPosition();
	}
}
//****************************************************************************

function cmbScale_Change()
{
/*
 * Procedura obsluhujici udalost zmeny hodnoty na objektu cmbScale.
 */
	
	if(document.getElementById("divWait").style.display == "none")
	{
		//Zastav probublavani udalosti dale
		window.event.cancelBubble = true;

		MapScale = document.getElementById("cmbScale").options[document.getElementById("cmbScale").selectedIndex].value;
		
		if(MapScale != "")
		{
			MapScale = parseInt(MapScale);
			MoveMap("changescale");
		}
	}	
}
//****************************************************************************

function btnSetScale_Click()
{
/*
 * Procedura obsluhujici udalost kliknuti na tlacitko SetScale.
 */

	if(document.getElementById("divWait").style.display == "none")
	{
		var s;
		
		SetMapAction("setscale");
		MapAction = "select";

		s = prompt(script_messages[33], "");
		
		if(s != null)
		{
			if(s != "")
			{
				s = parseFloat(s);
				/*If (Err <> 0) Then
				  Err.Clear
				  alert "Špatný formát zadané hodnoty měřítka."
				  Exit Sub
				End If*/
				
				MapScale = Math.round(s);
				
				if(MapScale > 0)
				{
					MoveMap("changescale");
				}
				else
				{
				  alert(script_messages[14]);
				}
			}
			else
			{
				alert(script_messages[15]);
			}
		}
		SetMapAction(MapAction);
	}
}
//****************************************************************************

function btnDistance_Click()
{
/*
 * Procedura obsluhujici udalost kliknuti na tlacitko Distance.
 */

	if(document.getElementById("divWait").style.display == "none")
	{
		//Zastav probublavani udalosti dale
		window.event.cancelBubble = true;

		//Nastaveni pozadovane akce
		SetMapAction("distance");
		
		//Nastaveni stylu kurzoru na kriz
		//document.getElementById("OknoMapa").style.cursor = "crosshair";

		document.getElementById('divKresleni').style.visibility = 'visible';
		jg_doc = new jsGraphics("divKresleni");
		jg_doc.setColor("#ff0000");
		jg_doc.setStroke(2);

	}
}
//****************************************************************************

function btnSurface_Click()
{
/*
 * Procedura obsluhujici udalost kliknuti na tlacitko Surface.
 */

	if(document.getElementById("divWait").style.display == "none")
	{	
		//Zastav probublavani udalosti dale
		window.event.cancelBubble = true;

		//Nastaveni pozadovane akce
		SetMapAction("surface");
		
		//Nastaveni stylu kurzoru na kriz
//		document.getElementById("OknoMapa").style.cursor = "crosshair";

		document.getElementById('divKresleni').style.visibility = 'visible';
		jg_doc = new jsGraphics("divKresleni");
		jg_doc.setColor("#ff0000");
		jg_doc.setStroke(2);

	}
}
//****************************************************************************

function btnPrint_Click()
{
/*
 * Procedura obsluhujici udalost kliknuti na tlacitko Print.
 */
	if(document.getElementById("divWait").style.display == "none")
	{
		//Zastav probublavani udalosti dale
		window.event.cancelBubble = true;

    var xmlDoc;
    var WrldWidth, WrldHeight, MapScale;
    var BBoxArray, WmsBBox;
    var print_scale, print_width, print_height, quality_factor, map_width, map_height;

   	var re_version = /[.]/ig;
    
    if (moz)
    {
      xmlDoc = document.implementation.createDocument("", "", null);      
    }
    else
    {
      xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); 
      xmlDoc.async = false;
    }

		//vytvor xml pro tiskovou sluzbu
    var print_mapElem = xmlDoc.createElement("PRINT_MAP");
    print_mapElem.setAttribute("map_width", map_list.maps.Item(map_list.map_id).map_width);
    print_mapElem.setAttribute("map_height", map_list.maps.Item(map_list.map_id).map_height);
    print_mapElem.setAttribute("map_bbox", map_list.maps.Item(map_list.map_id).bbox);
    print_mapElem.setAttribute("map_srs", map_list.maps.Item(map_list.map_id).srs);

    //projdi vsechny zobrazovane wms servery a pridej je do tiskove kompozice
  	for (var i = 0; i < map_list.maps.Item(map_list.map_id).wms_list.Length(); i++)
  	{
      var wms_server = map_list.maps.Item(map_list.map_id).wms_list.Item(i);
      
      if(wms_server.selected)
      {
        var wmsElem = xmlDoc.createElement("WMS_SERVER");
        wmsElem.setAttribute("url", wms_server.wms_url);
        wmsElem.setAttribute("opacity", wms_server.opacity);
        print_mapElem.appendChild(wmsElem);
      }
    }
    
    var legendElem = xmlDoc.createElement("MAP_LEGEND");

    //delej jen pro zobrazene WMS servery
  	for (var i = 0; i < map_list.maps.Item(map_list.map_id).wms_list.Length(); i++)
  	{
      var wms_server = map_list.maps.Item(map_list.map_id).wms_list.Item(i);
      
      if(wms_server.selected)
      {
        //var s_actual = ((((world_width * map_list.maps.Item(map_list.map_id).projection_to_scale) / wms_server.width) * 100) * (280/10));

        var wmsElem = xmlDoc.createElement("WMS_SERVER");
        wmsElem.setAttribute("title", wms_server.title);
        
        //projdi vsechny skupiny
				for(var j = 0; j < wms_server.legend.group_list.Length(); j++)
				{
          selected = false;
          var groupElem = xmlDoc.createElement("GROUP");
          //projdi vsechny vrstvy a pokud je nejaka zaskrtla tak celou skupinu pridej do legendy
          for(var k = 0; k < wms_server.legend.group_list.Item(j).layer_list.Length(); k++)
          {
            if(wms_server.legend.group_list.Item(j).layer_list.Item(k).checked)
            {
              //if((s_actual >= wms_server.legend.group_list.Item(j).layer_list.Item(k).scalemin) && (s_actual < wms_server.legend.group_list.Item(j).layer_list.Item(k).scalemax))
              //{
                var layerElem = xmlDoc.createElement("LAYER");
                layerElem.setAttribute("title", wms_server.legend.group_list.Item(j).layer_list.Item(k).title);
                layerElem.setAttribute("scalemin", wms_server.legend.group_list.Item(j).layer_list.Item(k).scalemin);
                layerElem.setAttribute("scalemax", wms_server.legend.group_list.Item(j).layer_list.Item(k).scalemax);
                layerElem.setAttribute("pic_url", wms_server.legend.group_list.Item(j).layer_list.Item(k).pic_url);
                layerElem.setAttribute("pic_width", wms_server.legend.group_list.Item(j).layer_list.Item(k).pic_width);
                layerElem.setAttribute("pic_height", wms_server.legend.group_list.Item(j).layer_list.Item(k).pic_height);
                groupElem.appendChild(layerElem);
                selected = true;
              //}
            }
          }
          if(selected)
          {
            groupElem.setAttribute("title", wms_server.legend.group_list.Item(j).title);
            wmsElem.appendChild(groupElem);
          }
          else
          {
            groupElem = null;
          }
        }

  			if(wms_server.legend.layer_list.Length() > 0)
  			{
  				// delej pro vrstvy co nejsou v zadne skupine
  				for(var j = 0; j < wms_server.legend.layer_list.Length(); j++)
  				{
  					if(wms_server.legend.layer_list.Item(j).checked)
  					{
              /*if((s_actual >= wms_server.legend.group_list.Item(j).layer_list.Item(k).scalemin) && (s_actual < wms_server.legend.group_list.Item(j).layer_list.Item(k).scalemax) || wms_server.version == "1.1.1" || wms_server.version == "1.1.0")
              {*/
                var layerElem = xmlDoc.createElement("LAYER");
                layerElem.setAttribute("title", wms_server.legend.layer_list.Item(j).title);
                layerElem.setAttribute("pic_url", wms_server.legend.layer_list.Item(j).pic_url);
                layerElem.setAttribute("pic_width", wms_server.legend.layer_list.Item(j).pic_width);
                layerElem.setAttribute("pic_height", wms_server.legend.layer_list.Item(j).pic_height);
                wmsElem.appendChild(layerElem);
                selected = true;
             // }
  					}
  				}
  			}
              
        legendElem.appendChild(wmsElem);
      }
    }

    print_mapElem.appendChild(legendElem);
    
    xmlDoc.appendChild(print_mapElem);

    var submit_form = document.createElement("FORM");
    submit_form.id = "frmPrintParam";
    submit_form.action = print_map_url;
    submit_form.method = "POST";
    submit_form.target = "_blank";

    var print_text_area = document.createElement("TEXTAREA");
    print_text_area.id = "txtPrintParam";
    print_text_area.name = "txtPrintParam";
    submit_form.appendChild(print_text_area);
    
    var targetElem = document.getElementById("divPrintForm");
    
    targetElem.appendChild(submit_form);

    if(moz)
    {
        var s = new XMLSerializer();

        document.getElementById("txtPrintParam").value = s.serializeToString(xmlDoc, "text/xml");
    }
    else
    {
      document.getElementById("txtPrintParam").innerText = xmlDoc.xml;
    }

    document.getElementById("frmPrintParam").submit();
	}
}
//****************************************************************************

function btnPrintOld_Click()
{
/*
 * Procedura obsluhujici udalost kliknuti na tlacitko Print.
 */
	if(document.getElementById("divWait").style.display == "none")
	{
		//Zastav probublavani udalosti dale
		window.event.cancelBubble = true;

    var xmlDoc;
    var xmlhttp;
    var WrldWidth, WrldHeight, MapScale;
    var BBoxArray, WmsBBox;
    var print_scale, print_width, print_height, quality_factor, map_width, map_height;
    
    if (moz)
    {
      xmlDoc = document.implementation.createDocument("", "", null);
      
      xmlhttp = new XMLHttpRequest();
      
    }
    else
    {
      xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); 
      xmlDoc.async = false;

      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

    }

    print_scale = parseInt(document.getElementById("cmbPrint_scales").options[document.getElementById("cmbPrint_scales").selectedIndex].value);
    print_width = parseInt(document.getElementById("txtPrint_width").value);
    print_height = parseInt(document.getElementById("txtPrint_height").value);
    quality_factor = parseInt(document.getElementById("cmbPrint_quality_factor").options[document.getElementById("cmbPrint_quality_factor").selectedIndex].value);

    map_width = map_list.maps.Item(map_list.map_id).map_width;
    map_height = map_list.maps.Item(map_list.map_id).map_height;
		BBoxArray = ParseBBox(map_list.maps.Item(map_list.map_id).bbox);
    
		WrldWidth = BBoxArray[2] - BBoxArray[0];
		WrldHeight = BBoxArray[3] - BBoxArray[1];
    
		//spocitej BBOx a meritka mapy
		if (print_scale == -1)
		{
			//zachovat stejne meritko

			var UnitX = WrldWidth / map_width;
			var UnitY = WrldHeight / map_height;
		
			centerX = BBoxArray[0] + (WrldWidth / 2);
			centerY = BBoxArray[1] + (WrldHeight / 2);

			BBoxArray[0] = centerX - ((print_width/2) * UnitX);
			BBoxArray[2] = centerX + ((print_width/2) * UnitX);
			BBoxArray[1] = centerY - ((print_height/2) * UnitY);
			BBoxArray[3] = centerY + ((print_height/2) * UnitY);
		}
		else
		{
			//tisknout v jinem meritku
			
			centerX = BBoxArray[0] + (WrldWidth / 2);
			centerY = BBoxArray[1] + (WrldHeight / 2);

			BBoxArray[0] = centerX - (((print_width/2)/(378/100)) / 1000 * print_scale);
			BBoxArray[2] = centerX + (((print_width/2)/(378/100)) / 1000 * print_scale);
			BBoxArray[1] = centerY - (((print_height/2)/(378/100)) / 1000 * print_scale);
			BBoxArray[3] = centerY + (((print_height/2)/(378/100)) / 1000 * print_scale);

		}

  	WmsBBox = dbl2StrEN(BBoxArray[0].toString()) + "," + dbl2StrEN(BBoxArray[1].toString()) + "," + dbl2StrEN(BBoxArray[2].toString()) + "," + dbl2StrEN(BBoxArray[3].toString());
		
		//vytvor xml pro tiskovou sluzbu

    var print_mapElem = xmlDoc.createElement("PRINT_MAP");
    print_mapElem.setAttribute("map_width", print_width);
    print_mapElem.setAttribute("map_height", print_height);
    print_mapElem.setAttribute("map_zoom", 100/quality_factor);
    print_mapElem.setAttribute("map_zoom", 100/quality_factor);

		WrldWidth = BBoxArray[2] - BBoxArray[0];
		MapScale = Math.round((((WrldWidth / print_width) * 100) * (378/10)));

    print_mapElem.setAttribute("map_scale", "1 : " + MapScale.toString());

    print_mapElem.setAttribute("length", Math.round((MapScale * 3) / 100) + "m");

    //projdi vsechny zobrazovane wms servery a pridej je do tiskove kompozice
  	for (var i = 0; i < map_list.maps.Item(map_list.map_id).wms_list.Length(); i++)
  	{
      var wms_server = map_list.maps.Item(map_list.map_id).wms_list.Item(i);
      
      if(wms_server.selected)
      {
        var wmsElem = xmlDoc.createElement("WMS_SERVER");
        wmsElem.setAttribute("url", replace_string(replace_string(replace_string(wms_server.wms_url, "HEIGHT", print_height), "WIDTH", print_width), "BBOX", WmsBBox));
        wmsElem.setAttribute("opacity", wms_server.opacity);
        print_mapElem.appendChild(wmsElem);
      }
    }
    
    
    xmlDoc.appendChild(print_mapElem);

    //alert(xmlDoc.xml);

    var submit_form = document.createElement("FORM");
    submit_form.id = "frmPrintParam";
    submit_form.action = print_map_url;
    submit_form.method = "POST";
    submit_form.target = "_blank";

    var print_text_area = document.createElement("TEXTAREA");
    print_text_area.id = "txtPrintParam";
    print_text_area.name = "txtPrintParam";
    submit_form.appendChild(print_text_area);
    
    var targetElem = document.getElementById("divPrintForm");
    
    targetElem.appendChild(submit_form);

    if(moz)
    {
        var s = new XMLSerializer();

        document.getElementById("txtPrintParam").innerHTML = s.serializeToString(xmlDoc, "text/xml");
    }
    else
    {
      document.getElementById("txtPrintParam").innerText = xmlDoc.xml;
    }

    document.getElementById("frmPrintParam").submit();
    //submit_form.submit();
    
    //var s_f = document.getElementById("frmPrintParam")
    //document.removeChild(s_f);
        
    //window.open(print_map_url);
		
	}
}
//****************************************************************************

function btnShowLegend_Click()
{

	if(document.getElementById("divWait").style.display == "none")
	{

    var xmlDoc;
    var xmlhttp;
    var selected;

    var BBoxArray = new Array();
		
    BBoxArray = map_list.maps.Item(map_list.map_id).bbox.split(',');
			
    var world_width = BBoxArray[2] - BBoxArray[0];
    
    if (moz)
    {
      xmlDoc = document.implementation.createDocument("", "", null);
      
      xmlhttp = new XMLHttpRequest();
      
    }
    else
    {
      xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); 
      xmlDoc.async = false;

      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

    }

    var legendElem = xmlDoc.createElement("MAP_LEGEND");

    legendElem.setAttribute("mode", 0);
    legendElem.setAttribute("show", 1);

    //delej jen pro zobrazene WMS servery
  	for (var i = 0; i < map_list.maps.Item(map_list.map_id).wms_list.Length(); i++)
  	{
      var wms_server = map_list.maps.Item(map_list.map_id).wms_list.Item(i);
      
      if(wms_server.selected)
      {
        //var s_actual = ((((world_width * map_list.maps.Item(map_list.map_id).projection_to_scale) / wms_server.width) * 100) * (280/10));

        var wmsElem = xmlDoc.createElement("WMS_SERVER");
        wmsElem.setAttribute("title", wms_server.title);
        
        //projdi vsechny skupiny
				for(var j = 0; j < wms_server.legend.group_list.Length(); j++)
				{
          selected = false;
          var groupElem = xmlDoc.createElement("GROUP");
          //projdi vsechny vrstvy a pokud je nejaka zaskrtla tak celou skupinu pridej do legendy
          for(var k = 0; k < wms_server.legend.group_list.Item(j).layer_list.Length(); k++)
          {
            if(wms_server.legend.group_list.Item(j).layer_list.Item(k).checked)
            {
              /*if((s_actual >= wms_server.legend.group_list.Item(j).layer_list.Item(k).scalemin) && (s_actual < wms_server.legend.group_list.Item(j).layer_list.Item(k).scalemax) || wms_server.version == "1.1.1" || wms_server.version == "1.1.0")
              {*/
                var layerElem = xmlDoc.createElement("LAYER");
                layerElem.setAttribute("title", wms_server.legend.group_list.Item(j).layer_list.Item(k).title);
                layerElem.setAttribute("pic_url", wms_server.legend.group_list.Item(j).layer_list.Item(k).pic_url);
                layerElem.setAttribute("pic_width", wms_server.legend.group_list.Item(j).layer_list.Item(k).pic_width);
                layerElem.setAttribute("pic_height", wms_server.legend.group_list.Item(j).layer_list.Item(k).pic_height);
                groupElem.appendChild(layerElem);
                selected = true;
             // }
            }
          }
          if(selected)
          {
            groupElem.setAttribute("title", wms_server.legend.group_list.Item(j).title);
            wmsElem.appendChild(groupElem);
          }
          else
          {
            groupElem = null;
          }
        }

  			if(wms_server.legend.layer_list.Length() > 0)
  			{
  				// delej pro vrstvy co nejsou v zadne skupine
  				for(var j = 0; j < wms_server.legend.layer_list.Length(); j++)
  				{
  					if(wms_server.legend.layer_list.Item(j).checked)
  					{
              /*if((s_actual >= wms_server.legend.group_list.Item(j).layer_list.Item(k).scalemin) && (s_actual < wms_server.legend.group_list.Item(j).layer_list.Item(k).scalemax) || wms_server.version == "1.1.1" || wms_server.version == "1.1.0")
              {*/
                var layerElem = xmlDoc.createElement("LAYER");
                layerElem.setAttribute("title", wms_server.legend.layer_list.Item(j).title);
                layerElem.setAttribute("pic_url", wms_server.legend.layer_list.Item(j).pic_url);
                layerElem.setAttribute("pic_width", wms_server.legend.layer_list.Item(j).pic_width);
                layerElem.setAttribute("pic_height", wms_server.legend.layer_list.Item(j).pic_height);
                wmsElem.appendChild(layerElem);
                selected = true;
             // }
  					}
  				}
  			}
              
        legendElem.appendChild(wmsElem);
      }
    }

    xmlDoc.appendChild(legendElem);

    var submit_form = document.createElement("FORM");
    submit_form.id = "frmLegendXML";
    submit_form.action = "legend.asp";
    submit_form.method = "POST";
    submit_form.target = "_blank";

    var legend_xml_area = document.createElement("TEXTAREA");
    legend_xml_area.id = "txtLegendXML";
    legend_xml_area.name = "txtLegendXML";
    submit_form.appendChild(legend_xml_area);
    
    var targetElem = document.getElementById("divLegendForm");
    
    targetElem.appendChild(submit_form);

    if(moz)
    {
        var s = new XMLSerializer();

        document.getElementById("txtLegendXML").value = s.serializeToString(xmlDoc, "text/xml");
    }
    else
    {
      document.getElementById("txtLegendXML").innerText = xmlDoc.xml;
    }

    document.getElementById("frmLegendXML").submit();
          	
/*  	Set xmlRoot = xmlDoc.createElement("LegendInfo")
  	Set xmlDoc.documentElement = xmlRoot
  
  	For i = 0 To Ubound(aWMSLayers)
  		If (aWMSLayers(i)(1) = 1) Then
  			If (aWMSLayers(i)(2) = 1) Then
  				Set xmlRec = xmlDoc.createElement("Feature")
  
  				xmlRec.setAttribute "Title", document.all.item("spnFeature_" & aWMSLayers(i)(0)).innerText
  				
  				on error resume next
  				picURL = document.all.item("imgFeature_" & aWMSLayers(i)(0)).src
  				
  				If (Err <> 0) Then
  					Err.Clear
  					xmlRec.setAttribute "PicURL", ""
  				Else
  					xmlRec.setAttribute "PicURL", picURL
  				End If
  
  				xmlDoc.documentElement.appendChild xmlRec
  
  			End If
  		End If
  	Next
  
  	document.all.xmlLegend.XMLDocument = xmlDoc*/
  }
}
//****************************************************************************

function btnUpdateMap_Click()
{
/*
 * Procedura obsluhujici udalost kliknuti na tlacitko btnUpdateMap.
 */

	if(document.getElementById("divWait").style.display == "none")
	{
		var a = MapAction;
		
		SetMapAction("reload");
		MapAction = a;
			
		document.getElementById("divWait").style.display = "";

		map_list.maps.Item(map_list.map_id).Actualize_LAYERS();
		
		/*'Click Map
		MAP_URL = document.all.ClickMapSrc.src
		MAP_URL = ReplaceLAYERS(MAP_URL, document.all.varActiveFeature.value)
		document.all.ClickMapSrc.src = MAP_URL
		*/
		//CheckAVrstva document.all.varActiveFeature.value
		//HighLightQuery()

		ViewSwitch("OknoMapa");
	}
}
//****************************************************************************

function HltBtn(BTN)
{
/*
 * Procedura, ktera zvyrazni obrazek tlacitka.
 */

    if(moz)
    {
      BTN.style.opacity = 1;
    }
    else
    {
    	BTN.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=100)";
    }

}
//****************************************************************************

function HdBtn(BTN)
{
/*
 * Procedura, ktera ztlumi obrazek tlacitka.
 */

    if(moz)
    {
      BTN.style.opacity = 0.6;
    }
    else
    {
    	BTN.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=60)";
    }

}
//****************************************************************************

function ShowMapLayers()
{
	//document.getElementById("spnMapLayersS").style.display = "none";
	document.getElementById("spnMapLayersH").style.display = "";
	document.getElementById("divMapLayers").style.display = "";
	document.getElementById("divAktivLayers").style.display = "none";
}
//****************************************************************************

function ShowAktivLayers()
{
	//document.getElementById("spnMapLayersS").style.display = "none";
	document.getElementById("spnMapLayersH").style.display = "";
	document.getElementById("divMapLayers").style.display = "none";
	document.getElementById("divAktivLayers").style.display = "";
}
//****************************************************************************

function HideMapLayers()
{
	//document.getElementById("spnMapLayersS").style.display = "";
	document.getElementById("spnMapLayersH").style.display = "none";
	document.getElementById("divMapLayers").style.display = "none";
	document.getElementById("divAktivLayers").style.display = "none";
}
//****************************************************************************

function doInit()
{
	var m_DocHeight;	//Sirka zobrazovaciho okna prohlizece
	var m_DocWidth;		//Vyska zobrazovaciho okna prohlizece
	var mWidth;			//Sirka mapy v pixelech
	var mHeight;		//Vyska mapy v pixelech

	prvnispusteni = true;
	
	//Inicializace klientske zobrazovaci casti
  m_DocHeight = document.body.offsetHeight - 5;
	m_DocWidth = document.body.offsetWidth - 20;

	if(m_DocHeight < 600)
	{
		m_DocHeight = 600;
	}
	
	if(m_DocWidth < 800)
	{
		m_DocWidth = 800;
	}

 	document.getElementById('divOknoZakladni').style.width = m_DocWidth - 1;
  document.getElementById('divOknoZakladni').style.height = m_DocHeight - parseInt(document.getElementById('divNavLista').style.height) - parseInt(document.getElementById('divZapati').style.height);
  document.getElementById('divOknoZakladni').style.top = parseInt(document.getElementById('divNavLista').style.height);
 
  document.getElementById('divNavOkno').style.height = m_DocHeight - parseInt(document.getElementById('divNavLista').style.height) - parseInt(document.getElementById('divZapati').style.height);
 
	//'document.all.divNavOkno.style.pixelTop = document.all.divNavLista.style.pixelHeight
	document.getElementById('divHlOkno').style.width = m_DocWidth - parseInt(document.getElementById('divNavOkno').style.width) - 1;
	document.getElementById('divHlOkno').style.height = m_DocHeight - parseInt(document.getElementById('divNavLista').style.height) - parseInt(document.getElementById('divZapati').style.height);
	//'document.all.divHlOkno.style.pixelTop = document.all.divNavLista.style.pixelHeight
	
	document.getElementById('divZapati').style.top = m_DocHeight - parseInt(document.getElementById('divZapati').style.height);


	document.getElementById('divMapToolbar').style.width = m_DocWidth - parseInt(document.getElementById('divNavOkno').style.width) - 1;

	document.getElementById('OknoMapa').style.width = parseInt(document.getElementById('divHlOkno').style.width);
	document.getElementById('OknoMapa').style.height = parseInt(document.getElementById('divHlOkno').style.height) - parseInt(document.getElementById('divMapToolbar').style.height);
	document.getElementById('OknoMapa').style.top = 22;

	document.getElementById('divKresleni').style.width = parseInt(document.getElementById('divHlOkno').style.width);
	document.getElementById('divKresleni').style.height = parseInt(document.getElementById('divHlOkno').style.height) - parseInt(document.getElementById('divMapToolbar').style.height);
	document.getElementById('divKresleni').style.top = 0;

	document.getElementById('divMapLayers').style.height = m_DocHeight - parseInt(document.getElementById('divNavLista').style.height) - parseInt(document.getElementById('divZapati').style.height) - parseInt(document.getElementById('divMapToolbar').style.height);
	document.getElementById('divMapLayers').style.top = parseInt(document.getElementById('divMapToolbar').style.height);
	document.getElementById('divMapLayers').style.left = m_DocWidth - parseInt(document.getElementById('divMapLayers').style.width) - parseInt(document.getElementById('divNavOkno').style.width) - 1;
	document.getElementById('pFeatures').style.height = parseInt(document.getElementById('divMapLayers').style.height) - 40;

	document.getElementById('divAktivLayers').style.height = m_DocHeight - parseInt(document.getElementById('divNavLista').style.height) - parseInt(document.getElementById('divZapati').style.height) - parseInt(document.getElementById('divMapToolbar').style.height);
	document.getElementById('divAktivLayers').style.top = parseInt(document.getElementById('divMapToolbar').style.height);
	document.getElementById('divAktivLayers').style.left = m_DocWidth - parseInt(document.getElementById('divMapLayers').style.width) - parseInt(document.getElementById('divNavOkno').style.width) - 1;
	document.getElementById('pAFeatures').style.height = parseInt(document.getElementById('divAktivLayers').style.height) - 20;

	document.getElementById('OknoVyhledat').style.width = parseInt(document.getElementById('divHlOkno').style.width);
	document.getElementById('OknoVyhledat').style.height = parseInt(document.getElementById('divHlOkno').style.height);
	document.getElementById('OknoVyhledat').style.left = parseInt(document.getElementById('divHlOkno').style.left);
	document.getElementById('OknoVyhledat').style.top = parseInt(document.getElementById('divHlOkno').style.top);

	document.getElementById('OknoFI').style.width = parseInt(document.getElementById('divHlOkno').style.width);
	document.getElementById('OknoFI').style.height = parseInt(document.getElementById('divHlOkno').style.height);
	document.getElementById('OknoFI').style.left = parseInt(document.getElementById('divHlOkno').style.left);
	document.getElementById('OknoFI').style.top = parseInt(document.getElementById('divHlOkno').style.top);

	document.getElementById('divFIBorder').style.width = m_DocWidth - parseInt(document.getElementById('divNavOkno').style.width) - 25;
	document.getElementById('divFIBorder').style.height = (m_DocHeight - parseInt(document.getElementById('divNavLista').style.height)) - 45;
	document.getElementById('divFI').style.width = m_DocWidth - parseInt(document.getElementById('divNavOkno').style.width) - 45;
	document.getElementById('divFI').style.height = (m_DocHeight - parseInt(document.getElementById('divNavLista').style.height)) - 70;
	document.getElementById('divFIPanel').style.width = m_DocWidth - parseInt(document.getElementById('divNavOkno').style.width) - 65;
	document.getElementById('divFIPanel').style.height = (m_DocHeight - parseInt(document.getElementById('divNavLista').style.height)) - 90;

	document.getElementById('OknoWMS').style.width = parseInt(document.getElementById('divHlOkno').style.width);
	document.getElementById('OknoWMS').style.height = parseInt(document.getElementById('divHlOkno').style.height);
	document.getElementById('OknoWMS').style.left = parseInt(document.getElementById('divHlOkno').style.left);
	document.getElementById('OknoWMS').style.top = parseInt(document.getElementById('divHlOkno').style.top);

	document.getElementById('divWMSBorder').style.width = m_DocWidth - parseInt(document.getElementById('divNavOkno').style.width) - 25;
	document.getElementById('divWMSBorder').style.height = (m_DocHeight - parseInt(document.getElementById('divNavLista').style.height)) - 45;
	document.getElementById('divWMS').style.width = m_DocWidth - parseInt(document.getElementById('divNavOkno').style.width) - 45;
	document.getElementById('divWMS').style.height = (m_DocHeight - parseInt(document.getElementById('divNavLista').style.height)) - 70;
	document.getElementById('divWMSPanel').style.width = m_DocWidth - parseInt(document.getElementById('divNavOkno').style.width) - 65;
	document.getElementById('divWMSPanel').style.height = (m_DocHeight - parseInt(document.getElementById('divNavLista').style.height)) - 90;

	document.getElementById('OknoWCS').style.width = parseInt(document.getElementById('divHlOkno').style.width);
	document.getElementById('OknoWCS').style.height = parseInt(document.getElementById('divHlOkno').style.height);
	document.getElementById('OknoWCS').style.left = parseInt(document.getElementById('divHlOkno').style.left);
	document.getElementById('OknoWCS').style.top = parseInt(document.getElementById('divHlOkno').style.top);

	document.getElementById('divWCSBorder').style.width = m_DocWidth - parseInt(document.getElementById('divNavOkno').style.width) - 25;
	document.getElementById('divWCSBorder').style.height = (m_DocHeight - parseInt(document.getElementById('divNavLista').style.height)) - 45;
	document.getElementById('divWCS').style.width = m_DocWidth - parseInt(document.getElementById('divNavOkno').style.width) - 45;
	document.getElementById('divWCS').style.height = (m_DocHeight - parseInt(document.getElementById('divNavLista').style.height)) - 70;
	document.getElementById('divWCSPanel').style.width = m_DocWidth - parseInt(document.getElementById('divNavOkno').style.width) - 65;
	document.getElementById('divWCSPanel').style.height = (m_DocHeight - parseInt(document.getElementById('divNavLista').style.height)) - 90;

	document.getElementById('OknoNastaveni').style.width = parseInt(document.getElementById('divHlOkno').style.width);
	document.getElementById('OknoNastaveni').style.height = parseInt(document.getElementById('divHlOkno').style.height);
	document.getElementById('OknoNastaveni').style.left = parseInt(document.getElementById('divHlOkno').style.left);
	document.getElementById('OknoNastaveni').style.top = parseInt(document.getElementById('divHlOkno').style.top);

	document.getElementById('OknoNapoveda').style.width = parseInt(document.getElementById('divHlOkno').style.width);
	document.getElementById('OknoNapoveda').style.height = parseInt(document.getElementById('divHlOkno').style.height);
	document.getElementById('OknoNapoveda').style.left = parseInt(document.getElementById('divHlOkno').style.left);
	document.getElementById('OknoNapoveda').style.top = parseInt(document.getElementById('divHlOkno').style.top);
	document.getElementById('divNapoveda').style.width = m_DocWidth - parseInt(document.getElementById('divNavOkno').style.width) - 20;
	document.getElementById('divNapoveda').style.height = m_DocHeight - parseInt(document.getElementById('divNavLista').style.height) - 45;

	//panel zalozky Vyhledat
	document.getElementById('divQueryList').style.width = m_DocWidth - parseInt(document.getElementById('divNavOkno').style.width) - 25;
	document.getElementById('divQueryList').style.height = (m_DocHeight - parseInt(document.getElementById('divNavLista').style.height)) / 2 - 40;
	document.getElementById('QueryList').style.width = m_DocWidth - parseInt(document.getElementById('divNavOkno').style.width) - 45;
	document.getElementById('QueryList').style.height = (m_DocHeight - parseInt(document.getElementById('divNavLista').style.height)) / 2 - 70;
	document.getElementById('pQueryList').style.width = m_DocWidth - parseInt(document.getElementById('divNavOkno').style.width) - 65;
	document.getElementById('pQueryList').style.height = (m_DocHeight - parseInt(document.getElementById('divNavLista').style.height)) / 2 - 90;

	document.getElementById('divQueryResult').style.width = m_DocWidth - parseInt(document.getElementById('divNavOkno').style.width) - 25;
	document.getElementById('divQueryResult').style.height = (m_DocHeight - parseInt(document.getElementById('divNavLista').style.height)) / 2 - 10;
	document.getElementById('QueryResult').style.width = m_DocWidth - parseInt(document.getElementById('divNavOkno').style.width) - 45;
	document.getElementById('QueryResult').style.height = (m_DocHeight - parseInt(document.getElementById('divNavLista').style.height)) / 2 - 35;
	document.getElementById('pQueryResult').style.width = m_DocWidth - parseInt(document.getElementById('divNavOkno').style.width) - 65;
	document.getElementById('pQueryResult').style.height = (m_DocHeight - parseInt(document.getElementById('divNavLista').style.height)) / 2 - 55;
	document.getElementById('divQueryResult').style.top = (m_DocHeight / 2) - 35;
	
	//tlacitka posuvu po mape
	document.getElementById('PanN').style.left = (m_DocWidth - parseInt(document.getElementById('divNavOkno').style.width) - 5) / 2;
	document.getElementById('PanN').style.top = parseInt(document.getElementById('divMapToolbar').style.height) + 2;
	document.getElementById('PanS').style.left = (m_DocWidth - parseInt(document.getElementById('divNavOkno').style.width) - 5) / 2;
	document.getElementById('PanS').style.top = m_DocHeight - parseInt(document.getElementById('divNavLista').style.height) - 40;
	document.getElementById('PanW').style.top = (m_DocHeight - parseInt(document.getElementById('divNavLista').style.height) - 5) / 2;
	document.getElementById('PanE').style.top = (m_DocHeight - parseInt(document.getElementById('divNavLista').style.height) - 5) / 2;
	document.getElementById('PanE').style.left = m_DocWidth - parseInt(document.getElementById('divNavOkno').style.width) - 20;
	document.getElementById('PanNE').style.left = m_DocWidth - parseInt(document.getElementById('divNavOkno').style.width) - 20;
	document.getElementById('PanNE').style.top = parseInt(document.getElementById('divMapToolbar').style.height) + 2;
	document.getElementById('PanNW').style.top = parseInt(document.getElementById('divMapToolbar').style.height) + 2;
	document.getElementById('PanSW').style.top = m_DocHeight - parseInt(document.getElementById('divNavLista').style.height) - 40;
	document.getElementById('PanSE').style.left = m_DocWidth - parseInt(document.getElementById('divNavOkno').style.width) - 20;
	document.getElementById('PanSE').style.top = m_DocHeight - parseInt(document.getElementById('divNavLista').style.height) - 40;

/*	document.getElementById('divWait').style.left = (m_DocWidth/2) - 60;
	document.getElementById('divWait').style.top = (m_DocHeight/2) - 20;		*/

	cmbQColor_Change();
	cmbQBackgroundColor_Change();
	
	btnActual = null;
		
	btnZoomArea_Click();

  document.getElementById("divWait").style.display = "";
	
	app_initialize(parseInt(document.getElementById('OknoMapa').style.width), parseInt(document.getElementById('OknoMapa').style.height));

	document.getElementById('tblHlaskaUvod').style.visibility = "hidden";

	document.getElementById('divNavOkno').style.visibility = "visible";
	document.getElementById('divHlOkno').style.visibility = "visible";
	document.getElementById('divZapati').style.visibility = "visible";
  
  ViewSwitch("OknoMapa");
  	
}
//****************************************************************************

function btnFitApp_Click()
{
	var m_DocHeight;	//Sirka zobrazovaciho okna prohlizece
	var m_DocWidth;		//Vyska zobrazovaciho okna prohlizece
	var mWidth;			//Sirka mapy v pixelech
	var mHeight;		//Vyska mapy v pixelech

	//Inicializace klientske zobrazovaci casti
  m_DocHeight = document.body.offsetHeight - 5;
	m_DocWidth = document.body.offsetWidth - 20;
  	
	if(m_DocHeight < 600)
	{
		m_DocHeight = 600;
	}
	
	if(m_DocWidth < 800)
	{
		m_DocWidth = 800;
	}

 	document.getElementById('divOknoZakladni').style.width = m_DocWidth - 1;
  document.getElementById('divOknoZakladni').style.height = m_DocHeight - parseInt(document.getElementById('divNavLista').style.height) - parseInt(document.getElementById('divZapati').style.height);
  document.getElementById('divOknoZakladni').style.top = parseInt(document.getElementById('divNavLista').style.height);
 
  document.getElementById('divNavOkno').style.height = m_DocHeight - parseInt(document.getElementById('divNavLista').style.height) - parseInt(document.getElementById('divZapati').style.height);
 
	//'document.all.divNavOkno.style.pixelTop = document.all.divNavLista.style.pixelHeight
	document.getElementById('divHlOkno').style.width = m_DocWidth - parseInt(document.getElementById('divNavOkno').style.width) - 1;
	document.getElementById('divHlOkno').style.height = m_DocHeight - parseInt(document.getElementById('divNavLista').style.height) - parseInt(document.getElementById('divZapati').style.height);
	//'document.all.divHlOkno.style.pixelTop = document.all.divNavLista.style.pixelHeight
	
	document.getElementById('divZapati').style.top = m_DocHeight - parseInt(document.getElementById('divZapati').style.height);


	document.getElementById('divMapToolbar').style.width = m_DocWidth - parseInt(document.getElementById('divNavOkno').style.width) - 1;

	document.getElementById('OknoMapa').style.width = parseInt(document.getElementById('divHlOkno').style.width);
	document.getElementById('OknoMapa').style.height = parseInt(document.getElementById('divHlOkno').style.height) - parseInt(document.getElementById('divMapToolbar').style.height);
	document.getElementById('OknoMapa').style.top = 22;

	document.getElementById('divKresleni').style.width = parseInt(document.getElementById('divHlOkno').style.width);
	document.getElementById('divKresleni').style.height = parseInt(document.getElementById('divHlOkno').style.height) - parseInt(document.getElementById('divMapToolbar').style.height);
	document.getElementById('divKresleni').style.top = 0;

	document.getElementById('divMapLayers').style.height = m_DocHeight - parseInt(document.getElementById('divNavLista').style.height) - parseInt(document.getElementById('divZapati').style.height) - parseInt(document.getElementById('divMapToolbar').style.height);
	document.getElementById('divMapLayers').style.top = parseInt(document.getElementById('divMapToolbar').style.height);
	document.getElementById('divMapLayers').style.left = m_DocWidth - parseInt(document.getElementById('divMapLayers').style.width) - parseInt(document.getElementById('divNavOkno').style.width) - 1;
	document.getElementById('pFeatures').style.height = parseInt(document.getElementById('divMapLayers').style.height) - 40;

	document.getElementById('divAktivLayers').style.height = m_DocHeight - parseInt(document.getElementById('divNavLista').style.height) - parseInt(document.getElementById('divZapati').style.height) - parseInt(document.getElementById('divMapToolbar').style.height);
	document.getElementById('divAktivLayers').style.top = parseInt(document.getElementById('divMapToolbar').style.height);
	document.getElementById('divAktivLayers').style.left = m_DocWidth - parseInt(document.getElementById('divMapLayers').style.width) - parseInt(document.getElementById('divNavOkno').style.width) - 1;
	document.getElementById('pAFeatures').style.height = parseInt(document.getElementById('divAktivLayers').style.height) - 20;

	document.getElementById('OknoVyhledat').style.width = parseInt(document.getElementById('divHlOkno').style.width);
	document.getElementById('OknoVyhledat').style.height = parseInt(document.getElementById('divHlOkno').style.height);
	document.getElementById('OknoVyhledat').style.left = parseInt(document.getElementById('divHlOkno').style.left);
	document.getElementById('OknoVyhledat').style.top = parseInt(document.getElementById('divHlOkno').style.top);

	document.getElementById('OknoFI').style.width = parseInt(document.getElementById('divHlOkno').style.width);
	document.getElementById('OknoFI').style.height = parseInt(document.getElementById('divHlOkno').style.height);
	document.getElementById('OknoFI').style.left = parseInt(document.getElementById('divHlOkno').style.left);
	document.getElementById('OknoFI').style.top = parseInt(document.getElementById('divHlOkno').style.top);

	document.getElementById('divFIBorder').style.width = m_DocWidth - parseInt(document.getElementById('divNavOkno').style.width) - 25;
	document.getElementById('divFIBorder').style.height = (m_DocHeight - parseInt(document.getElementById('divNavLista').style.height)) - 45;
	document.getElementById('divFI').style.width = m_DocWidth - parseInt(document.getElementById('divNavOkno').style.width) - 45;
	document.getElementById('divFI').style.height = (m_DocHeight - parseInt(document.getElementById('divNavLista').style.height)) - 70;
	document.getElementById('divFIPanel').style.width = m_DocWidth - parseInt(document.getElementById('divNavOkno').style.width) - 65;
	document.getElementById('divFIPanel').style.height = (m_DocHeight - parseInt(document.getElementById('divNavLista').style.height)) - 90;

	document.getElementById('OknoWMS').style.width = parseInt(document.getElementById('divHlOkno').style.width);
	document.getElementById('OknoWMS').style.height = parseInt(document.getElementById('divHlOkno').style.height);
	document.getElementById('OknoWMS').style.left = parseInt(document.getElementById('divHlOkno').style.left);
	document.getElementById('OknoWMS').style.top = parseInt(document.getElementById('divHlOkno').style.top);

	document.getElementById('divWMSBorder').style.width = m_DocWidth - parseInt(document.getElementById('divNavOkno').style.width) - 25;
	document.getElementById('divWMSBorder').style.height = (m_DocHeight - parseInt(document.getElementById('divNavLista').style.height)) - 45;
	document.getElementById('divWMS').style.width = m_DocWidth - parseInt(document.getElementById('divNavOkno').style.width) - 45;
	document.getElementById('divWMS').style.height = (m_DocHeight - parseInt(document.getElementById('divNavLista').style.height)) - 70;
	document.getElementById('divWMSPanel').style.width = m_DocWidth - parseInt(document.getElementById('divNavOkno').style.width) - 65;
	document.getElementById('divWMSPanel').style.height = (m_DocHeight - parseInt(document.getElementById('divNavLista').style.height)) - 90;

	document.getElementById('OknoNastaveni').style.width = parseInt(document.getElementById('divHlOkno').style.width);
	document.getElementById('OknoNastaveni').style.height = parseInt(document.getElementById('divHlOkno').style.height);
	document.getElementById('OknoNastaveni').style.left = parseInt(document.getElementById('divHlOkno').style.left);
	document.getElementById('OknoNastaveni').style.top = parseInt(document.getElementById('divHlOkno').style.top);

	document.getElementById('OknoNapoveda').style.width = parseInt(document.getElementById('divHlOkno').style.width);
	document.getElementById('OknoNapoveda').style.height = parseInt(document.getElementById('divHlOkno').style.height);
	document.getElementById('OknoNapoveda').style.left = parseInt(document.getElementById('divHlOkno').style.left);
	document.getElementById('OknoNapoveda').style.top = parseInt(document.getElementById('divHlOkno').style.top);
	document.getElementById('divNapoveda').style.width = m_DocWidth - parseInt(document.getElementById('divNavOkno').style.width) - 20;
	document.getElementById('divNapoveda').style.height = m_DocHeight - parseInt(document.getElementById('divNavLista').style.height) - 45;

	//panel zalozky Vyhledat
	document.getElementById('divQueryList').style.width = m_DocWidth - parseInt(document.getElementById('divNavOkno').style.width) - 25;
	document.getElementById('divQueryList').style.height = (m_DocHeight - parseInt(document.getElementById('divNavLista').style.height)) / 2 - 40;
	document.getElementById('QueryList').style.width = m_DocWidth - parseInt(document.getElementById('divNavOkno').style.width) - 45;
	document.getElementById('QueryList').style.height = (m_DocHeight - parseInt(document.getElementById('divNavLista').style.height)) / 2 - 70;
	document.getElementById('pQueryList').style.width = m_DocWidth - parseInt(document.getElementById('divNavOkno').style.width) - 65;
	document.getElementById('pQueryList').style.height = (m_DocHeight - parseInt(document.getElementById('divNavLista').style.height)) / 2 - 90;

	document.getElementById('divQueryResult').style.width = m_DocWidth - parseInt(document.getElementById('divNavOkno').style.width) - 25;
	document.getElementById('divQueryResult').style.height = (m_DocHeight - parseInt(document.getElementById('divNavLista').style.height)) / 2 - 10;
	document.getElementById('QueryResult').style.width = m_DocWidth - parseInt(document.getElementById('divNavOkno').style.width) - 45;
	document.getElementById('QueryResult').style.height = (m_DocHeight - parseInt(document.getElementById('divNavLista').style.height)) / 2 - 35;
	document.getElementById('pQueryResult').style.width = m_DocWidth - parseInt(document.getElementById('divNavOkno').style.width) - 65;
	document.getElementById('pQueryResult').style.height = (m_DocHeight - parseInt(document.getElementById('divNavLista').style.height)) / 2 - 55;
	document.getElementById('divQueryResult').style.top = (m_DocHeight / 2) - 65;
	
	//document.getElementById('divNavOkno').style.visibility = "visible";
	//document.getElementById('divHlOkno').style.visibility = "visible";
	//document.getElementById('divZapati').style.visibility = "visible";
	
	//tlacitka posuvu po mape
	document.getElementById('PanN').style.left = (m_DocWidth - parseInt(document.getElementById('divNavOkno').style.width) - 5) / 2;
	document.getElementById('PanN').style.top = parseInt(document.getElementById('divMapToolbar').style.height) + 2;
	document.getElementById('PanS').style.left = (m_DocWidth - parseInt(document.getElementById('divNavOkno').style.width) - 5) / 2;
	document.getElementById('PanS').style.top = m_DocHeight - parseInt(document.getElementById('divNavLista').style.height) - 40;
	document.getElementById('PanW').style.top = (m_DocHeight - parseInt(document.getElementById('divNavLista').style.height) - 5) / 2;
	document.getElementById('PanE').style.top = (m_DocHeight - parseInt(document.getElementById('divNavLista').style.height) - 5) / 2;
	document.getElementById('PanE').style.left = m_DocWidth - parseInt(document.getElementById('divNavOkno').style.width) - 20;
	document.getElementById('PanNE').style.left = m_DocWidth - parseInt(document.getElementById('divNavOkno').style.width) - 20;
	document.getElementById('PanNE').style.top = parseInt(document.getElementById('divMapToolbar').style.height) + 2;
	document.getElementById('PanNW').style.top = parseInt(document.getElementById('divMapToolbar').style.height) + 2;
	document.getElementById('PanSW').style.top = m_DocHeight - parseInt(document.getElementById('divNavLista').style.height) - 40;
	document.getElementById('PanSE').style.left = m_DocWidth - parseInt(document.getElementById('divNavOkno').style.width) - 20;
	document.getElementById('PanSE').style.top = m_DocHeight - parseInt(document.getElementById('divNavLista').style.height) - 40;

	document.getElementById('divWait').style.left = (m_DocWidth/2) - 60;
	document.getElementById('divWait').style.top = (m_DocHeight/2) - 20;		

  //aktualizace mapoveho okna
  map_list.maps.Item(map_list.map_id).Actualize_DIMENSIONS(parseInt(document.getElementById('OknoMapa').style.width), parseInt(document.getElementById('OknoMapa').style.height));
  
	//cmbQColor_Change();
	//cmbQBackgroundColor_Change();
	
  //document.getElementById("divWait").style.display = "";
	
	//app_initialize(parseInt(document.getElementById('OknoMapa').style.width), parseInt(document.getElementById('OknoMapa').style.height));
}
//****************************************************************************

function cmbQColor_Change()
{
/*
 * Procedura obsluhujici udalost zmeny hodnoty na objektu cmbQColor.
 */
	
	document.getElementById("QColorPan").style.backgroundColor = document.getElementById("cmbQColor").options[document.getElementById("cmbQColor").selectedIndex].value;
	
}
//****************************************************************************

function cmbQBackgroundColor_Change()
{
/*
 * Procedura obsluhujici udalost zmeny hodnoty na objektu cmbQBackgroundColor.
 */
	
	document.getElementById("QBgColorPan").style.backgroundColor = document.getElementById("cmbQBackgroundColor").options[document.getElementById("cmbQBackgroundColor").selectedIndex].value;
	
}
//****************************************************************************

//DOTAZY

function CallGetQueries(tema)
{
  var xmlNodes;

  var moz = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined');
  var ie = (typeof window.ActiveXObject != 'undefined'); 

  if(moz)
  {
  	if (tema == "")
  	{
      var xsltProcessor = new XSLTProcessor();
      xsltProcessor.importStylesheet(get_o_queries_xslt);
      var fragment = xsltProcessor.transformToFragment(xmlQueries, document);
      document.getElementById("pQueryList").innerHTML = "";
      document.getElementById("pQueryList").appendChild(fragment);
  	}
    else
  	{
      xmlNodes = xmlQueries.evaluate("REPORT/TEMA", xmlQueries, null, 7, null);
  	
      if(xmlNodes.snapshotLength > 0)
  		{
  			for(var i = 0; i < xmlNodes.snapshotLength; i++)
  			{
  				if (tema == xmlNodes.snapshotItem(i).getAttribute("Title"))
  				{

            var s = new XMLSerializer();
            var parser = new DOMParser(); 
            var xsltProcessor = new XSLTProcessor();

            var xmlPart = parser.parseFromString(s.serializeToString(xmlNodes.snapshotItem(i)), "text/xml"); 
            xsltProcessor.importStylesheet(get_t_queries_xslt);
            var fragment = xsltProcessor.transformToFragment(xmlPart, document);
            document.getElementById("pQueryList").innerHTML = "";
            document.getElementById("pQueryList").appendChild(fragment);
  					break;
  				}
  			}
  		}
  	}
  }
  else
  {
  	if (tema == "")
  	{
      document.getElementById("pQueryList").innerHTML = xmlQueries.transformNode(get_o_queries_xslt);
  	}
    else
  	{
  		xmlNodes = xmlQueries.selectNodes("REPORT/TEMA");
  	
  		if (xmlNodes.length > 0)
  		{
  			for(var i = 0; i < xmlNodes.length; i++)
  			{
  				if (tema == xmlNodes.item(i).getAttribute("Title"))
  				{
            var xmlPart = new ActiveXObject("Microsoft.XMLDOM"); 
            xmlPart.async = false; 
      			xmlPart.validateOnParse = false;
  					xmlPart.loadXML(xmlNodes.item(i).xml);
  					document.getElementById("pQueryList").innerHTML = xmlPart.transformNode(get_t_queries_xslt);
  					break;
  				}
  			}
  		}
  	}
  }
}
//****************************************************************************

function CallGetQueriesIQS(tema)
{
  var xmlNodes;

  var moz = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined');
  var ie = (typeof window.ActiveXObject != 'undefined'); 

  if(moz)
  {
    var xpe = new XPathEvaluator();
    var nsResolver = xpe.createNSResolver(xmlQueries.ownerDocument == null ? xmlQueries.documentElement : xmlQueries.ownerDocument.documentElement);

  	if (tema == "")
  	{
      var xsltProcessor = new XSLTProcessor();
      xsltProcessor.importStylesheet(get_o_queries_xslt);
      var fragment = xsltProcessor.transformToFragment(xmlQueries, document);
      document.getElementById("pQueryList").innerHTML = "";
      document.getElementById("pQueryList").appendChild(fragment);
  	}
    else
  	{
      xmlNodes = xmlQueries.evaluate("ingr:Queries_Capabilities/ingr:QueryList/ingr:QueryGroup", xmlQueries, nsResolver, 7, null);
  	
      if(xmlNodes.snapshotLength > 0)
  		{
  			for(var i = 0; i < xmlNodes.snapshotLength; i++)
  			{
  				if (tema == xmlNodes.snapshotItem(i).getAttribute("id"))
  				{

            var s = new XMLSerializer();
            var parser = new DOMParser(); 
            var xsltProcessor = new XSLTProcessor();

            var xmlPart = parser.parseFromString(s.serializeToString(xmlNodes.snapshotItem(i)), "text/xml"); 
            xsltProcessor.importStylesheet(get_t_queries_xslt);
            var fragment = xsltProcessor.transformToFragment(xmlPart, document);
            document.getElementById("pQueryList").innerHTML = "";
            document.getElementById("pQueryList").appendChild(fragment);
  					break;
  				}
  			}
  		}
  	}
  }
  else
  {
  	if (tema == "")
  	{
      document.getElementById("pQueryList").innerHTML = xmlQueries.transformNode(get_o_queries_xslt);
  	}
    else
  	{
  		xmlNodes = xmlQueries.selectNodes("ingr:Queries_Capabilities/ingr:QueryList/ingr:QueryGroup");
  	
  		if (xmlNodes.length > 0)
  		{
  			for(var i = 0; i < xmlNodes.length; i++)
  			{
  				if (tema == xmlNodes.item(i).getAttribute("id"))
  				{
            var xmlPart = new ActiveXObject("Microsoft.XMLDOM"); 
            xmlPart.async = false; 
      			xmlPart.validateOnParse = false;
  					xmlPart.loadXML(xmlNodes.item(i).xml);
  					document.getElementById("pQueryList").innerHTML = xmlPart.transformNode(get_t_queries_xslt);
  					break;
  				}
  			}
  		}
  	}
  }
}
//****************************************************************************

function SetQueriesSource()
{
/*
 * Procedura realizujici XML transformaci dostupnych dotazu tematicke mapy, ktere
 * jsou vraceny ze strany serveru jako odpoved na pozadavek klienta.
 */

	var sHTML, tema, tema_id, xmlNodes;
		
  var moz = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined');
  var ie = (typeof window.ActiveXObject != 'undefined'); 

  if(moz)
  {
    var xmlNodes = xmlQueries.evaluate("REPORT/TEMA", xmlQueries, null, 7, null);
  	
    if(xmlNodes.snapshotLength > 0)
  	{
      sHTML = "<table id='tblTemas' width='100%' border='0' cellspacing='0' cellpadding='2' style='font-family:Verdana,Arial;font-size:12px;border-right: 1px solid black; border-bottom:1px solid black; BACKGROUND-COLOR:#ffffff;'>";
  		
      for(var i = 0; i <  xmlNodes.snapshotLength; i++)
      {
  			tema = xmlNodes.snapshotItem(i).getAttribute("Title");
  			sHTML = sHTML + "<tr onclick='CallGetQueries(" + String.fromCharCode(34) + tema + String.fromCharCode(34) + ")' title='" + script_messages[29] + "' style='cursor:pointer;' onmouseOver='this.style.backgroundColor = " + String.fromCharCode(34) + "#24BAFF" + String.fromCharCode(34) + ";this.style.borderTop = " + String.fromCharCode(34) + "1px solid" + String.fromCharCode(34) + ";this.style.borderBottom = " + String.fromCharCode(34) + "1px solid" + String.fromCharCode(34) + "' onmouseOut='this.style.backgroundColor = " + String.fromCharCode(34) + String.fromCharCode(34) + ";this.style.borderTop = " + String.fromCharCode(34) + String.fromCharCode(34) + ";this.style.borderBottom = " + String.fromCharCode(34) + String.fromCharCode(34) + "'>";
  			sHTML = sHTML + "<td width='100%' style='border:1px solid black;border-right: 0px; border-bottom:0px;'><b>" + tema + "</b></td>";
  			sHTML = sHTML + "<td align='right' style='border:1px solid black;border-right: 0px; border-bottom:0px;'><font style='color:blue'><b>&gt;&gt;&gt;</b></font></td>";
  							
  			sHTML = sHTML + "</tr>"
  		}
  		
  		xmlNodes = xmlQueries.evaluate("REPORT/REC", xmlQueries, null, 7, null);
  		
      if (xmlNodes.snapshotLength > 0)
      {
  			sHTML = sHTML + "<tr onclick='CallGetQueries(" + String.fromCharCode(34) + String.fromCharCode(34) + ")' title='" + script_messages[29] + "' style='cursor:pointer;' onmouseOver='this.style.backgroundColor = " + String.fromCharCode(34) + "#24BAFF" + String.fromCharCode(34) + ";this.style.borderTop = " + String.fromCharCode(34) + "1px solid" + String.fromCharCode(34) + ";this.style.borderBottom = " + String.fromCharCode(34) + "1px solid" + String.fromCharCode(34) + "' onmouseOut='this.style.backgroundColor = " + String.fromCharCode(34) + String.fromCharCode(34) + ";this.style.borderTop = " + String.fromCharCode(34) + String.fromCharCode(34) + ";this.style.borderBottom = " + String.fromCharCode(34) + String.fromCharCode(34) + "'>";
        sHTML = sHTML + "<td width='100%' style='border:1px solid black;border-right: 0px; border-bottom:0px;'><b>OSTATNÍ</b></td>";
  			sHTML = sHTML + "<td align='right' style='border:1px solid black;border-right: 0px; border-bottom:0px;'><font style='color:blue'><b>&gt;&gt;&gt;</b></font></td>";
  								
  			sHTML = sHTML + "</tr>";
  		}
  		sHTML = sHTML + "</table>";
      document.getElementById("pQueryList").innerHTML = sHTML;
    }
    else
    {
      //nacti sablonu a proved transformaci
      var xsltProcessor = new XSLTProcessor();
      xsltProcessor.importStylesheet(get_queries_xslt);
      var fragment = xsltProcessor.transformToFragment(xmlQueries, document);
      document.getElementById("pQueryList").innerHTML = "";
      document.getElementById("pQueryList").appendChild(fragment);
    }
  }
  else
  {
    xmlNodes = xmlQueries.selectNodes("REPORT/TEMA");
  	
  	if (xmlNodes.length > 0)
  	{
  
      sHTML = "<table id='tblTemas' width='100%' border='0' cellspacing='0' cellpadding='2' style='font-family:Verdana,Arial;font-size:12px;border-right: 1px solid black; border-bottom:1px solid black; BACKGROUND-COLOR:#ffffff;'>";
  		
      for(var i = 0; i <  xmlNodes.length; i++)
      {
  			tema = xmlNodes.item(i).getAttribute("Title");
  			sHTML = sHTML + "<tr onclick='CallGetQueries(" + String.fromCharCode(34) + tema + String.fromCharCode(34) + ")' title='" + script_messages[29] + "' style='cursor:hand;' onmouseOver='this.style.backgroundColor = " + String.fromCharCode(34) + "#24BAFF" + String.fromCharCode(34) + ";this.style.borderTop = " + String.fromCharCode(34) + "1px solid" + String.fromCharCode(34) + ";this.style.borderBottom = " + String.fromCharCode(34) + "1px solid" + String.fromCharCode(34) + "' onmouseOut='this.style.backgroundColor = " + String.fromCharCode(34) + String.fromCharCode(34) + ";this.style.borderTop = " + String.fromCharCode(34) + String.fromCharCode(34) + ";this.style.borderBottom = " + String.fromCharCode(34) + String.fromCharCode(34) + "'>";
  			sHTML = sHTML + "<td width='100%' style='border:1px solid black;border-right: 0px; border-bottom:0px;'><b>" + tema + "</b></td>";
  			sHTML = sHTML + "<td align='right' style='border:1px solid black;border-right: 0px; border-bottom:0px;'><font style='color:blue'><b>&gt;&gt;&gt;</b></font></td>";
  							
  			sHTML = sHTML + "</tr>"
  		}
  		
  		xmlNodes = xmlQueries.selectNodes("REPORT/REC");
  		
      if (xmlNodes.length > 0)
      {
  			sHTML = sHTML + "<tr onclick='CallGetQueries(" + String.fromCharCode(34) + String.fromCharCode(34) + ")' title='" + script_messages[29] + "' style='cursor:hand;' onmouseOver='this.style.backgroundColor = " + String.fromCharCode(34) + "#24BAFF" + String.fromCharCode(34) + ";this.style.borderTop = " + String.fromCharCode(34) + "1px solid" + String.fromCharCode(34) + ";this.style.borderBottom = " + String.fromCharCode(34) + "1px solid" + String.fromCharCode(34) + "' onmouseOut='this.style.backgroundColor = " + String.fromCharCode(34) + String.fromCharCode(34) + ";this.style.borderTop = " + String.fromCharCode(34) + String.fromCharCode(34) + ";this.style.borderBottom = " + String.fromCharCode(34) + String.fromCharCode(34) + "'>";
        sHTML = sHTML + "<td width='100%' style='border:1px solid black;border-right: 0px; border-bottom:0px;'><b>OSTATNÍ</b></td>";
  			sHTML = sHTML + "<td align='right' style='border:1px solid black;border-right: 0px; border-bottom:0px;'><font style='color:blue'><b>&gt;&gt;&gt;</b></font></td>";
  								
  			sHTML = sHTML + "</tr>";
  		}
  		sHTML = sHTML + "</table>";
      document.getElementById("pQueryList").innerHTML = sHTML;
  	}
  	else
  	{
      
  		document.getElementById("pQueryList").innerHTML = xmlQueries.transformNode(get_queries_xslt);
  	}
  }	
} 
//****************************************************************************

function SetQueriesSourceIQS()
{
/*
 * Procedura realizujici XML transformaci dostupnych dotazu tematicke mapy, ktere
 * jsou vraceny ze strany serveru jako odpoved na pozadavek klienta.
 */

	var sHTML, tema, tema_id, xmlNodes;
		
  var moz = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined');
  var ie = (typeof window.ActiveXObject != 'undefined'); 

  if(moz)
  {
    var xpe = new XPathEvaluator();
    var nsResolver = xpe.createNSResolver(xmlQueries.ownerDocument == null ? xmlQueries.documentElement : xmlQueries.ownerDocument.documentElement);
    
    var xmlNodes = xmlQueries.evaluate("ingr:Queries_Capabilities/ingr:QueryList/ingr:QueryGroup", xmlQueries, nsResolver, 7, null);
  	
    if(xmlNodes.snapshotLength > 0)
  	{
      sHTML = "<table id='tblTemas' width='100%' border='0' cellspacing='0' cellpadding='2' style='font-family:Verdana,Arial;font-size:12px;border-right: 1px solid black; border-bottom:1px solid black; BACKGROUND-COLOR:#ffffff;'>";
  		
      for(var i = 0; i < xmlNodes.snapshotLength; i++)
      {
  			tema = xmlNodes.snapshotItem(i).getAttribute("name");
  			tema_id = xmlNodes.snapshotItem(i).getAttribute("id");
  			sHTML = sHTML + "<tr onclick='CallGetQueriesIQS(" + String.fromCharCode(34) + tema_id + String.fromCharCode(34) + ")' title='" + script_messages[29] + "' style='cursor:hand;' onmouseOver='this.style.backgroundColor = " + String.fromCharCode(34) + "#24BAFF" + String.fromCharCode(34) + ";this.style.borderTop = " + String.fromCharCode(34) + "1px solid" + String.fromCharCode(34) + ";this.style.borderBottom = " + String.fromCharCode(34) + "1px solid" + String.fromCharCode(34) + "' onmouseOut='this.style.backgroundColor = " + String.fromCharCode(34) + String.fromCharCode(34) + ";this.style.borderTop = " + String.fromCharCode(34) + String.fromCharCode(34) + ";this.style.borderBottom = " + String.fromCharCode(34) + String.fromCharCode(34) + "'>";
  			sHTML = sHTML + "<td width='100%' style='border:1px solid black;border-right: 0px; border-bottom:0px;'><b>" + tema + "</b></td>";
  			sHTML = sHTML + "<td align='right' style='border:1px solid black;border-right: 0px; border-bottom:0px;'><font style='color:blue'><b>&gt;&gt;&gt;</b></font></td>";
  							
  			sHTML = sHTML + "</tr>"
  		}
  		
  		sHTML = sHTML + "</table>";
      document.getElementById("pQueryList").innerHTML = sHTML;
    }
    else
    {
      //nacti sablonu a proved transformaci
      var xsltProcessor = new XSLTProcessor();
      xsltProcessor.importStylesheet(get_queries_xslt);
      var fragment = xsltProcessor.transformToFragment(xmlQueries, document);
      document.getElementById("pQueryList").innerHTML = "";
      document.getElementById("pQueryList").appendChild(fragment);
    }
  }
  else
  {
    xmlNodes = xmlQueries.selectNodes("ingr:Queries_Capabilities/ingr:QueryList/ingr:QueryGroup");
  	
  	if (xmlNodes.length > 0)
  	{
  
      sHTML = "<table id='tblTemas' width='100%' border='0' cellspacing='0' cellpadding='2' style='font-family:Verdana,Arial;font-size:12px;border-right: 1px solid black; border-bottom:1px solid black; BACKGROUND-COLOR:#ffffff;'>";
  		
      for(var i = 0; i <  xmlNodes.length; i++)
      {
  			tema = xmlNodes.item(i).getAttribute("name");
  			tema_id = xmlNodes.item(i).getAttribute("id");
  			sHTML = sHTML + "<tr onclick='CallGetQueriesIQS(" + String.fromCharCode(34) + tema_id + String.fromCharCode(34) + ")' title='" + script_messages[29] + "' style='cursor:hand;' onmouseOver='this.style.backgroundColor = " + String.fromCharCode(34) + "#24BAFF" + String.fromCharCode(34) + ";this.style.borderTop = " + String.fromCharCode(34) + "1px solid" + String.fromCharCode(34) + ";this.style.borderBottom = " + String.fromCharCode(34) + "1px solid" + String.fromCharCode(34) + "' onmouseOut='this.style.backgroundColor = " + String.fromCharCode(34) + String.fromCharCode(34) + ";this.style.borderTop = " + String.fromCharCode(34) + String.fromCharCode(34) + ";this.style.borderBottom = " + String.fromCharCode(34) + String.fromCharCode(34) + "'>";
  			sHTML = sHTML + "<td width='100%' style='border:1px solid black;border-right: 0px; border-bottom:0px;'><b>" + tema + "</b></td>";
  			sHTML = sHTML + "<td align='right' style='border:1px solid black;border-right: 0px; border-bottom:0px;'><font style='color:blue'><b>&gt;&gt;&gt;</b></font></td>";
  							
  			sHTML = sHTML + "</tr>"
  		}
  		
  		/*xmlNodes = xmlQueries.selectNodes("REPORT/REC");
  		
      if (xmlNodes.length > 0)
      {
  			sHTML = sHTML + "<tr onclick='CallGetQueries(" + String.fromCharCode(34) + String.fromCharCode(34) + ")' title='" + script_messages[29] + "' style='cursor:hand;' onmouseOver='this.style.backgroundColor = " + String.fromCharCode(34) + "#24BAFF" + String.fromCharCode(34) + ";this.style.borderTop = " + String.fromCharCode(34) + "1px solid" + String.fromCharCode(34) + ";this.style.borderBottom = " + String.fromCharCode(34) + "1px solid" + String.fromCharCode(34) + "' onmouseOut='this.style.backgroundColor = " + String.fromCharCode(34) + String.fromCharCode(34) + ";this.style.borderTop = " + String.fromCharCode(34) + String.fromCharCode(34) + ";this.style.borderBottom = " + String.fromCharCode(34) + String.fromCharCode(34) + "'>";
        sHTML = sHTML + "<td width='100%' style='border:1px solid black;border-right: 0px; border-bottom:0px;'><b>OSTATNÍ</b></td>";
  			sHTML = sHTML + "<td align='right' style='border:1px solid black;border-right: 0px; border-bottom:0px;'><font style='color:blue'><b>&gt;&gt;&gt;</b></font></td>";
  								
  			sHTML = sHTML + "</tr>";
  		}*/
  		sHTML = sHTML + "</table>";
      document.getElementById("pQueryList").innerHTML = sHTML;
  	}
  	else
  	{
      
  		document.getElementById("pQueryList").innerHTML = xmlQueries.transformNode(get_queries_xslt);
  	}
  }	
} 
//****************************************************************************

function CallGetQueryParam(query)
{
/* 
 * Procedura realizujici pozadavek klienta na vraceni parametru zvoleneho dotazu.
 */
	var re = /[?]/i;
	var xml_req = "";
	if(map_list.maps.Item(map_list.map_id).query_url.search(re) != -1)
	{
    //sloz XML request
    
    xml_req = this.map_list.maps.Item(map_list.map_id).query_url + "&";
        
	}
	else
	{
      //sloz XML request
    xml_req = this.map_list.maps.Item(map_list.map_id).query_url + "?";
	}

  xmlParam = AJAX(xml_req + "REQUEST=getqueryparam" + "&QUERYINDEX=" + query.id, false);
	
  var moz = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined');
  var ie = (typeof window.ActiveXObject != 'undefined'); 

  if(moz)
  {
      var s = new XMLSerializer();
      var xsltProcessor = new XSLTProcessor();

      xsltProcessor.importStylesheet(get_query_param_xslt);
      var fragment = xsltProcessor.transformToFragment(xmlParam, document);
      //document.getElementById("pQueryResult").innerHTML = "<form id='QueryParamForm' method='post'>" + s.serializeToString(fragment) + "</form>";
      document.getElementById("pQueryResult").innerHTML = "";
      document.getElementById("pQueryResult").appendChild(fragment);
      //document.getElementById("pQueryResult").innerHTML = "<form id='QueryParamForm' method='post'>" + s.serializeToString(fragment) + "</form>";
  }
  else
  {
  	document.getElementById("pQueryResult").innerHTML = xmlParam.transformNode(get_query_param_xslt);    
  }
  //document.getElementById("GetQueryParamSrc").src = map_list.maps.Item(map_list.map_id).query_url + "?REQUEST=getqueryparam" + "&QUERYINDEX=" + query.id;

}
//************************************************************************

function CallGetQueryParamIQS(query)
{
/* 
 * Procedura realizujici pozadavek klienta na vraceni parametru zvoleneho dotazu.
 */
	var re = /[?]/i;
	var xml_req = "";
	if(map_list.maps.Item(map_list.map_id).query_url.search(re) != -1)
	{
    //sloz XML request
    
    xml_req = this.map_list.maps.Item(map_list.map_id).query_url + "&";
        
	}
	else
	{
      //sloz XML request
    xml_req = this.map_list.maps.Item(map_list.map_id).query_url + "?";
	}

  xmlParam = AJAX(xml_req + "REQUEST=DescribeQuery" + "&ID=" + query.id, false);

  var moz = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined');
  var ie = (typeof window.ActiveXObject != 'undefined'); 

  if(moz)
  {
      var s = new XMLSerializer();
      var xsltProcessor = new XSLTProcessor();

      xsltProcessor.importStylesheet(get_query_param_xslt);
      var fragment = xsltProcessor.transformToFragment(xmlParam, document);
      //document.getElementById("pQueryResult").innerHTML = "<form id='QueryParamForm' method='post'>" + s.serializeToString(fragment) + "</form>";
      document.getElementById("pQueryResult").innerHTML = "";
      document.getElementById("pQueryResult").appendChild(fragment);
      //document.getElementById("pQueryResult").innerHTML = "<form id='QueryParamForm' method='post'>" + s.serializeToString(fragment) + "</form>";
  }
  else
  {
  	document.getElementById("pQueryResult").innerHTML = xmlParam.transformNode(get_query_param_xslt);    
  }
  //document.getElementById("GetQueryParamSrc").src = map_list.maps.Item(map_list.map_id).query_url + "?REQUEST=getqueryparam" + "&QUERYINDEX=" + query.id;

}
//************************************************************************

function cmbQParamChangeIQS(id, c, v)
{
  var re = /[?]/i;
	var xml_req = "";
	var QueryNodes, QueryNode, RecNodes;
	var filter = "";
	
	if(map_list.maps.Item(map_list.map_id).query_url.search(re) != -1)
	{
    //sloz XML request
    
    xml_req = this.map_list.maps.Item(map_list.map_id).query_url + "&";
        
	}
	else
	{
      //sloz XML request
    xml_req = this.map_list.maps.Item(map_list.map_id).query_url + "?";
	}
  
  if(v == '%')
  {
    filter = "<Filter><PropertyIsLike><PropertyName>" + c + "</PropertyName><Literal>" + v + "</Literal></PropertyIsLike></Filter>";
  }
  else
  {
    filter = "<Filter><PropertyIsEqualTo><PropertyName>" + c + "</PropertyName><Literal>" + v + "</Literal></PropertyIsEqualTo></Filter>";
  }

  var xmlParamValues = AJAX(xml_req + "request=getParamValues&id=" + id + "&filter=" + filter, false);
	
  var moz = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined');
  var ie = (typeof window.ActiveXObject != 'undefined'); 

  if(moz)
  {
      var xpe = new XPathEvaluator();
      var nsResolver = xpe.createNSResolver(xmlParam.ownerDocument == null ? xmlParam.documentElement : xmlParam.ownerDocument.documentElement);
      var nspResolver = xpe.createNSResolver(xmlParamValues.ownerDocument == null ? xmlParamValues.documentElement : xmlParamValues.ownerDocument.documentElement);

      var s = new XMLSerializer();
      var xsltProcessor = new XSLTProcessor();

      QueryNodes = xmlParam.evaluate("ingr:QueryDescriptionList/ingr:Query", xmlParam, nsResolver, 7, null);
      QueryNode = xmlParam.evaluate("ingr:QueryParamList/ingr:QueryParam[@id='" + id + "']", QueryNodes.snapshotItem(0), nsResolver, 9, null);
      RecNodes = xmlParamValues.evaluate("ingr:ParamValueList/ingr:ParamValues[@id='" + id + "']/ingr:ParamValue", xmlParamValues, nspResolver, 7, null);	

      if (RecNodes.snapshotLength > 0)
      {
      	var param = "iqs_param_" + id;
        var ParamNode = xmlParam.evaluate("ingr:ColumnName", QueryNode.singleNodeValue, nsResolver, 9, null);
        var param_value = ParamNode.singleNodeValue.firstChild.nodeValue;
        var str_html = "<select class='vyber' id='" + param + "' ";
        
        if(QueryNode.singleNodeValue.getAttribute("childParam").toString() != null && QueryNode.singleNodeValue.getAttribute("childParam").toString() != '')
        {
          str_html = str_html + "onChange='cmbQParamChangeIQS(" + String.fromCharCode(34) + QueryNode.singleNodeValue.getAttribute("childParam") + String.fromCharCode(34) + "," + String.fromCharCode(34) + param_value + String.fromCharCode(34) + "," + "document.getElementById(" + String.fromCharCode(34) + param + String.fromCharCode(34) + ").options[document.getElementById(" + String.fromCharCode(34) + param + String.fromCharCode(34) + ").selectedIndex].value);'"
        }
        
        str_html = str_html + ">";

        str_html = str_html + "<OPTION value='%'></OPTION>";
                    	
        //Pro kazdy element REC delej
      	for(var i = 0; i < RecNodes.snapshotLength; i++)
      	{
          str_html = str_html + "<OPTION value='" + RecNodes.snapshotItem(i).firstChild.nodeValue + "'>" + RecNodes.snapshotItem(i).firstChild.nodeValue + "</OPTION>";
      	}
      	
      	str_html = str_html + "</select>";
      	
        document.getElementById("s_" + param).innerHTML = str_html;        
      }
  }
  else
  {
    QueryNode = xmlParam.selectSingleNode("ingr:QueryDescriptionList/ingr:Query[0]/ingr:QueryParamList/ingr:QueryParam[@id='" + id + "']");
    
    RecNodes = xmlParamValues.selectNodes("ingr:ParamValueList/ingr:ParamValues[@id='" + id + "']/ingr:ParamValue");	
  
    if (RecNodes.length > 0)
    {
    	var param = "iqs_param_" + id;
      var str_html = "<select class='vyber' id='" + param + "' ";
      
      if(QueryNode.getAttribute("childParam").toString() != null && QueryNode.getAttribute("childParam").toString() != '')
      {
        str_html = str_html + "onChange='cmbQParamChangeIQS(" + String.fromCharCode(34) + QueryNode.getAttribute("childParam") + String.fromCharCode(34) + "," + String.fromCharCode(34) + QueryNode.selectSingleNode("ingr:ColumnName").text + String.fromCharCode(34) + "," + "document.getElementById(" + String.fromCharCode(34) + param + String.fromCharCode(34) + ").options[document.getElementById(" + String.fromCharCode(34) + param + String.fromCharCode(34) + ").selectedIndex].value);'";
      }
      
      str_html = str_html + ">";

      str_html = str_html + "<OPTION value='%'></OPTION>";
        	
      //Pro kazdy element REC delej
    	for(var i = 0; i < RecNodes.length; i++)
    	{
        str_html = str_html + "<OPTION value='" + RecNodes.item(i).text + "'>" + RecNodes.item(i).text + "</OPTION>";
    	}
    	
    	str_html = str_html + "</select>";
    	
      //document.getElementById(param).iHTML = "";
      document.getElementById("s_" + param).innerHTML = str_html;
    }
  }

}

function TransformQueryForm(p)
{
/*
 * Procedura realizujici vytvoreni URL pozadavku, ze zadanych parametru dotazu.
 */

	var RecNodes;  		//Seznam XML elementu s nazvem REC
	var RecNode;			//Promenna uchovavajici jeden element REC
	var FldNodes;	   	//Seznam XML elementu s nazvem FLD
	var FldNode;			//Promenna uchovavajici jeden element FLD
	
	var param;			  //Identifikator HTML prvku s hodnotou parametru
	var ParamString = "";	//Retezec obsahujici seznam parametru s prislusnymi hodnotami
	var QueryMap;
	var RecNodes, FldNodes;

  var BBoxArray;

	document.getElementById("divWait").style.display = "";

	var re = /[?]/i;
	var xml_req = "";
	if(map_list.maps.Item(map_list.map_id).query_url.search(re) != -1)
	{
    //sloz XML request
    
    xml_req = this.map_list.maps.Item(map_list.map_id).query_url + "&";
        
	}
	else
	{
      //sloz XML request
    xml_req = this.map_list.maps.Item(map_list.map_id).query_url + "?";
	}
	
  var moz = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined');
  var ie = (typeof window.ActiveXObject != 'undefined'); 

  if(moz)
  {
    RecNodes = xmlParam.evaluate("REPORT/REC", xmlParam, null, 7, null);

    for(var i = 0; i < RecNodes.snapshotLength; i++)
    {
      FldNodes = xmlParam.evaluate("FLD", RecNodes.snapshotItem(i), null, 7, null);

      param = FldNodes.snapshotItem(0).getAttribute("Value") + "_" + FldNodes.snapshotItem(3).getAttribute("Value");
      
      ParamString = ParamString + param + "=" + document.getElementById(param).value + "&";
    }

  	ParamString = ParamString.slice(0, ParamString.length - 1);

    map_list.maps.Item(map_list.map_id).query_param_string = ParamString;
    map_list.maps.Item(map_list.map_id).query_index = p.id;
    
  	//Realilzuje pozadavek klienta na ziskani vysledku dotazu
    xmlQueryResult = AJAX(xml_req + "REQUEST=getqueryresult&QUERYINDEX=" + p.id + "&" + ParamString + "&PAGE=1&ITEMS=" + document.getElementById("cmbQueryPaging").options[document.getElementById("cmbQueryPaging").selectedIndex].value + "&SRS=" + map_list.maps.Item(map_list.map_id).srs, false);

    var s = new XMLSerializer();
    var xsltProcessor = new XSLTProcessor();

    xsltProcessor.importStylesheet(get_query_result_xslt);
    var fragment = xsltProcessor.transformToFragment(xmlQueryResult, document);
    document.getElementById("pQueryResult").innerHTML = "";
    document.getElementById("pQueryResult").appendChild(fragment);

    RecNodes = xmlQueryResult.evaluate("REPORT/REC", xmlQueryResult, null, 7, null);

    if(RecNodes.snapshotLength > 0)
    {
      if(RecNodes.snapshotLength == 2)
      {
        FldNodes = xmlQueryResult.evaluate("FLD", RecNodes.snapshotItem(0), null, 7, null);

        if(FldNodes.snapshotLength > 1)
        {
  				queryid = FldNodes.snapshotItem(0).getAttribute("Value");
  				querypar = FldNodes.snapshotItem(1).getAttribute("Value");
  			}
  			else
  			{
  				alert(script_messages[16]);
  				return;
  			}

      	if(LayerManager.Query)
      	{
          LayerManager.DeleteQuery();
      	}

        FldNodes = xmlQueryResult.evaluate("FLD", RecNodes.snapshotItem(1), null, 7, null);
  
        if(FldNodes.snapshotLength > 1)
        {
  				for(var i = 0; i < FldNodes.snapshotLength; i++)
  				{
  					if (FldNodes.snapshotItem(i).getAttribute("Name").toUpperCase() == "BBOX")
  					{
  						BBOX = FldNodes.snapshotItem(i).getAttribute("Value");
  						break;
  					}
  				}

  				if (BBOX == "")
  				{
  					alert(script_messages[17]);
  					return;
  				}
  				
          BBoxArray = ParseBBox(BBOX);
        }
  			else
  			{
					alert(script_messages[17]);
  				return;
  			}
  			
  			//Transformace zobrazeni BBOXu
      	BBoxArray = TransformBBox(BBoxArray, map_list.maps.Item(map_list.map_id).map_width,map_list.maps.Item(map_list.map_id).map_height);

   			WrldWidth = BBoxArray[2] - BBoxArray[0];
  
  			MapScale = Math.round(((((WrldWidth * map_list.maps.Item(map_list.map_id).projection_to_scale) / map_list.maps.Item(map_list.map_id).map_width) * 100) * (280/10)));
  			
        if(parseInt(document.getElementById("selMaxScale").options[document.getElementById("selMaxScale").selectedIndex].value) > parseInt(MapScale))
  			{
  				MapScale = parseInt(document.getElementById("selMaxScale").options[document.getElementById("selMaxScale").selectedIndex].value);
  				
          wrldhalfx = BBoxArray[0] + ((BBoxArray[2] - BBoxArray[0]) / 2);
  				wrldhalfy = BBoxArray[1] + ((BBoxArray[3] - BBoxArray[1]) / 2);
  				BBoxArray[0] = wrldhalfx - (((map_list.maps.Item(map_list.map_id).map_width / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
  				BBoxArray[2] = wrldhalfx + (((map_list.maps.Item(map_list.map_id).map_width / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
  				BBoxArray[1] = wrldhalfy - (((map_list.maps.Item(map_list.map_id).map_height / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
  				BBoxArray[3] = wrldhalfy + (((map_list.maps.Item(map_list.map_id).map_height / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
  			}
 				
  			LayerManager.HideAll();

      	BBOX = dbl2StrEN(BBoxArray[0].toString()) + "," + dbl2StrEN(BBoxArray[1].toString()) + "," + dbl2StrEN(BBoxArray[2].toString()) + "," + dbl2StrEN(BBoxArray[3].toString());
      
      	map_list.maps.Item(map_list.map_id).bbox = BBOX;
        map_list.maps.Item(map_list.map_id).Actualize_BBOX();

        LayerManager.ShowQuery(queryid, querypar, map_list.maps.Item(map_list.map_id).query_url, 0);

  			LayerManager.ShowAll();

        SetPosition();
        ViewSwitch("OknoMapa");

      }  
  		else
  		{
    		document.getElementById("divWait").style.display = "none";
  			return;
  		}
    }
    else
    {
  		ResultNotFound();
  		document.getElementById("divWait").style.display = "none";
  		return;
  	}
  }
  else
  {
    RecNodes = xmlParam.selectNodes("/REPORT/REC");	
  
  	//Pro kazdy element REC delej
  	for(var i = 0; i < RecNodes.length; i++)
  	{
  		
  		//Prirazeni kolekce elementu s nazvem FLD
  		FldNodes = RecNodes.item(i).selectNodes("./FLD");
  		
  		//Slozeni jmena parametru
  		param = FldNodes.item(0).getAttribute("Value") + "_" + FldNodes.item(3).getAttribute("Value");
  		
  		//Pridani do retezce s parametry a prirazeni prislusne hodnoty prvku na HTML strance
  		ParamString = ParamString + param + "=" + document.getElementById(param).value + "&";
  	}
  	ParamString = ParamString.slice(0, ParamString.length - 1);
  
    map_list.maps.Item(map_list.map_id).query_param_string = ParamString;
    map_list.maps.Item(map_list.map_id).query_index = p.id;
    
  	//Realilzuje pozadavek klienta na ziskani vysledku dotazu
    xmlQueryResult = AJAX(xml_req + "REQUEST=getqueryresult&QUERYINDEX=" + p.id + "&" + ParamString + "&PAGE=1&ITEMS=" + document.getElementById("cmbQueryPaging").options[document.getElementById("cmbQueryPaging").selectedIndex].value + "&SRS=" + map_list.maps.Item(map_list.map_id).srs, false);

  	document.getElementById("pQueryResult").innerHTML = xmlQueryResult.transformNode(get_query_result_xslt);
  
  	//Prirazeni kolekce elementu s nazvem REC
  	RecNodes = xmlQueryResult.selectNodes("/REPORT/REC");
  
  	//Musi byt minimalne dva zaznamy aby byl nalezen vysledek (prvni je pomocny)
  	if(RecNodes.length > 1)
  	{
  		if (RecNodes.length == 2)
  		{
  			//Nacteni pomocnych hodnot
  			FldNodes = RecNodes.item(0).selectNodes("FLD");
  		
  			if (FldNodes.length > 1)
  			{
  				queryid = FldNodes.item(0).getAttribute("Value");
  				querypar = FldNodes.item(1).getAttribute("Value");
  			}
  			else
  			{
  				alert(script_messages[16]);
  				return;
  			}

      	if(LayerManager.Query)
      	{
          LayerManager.DeleteQuery();
      	}
  		  		
  			//Prirazeni kolekce elementu s nazvem FLD
  			FldNodes = RecNodes.item(1).selectNodes("FLD");
  
  			if (FldNodes.length > 0)
  			{
  				for(var i = 0; i < FldNodes.length; i++)
  				{
  					if (FldNodes.item(i).getAttribute("Name").toUpperCase() == "BBOX")
  					{
  						BBOX = FldNodes.item(i).getAttribute("Value");
  						break;
  					}
  				}

  				if (BBOX == "")
  				{
  					alert(script_messages[17]);
  					return;
  				}
  				
          BBoxArray = ParseBBox(BBOX);
        }
  			else
  			{
 					alert(script_messages[17]);
  				return;
  			}
  			
  			//Transformace zobrazeni BBOXu
      	BBoxArray = TransformBBox(BBoxArray, map_list.maps.Item(map_list.map_id).map_width,map_list.maps.Item(map_list.map_id).map_height);

   			WrldWidth = BBoxArray[2] - BBoxArray[0];
  
  			MapScale = Math.round(((((WrldWidth * map_list.maps.Item(map_list.map_id).projection_to_scale) / map_list.maps.Item(map_list.map_id).map_width) * 100) * (280/10)));
  			
        if(parseInt(document.getElementById("selMaxScale").options[document.getElementById("selMaxScale").selectedIndex].value) > parseInt(MapScale))
  			{
  				MapScale = parseInt(document.getElementById("selMaxScale").options[document.getElementById("selMaxScale").selectedIndex].value);
  				
          wrldhalfx = BBoxArray[0] + ((BBoxArray[2] - BBoxArray[0]) / 2);
  				wrldhalfy = BBoxArray[1] + ((BBoxArray[3] - BBoxArray[1]) / 2);
  				BBoxArray[0] = wrldhalfx - (((map_list.maps.Item(map_list.map_id).map_width / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
  				BBoxArray[2] = wrldhalfx + (((map_list.maps.Item(map_list.map_id).map_width / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
  				BBoxArray[1] = wrldhalfy - (((map_list.maps.Item(map_list.map_id).map_height / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
  				BBoxArray[3] = wrldhalfy + (((map_list.maps.Item(map_list.map_id).map_height / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
  			}
 				
  			LayerManager.HideAll();

      	BBOX = dbl2StrEN(BBoxArray[0].toString()) + "," + dbl2StrEN(BBoxArray[1].toString()) + "," + dbl2StrEN(BBoxArray[2].toString()) + "," + dbl2StrEN(BBoxArray[3].toString());
      
      	map_list.maps.Item(map_list.map_id).bbox = BBOX;
        map_list.maps.Item(map_list.map_id).Actualize_BBOX();

        LayerManager.ShowQuery(queryid, querypar, map_list.maps.Item(map_list.map_id).query_url, 0);

  			LayerManager.ShowAll();
        
        SetPosition();
        
        ViewSwitch("OknoMapa");
      }
  		else
  		{
    		document.getElementById("divWait").style.display = "none";
  			return;
  		}
  	}
    else
    {
  		ResultNotFound();
  		document.getElementById("divWait").style.display = "none";
  		return;
  	}
  	
  }
}
//****************************************************************************

function TransformQueryFormIQS(p)
{
/*
 * Procedura realizujici vytvoreni URL pozadavku, ze zadanych parametru dotazu.
 */

	var RecNodes;  		//Seznam XML elementu s nazvem REC
	var RecNode;			//Promenna uchovavajici jeden element REC
	var FldNodes;	   	//Seznam XML elementu s nazvem FLD
	var FldNode;			//Promenna uchovavajici jeden element FLD
	
	var param, ids;			  //Identifikator HTML prvku s hodnotou parametru
	var ParamString = "";	//Retezec obsahujici seznam parametru s prislusnymi hodnotami
	var QueryMap;
	var queryid, queryidcol;;

  var BBoxArray;

  var ogc_filter = '';
  
	document.getElementById("divWait").style.display = "";

	var re = /[?]/i;
	var xml_req = "";
	if(map_list.maps.Item(map_list.map_id).query_url.search(re) != -1)
	{
    //sloz XML request
    
    xml_req = this.map_list.maps.Item(map_list.map_id).query_url + "&";
        
	}
	else
	{
      //sloz XML request
    xml_req = this.map_list.maps.Item(map_list.map_id).query_url + "?";
	}
	
  var moz = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined');
  var ie = (typeof window.ActiveXObject != 'undefined'); 

  if(moz)
  {
    var xpe = new XPathEvaluator();
    var nsResolver = xpe.createNSResolver(xmlParam.ownerDocument == null ? xmlParam.documentElement : xmlParam.ownerDocument.documentElement);

    ogc_filter = "<Filter>";
    
    RecNodes = xmlParam.evaluate("ingr:QueryDescriptionList/ingr:Query/ingr:QueryParamList/ingr:QueryParam", xmlParam, nsResolver, 7 , null);	
    if (RecNodes.snapshotLength > 1)
    {
      ogc_filter = ogc_filter + "<And>";
    }
  	//Pro kazdy element REC delej
  	for(var i = 0; i < RecNodes.snapshotLength; i++)
  	{
      param = "iqs_param_" + RecNodes.snapshotItem(i).getAttribute("id");
      
      var xmlFormType = xmlParam.evaluate("ingr:FormType", RecNodes.snapshotItem(i), nsResolver, 9, null);
      var xmlColumnName = xmlParam.evaluate("ingr:ColumnName", RecNodes.snapshotItem(i), nsResolver, 9, null);
      switch (xmlFormType.singleNodeValue.firstChild.nodeValue.toString())
      {        
        case "TEXTBOX" :
      			var re = /[*]/i;
      			if(document.getElementById(param).value.search(re) != -1)
      			{
              ogc_filter = ogc_filter + "<PropertyIsLike><PropertyName>" + xmlColumnName.singleNodeValue.firstChild.nodeValue.toString() + "</PropertyName><Literal>" + document.getElementById(param).value + "</Literal></PropertyIsLike>";
            }
            else
            {
              ogc_filter = ogc_filter + "<PropertyIsEqualTo><PropertyName>" + xmlColumnName.singleNodeValue.firstChild.nodeValue.toString() + "</PropertyName><Literal>" + document.getElementById(param).value + "</Literal></PropertyIsEqualTo>";
            }
          break;
        case "LISTBOX" :
            ogc_filter = ogc_filter + "<PropertyIsEqualTo><PropertyName>" + xmlColumnName.singleNodeValue.firstChild.nodeValue.toString() + "</PropertyName><Literal>" + document.getElementById(param).options[document.getElementById(param).selectedIndex].value + "</Literal></PropertyIsEqualTo>";
          break;
        default:
          break;
      }
  		
  		//Pridani do retezce s parametry a prirazeni prislusne hodnoty prvku na HTML strance
  //		ParamString = ParamString + param + "=" + document.getElementById(param).value + "&";
  	}
  	
 //   ParamString = ParamString.slice(0, ParamString.length - 1);

    if (RecNodes.snapshotLength > 1)
    {
      ogc_filter = ogc_filter + "</And>";
    }

    ogc_filter = ogc_filter + "</Filter>";
    
    map_list.maps.Item(map_list.map_id).query_param_string = ogc_filter;
    map_list.maps.Item(map_list.map_id).query_index = p.id;

  	//Realilzuje pozadavek klienta na ziskani vysledku dotazu
    xmlQueryResult = AJAX(xml_req + "REQUEST=getquery&id=" + p.id + "&filter=" + ogc_filter + "&PAGE=1&SIZE=" + document.getElementById("cmbQueryPaging").options[document.getElementById("cmbQueryPaging").selectedIndex].value + "&SRS=" + map_list.maps.Item(map_list.map_id).srs + "&RETURNBBOX=1", false);

    var s = new XMLSerializer();
    var xsltProcessor = new XSLTProcessor();

    xsltProcessor.importStylesheet(get_query_result_xslt);
    var fragment = xsltProcessor.transformToFragment(xmlQueryResult, document);
    document.getElementById("pQueryResult").innerHTML = "";
    document.getElementById("pQueryResult").appendChild(fragment);

    var nsQResolver = xpe.createNSResolver(xmlQueryResult.ownerDocument == null ? xmlQueryResult.documentElement : xmlQueryResult.ownerDocument.documentElement);
    RecNodes = xmlQueryResult.evaluate("/ingr:QueryResult/ingr:TotalRecords", xmlQueryResult, nsQResolver, 9, null);

    if(parseInt(RecNodes.singleNodeValue.firstChild.nodeValue.toString()) > 0)
    {
      if(parseInt(RecNodes.singleNodeValue.firstChild.nodeValue.toString()) == 1)
      {
        FldNodes = xmlQueryResult.evaluate("/ingr:QueryResult/ingr:QueryID", xmlQueryResult, nsQResolver, 9, null);

        if(FldNodes != null)
        {
  				queryid = FldNodes.singleNodeValue.firstChild.nodeValue.toString();
  			}
  			else
  			{
  				alert(script_messages[16]);
  				return;
  			}

  			//Nacteni pomocnych hodnot
  			FldNodes = xmlQueryResult.evaluate("ingr:QueryResult/ingr:PkeyColumns", xmlQueryResult, nsQResolver, 9, null);
  			if (FldNodes != null)
  			{
  				queryidcol = FldNodes.singleNodeValue.childNodes[1].getAttribute("name");
  			}
  			else
  			{
  				alert(script_messages[16]);
  				return;
  			}

      	if(LayerManager.Query)
      	{
          LayerManager.DeleteQuery();
      	}

        RecNodes = xmlQueryResult.evaluate("/ingr:QueryResult/ingr:RowSet/ingr:Row", xmlQueryResult, nsQResolver, 9, null);

        if(RecNodes != null)
        {
					BBOX = RecNodes.singleNodeValue.getAttribute("bbox").toString();

  				if (BBOX == "")
  				{
  					alert(script_messages[17]);
  					return;
  				}
  				
          BBoxArray = ParseBBox(BBOX);
        }
  			else
  			{
					alert(script_messages[17]);
  				return;
  			}

        RecNodes = xmlQueryResult.evaluate("/ingr:QueryResult/ingr:RowSet/ingr:Row", xmlQueryResult, nsQResolver, 9, null);	
  
      	//Pro kazdy element REC delej
      	for(var i = 0; i < RecNodes.singleNodeValue.childNodes.length; i++)
      	{
          if(RecNodes.singleNodeValue.childNodes[i].nodeName.toLowerCase()== 'column')
          {
            if(RecNodes.singleNodeValue.childNodes[i].getAttribute("name").toLowerCase() == queryidcol.toLowerCase())
            { 
              ids = RecNodes.singleNodeValue.childNodes[i].firstChild.nodeValue;
            }
          } 
        }
  			
  			//Transformace zobrazeni BBOXu
      	BBoxArray = TransformBBox(BBoxArray, map_list.maps.Item(map_list.map_id).map_width,map_list.maps.Item(map_list.map_id).map_height);

   			WrldWidth = BBoxArray[2] - BBoxArray[0];
  
  			MapScale = Math.round(((((WrldWidth * map_list.maps.Item(map_list.map_id).projection_to_scale) / map_list.maps.Item(map_list.map_id).map_width) * 100) * (280/10)));
  			
        if(parseInt(document.getElementById("selMaxScale").options[document.getElementById("selMaxScale").selectedIndex].value) > parseInt(MapScale))
  			{
  				MapScale = parseInt(document.getElementById("selMaxScale").options[document.getElementById("selMaxScale").selectedIndex].value);
  				
          wrldhalfx = BBoxArray[0] + ((BBoxArray[2] - BBoxArray[0]) / 2);
  				wrldhalfy = BBoxArray[1] + ((BBoxArray[3] - BBoxArray[1]) / 2);
  				BBoxArray[0] = wrldhalfx - (((map_list.maps.Item(map_list.map_id).map_width / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
  				BBoxArray[2] = wrldhalfx + (((map_list.maps.Item(map_list.map_id).map_width / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
  				BBoxArray[1] = wrldhalfy - (((map_list.maps.Item(map_list.map_id).map_height / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
  				BBoxArray[3] = wrldhalfy + (((map_list.maps.Item(map_list.map_id).map_height / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
  			}
 				
  			LayerManager.HideAll();

      	BBOX = dbl2StrEN(BBoxArray[0].toString()) + "," + dbl2StrEN(BBoxArray[1].toString()) + "," + dbl2StrEN(BBoxArray[2].toString()) + "," + dbl2StrEN(BBoxArray[3].toString());
      
      	map_list.maps.Item(map_list.map_id).bbox = BBOX;
        map_list.maps.Item(map_list.map_id).Actualize_BBOX();

        LayerManager.ShowQuery(queryid, ids, map_list.maps.Item(map_list.map_id).query_url, 0);

  			LayerManager.ShowAll();

        SetPosition();
        ViewSwitch("OknoMapa");

      }  
  		else
  		{
    		document.getElementById("divWait").style.display = "none";
  			return;
  		}
    }
    else
    {
  		ResultNotFound();
  		document.getElementById("divWait").style.display = "none";
  		return;
  	}
  }
  else
  {
    ogc_filter = "<Filter>";
    
    RecNodes = xmlParam.selectNodes("ingr:QueryDescriptionList/ingr:Query/ingr:QueryParamList/ingr:QueryParam");	
  
    if (RecNodes.length > 1)
    {
      ogc_filter = ogc_filter + "<And>";
    }
  	//Pro kazdy element REC delej
  	for(var i = 0; i < RecNodes.length; i++)
  	{
      param = "iqs_param_" + RecNodes.item(i).getAttribute("id");
      switch (RecNodes.item(i).selectSingleNode("ingr:FormType").text)
      {        
        case "TEXTBOX" :
      			var re = /[*]/i;
      			if(document.getElementById(param).value.search(re) != -1)
      			{
              ogc_filter = ogc_filter + "<PropertyIsLike><PropertyName>" + RecNodes.item(i).selectSingleNode("ingr:ColumnName").text + "</PropertyName><Literal>" + document.getElementById(param).value + "</Literal></PropertyIsLike>";
            }
            else
            {
              ogc_filter = ogc_filter + "<PropertyIsEqualTo><PropertyName>" + RecNodes.item(i).selectSingleNode("ingr:ColumnName").text + "</PropertyName><Literal>" + document.getElementById(param).value + "</Literal></PropertyIsEqualTo>";
            }
          break;
        case "LISTBOX" :
            ogc_filter = ogc_filter + "<PropertyIsEqualTo><PropertyName>" + RecNodes.item(i).selectSingleNode("ingr:ColumnName").text + "</PropertyName><Literal>" + document.getElementById(param).options[document.getElementById(param).selectedIndex].value + "</Literal></PropertyIsEqualTo>";
          break;
        default:
          break;
      }
  		
  		//Pridani do retezce s parametry a prirazeni prislusne hodnoty prvku na HTML strance
  //		ParamString = ParamString + param + "=" + document.getElementById(param).value + "&";
  	}
  	
 //   ParamString = ParamString.slice(0, ParamString.length - 1);

    if (RecNodes.length > 1)
    {
      ogc_filter = ogc_filter + "</And>";
    }

    ogc_filter = ogc_filter + "</Filter>";
    
    map_list.maps.Item(map_list.map_id).query_param_string = ogc_filter;
    map_list.maps.Item(map_list.map_id).query_index = p.id;

    //Realilzuje pozadavek klienta na ziskani vysledku dotazu
    xmlQueryResult = AJAX(xml_req + "REQUEST=getquery&id=" + p.id + "&filter=" + ogc_filter + "&PAGE=1&SIZE=" + document.getElementById("cmbQueryPaging").options[document.getElementById("cmbQueryPaging").selectedIndex].value + "&SRS=" + map_list.maps.Item(map_list.map_id).srs + "&RETURNBBOX=1", false);
  	document.getElementById("pQueryResult").innerHTML = xmlQueryResult.transformNode(get_query_result_xslt);
  
  	//Prirazeni kolekce elementu s nazvem REC
  	RecNodes = xmlQueryResult.selectSingleNode("/ingr:QueryResult/ingr:TotalRecords");
  
  	//Musi byt minimalne dva zaznamy aby byl nalezen vysledek (prvni je pomocny)
  	if(parseInt(RecNodes.text) > 0)
  	{
  		if (parseInt(RecNodes.text) == 1)
  		{
  			//Nacteni pomocnych hodnot
  			FldNodes = xmlQueryResult.selectSingleNode("/ingr:QueryResult/ingr:QueryID");
  		
  			if (FldNodes != null)
  			{
  				queryid = FldNodes.text;
  			}
  			else
  			{
  				alert(script_messages[16]);
  				return;
  			}

  			//Nacteni pomocnych hodnot
  			FldNodes = xmlQueryResult.selectSingleNode("/ingr:QueryResult/ingr:PkeyColumns/column[0]");
  		
  			if (FldNodes != null)
  			{
  				queryidcol = FldNodes.getAttribute("name");
  			}
  			else
  			{
  				alert(script_messages[16]);
  				return;
  			}

      	if(LayerManager.Query)
      	{
          LayerManager.DeleteQuery();
      	}
  		  		
      	//Prirazeni kolekce elementu s nazvem REC
      	RecNodes = xmlQueryResult.selectSingleNode("/ingr:QueryResult/ingr:RowSet/ingr:Row");
  
  			if (RecNodes != null)
  			{
  				BBOX = RecNodes.getAttribute("bbox");

  				if (BBOX == "")
  				{
  					alert(script_messages[17]);
  					return;
  				}
          BBoxArray = ParseBBox(BBOX);
        }
  			else
  			{
 					alert(script_messages[17]);
  				return;
  			}

        RecNodes = xmlQueryResult.selectNodes("/ingr:QueryResult/ingr:RowSet/ingr:Row/column");	
  
      	//Pro kazdy element REC delej
      	for(var i = 0; i < RecNodes.length; i++)
      	{
          if(RecNodes.item(i).getAttribute("name").toLowerCase() == queryidcol.toLowerCase())
          {
            ids = RecNodes.item(i).text;
          } 
        }
         			
  			//Transformace zobrazeni BBOXu
      	BBoxArray = TransformBBox(BBoxArray, map_list.maps.Item(map_list.map_id).map_width,map_list.maps.Item(map_list.map_id).map_height);

   			WrldWidth = BBoxArray[2] - BBoxArray[0];
  
  			MapScale = Math.round(((((WrldWidth * map_list.maps.Item(map_list.map_id).projection_to_scale) / map_list.maps.Item(map_list.map_id).map_width) * 100) * (280/10)));
  			
        if(parseInt(document.getElementById("selMaxScale").options[document.getElementById("selMaxScale").selectedIndex].value) > parseInt(MapScale))
  			{
  				MapScale = parseInt(document.getElementById("selMaxScale").options[document.getElementById("selMaxScale").selectedIndex].value);
  				
          wrldhalfx = BBoxArray[0] + ((BBoxArray[2] - BBoxArray[0]) / 2);
  				wrldhalfy = BBoxArray[1] + ((BBoxArray[3] - BBoxArray[1]) / 2);
  				BBoxArray[0] = wrldhalfx - (((map_list.maps.Item(map_list.map_id).map_width / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
  				BBoxArray[2] = wrldhalfx + (((map_list.maps.Item(map_list.map_id).map_width / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
  				BBoxArray[1] = wrldhalfy - (((map_list.maps.Item(map_list.map_id).map_height / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
  				BBoxArray[3] = wrldhalfy + (((map_list.maps.Item(map_list.map_id).map_height / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
  			}
 				
  			LayerManager.HideAll();

      	BBOX = dbl2StrEN(BBoxArray[0].toString()) + "," + dbl2StrEN(BBoxArray[1].toString()) + "," + dbl2StrEN(BBoxArray[2].toString()) + "," + dbl2StrEN(BBoxArray[3].toString());
      	map_list.maps.Item(map_list.map_id).bbox = BBOX;
        map_list.maps.Item(map_list.map_id).Actualize_BBOX();

        LayerManager.ShowQuery(queryid, ids, map_list.maps.Item(map_list.map_id).query_url, 0);

  			LayerManager.ShowAll();
        
        SetPosition();
        
        ViewSwitch("OknoMapa");
        
      }
  		else
  		{
    		document.getElementById("divWait").style.display = "none";
  			return;
  		}
  	}
    else
    {
  		ResultNotFound();
  		document.getElementById("divWait").style.display = "none";
  		return;
  	}
  	
  }
}
//****************************************************************************

function ResultNotFound()
{
	document.getElementById("pQueryResult").innerHTML = "<DIV id='divQNoSelect' class='footerbold' style='position: absolute; left: 0px; top: 10px; width: 100%; height: 50px; padding-left: 3px; padding-right: 3px; background-color: #ECF5FF; border: 1px solid #336666; overflow: auto;'>Výsledek nebyl nalezen.</DIV>"

}
//****************************************************************************

function CallGetQueryResult(map)
/*
 * Procedura realizujici zmenu mapoveho vyrezu tak aby obsahoval vybrany prvek
 * z vysledku dotazu.
 */
{
  var i;
	var j;
	var initialize;
	var queryid;
	var querypar;
	var RecNodes;
	var FldNodes;
	var TmpArray;
	var BBoxArray;
	var WrldWidth;
	var wrldhalfx;
	var wrldhalfy;
	var BBOX;
	var param_array;

	if(LayerManager.Query)
	{
    LayerManager.DeleteQuery();
	}

  var moz = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined');
  var ie = (typeof window.ActiveXObject != 'undefined'); 

  if(moz)
  {
    RecNodes = xmlQueryResult.evaluate("REPORT/REC", xmlQueryResult, null, 7, null);

    if(RecNodes.snapshotLength > 0)
    {
      FldNodes = xmlQueryResult.evaluate("FLD", RecNodes.snapshotItem(0), null, 7, null);

      if(FldNodes.snapshotLength > 1)
      {
				queryid = FldNodes.snapshotItem(0).getAttribute("Value");
				querypar = FldNodes.snapshotItem(1).getAttribute("Value");
			}
			else
			{
				alert(script_messages[16]);
				return;
			}

    	document.getElementById("divWait").style.display = "";
    
    	param_array = map.id.split("|");
    
      BBoxArray = ParseBBox(param_array[0]);
    
    	BBoxArray = TransformBBox(BBoxArray, map_list.maps.Item(map_list.map_id).map_width,map_list.maps.Item(map_list.map_id).map_height);
    
    	BBOX = dbl2StrEN(BBoxArray[0].toString()) + "," + dbl2StrEN(BBoxArray[1].toString()) + "," + dbl2StrEN(BBoxArray[2].toString()) + "," + dbl2StrEN(BBoxArray[3].toString());
      
      LayerManager.HideAll();
      
    	map_list.maps.Item(map_list.map_id).bbox = BBOX;
      map_list.maps.Item(map_list.map_id).Actualize_BBOX();
    
    	//document.getElementById("divWait").style.display = "none";	

      LayerManager.ShowQuery(queryid, param_array[1], map_list.maps.Item(map_list.map_id).query_url, 1);
      LayerManager.ShowAll();
      
      SetPosition();
    	//Prepni na zalozku mapa
    	ViewSwitch("OknoMapa")
    }  
    else
    {
  		ResultNotFound();
  		document.getElementById("divWait").style.display = "none";
  		return;
  	}
  }
  else
  {
  	//Prirazeni kolekce elementu s nazvem REC
  	RecNodes = xmlQueryResult.selectNodes("/REPORT/REC");

  	//Musi byt minimalne dva zaznamy aby byl nalezen vysledek (prvni je pomocny)
  	if(RecNodes.length > 1)
  	{
			//Nacteni pomocnych hodnot
			FldNodes = RecNodes.item(0).selectNodes("FLD");
		
			if (FldNodes.length > 1)
			{
				queryid = FldNodes.item(0).getAttribute("Value");
				querypar = FldNodes.item(1).getAttribute("Value");
			}
			else
			{
				alert(script_messages[16]);
				return;
			}
		
    	document.getElementById("divWait").style.display = "";
    
    	param_array = map.id.split("|");
    
    	//Transformace zobrazeni BBOXu
      //var a = new VBArray(ParseBBox(param_array[0]));
          
      BBoxArray = ParseBBox(param_array[0]);
    
    	BBoxArray = TransformBBox(BBoxArray, map_list.maps.Item(map_list.map_id).map_width,map_list.maps.Item(map_list.map_id).map_height);
    	
 			WrldWidth = BBoxArray[2] - BBoxArray[0];

			MapScale = Math.round(((((WrldWidth * map_list.maps.Item(map_list.map_id).projection_to_scale) / map_list.maps.Item(map_list.map_id).map_width) * 100) * (280/10)));
			
      if(parseInt(document.getElementById("selMaxScale").options[document.getElementById("selMaxScale").selectedIndex].value) > parseInt(MapScale))
			{
				MapScale = parseInt(document.getElementById("selMaxScale").options[document.getElementById("selMaxScale").selectedIndex].value);
				
        wrldhalfx = BBoxArray[0] + ((BBoxArray[2] - BBoxArray[0]) / 2);
				wrldhalfy = BBoxArray[1] + ((BBoxArray[3] - BBoxArray[1]) / 2);
				BBoxArray[0] = wrldhalfx - (((map_list.maps.Item(map_list.map_id).map_width / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
				BBoxArray[2] = wrldhalfx + (((map_list.maps.Item(map_list.map_id).map_width / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
				BBoxArray[1] = wrldhalfy - (((map_list.maps.Item(map_list.map_id).map_height / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
				BBoxArray[3] = wrldhalfy + (((map_list.maps.Item(map_list.map_id).map_height / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
			}
    
    	BBOX = dbl2StrEN(BBoxArray[0].toString()) + "," + dbl2StrEN(BBoxArray[1].toString()) + "," + dbl2StrEN(BBoxArray[2].toString()) + "," + dbl2StrEN(BBoxArray[3].toString());
      
      LayerManager.HideAll();
    	
      map_list.maps.Item(map_list.map_id).bbox = BBOX;
      map_list.maps.Item(map_list.map_id).Actualize_BBOX();

      LayerManager.ShowQuery(queryid, param_array[1], map_list.maps.Item(map_list.map_id).query_url, 1);
      
      LayerManager.ShowAll();
    	
    	SetPosition();
      //document.getElementById("divWait").style.display = "none";	
    
    	//'LayerManager.HideAll
    
    	//Aktualizace mapy
    	/*MAP_URL = document.all.map.src
    	MAP_URL = ReplaceBBOX(MAP_URL, BBOX)
    	MAP_URL = ReplaceLAYERS(MAP_URL, GetWMSLAYERS())
    	MAP_URL = ReplaceSTYLES(MAP_URL, GetWMSSTYLES())
    	document.all.map.src = MAP_URL*/
    
    
    	//Prepni na zalozku mapa
    	ViewSwitch("OknoMapa")
  	}
    else
    {
  		ResultNotFound();
  		document.getElementById("divWait").style.display = "none";
  		return;
  	}
	}
}
//****************************************************************************

function CallGetQueryResultIQS(map)
/*
 * Procedura realizujici zmenu mapoveho vyrezu tak aby obsahoval vybrany prvek
 * z vysledku dotazu.
 */
{
  var i;
	var j;
	var initialize;
	var queryid;
	var querypar;
	var RecNodes;
	var FldNodes;
	var TmpArray;
	var BBoxArray;
	var WrldWidth;
	var wrldhalfx;
	var wrldhalfy;
	var BBOX;
	var param_array;

	if(LayerManager.Query)
	{
    LayerManager.DeleteQuery();
	}

  var moz = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined');
  var ie = (typeof window.ActiveXObject != 'undefined'); 

  if(moz)
  {
    var xpe = new XPathEvaluator();
    var nsResolver = xpe.createNSResolver(xmlQueryResult.ownerDocument == null ? xmlQueryResult.documentElement : xmlQueryResult.ownerDocument.documentElement);

    RecNodes = xmlQueryResult.evaluate("ingr:QueryResult/ingr:TotalRecords", xmlQueryResult, nsResolver, 9, null);

    if(parseInt(RecNodes.singleNodeValue.firstChild.nodeValue.toString()) > 0)
    {
      FldNodes = xmlQueryResult.evaluate("/ingr:QueryResult/ingr:QueryID", xmlQueryResult, nsResolver, 9, null);

      if(FldNodes != null)
      {
				queryid = FldNodes.singleNodeValue.firstChild.nodeValue.toString();
			}
			else
			{
				alert(script_messages[16]);
				return;
			}

    	if(LayerManager.Query)
    	{
        LayerManager.DeleteQuery();
    	}

    	document.getElementById("divWait").style.display = "";
    
    	param_array = map.split("|");
    
    	//Transformace zobrazeni BBOXu
      BBoxArray = ParseBBox(param_array[0]);
    
    	BBoxArray = TransformBBox(BBoxArray, map_list.maps.Item(map_list.map_id).map_width,map_list.maps.Item(map_list.map_id).map_height);
    	
 			WrldWidth = BBoxArray[2] - BBoxArray[0];

			MapScale = Math.round(((((WrldWidth * map_list.maps.Item(map_list.map_id).projection_to_scale) / map_list.maps.Item(map_list.map_id).map_width) * 100) * (280/10)));
			
      if(parseInt(document.getElementById("selMaxScale").options[document.getElementById("selMaxScale").selectedIndex].value) > parseInt(MapScale))
			{
				MapScale = parseInt(document.getElementById("selMaxScale").options[document.getElementById("selMaxScale").selectedIndex].value);
				
        wrldhalfx = BBoxArray[0] + ((BBoxArray[2] - BBoxArray[0]) / 2);
				wrldhalfy = BBoxArray[1] + ((BBoxArray[3] - BBoxArray[1]) / 2);
				BBoxArray[0] = wrldhalfx - (((map_list.maps.Item(map_list.map_id).map_width / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
				BBoxArray[2] = wrldhalfx + (((map_list.maps.Item(map_list.map_id).map_width / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
				BBoxArray[1] = wrldhalfy - (((map_list.maps.Item(map_list.map_id).map_height / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
				BBoxArray[3] = wrldhalfy + (((map_list.maps.Item(map_list.map_id).map_height / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
			}
    
    	BBOX = dbl2StrEN(BBoxArray[0].toString()) + "," + dbl2StrEN(BBoxArray[1].toString()) + "," + dbl2StrEN(BBoxArray[2].toString()) + "," + dbl2StrEN(BBoxArray[3].toString());
      
      LayerManager.HideAll();
    	
      map_list.maps.Item(map_list.map_id).bbox = BBOX;
      map_list.maps.Item(map_list.map_id).Actualize_BBOX();

      LayerManager.ShowQuery(queryid, param_array[1], map_list.maps.Item(map_list.map_id).query_url, 1);
      
      LayerManager.ShowAll();
    	
    	SetPosition();
    
    	//Prepni na zalozku mapa
    	ViewSwitch("OknoMapa")
    }  
    else
    {
  		ResultNotFound();
  		document.getElementById("divWait").style.display = "none";
  		return;
  	}
  }
  else
  {
  	//Prirazeni kolekce elementu s nazvem REC
  	RecNodes = xmlQueryResult.selectSingleNode("/ingr:QueryResult/ingr:TotalRecords");
  
  	//Musi byt minimalne dva zaznamy aby byl nalezen vysledek (prvni je pomocny)
  	if(parseInt(RecNodes.text) > 0)
  	{
			//Nacteni pomocnych hodnot
			FldNodes = xmlQueryResult.selectSingleNode("/ingr:QueryResult/ingr:QueryID");
		
			if (FldNodes != null)
			{
				queryid = FldNodes.text;
			}
			else
			{
				alert(script_messages[16]);
				return;
			}

    	document.getElementById("divWait").style.display = "";
    
    	param_array = map.split("|");

    	//Transformace zobrazeni BBOXu
      BBoxArray = ParseBBox(param_array[0]);
    
    	BBoxArray = TransformBBox(BBoxArray, map_list.maps.Item(map_list.map_id).map_width,map_list.maps.Item(map_list.map_id).map_height);
    	
 			WrldWidth = BBoxArray[2] - BBoxArray[0];

			MapScale = Math.round(((((WrldWidth * map_list.maps.Item(map_list.map_id).projection_to_scale) / map_list.maps.Item(map_list.map_id).map_width) * 100) * (280/10)));
			
      if(parseInt(document.getElementById("selMaxScale").options[document.getElementById("selMaxScale").selectedIndex].value) > parseInt(MapScale))
			{
				MapScale = parseInt(document.getElementById("selMaxScale").options[document.getElementById("selMaxScale").selectedIndex].value);
				
        wrldhalfx = BBoxArray[0] + ((BBoxArray[2] - BBoxArray[0]) / 2);
				wrldhalfy = BBoxArray[1] + ((BBoxArray[3] - BBoxArray[1]) / 2);
				BBoxArray[0] = wrldhalfx - (((map_list.maps.Item(map_list.map_id).map_width / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
				BBoxArray[2] = wrldhalfx + (((map_list.maps.Item(map_list.map_id).map_width / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
				BBoxArray[1] = wrldhalfy - (((map_list.maps.Item(map_list.map_id).map_height / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
				BBoxArray[3] = wrldhalfy + (((map_list.maps.Item(map_list.map_id).map_height / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
			}
    
    	BBOX = dbl2StrEN(BBoxArray[0].toString()) + "," + dbl2StrEN(BBoxArray[1].toString()) + "," + dbl2StrEN(BBoxArray[2].toString()) + "," + dbl2StrEN(BBoxArray[3].toString());
      
      LayerManager.HideAll();
    	
      map_list.maps.Item(map_list.map_id).bbox = BBOX;
      map_list.maps.Item(map_list.map_id).Actualize_BBOX();

      LayerManager.ShowQuery(queryid, param_array[1], map_list.maps.Item(map_list.map_id).query_url, 1);
      
      LayerManager.ShowAll();
    	
    	SetPosition();
    
    	//Prepni na zalozku mapa
    	ViewSwitch("OknoMapa")
  	}
    else
    {
  		ResultNotFound();
  		document.getElementById("divWait").style.display = "none";
  		return;
  	}
		
	}
}
//****************************************************************************

function btnQShowSelected_Click()
{
/*
 * Procedura realizujici XML transformaci vysledku dotazu.
 */

	var initialize;
	var queryid;
	var querypar;
	var RecNodes;
	var FldNodes;
	var BBoxArray, TmpArray;
	
	var map_param;

  initialize = false;
  
	if(LayerManager.Query)
	{
		LayerManager.DeleteQuery();
	}

  var moz = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined');
  var ie = (typeof window.ActiveXObject != 'undefined'); 

  if(moz)
  {
    RecNodes = xmlQueryResult.evaluate("REPORT/REC", xmlQueryResult, null, 7, null);

    if(RecNodes.snapshotLength > 0)
    {
  		initialize = true;
		
  		map_param = "";
		
      FldNodes = xmlQueryResult.evaluate("FLD", RecNodes.snapshotItem(0), null, 7, null);

      if(FldNodes.snapshotLength > 1)
      {
				queryid = FldNodes.snapshotItem(0).getAttribute("Value");
				querypar = FldNodes.snapshotItem(1).getAttribute("Value");
			}
			else
			{
				alert(script_messages[16]);
				return;
			}

  		for(var j = 1; j < RecNodes.snapshotLength; j++)
  		{
        if (document.getElementById("chbQuery_" + (j + 1).toString()).checked)
  			{
  				map_param = map_param + RecNodes.snapshotItem(j).getAttribute("Param") + ";";
  
          FldNodes = xmlQueryResult.evaluate("FLD", RecNodes.snapshotItem(j), null, 7, null);
    
    			if (FldNodes.snapshotLength > 0)
    			{
    				for(var i = 0; i < FldNodes.snapshotLength; i++)
    				{
    					if (FldNodes.snapshotItem(i).getAttribute("Name").toUpperCase() == "BBOX")
    					{
    						BBOX = FldNodes.snapshotItem(i).getAttribute("Value");
    						break;
    					}
    				}
  
    				if (BBOX == "")
    				{
    					alert(script_messages[17]);
    					return;
    				}
    				
            if(initialize)
            {
              initialize = false;
              BBoxArray = ParseBBox(BBOX);
            }
            else
            {
              TmpArray = ParseBBox(BBOX);

  						if (parseFloat(TmpArray[0]) < parseFloat(BBoxArray[0]))
  						{
  							BBoxArray[0] = parseFloat(TmpArray[0]);
  						}
  
  						if (parseFloat(TmpArray[1]) < parseFloat(BBoxArray[1]))
  						{
  							BBoxArray[1] = parseFloat(TmpArray[1]);
  						}
  
  						if (parseFloat(TmpArray[2]) > parseFloat(BBoxArray[2]))
  						{
  							BBoxArray[2] = parseFloat(TmpArray[2]);
  						} 
  
  						if (parseFloat(TmpArray[3]) > parseFloat(BBoxArray[3]))
  						{
  							BBoxArray[3] = parseFloat(TmpArray[3]);
  						}
            }
          }
    			else
    			{
    				alert(script_messages[17]);
    				return;
    			}
  			}		
  		}

      if(map_param != "")
      {
        map_param = map_param.substr(0, map_param.length-1);
      }
        		
    	BBoxArray = TransformBBox(BBoxArray, map_list.maps.Item(map_list.map_id).map_width,map_list.maps.Item(map_list.map_id).map_height);
  			
    	BBOX = dbl2StrEN(BBoxArray[0].toString()) + "," + dbl2StrEN(BBoxArray[1].toString()) + "," + dbl2StrEN(BBoxArray[2].toString()) + "," + dbl2StrEN(BBoxArray[3].toString());
      
      LayerManager.HideAll();
    
    	map_list.maps.Item(map_list.map_id).bbox = BBOX;
      map_list.maps.Item(map_list.map_id).Actualize_BBOX();

      LayerManager.ShowQuery(queryid, map_param, map_list.maps.Item(map_list.map_id).query_url, 1);
      
      LayerManager.ShowAll();
    
      SetPosition();
    	//document.getElementById("divWait").style.display = "none";	
  
      ViewSwitch("OknoMapa");

    }  
    else
    {
  		ResultNotFound();
  		document.getElementById("divWait").style.display = "none";
  		return;
  	}
  }
  else
  {
  	//Prirazeni kolekce elementu s nazvem REC
  	RecNodes = xmlQueryResult.selectNodes("/REPORT/REC");

  	//Musi byt minimalne dva zaznamy aby byl nalezen vysledek (prvni je pomocny)
  	if(RecNodes.length > 1)
  	{
  		initialize = true;
		
  		map_param = "";
		
			//Nacteni pomocnych hodnot
			FldNodes = RecNodes.item(0).selectNodes("FLD");
		
			if (FldNodes.length > 1)
			{
				queryid = FldNodes.item(0).getAttribute("Value");
				querypar = FldNodes.item(1).getAttribute("Value");
			}
			else
			{
				alert(script_messages[16]);
				return;
			}
		
  		//Pro vsechny zaznamy delej (kvuli tomu, ze vysledkem nemusi byt jedna plocha)
  		for(var j = 1; j < RecNodes.length; j++)
  		{
        if (document.getElementById("chbQuery_" + (j + 1).toString()).checked)
  			{
  				map_param = map_param + RecNodes.item(j).getAttribute("Param") + ";";
  
    			//Prirazeni kolekce elementu s nazvem FLD
    			FldNodes = RecNodes.item(j).selectNodes("FLD");
    
    			if (FldNodes.length > 0)
    			{
    				for(var i = 0; i < FldNodes.length; i++)
    				{
    					if (FldNodes.item(i).getAttribute("Name").toUpperCase() == "BBOX")
    					{
    						BBOX = FldNodes.item(i).getAttribute("Value");
    						break;
    					}
    				}
  
    				if (BBOX == "")
    				{
    					alert(script_messages[17]);
    					return;
    				}
    				
            if(initialize)
            {
              initialize = false;
              BBoxArray = ParseBBox(BBOX);
            }
            else
            {
              TmpArray = ParseBBox(BBOX);

  						if (parseFloat(TmpArray[0]) < parseFloat(BBoxArray[0]))
  						{
  							BBoxArray[0] = parseFloat(TmpArray[0]);
  						}
  
  						if (parseFloat(TmpArray[1]) < parseFloat(BBoxArray[1]))
  						{
  							BBoxArray[1] = parseFloat(TmpArray[1]);
  						}
  
  						if (parseFloat(TmpArray[2]) > parseFloat(BBoxArray[2]))
  						{
  							BBoxArray[2] = parseFloat(TmpArray[2]);
  						} 
  
  						if (parseFloat(TmpArray[3]) > parseFloat(BBoxArray[3]))
  						{
  							BBoxArray[3] = parseFloat(TmpArray[3]);
  						}
            }
          }
    			else
    			{
    				alert(script_messages[17]);
    				return;
    			}
  			}		
  		}

      if(map_param != "")
      {
        map_param = map_param.substr(0, map_param.length-1);
      }
  		
  		/*if(map_param != "")
  		{
  			map_param = Left(map_param, Len(map_param)-1)
  		}*/
  
//      BBoxArray = ParseBBox(param_array[0]);
    
    	BBoxArray = TransformBBox(BBoxArray, map_list.maps.Item(map_list.map_id).map_width,map_list.maps.Item(map_list.map_id).map_height);
  
 			WrldWidth = BBoxArray[2] - BBoxArray[0];

			MapScale = Math.round(((((WrldWidth * map_list.maps.Item(map_list.map_id).projection_to_scale) / map_list.maps.Item(map_list.map_id).map_width) * 100) * (280/10)));
			
      if(parseInt(document.getElementById("selMaxScale").options[document.getElementById("selMaxScale").selectedIndex].value) > parseInt(MapScale))
			{
				MapScale = parseInt(document.getElementById("selMaxScale").options[document.getElementById("selMaxScale").selectedIndex].value);
				
        wrldhalfx = BBoxArray[0] + ((BBoxArray[2] - BBoxArray[0]) / 2);
				wrldhalfy = BBoxArray[1] + ((BBoxArray[3] - BBoxArray[1]) / 2);
				BBoxArray[0] = wrldhalfx - (((map_list.maps.Item(map_list.map_id).map_width / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
				BBoxArray[2] = wrldhalfx + (((map_list.maps.Item(map_list.map_id).map_width / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
				BBoxArray[1] = wrldhalfy - (((map_list.maps.Item(map_list.map_id).map_height / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
				BBoxArray[3] = wrldhalfy + (((map_list.maps.Item(map_list.map_id).map_height / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
			}
  			
    	BBOX = dbl2StrEN(BBoxArray[0].toString()) + "," + dbl2StrEN(BBoxArray[1].toString()) + "," + dbl2StrEN(BBoxArray[2].toString()) + "," + dbl2StrEN(BBoxArray[3].toString());

      LayerManager.HideAll();
    
    	map_list.maps.Item(map_list.map_id).bbox = BBOX;
      map_list.maps.Item(map_list.map_id).Actualize_BBOX();

      LayerManager.ShowQuery(queryid, map_param, map_list.maps.Item(map_list.map_id).query_url, 1);
      
      LayerManager.ShowAll();
      
      SetPosition();
    	//document.getElementById("divWait").style.display = "none";	
  
/*  		LayerManager.HideAll
  		
  		'Aktualizace mapy
  		MAP_URL = document.all.map.src
  		MAP_URL = ReplaceBBOX(MAP_URL, BBOX)
  		MAP_URL = ReplaceLAYERS(MAP_URL, GetWMSLAYERS())
  		MAP_URL = ReplaceSTYLES(MAP_URL, GetWMSSTYLES())
  		document.all.map.src = MAP_URL
  
  
  		'Aktualizace klikaci mapy
  		MAP_URL = document.all.ClickMapSrc.src
  		MAP_URL = ReplaceBBOX(MAP_URL, BBOX)
  		document.all.ClickMapSrc.src = MAP_URL
  
  		LayerManager.ShowQuery queryid, map_param, map_list.maps.Item(map_list.map_id).query_url, 1
  
  		LayerManager.ShowAll
  
  		MapHistory.Add "Mapový výřez", document.all.map.src , document.all.ClickMapSrc.src, document.all.varActiveFeature.value, document.all.QueryMap.src, document.all.SelectMap.src, window.status
  		UpdateHistory*/

      ViewSwitch("OknoMapa");
  	}
    else
    {
  		ResultNotFound();
  		document.getElementById("divWait").style.display = "none";
  		return;
  	}
	}	
}
//****************************************************************************

function btnQShowSelectedIQS_Click()
{
/*
 * Procedura realizujici XML transformaci vysledku dotazu.
 */

	var initialize;
	var queryid, queryidcol, ids;
	var querypar;
	var RecNodes;
	var FldNodes;
	var BBoxArray, TmpArray;
	
	var map_param;

  initialize = false;
  
	if(LayerManager.Query)
	{
		LayerManager.DeleteQuery();
	}

  var moz = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined');
  var ie = (typeof window.ActiveXObject != 'undefined'); 

  if(moz)
  {
    var xpe = new XPathEvaluator();
    var nsResolver = xpe.createNSResolver(xmlQueryResult.ownerDocument == null ? xmlQueryResult.documentElement : xmlQueryResult.ownerDocument.documentElement);

    RecNodes = xmlQueryResult.evaluate("/ingr:QueryResult/ingr:TotalRecords", xmlQueryResult, nsResolver, 9, null);

    if(parseInt(RecNodes.singleNodeValue.firstChild.nodeValue.toString()) > 0)
    {
  		initialize = true;
		
  		map_param = "";
            
      FldNodes = xmlQueryResult.evaluate("/ingr:QueryResult/ingr:QueryID", xmlQueryResult, nsResolver, 9, null);

      if(FldNodes != null)
      {
				queryid = FldNodes.singleNodeValue.firstChild.nodeValue.toString();
			}
			else
			{
				alert(script_messages[16]);
				return;
			}

			//Nacteni pomocnych hodnot
			FldNodes = xmlQueryResult.evaluate("ingr:QueryResult/ingr:PkeyColumns", xmlQueryResult, nsResolver, 9, null);
			if (FldNodes != null)
			{
				queryidcol = FldNodes.singleNodeValue.childNodes[1].getAttribute("name");
			}
			else
			{
				alert(script_messages[16]);
				return;
			}

      RecNodes = xmlQueryResult.evaluate("/ingr:QueryResult/ingr:RowSet/ingr:Row", xmlQueryResult, nsResolver, 7, null);

  		for(var j = 0; j < RecNodes.snapshotLength; j++)
  		{
        if (document.getElementById("chbQuery_" + (j + 1).toString()).checked)
  			{
        	//Pro kazdy element REC delej
        	for(var i = 0; i < RecNodes.snapshotItem(j).childNodes.length; i++)
        	{
            if(RecNodes.snapshotItem(j).childNodes[i].nodeName.toLowerCase()== 'column')
            {
              if(RecNodes.snapshotItem(j).childNodes[i].getAttribute("name").toLowerCase() == queryidcol.toLowerCase())
              { 
                ids = RecNodes.snapshotItem(j).childNodes[i].firstChild.nodeValue;
              }
            } 
          }
  				
          map_param = map_param + ids + ",";
  
					BBOX = RecNodes.snapshotItem(j).getAttribute("bbox").toString();
  
  				if (BBOX == "")
  				{
  					alert(script_messages[17]);
  					return;
  				}
  				
          if(initialize)
          {
            initialize = false;
            BBoxArray = ParseBBox(BBOX);
          }
          else
          {
            TmpArray = ParseBBox(BBOX);

						if (parseFloat(TmpArray[0]) < parseFloat(BBoxArray[0]))
						{
							BBoxArray[0] = parseFloat(TmpArray[0]);
						}

						if (parseFloat(TmpArray[1]) < parseFloat(BBoxArray[1]))
						{
							BBoxArray[1] = parseFloat(TmpArray[1]);
						}

						if (parseFloat(TmpArray[2]) > parseFloat(BBoxArray[2]))
						{
							BBoxArray[2] = parseFloat(TmpArray[2]);
						} 

						if (parseFloat(TmpArray[3]) > parseFloat(BBoxArray[3]))
						{
							BBoxArray[3] = parseFloat(TmpArray[3]);
						}
          }
  			}		
  		}

      if(map_param != "")
      {
        map_param = map_param.substr(0, map_param.length-1);
      }

    	BBoxArray = TransformBBox(BBoxArray, map_list.maps.Item(map_list.map_id).map_width,map_list.maps.Item(map_list.map_id).map_height);
  			
    	BBOX = dbl2StrEN(BBoxArray[0].toString()) + "," + dbl2StrEN(BBoxArray[1].toString()) + "," + dbl2StrEN(BBoxArray[2].toString()) + "," + dbl2StrEN(BBoxArray[3].toString());
      
      LayerManager.HideAll();
    
    	map_list.maps.Item(map_list.map_id).bbox = BBOX;
      map_list.maps.Item(map_list.map_id).Actualize_BBOX();

      LayerManager.ShowQuery(queryid, map_param, map_list.maps.Item(map_list.map_id).query_url, 1);
      
      LayerManager.ShowAll();
    
      SetPosition();
    	//document.getElementById("divWait").style.display = "none";	
  
      ViewSwitch("OknoMapa");

    }  
    else
    {
  		ResultNotFound();
  		document.getElementById("divWait").style.display = "none";
  		return;
  	}
  }
  else
  {
  	//Prirazeni kolekce elementu s nazvem REC
  	RecNodes = xmlQueryResult.selectSingleNode("/ingr:QueryResult/ingr:TotalRecords");
  
  	//Musi byt minimalne dva zaznamy aby byl nalezen vysledek (prvni je pomocny)
  	if(parseInt(RecNodes.text) > 0)
  	{
			//Nacteni pomocnych hodnot
			FldNodes = xmlQueryResult.selectSingleNode("/ingr:QueryResult/ingr:QueryID");
		
			if (FldNodes != null)
			{
				queryid = FldNodes.text;
			}
			else
			{
				alert(script_messages[16]);
				return;
			}

			//Nacteni pomocnych hodnot
			FldNodes = xmlQueryResult.selectSingleNode("/ingr:QueryResult/ingr:PkeyColumns/column[0]");
		
			if (FldNodes != null)
			{
				queryidcol = FldNodes.getAttribute("name");
			}
			else
			{
				alert(script_messages[16]);
				return;
			}

  		initialize = true;
		
  		map_param = "";
		
    	//Prirazeni kolekce elementu s nazvem REC
    	RecNodes = xmlQueryResult.selectNodes("/ingr:QueryResult/ingr:RowSet/ingr:Row");
		
  		//Pro vsechny zaznamy delej (kvuli tomu, ze vysledkem nemusi byt jedna plocha)
  		for(var j = 0; j < RecNodes.length; j++)
  		{
        if (document.getElementById("chbQuery_" + (j + 1).toString()).checked)
  			{
          var xmlCNodes = RecNodes.item(j).selectNodes("column");
          
          //Pro kazdy element REC delej
        	for(var i = 0; i < xmlCNodes.length; i++)
        	{
            if(xmlCNodes.item(i).getAttribute("name").toLowerCase() == queryidcol.toLowerCase())
            { 
              ids = xmlCNodes.item(i).text;
            }
          }
  				
          map_param = map_param + ids + ",";

  				BBOX = RecNodes.item(j).getAttribute("bbox");

  				if (BBOX == "")
  				{
  					alert(script_messages[17]);
  					return;
  				}
  				
          if(initialize)
          {
            initialize = false;
            BBoxArray = ParseBBox(BBOX);
          }
          else
          {
            TmpArray = ParseBBox(BBOX);

						if (parseFloat(TmpArray[0]) < parseFloat(BBoxArray[0]))
						{
							BBoxArray[0] = parseFloat(TmpArray[0]);
						}

						if (parseFloat(TmpArray[1]) < parseFloat(BBoxArray[1]))
						{
							BBoxArray[1] = parseFloat(TmpArray[1]);
						}

						if (parseFloat(TmpArray[2]) > parseFloat(BBoxArray[2]))
						{
							BBoxArray[2] = parseFloat(TmpArray[2]);
						} 

						if (parseFloat(TmpArray[3]) > parseFloat(BBoxArray[3]))
						{
							BBoxArray[3] = parseFloat(TmpArray[3]);
						}
          }
  			}		
  		}

      if(map_param != "")
      {
        map_param = map_param.substr(0, map_param.length-1);
      }

//      BBoxArray = ParseBBox(param_array[0]);
    
    	BBoxArray = TransformBBox(BBoxArray, map_list.maps.Item(map_list.map_id).map_width,map_list.maps.Item(map_list.map_id).map_height);
  
 			WrldWidth = BBoxArray[2] - BBoxArray[0];

			MapScale = Math.round(((((WrldWidth * map_list.maps.Item(map_list.map_id).projection_to_scale) / map_list.maps.Item(map_list.map_id).map_width) * 100) * (280/10)));
			
      if(parseInt(document.getElementById("selMaxScale").options[document.getElementById("selMaxScale").selectedIndex].value) > parseInt(MapScale))
			{
				MapScale = parseInt(document.getElementById("selMaxScale").options[document.getElementById("selMaxScale").selectedIndex].value);
				
        wrldhalfx = BBoxArray[0] + ((BBoxArray[2] - BBoxArray[0]) / 2);
				wrldhalfy = BBoxArray[1] + ((BBoxArray[3] - BBoxArray[1]) / 2);
				BBoxArray[0] = wrldhalfx - (((map_list.maps.Item(map_list.map_id).map_width / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
				BBoxArray[2] = wrldhalfx + (((map_list.maps.Item(map_list.map_id).map_width / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
				BBoxArray[1] = wrldhalfy - (((map_list.maps.Item(map_list.map_id).map_height / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
				BBoxArray[3] = wrldhalfy + (((map_list.maps.Item(map_list.map_id).map_height / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
			}
  			
    	BBOX = dbl2StrEN(BBoxArray[0].toString()) + "," + dbl2StrEN(BBoxArray[1].toString()) + "," + dbl2StrEN(BBoxArray[2].toString()) + "," + dbl2StrEN(BBoxArray[3].toString());

      LayerManager.HideAll();
    
    	map_list.maps.Item(map_list.map_id).bbox = BBOX;
      map_list.maps.Item(map_list.map_id).Actualize_BBOX();

      LayerManager.ShowQuery(queryid, map_param, map_list.maps.Item(map_list.map_id).query_url, 1);
      
      LayerManager.ShowAll();
      
      SetPosition();
    	//document.getElementById("divWait").style.display = "none";	
  
/*  		LayerManager.HideAll
  		
  		'Aktualizace mapy
  		MAP_URL = document.all.map.src
  		MAP_URL = ReplaceBBOX(MAP_URL, BBOX)
  		MAP_URL = ReplaceLAYERS(MAP_URL, GetWMSLAYERS())
  		MAP_URL = ReplaceSTYLES(MAP_URL, GetWMSSTYLES())
  		document.all.map.src = MAP_URL
  
  
  		'Aktualizace klikaci mapy
  		MAP_URL = document.all.ClickMapSrc.src
  		MAP_URL = ReplaceBBOX(MAP_URL, BBOX)
  		document.all.ClickMapSrc.src = MAP_URL
  
  		LayerManager.ShowQuery queryid, map_param, map_list.maps.Item(map_list.map_id).query_url, 1
  
  		LayerManager.ShowAll
  
  		MapHistory.Add "Mapový výřez", document.all.map.src , document.all.ClickMapSrc.src, document.all.varActiveFeature.value, document.all.QueryMap.src, document.all.SelectMap.src, window.status
  		UpdateHistory*/

      ViewSwitch("OknoMapa");
  	}
    else
    {
  		ResultNotFound();
  		document.getElementById("divWait").style.display = "none";
  		return;
  	}
	}	
}
//****************************************************************************

function btnQShowAll_Click()
{
/*
 * Procedura realizujici XML transformaci vysledku dotazu.
 */

	var initialize;
	var queryid;
	var querypar;
	var RecNodes;
	var FldNodes;
	var BBoxArray, TmpArray;
	
  initialize = false;
  
	if(LayerManager.Query)
	{
		LayerManager.DeleteQuery();
	}

  var moz = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined');
  var ie = (typeof window.ActiveXObject != 'undefined'); 

  if(moz)
  {
    RecNodes = xmlQueryResult.evaluate("REPORT/REC", xmlQueryResult, null, 7, null);

    if(RecNodes.snapshotLength > 0)
    {
  		initialize = true;
		
      FldNodes = xmlQueryResult.evaluate("FLD", RecNodes.snapshotItem(0), null, 7, null);

      if(FldNodes.snapshotLength > 1)
      {
				queryid = FldNodes.snapshotItem(0).getAttribute("Value");
				querypar = FldNodes.snapshotItem(1).getAttribute("Value");
			}
			else
			{
				alert(script_messages[16]);
				return;
			}

  		for(var j = 1; j < RecNodes.snapshotLength; j++)
  		{
        FldNodes = xmlQueryResult.evaluate("FLD", RecNodes.snapshotItem(j), null, 7, null);
  
  			if (FldNodes.snapshotLength > 0)
  			{
  				for(var i = 0; i < FldNodes.snapshotLength; i++)
  				{
  					if (FldNodes.snapshotItem(i).getAttribute("Name").toUpperCase() == "BBOX")
  					{
  						BBOX = FldNodes.snapshotItem(i).getAttribute("Value");
  						break;
  					}
  				}

  				if (BBOX == "")
  				{
  					alert(script_messages[17]);
  					return;
  				}
  				
          if(initialize)
          {
            initialize = false;
            BBoxArray = ParseBBox(BBOX);
          }
          else
          {
            TmpArray = ParseBBox(BBOX);

						if (parseFloat(TmpArray[0]) < parseFloat(BBoxArray[0]))
						{
							BBoxArray[0] = parseFloat(TmpArray[0]);
						}

						if (parseFloat(TmpArray[1]) < parseFloat(BBoxArray[1]))
						{
							BBoxArray[1] = parseFloat(TmpArray[1]);
						}

						if (parseFloat(TmpArray[2]) > parseFloat(BBoxArray[2]))
						{
							BBoxArray[2] = parseFloat(TmpArray[2]);
						} 

						if (parseFloat(TmpArray[3]) > parseFloat(BBoxArray[3]))
						{
							BBoxArray[3] = parseFloat(TmpArray[3]);
						}
          }
  			}		
  		}
  		
    	BBoxArray = TransformBBox(BBoxArray, map_list.maps.Item(map_list.map_id).map_width,map_list.maps.Item(map_list.map_id).map_height);
  			
    	BBOX = dbl2StrEN(BBoxArray[0].toString()) + "," + dbl2StrEN(BBoxArray[1].toString()) + "," + dbl2StrEN(BBoxArray[2].toString()) + "," + dbl2StrEN(BBoxArray[3].toString());
    
      LayerManager.HideAll();
      
    	map_list.maps.Item(map_list.map_id).bbox = BBOX;
      map_list.maps.Item(map_list.map_id).Actualize_BBOX();
   
      LayerManager.ShowQuery(queryid, querypar, map_list.maps.Item(map_list.map_id).query_url, 0);
      
      LayerManager.ShowAll();
 
      SetPosition();
    	//document.getElementById("divWait").style.display = "none";	
  
      ViewSwitch("OknoMapa");
    }  
    else
    {
  		ResultNotFound();
  		document.getElementById("divWait").style.display = "none";
  		return;
  	}
  }
  else
  {
  	//Prirazeni kolekce elementu s nazvem REC
  	RecNodes = xmlQueryResult.selectNodes("/REPORT/REC");

  	//Musi byt minimalne dva zaznamy aby byl nalezen vysledek (prvni je pomocny)
  	if(RecNodes.length > 1)
  	{
  		initialize = true;
		
			//Nacteni pomocnych hodnot
			FldNodes = RecNodes.item(0).selectNodes("FLD");
		
			if (FldNodes.length > 1)
			{
				queryid = FldNodes.item(0).getAttribute("Value");
				querypar = FldNodes.item(1).getAttribute("Value");
			}
			else
			{
				alert(script_messages[16]);
				return;
			}
		
  		//Pro vsechny zaznamy delej (kvuli tomu, ze vysledkem nemusi byt jedna plocha)
  		for(var j = 1; j < RecNodes.length; j++)
  		{
  			//Prirazeni kolekce elementu s nazvem FLD
  			FldNodes = RecNodes.item(j).selectNodes("FLD");
  
  			if (FldNodes.length > 0)
  			{
  				for(var i = 0; i < FldNodes.length; i++)
  				{
  					if (FldNodes.item(i).getAttribute("Name").toUpperCase() == "BBOX")
  					{
  						BBOX = FldNodes.item(i).getAttribute("Value");
  						break;
  					}
  				}

  				if (BBOX == "")
  				{
  					alert(script_messages[17]);
  					return;
  				}
  				
          if(initialize)
          {
            initialize = false;
            BBoxArray = ParseBBox(BBOX);
          }
          else
          {
            TmpArray = ParseBBox(BBOX);

						if (parseFloat(TmpArray[0]) < parseFloat(BBoxArray[0]))
						{
							BBoxArray[0] = parseFloat(TmpArray[0]);
						}

						if (parseFloat(TmpArray[1]) < parseFloat(BBoxArray[1]))
						{
							BBoxArray[1] = parseFloat(TmpArray[1]);
						}

						if (parseFloat(TmpArray[2]) > parseFloat(BBoxArray[2]))
						{
							BBoxArray[2] = parseFloat(TmpArray[2]);
						} 

						if (parseFloat(TmpArray[3]) > parseFloat(BBoxArray[3]))
						{
							BBoxArray[3] = parseFloat(TmpArray[3]);
						}
          }
        }
  			else
  			{
 					alert(script_messages[17]);
  				return;
  			}
  		}
  		
  		/*if(map_param != "")
  		{
  			map_param = Left(map_param, Len(map_param)-1)
  		}*/
  
//      BBoxArray = ParseBBox(param_array[0]);
    
    	BBoxArray = TransformBBox(BBoxArray, map_list.maps.Item(map_list.map_id).map_width,map_list.maps.Item(map_list.map_id).map_height);
  
 			WrldWidth = BBoxArray[2] - BBoxArray[0];

			MapScale = Math.round(((((WrldWidth * map_list.maps.Item(map_list.map_id).projection_to_scale) / map_list.maps.Item(map_list.map_id).map_width) * 100) * (280/10)));
			
      if(parseInt(document.getElementById("selMaxScale").options[document.getElementById("selMaxScale").selectedIndex].value) > parseInt(MapScale))
			{
				MapScale = parseInt(document.getElementById("selMaxScale").options[document.getElementById("selMaxScale").selectedIndex].value);
				
        wrldhalfx = BBoxArray[0] + ((BBoxArray[2] - BBoxArray[0]) / 2);
				wrldhalfy = BBoxArray[1] + ((BBoxArray[3] - BBoxArray[1]) / 2);
				BBoxArray[0] = wrldhalfx - (((map_list.maps.Item(map_list.map_id).map_width / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
				BBoxArray[2] = wrldhalfx + (((map_list.maps.Item(map_list.map_id).map_width / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
				BBoxArray[1] = wrldhalfy - (((map_list.maps.Item(map_list.map_id).map_height / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
				BBoxArray[3] = wrldhalfy + (((map_list.maps.Item(map_list.map_id).map_height / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
			}
  			
    	BBOX = dbl2StrEN(BBoxArray[0].toString()) + "," + dbl2StrEN(BBoxArray[1].toString()) + "," + dbl2StrEN(BBoxArray[2].toString()) + "," + dbl2StrEN(BBoxArray[3].toString());
      
      LayerManager.HideAll();
          
    	map_list.maps.Item(map_list.map_id).bbox = BBOX;
      map_list.maps.Item(map_list.map_id).Actualize_BBOX();

      LayerManager.ShowQuery(queryid, querypar, map_list.maps.Item(map_list.map_id).query_url, 0);
      
      LayerManager.ShowAll();
    
      SetPosition();
    	//document.getElementById("divWait").style.display = "none";	
  
/*  		LayerManager.HideAll
  		
  		'Aktualizace mapy
  		MAP_URL = document.all.map.src
  		MAP_URL = ReplaceBBOX(MAP_URL, BBOX)
  		MAP_URL = ReplaceLAYERS(MAP_URL, GetWMSLAYERS())
  		MAP_URL = ReplaceSTYLES(MAP_URL, GetWMSSTYLES())
  		document.all.map.src = MAP_URL
  
  
  		'Aktualizace klikaci mapy
  		MAP_URL = document.all.ClickMapSrc.src
  		MAP_URL = ReplaceBBOX(MAP_URL, BBOX)
  		document.all.ClickMapSrc.src = MAP_URL
  
  		LayerManager.ShowQuery queryid, map_param, map_list.maps.Item(map_list.map_id).query_url, 1
  
  		LayerManager.ShowAll
  
  		MapHistory.Add "Mapový výřez", document.all.map.src , document.all.ClickMapSrc.src, document.all.varActiveFeature.value, document.all.QueryMap.src, document.all.SelectMap.src, window.status
  		UpdateHistory*/

      ViewSwitch("OknoMapa");
  	}
    else
    {
  		ResultNotFound();
  		document.getElementById("divWait").style.display = "none";
  		return;
  	}
	}	
}
//****************************************************************************

function btnQShowAllIQS_Click()
{
/*
 * Procedura realizujici XML transformaci vysledku dotazu.
 */

	var initialize;
	var queryid, queryidcol, ids;
	var querypar;
	var RecNodes;
	var FldNodes;
	var BBoxArray, TmpArray;
	
  initialize = false;
  
	if(LayerManager.Query)
	{
		LayerManager.DeleteQuery();
	}

  var moz = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined');
  var ie = (typeof window.ActiveXObject != 'undefined'); 

  if(moz)
  {
    var xpe = new XPathEvaluator();
    var nsResolver = xpe.createNSResolver(xmlQueryResult.ownerDocument == null ? xmlQueryResult.documentElement : xmlQueryResult.ownerDocument.documentElement);

    RecNodes = xmlQueryResult.evaluate("/ingr:QueryResult/ingr:TotalRecords", xmlQueryResult, nsResolver, 9, null);

    if(parseInt(RecNodes.singleNodeValue.firstChild.nodeValue.toString()) > 0)
    {
  		initialize = true;
		
  		map_param = "";
            
      FldNodes = xmlQueryResult.evaluate("/ingr:QueryResult/ingr:QueryID", xmlQueryResult, nsResolver, 9, null);

      if(FldNodes != null)
      {
				queryid = FldNodes.singleNodeValue.firstChild.nodeValue.toString();
			}
			else
			{
				alert(script_messages[16]);
				return;
			}

			//Nacteni pomocnych hodnot
			FldNodes = xmlQueryResult.evaluate("ingr:QueryResult/ingr:PkeyColumns", xmlQueryResult, nsResolver, 9, null);
			if (FldNodes != null)
			{
				queryidcol = FldNodes.singleNodeValue.childNodes[1].getAttribute("name");
			}
			else
			{
				alert(script_messages[16]);
				return;
			}

      RecNodes = xmlQueryResult.evaluate("/ingr:QueryResult/ingr:RowSet/ingr:Row", xmlQueryResult, nsResolver, 7, null);

  		for(var j = 0; j < RecNodes.snapshotLength; j++)
  		{
      	//Pro kazdy element REC delej
      	for(var i = 0; i < RecNodes.snapshotItem(j).childNodes.length; i++)
      	{
          if(RecNodes.snapshotItem(j).childNodes[i].nodeName.toLowerCase()== 'column')
          {
            if(RecNodes.snapshotItem(j).childNodes[i].getAttribute("name").toLowerCase() == queryidcol.toLowerCase())
            { 
              ids = RecNodes.snapshotItem(j).childNodes[i].firstChild.nodeValue;
            }
          } 
        }
				
        map_param = map_param + ids + ",";

				BBOX = RecNodes.snapshotItem(j).getAttribute("bbox").toString();

				if (BBOX == "")
				{
					alert(script_messages[17]);
					return;
				}
				
        if(initialize)
        {
          initialize = false;
          BBoxArray = ParseBBox(BBOX);
        }
        else
        {
          TmpArray = ParseBBox(BBOX);

					if (parseFloat(TmpArray[0]) < parseFloat(BBoxArray[0]))
					{
						BBoxArray[0] = parseFloat(TmpArray[0]);
					}

					if (parseFloat(TmpArray[1]) < parseFloat(BBoxArray[1]))
					{
						BBoxArray[1] = parseFloat(TmpArray[1]);
					}

					if (parseFloat(TmpArray[2]) > parseFloat(BBoxArray[2]))
					{
						BBoxArray[2] = parseFloat(TmpArray[2]);
					} 

					if (parseFloat(TmpArray[3]) > parseFloat(BBoxArray[3]))
					{
						BBoxArray[3] = parseFloat(TmpArray[3]);
					}
        }
  		}

      if(map_param != "")
      {
        map_param = map_param.substr(0, map_param.length-1);
      }

    	BBoxArray = TransformBBox(BBoxArray, map_list.maps.Item(map_list.map_id).map_width,map_list.maps.Item(map_list.map_id).map_height);
  			
    	BBOX = dbl2StrEN(BBoxArray[0].toString()) + "," + dbl2StrEN(BBoxArray[1].toString()) + "," + dbl2StrEN(BBoxArray[2].toString()) + "," + dbl2StrEN(BBoxArray[3].toString());
    
      LayerManager.HideAll();
      
    	map_list.maps.Item(map_list.map_id).bbox = BBOX;
      map_list.maps.Item(map_list.map_id).Actualize_BBOX();
   
      LayerManager.ShowQuery(queryid, map_param, map_list.maps.Item(map_list.map_id).query_url, 0);
      
      LayerManager.ShowAll();
 
      SetPosition();
    	//document.getElementById("divWait").style.display = "none";	
  
      ViewSwitch("OknoMapa");
    }  
    else
    {
  		ResultNotFound();
  		document.getElementById("divWait").style.display = "none";
  		return;
  	}
  }
  else
  {
  	//Prirazeni kolekce elementu s nazvem REC
  	RecNodes = xmlQueryResult.selectSingleNode("/ingr:QueryResult/ingr:TotalRecords");
  
  	//Musi byt minimalne dva zaznamy aby byl nalezen vysledek (prvni je pomocny)
  	if(parseInt(RecNodes.text) > 0)
  	{
			//Nacteni pomocnych hodnot
			FldNodes = xmlQueryResult.selectSingleNode("/ingr:QueryResult/ingr:QueryID");
		
			if (FldNodes != null)
			{
				queryid = FldNodes.text;
			}
			else
			{
				alert(script_messages[16]);
				return;
			}

			//Nacteni pomocnych hodnot
			FldNodes = xmlQueryResult.selectSingleNode("/ingr:QueryResult/ingr:PkeyColumns/column[0]");
		
			if (FldNodes != null)
			{
				queryidcol = FldNodes.getAttribute("name");
			}
			else
			{
				alert(script_messages[16]);
				return;
			}

  		initialize = true;
		
  		map_param = "";
		
    	//Prirazeni kolekce elementu s nazvem REC
    	RecNodes = xmlQueryResult.selectNodes("/ingr:QueryResult/ingr:RowSet/ingr:Row");
		
  		//Pro vsechny zaznamy delej (kvuli tomu, ze vysledkem nemusi byt jedna plocha)
  		for(var j = 0; j < RecNodes.length; j++)
  		{
        var xmlCNodes = RecNodes.item(j).selectNodes("column");
        
        //Pro kazdy element REC delej
      	for(var i = 0; i < xmlCNodes.length; i++)
      	{
          if(xmlCNodes.item(i).getAttribute("name").toLowerCase() == queryidcol.toLowerCase())
          { 
            ids = xmlCNodes.item(i).text;
          }
        }
				
        map_param = map_param + ids + ",";

				BBOX = RecNodes.item(j).getAttribute("bbox");

				if (BBOX == "")
				{
					alert(script_messages[17]);
					return;
				}
				
        if(initialize)
        {
          initialize = false;
          BBoxArray = ParseBBox(BBOX);
        }
        else
        {
          TmpArray = ParseBBox(BBOX);

					if (parseFloat(TmpArray[0]) < parseFloat(BBoxArray[0]))
					{
						BBoxArray[0] = parseFloat(TmpArray[0]);
					}

					if (parseFloat(TmpArray[1]) < parseFloat(BBoxArray[1]))
					{
						BBoxArray[1] = parseFloat(TmpArray[1]);
					}

					if (parseFloat(TmpArray[2]) > parseFloat(BBoxArray[2]))
					{
						BBoxArray[2] = parseFloat(TmpArray[2]);
					} 

					if (parseFloat(TmpArray[3]) > parseFloat(BBoxArray[3]))
					{
						BBoxArray[3] = parseFloat(TmpArray[3]);
					}
        }
  		}

      if(map_param != "")
      {
        map_param = map_param.substr(0, map_param.length-1);
      }
  		
//      BBoxArray = ParseBBox(param_array[0]);
    
    	BBoxArray = TransformBBox(BBoxArray, map_list.maps.Item(map_list.map_id).map_width,map_list.maps.Item(map_list.map_id).map_height);
  
 			WrldWidth = BBoxArray[2] - BBoxArray[0];

			MapScale = Math.round(((((WrldWidth * map_list.maps.Item(map_list.map_id).projection_to_scale) / map_list.maps.Item(map_list.map_id).map_width) * 100) * (280/10)));
			
      if(parseInt(document.getElementById("selMaxScale").options[document.getElementById("selMaxScale").selectedIndex].value) > parseInt(MapScale))
			{
				MapScale = parseInt(document.getElementById("selMaxScale").options[document.getElementById("selMaxScale").selectedIndex].value);
				
        wrldhalfx = BBoxArray[0] + ((BBoxArray[2] - BBoxArray[0]) / 2);
				wrldhalfy = BBoxArray[1] + ((BBoxArray[3] - BBoxArray[1]) / 2);
				BBoxArray[0] = wrldhalfx - (((map_list.maps.Item(map_list.map_id).map_width / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
				BBoxArray[2] = wrldhalfx + (((map_list.maps.Item(map_list.map_id).map_width / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
				BBoxArray[1] = wrldhalfy - (((map_list.maps.Item(map_list.map_id).map_height / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
				BBoxArray[3] = wrldhalfy + (((map_list.maps.Item(map_list.map_id).map_height / 2)/(280/100)) / 1000 * MapScale / map_list.maps.Item(map_list.map_id).projection_to_scale);
			}
  			
    	BBOX = dbl2StrEN(BBoxArray[0].toString()) + "," + dbl2StrEN(BBoxArray[1].toString()) + "," + dbl2StrEN(BBoxArray[2].toString()) + "," + dbl2StrEN(BBoxArray[3].toString());
      
      LayerManager.HideAll();
          
    	map_list.maps.Item(map_list.map_id).bbox = BBOX;
      map_list.maps.Item(map_list.map_id).Actualize_BBOX();

      LayerManager.ShowQuery(queryid, map_param, map_list.maps.Item(map_list.map_id).query_url, 0);
      
      LayerManager.ShowAll();
    
      SetPosition();
    	//document.getElementById("divWait").style.display = "none";	
  
/*  		LayerManager.HideAll
  		
  		'Aktualizace mapy
  		MAP_URL = document.all.map.src
  		MAP_URL = ReplaceBBOX(MAP_URL, BBOX)
  		MAP_URL = ReplaceLAYERS(MAP_URL, GetWMSLAYERS())
  		MAP_URL = ReplaceSTYLES(MAP_URL, GetWMSSTYLES())
  		document.all.map.src = MAP_URL
  
  
  		'Aktualizace klikaci mapy
  		MAP_URL = document.all.ClickMapSrc.src
  		MAP_URL = ReplaceBBOX(MAP_URL, BBOX)
  		document.all.ClickMapSrc.src = MAP_URL
  
  		LayerManager.ShowQuery queryid, map_param, map_list.maps.Item(map_list.map_id).query_url, 1
  
  		LayerManager.ShowAll
  
  		MapHistory.Add "Mapový výřez", document.all.map.src , document.all.ClickMapSrc.src, document.all.varActiveFeature.value, document.all.QueryMap.src, document.all.SelectMap.src, window.status
  		UpdateHistory*/

      ViewSwitch("OknoMapa");
  	}
    else
    {
  		ResultNotFound();
  		document.getElementById("divWait").style.display = "none";
  		return;
  	}
	}	
}
//****************************************************************************

function btnPageShow(page)
{

	document.getElementById("divWait").style.display = "";

  map_list.maps.Item(map_list.map_id).query_page = page;
	
  //Realilzuje pozadavek klienta na ziskani vysledku dotazu
  xmlQueryResult = AJAX(map_list.maps.Item(map_list.map_id).query_url + "?REQUEST=getqueryresult&QUERYINDEX=" + map_list.maps.Item(map_list.map_id).query_index + "&" + map_list.maps.Item(map_list.map_id).query_param_string + "&PAGE=" + page + "&ITEMS=" + document.getElementById("cmbResultPaging").options[document.getElementById("cmbResultPaging").selectedIndex].value + "&SRS=" + map_list.maps.Item(map_list.map_id).srs, false);

  var moz = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined');
  var ie = (typeof window.ActiveXObject != 'undefined'); 

  if(moz)
  {
    var s = new XMLSerializer();
    var xsltProcessor = new XSLTProcessor();

    xsltProcessor.importStylesheet(get_query_result_xslt);
    var fragment = xsltProcessor.transformToFragment(xmlQueryResult, document);
    document.getElementById("pQueryResult").innerHTML = "";
    document.getElementById("pQueryResult").appendChild(fragment);
		document.getElementById("divWait").style.display = "none";
  }
  else
  {
    document.getElementById("pQueryResult").innerHTML = xmlQueryResult.transformNode(get_query_result_xslt);

		document.getElementById("divWait").style.display = "none";
  }

}
//****************************************************************************

function btnPageShowIQS(page)
{

	var re = /[?]/i;
	var xml_req = "";
	if(map_list.maps.Item(map_list.map_id).query_url.search(re) != -1)
	{
    //sloz XML request
    
    xml_req = this.map_list.maps.Item(map_list.map_id).query_url + "&";
        
	}
	else
	{
      //sloz XML request
    xml_req = this.map_list.maps.Item(map_list.map_id).query_url + "?";
	}

	document.getElementById("divWait").style.display = "";

  map_list.maps.Item(map_list.map_id).query_page = page;
	
  //Realilzuje pozadavek klienta na ziskani vysledku dotazu
  xmlQueryResult = AJAX(xml_req + "REQUEST=getquery&id=" + map_list.maps.Item(map_list.map_id).query_index + "&filter=" + map_list.maps.Item(map_list.map_id).query_param_string + "&PAGE=" + page + "&SIZE=" + document.getElementById("cmbResultPaging").options[document.getElementById("cmbResultPaging").selectedIndex].value + "&SRS=" + map_list.maps.Item(map_list.map_id).srs + "&RETURNBBOX=1", false);

  var moz = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined');
  var ie = (typeof window.ActiveXObject != 'undefined'); 

  if(moz)
  {
    var s = new XMLSerializer();
    var xsltProcessor = new XSLTProcessor();

    xsltProcessor.importStylesheet(get_query_result_xslt);
    var fragment = xsltProcessor.transformToFragment(xmlQueryResult, document);
    document.getElementById("pQueryResult").innerHTML = "";
    document.getElementById("pQueryResult").appendChild(fragment);
		document.getElementById("divWait").style.display = "none";
  }
  else
  {
    document.getElementById("pQueryResult").innerHTML = xmlQueryResult.transformNode(get_query_result_xslt);

		document.getElementById("divWait").style.display = "none";
  }

}
//****************************************************************************

function cmbItemsChange()
{	
	
	var items = document.getElementById("cmbResultPaging").options[document.getElementById("cmbResultPaging").selectedIndex].value;
	
	document.getElementById("divWait").style.display = "";

	//Realilzuje pozadavek klienta na ziskani vysledku dotazu
  xmlQueryResult = AJAX(map_list.maps.Item(map_list.map_id).query_url + "?REQUEST=getqueryresult&QUERYINDEX=" + map_list.maps.Item(map_list.map_id).query_index + "&" + map_list.maps.Item(map_list.map_id).query_param_string + "&PAGE=1&ITEMS=" + items +"&SRS=" + map_list.maps.Item(map_list.map_id).srs, false);

  var moz = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined');
  var ie = (typeof window.ActiveXObject != 'undefined'); 

  if(moz)
  {
    var s = new XMLSerializer();
    var xsltProcessor = new XSLTProcessor();

    xsltProcessor.importStylesheet(get_query_result_xslt);
    var fragment = xsltProcessor.transformToFragment(xmlQueryResult, document);
    document.getElementById("pQueryResult").innerHTML = "";
    document.getElementById("pQueryResult").appendChild(fragment);
		document.getElementById("divWait").style.display = "none";
  }
  else
  {
    document.getElementById("pQueryResult").innerHTML = xmlQueryResult.transformNode(get_query_result_xslt);

		document.getElementById("divWait").style.display = "none";
  }
}
//****************************************************************************

function cmbItemsChangeIQS()
{	
	var re = /[?]/i;
	var xml_req = "";
	if(map_list.maps.Item(map_list.map_id).query_url.search(re) != -1)
	{
    //sloz XML request
    
    xml_req = this.map_list.maps.Item(map_list.map_id).query_url + "&";
        
	}
	else
	{
      //sloz XML request
    xml_req = this.map_list.maps.Item(map_list.map_id).query_url + "?";
	}
	
	var items = document.getElementById("cmbResultPaging").options[document.getElementById("cmbResultPaging").selectedIndex].value;
	
	document.getElementById("divWait").style.display = "";

	//Realilzuje pozadavek klienta na ziskani vysledku dotazu
  xmlQueryResult = AJAX(xml_req + "REQUEST=getquery&id=" + map_list.maps.Item(map_list.map_id).query_index + "&filter=" + map_list.maps.Item(map_list.map_id).query_param_string + "&PAGE=1&SIZE=" + items + "&SRS=" + map_list.maps.Item(map_list.map_id).srs + "&RETURNBBOX=1", false);

  var moz = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined');
  var ie = (typeof window.ActiveXObject != 'undefined'); 

  if(moz)
  {
    var s = new XMLSerializer();
    var xsltProcessor = new XSLTProcessor();

    xsltProcessor.importStylesheet(get_query_result_xslt);
    var fragment = xsltProcessor.transformToFragment(xmlQueryResult, document);
    document.getElementById("pQueryResult").innerHTML = "";
    document.getElementById("pQueryResult").appendChild(fragment);
		document.getElementById("divWait").style.display = "none";
  }
  else
  {
    document.getElementById("pQueryResult").innerHTML = xmlQueryResult.transformNode(get_query_result_xslt);

		document.getElementById("divWait").style.display = "none";
  }
}
//****************************************************************************

function btnPrintQuery_onmouseleave()
{
	document.getElementById("btnPrintQuery").src = "./DisplayStyle/printup.jpg";
}
//****************************************************************************

function btnPrintQuery_onmousedown()
{
	document.getElementById("btnPrintQuery").src = "./DisplayStyle/printd.jpg";
}
//****************************************************************************

function btnPrintQuery_onmouseup()
{
	document.getElementById("btnPrintQuery").src = "./DisplayStyle/printup.jpg";
}
//****************************************************************************

function btnPrintQuery_Click()
{
	var re = /[?]/i;
	var xml_req = "";
  var URL = map_list.maps.Item(map_list.map_id).query_url;
	if(URL.search(re) != -1)
	{
    //sloz XML request
    
    URL = URL + "&";
        
	}
	else
	{
      //sloz XML request
    URL = URL + "?";
	}

  window.open(print_query_url + "?" + URL + "REQUEST=getquery&id=" + map_list.maps.Item(map_list.map_id).query_index + "&filter=" + map_list.maps.Item(map_list.map_id).query_param_string + "&PAGE=" + map_list.maps.Item(map_list.map_id).query_page + "&SIZE=" + document.getElementById("cmbResultPaging").options[document.getElementById("cmbResultPaging").selectedIndex].value + "&SRS=" + map_list.maps.Item(map_list.map_id).srs);
}
//****************************************************************************

function ShowParamList(param, qIndex, pIndex)
{
  
  tmp_param = param.id;
  
 	var re = new RegExp("@", "i");
  
  if (window.showModalDialog)
  {
    var id = window.showModalDialog(param_dialog_url + "?QUERYURL=" + map_list.maps.Item(map_list.map_id).query_url + "&QUERYINDEX=" + qIndex + "&PARAMINDEX=" + pIndex,"","center; dialogHeight: 300px; dialogWidth: 430px; edge: Raised; help: No; resizable: No; status: No;");
  	
    if(id)
  	{
      if (id == "-1")
    	{
  			alert(script_messages[18]);
      }
  		else
  		{
        document.getElementById(param.id.replace(re,"")).value = id;
  		}
    }
  }
  else
  {
    
    Dialog(param_dialog_url + "?QUERYURL=" + map_list.maps.Item(map_list.map_id).query_url + "&QUERYINDEX=" + qIndex + "&PARAMINDEX=" + pIndex, null, null, 415, 282);
    //var id = window.open(param_dialog_url + "?QUERYURL=" + map_list.maps.Item(map_list.map_id).query_url + "&QUERYINDEX=" + qIndex + "&PARAMINDEX=" + pIndex,'Rozšířený výběr parametru dotazu','height=282,width=415,toolbar=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=no ,modal=yes');
    
  }	
}
//****************************************************************************

function param_list_mozilla(id)
{
   	var re = new RegExp("@", "i");

    if(id)
  	{
      if (id == "-1")
    	{
  			alert(script_messages[18]);
      }
  		else
  		{
        document.getElementById(tmp_param.replace(re,"")).value = id;
  		}
    }
}
//****************************************************************************

function btnSaveEnviroment_Click()
{

  map_list.Save_MapEnviroment(map_list.map_id);
}
//****************************************************************************

function btnLoadEnviroment_Click(o)
{

  var gFile = document.getElementById("txtGFile").value

  if(gFile != "")
  {
    o.form.submit();
  }
  else
  {
    alert(script_messages[19]);
  }

  //map_list.Enviroment(map_list.map_id);
}
//****************************************************************************

function spnFI_Close_Click()
{
  document.getElementById("zalozkaFI").style.display = "none";
}
//****************************************************************************

function btnDisableQuery_Click()
{

  if(document.getElementById("divWait").style.display == "none")
  {	
  	if(LayerManager.Query)
  	{
      LayerManager.DeleteQuery();
  		
      btnQBack_Click();
  	}	
  }
}
//****************************************************************************

function btnShowQuery_Click()
{
  if(document.getElementById("divWait").style.display == "none")
  {	
  	if(LayerManager.Query)
  	{
  		if(LayerManager.IsQHide)
  		{
  			LayerManager.ShowQuery(LayerManager.QueryIndex, LayerManager.QueryParam, map_list.maps.Item(map_list.map_id).query_url, LayerManager.Mode);
  			LayerManager.IsQShowed = true;
  			LayerManager.IsQHidded = false;
  		}
  		else
  		{
  			if(LayerManager.IsQShow)
  			{
  				LayerManager.HideQuery();
  				LayerManager.IsQHidded = true;
  				LayerManager.IsQShowed = false;
  			}
  		}
  	
    //ViewSwitch("OknoMapa")
  	}	
  
  }
}
//****************************************************************************

function btnQBack_Click()
{
/*
 * Procedura se vola po kliknuti na tlacitko Storno pri zadavani parametru dotazu.
 */
	document.getElementById("pQueryResult").innerHTML = "";

}
//****************************************************************************

function imgQueryMap_Load()
{
/*
 * Procedura obsluhujici udalost nacteni dat na objektu imgQueryMap.
 */

	if(LayerManager.Query && LayerManager.IsQShowed)
	{
		document.getElementById("QueryMap").style.display = "";
		document.getElementById("QueryMap").style.visibility = "visible";
	}
}
//****************************************************************************

function chbQ_Click()
{
  if(moz)
  {
    //window.event.stopPropagation();
  }
  else
  {
    window.event.cancelBubble = true;
  }
}
//****************************************************************************

function btnTMapaOK_Click()
{
  var map_id = document.getElementById("cmbTMapa").options[document.getElementById("cmbTMapa").selectedIndex].value
	
  var b = false;

	for(var i = 0; i < map_list.maps.Item(map_id).wms_list.Length(); i++)
	{

		//nacteni capabilities serveru
		map_list.maps.Item(map_id).wms_list.Item(i).Get_Capabilities(map_list.maps.Item(map_id).default_version);

  }

	//zjisti jestli nova tematicka mapa obsahuje aktualni sour. system
	var tmp_srs = map_list.maps.Item(map_list.map_id).srs;
	var csl = map_list.maps.Item(map_list.map_id).common_srs_list;
	for (var i = 0; i < csl.Length(); i++)
	{
    if(tmp_srs.toLowerCase() == csl.Item(i).value.toLowerCase())
    {
      b = true;
      break;
    }
  }

  if(b)
  {
    var strSrs;
  	var re_version = /[.]/ig;
 		var re = /[?]/i;
    var url;
    
    var default_bbox = map_list.maps.Item(map_id).default_bbox;
    var new_default_bbox;
    var source_srs = map_list.maps.Item(map_id).srs;
    
    map_list.maps.Item(map_id).bbox = map_list.maps.Item(map_list.map_id).bbox;	
  	//map_list.maps.Item(map_id).Actualize_BBOX();
  	map_list.maps.Item(map_id).srs = map_list.maps.Item(map_list.map_id).srs;	
  	//map_list.maps.Item(map_id).Actualize_SRS();

    //transformuj defaultni bbox
		if(map_list.maps.Item(map_list.map_id).cst_url.search(re) != -1)
		{
			url = map_list.maps.Item(map_list.map_id).cst_url + "request=getcstrans&SOURCESRS=" + source_srs + "&TARGETSRS=" + map_list.maps.Item(map_list.map_id).srs + "&BBOX=" + default_bbox;
		}
		else
		{
			url = map_list.maps.Item(map_list.map_id).cst_url + "?request=getcstrans&SOURCESRS=" + source_srs + "&TARGETSRS=" + map_list.maps.Item(map_list.map_id).srs + "&BBOX=" + default_bbox;
		}
		
		xmlResponse = AJAX(url, proxy_enabled);
		
    if(moz)
    {
      xmlNode = xmlResponse.evaluate("//CSTResponse/TargetBBOX", xmlResponse, null, 9, null);
			new_default_bbox = (xmlNode != null)?xmlNode.singleNodeValue.getAttribute("value"):"";
    }
    else
    {
  		xmlNode = xmlResponse.selectSingleNode("//CSTResponse/TargetBBOX");
  		new_default_bbox = (xmlNode != null)?xmlNode.getAttribute("value"):"";
  	}

    map_list.maps.Item(map_id).default_bbox = new_default_bbox;

    //transformuj prehledku
		if(map_list.maps.Item(map_list.map_id).cst_url.search(re) != -1)
		{
			url = map_list.maps.Item(map_list.map_id).cst_url + "request=getcstrans&SOURCESRS=" + source_srs + "&TARGETSRS=" + map_list.maps.Item(map_list.map_id).srs + "&BBOX=" + get_string(map_list.maps.Item(map_id).position_url, "BBOX");
		}
		else
		{
			url = map_list.maps.Item(map_list.map_id).cst_url + "?request=getcstrans&SOURCESRS=" + source_srs + "&TARGETSRS=" + map_list.maps.Item(map_list.map_id).srs + "&BBOX=" + get_string(map_list.maps.Item(map_id).position_url, "BBOX");
		}
		
		xmlResponse = AJAX(url, proxy_enabled);
		
    if(moz)
    {
      xmlNode = xmlResponse.evaluate("//CSTResponse/TargetBBOX", xmlResponse, null, 9, null);
			new_default_bbox = (xmlNode != null)?xmlNode.singleNodeValue.getAttribute("value"):"";
    }
    else
    {
  		xmlNode = xmlResponse.selectSingleNode("//CSTResponse/TargetBBOX");
  		new_default_bbox = (xmlNode != null)?xmlNode.getAttribute("value"):"";
  	}

    //Aktualizace prehledky
		map_list.maps.Item(map_id).preview_url = replace_string(map_list.maps.Item(map_id).preview_url, "SRS", map_list.maps.Item(map_list.map_id).srs);
		map_list.maps.Item(map_id).preview_url = replace_string(map_list.maps.Item(map_id).preview_url, "BBOX", new_default_bbox);

		map_list.maps.Item(map_id).position_url = replace_string(map_list.maps.Item(map_id).position_url, "SRS", map_list.maps.Item(map_list.map_id).srs);
		map_list.maps.Item(map_id).position_url = replace_string(map_list.maps.Item(map_id).position_url, "BBOX", new_default_bbox);

    var BBoxArray = ParseBBox(get_string(map_list.maps.Item(map_id).position_url, "BBOX"));
    	
    var MidpointX = BBoxArray[0] + ((BBoxArray[2] - BBoxArray[0]) / 2);
    var MidpointY = BBoxArray[1] + ((BBoxArray[3] - BBoxArray[1]) / 2);
    
    map_list.maps.Item(map_id).position_url = replace_string(map_list.maps.Item(map_id).position_url, "XCOORD", dbl2StrEN(MidpointX));
    map_list.maps.Item(map_id).position_url = replace_string(map_list.maps.Item(map_id).position_url, "YCOORD", dbl2StrEN(MidpointY));

    //Aktualizace mapy
		for(var i = 0; i < map_list.maps.Item(map_id).wms_list.Length(); i++)
		{
      if(parseInt(map_list.maps.Item(map_id).wms_list.Item(i).version.replace(re_version,"")) >= 130)
      {
        strSrs = "CRS";
      }
      else
      {
        strSrs = "SRS";
      }

      map_list.maps.Item(map_id).wms_list.Item(i).bbox = map_list.maps.Item(map_id).bbox; 
      map_list.maps.Item(map_id).wms_list.Item(i).srs = map_list.maps.Item(map_id).srs; 
			map_list.maps.Item(map_id).wms_list.Item(i).wms_url = replace_string(map_list.maps.Item(map_id).wms_list.Item(i).wms_url, "BBOX", map_list.maps.Item(map_id).bbox);
      map_list.maps.Item(map_id).wms_list.Item(i).wms_url = replace_string(map_list.maps.Item(map_id).wms_list.Item(i).wms_url, strSrs, map_list.maps.Item(map_id).srs);
		}
  }
  else
  {
    alert(script_messages[20]);
  }
  // Zobrazeni preddefinovane mapy
	map_list.Load_Map(map_id);

      //map_list.maps.Item(map_list.map_id).bbox = actual_bbox;
      //map_list.maps.Item(map_list.map_id).Actualize_BBOX();
	
	SetPosition();
	
}
//****************************************************************************

function cmbPrintPageSetting_Change()
{
	var strPage = document.getElementById("cmbPrint_page_setting").options[document.getElementById("cmbPrint_page_setting").selectedIndex].value.split("|");

	document.getElementById("txtPrint_width").value = strPage[0];
  document.getElementById("txtPrint_height").value = strPage[1];
}
//****************************************************************************

function notifyQ(oSelect)
{
  if (oSelect.selectedIndex > 0)
  {
    alert(script_messages[21]);
  }
}
//****************************************************************************

function SetMeasure()
{
  if(nemerit)
  {
    //document.getElementById("tdToolScale").style.display = "none";
    //document.getElementById("tdSetScale").style.display = "none";
    document.getElementById("tdDistance").style.display = "none";
    document.getElementById("tdSurface").style.display = "none";
    document.getElementById("tdToolDiv1").style.display = "none";
    document.getElementById("tdToolDiv2").style.display = "none";
    //document.getElementById("trMeritkoLevyPanel").style.display = "none";
    //document.getElementById("trMeritkoLineDown").style.display = "none";
  }
  else
  {
    //document.getElementById("tdToolScale").style.display = "";
    //document.getElementById("tdSetScale").style.display = "";
    document.getElementById("tdDistance").style.display = "";
    document.getElementById("tdSurface").style.display = "";
    document.getElementById("tdToolDiv1").style.display = "";
    document.getElementById("tdToolDiv2").style.display = "";
    //document.getElementById("trMeritkoLevyPanel").style.display = "";
    //document.getElementById("trMeritkoLineDown").style.display = "";
  }
}
//****************************************************************************

function cmbWCS_Servers_Change()
{

  var id = document.getElementById("cmbWCS_Servers").options[document.getElementById("cmbWCS_Servers").selectedIndex].value;
  
  var wcs_id = map_list.maps.Item(map_list.map_id).Get_WCS_Id(id);
  
  var wcs_s = map_list.maps.Item(map_list.map_id).wcs_list.Item(wcs_id);
  
  document.getElementById("spnWCS_Url").innerText = wcs_s.url;
}

function btnWCS_GetCapabilities_Click()
{

  if(document.getElementById("btnWCS_ServiceInfo").disabled == true)
  {
    //zmacknut getcapabilities

    var id = document.getElementById("cmbWCS_Servers").options[document.getElementById("cmbWCS_Servers").selectedIndex].value;
    
    var wcs_id = map_list.maps.Item(map_list.map_id).Get_WCS_Id(id);
    
    var wcs_s = map_list.maps.Item(map_list.map_id).wcs_list.Item(wcs_id);
  
    if(wcs_s.Get_Capabilities("1.0.0"))
    {
      //podarilo se nacist capabilities, enabluj dalsi funkce
      document.getElementById("btnWCS_GetCapabilities").value = "Disconnect";
      document.getElementById("btnWCS_ServiceInfo").disabled = false;
      
      wcs_s.Write_Coverages("tdWCS_Coverages");
      
      if(wcs_s.coverage_list.Length() > 0)
      {
        document.getElementById("btnWCS_CoverageInfo").disabled = false;
        document.getElementById("btnWCS_DescribeCoverage").disabled = false;
        document.getElementById("btnWCS_ShowCoverage").disabled = false;
      }
      
      document.getElementById("cmbWCS_Servers").disabled = true;

    }
    else
    {
      alert(script_messages[22]);
    }
  }
  else
  {
    //zmacknut disconnect
    var id = document.getElementById("cmbWCS_Servers").options[document.getElementById("cmbWCS_Servers").selectedIndex].value;
    
    var wcs_id = map_list.maps.Item(map_list.map_id).Get_WCS_Id(id);
    
    var wcs_s = map_list.maps.Item(map_list.map_id).wcs_list.Item(wcs_id);

    wcs_s.coverage_list.Clear();
    
    document.getElementById("tdWCS_Coverages").innerHTML = "<SELECT id='cmbWCS_Coverages' class='vyber' style='width:300px;'><OPTION></OPTION></SELECT>";

    document.getElementById("btnWCS_CoverageInfo").disabled = true;
    document.getElementById("btnWCS_DescribeCoverage").disabled = true;
    document.getElementById("btnWCS_ShowCoverage").disabled = true;
    document.getElementById("btnWCS_HideCoverage").disabled = true;

    document.getElementById("cmbWCS_Servers").disabled = false;
    document.getElementById("btnWCS_GetCapabilities").value = "Get Capabilities";
    document.getElementById("btnWCS_ServiceInfo").disabled = true;
  }
}

function btnWCS_ServiceInfo_Click()
{
    //zmacknut disconnect
    var id = document.getElementById("cmbWCS_Servers").options[document.getElementById("cmbWCS_Servers").selectedIndex].value;
    
    var wcs_id = map_list.maps.Item(map_list.map_id).Get_WCS_Id(id);
    
    var wcs_s = map_list.maps.Item(map_list.map_id).wcs_list.Item(wcs_id);

    window.open("WCS_s_info.asp?L=" + wcs_s.label + "&N=" + wcs_s.name + "&D=" + wcs_s.description + "&R=" + wcs_s.c_i_name + "," + wcs_s.c_organization + "&C=" + wcs_s.c_address + "," + wcs_s.c_post_code + "," + wcs_s.c_city + "," + wcs_s.c_country + "&P=email:" + wcs_s.c_email + ",phone:" + wcs_s.c_phone);

}

function btnWCS_CoverageInfo_Click()
{
    var id = document.getElementById("cmbWCS_Servers").options[document.getElementById("cmbWCS_Servers").selectedIndex].value;
    
    var wcs_id = map_list.maps.Item(map_list.map_id).Get_WCS_Id(id);
    
    var wcs_s = map_list.maps.Item(map_list.map_id).wcs_list.Item(wcs_id);

    var c_id = document.getElementById("cmbWCS_Coverages").options[document.getElementById("cmbWCS_Coverages").selectedIndex].value;

    var c_s = wcs_s.coverage_list.Item(c_id);
    
    window.open("WCS_c_info.asp?L=" + c_s.label + "&N=" + c_s.name + "&D=" + c_s.description + "&G=" + c_s.graphics);
 
}

function btnWCS_DescribeCoverage_Click()
{
    var dc_url;
    
    var id = document.getElementById("cmbWCS_Servers").options[document.getElementById("cmbWCS_Servers").selectedIndex].value;
    
    var wcs_id = map_list.maps.Item(map_list.map_id).Get_WCS_Id(id);
    
    var wcs_s = map_list.maps.Item(map_list.map_id).wcs_list.Item(wcs_id);

    var c_id = document.getElementById("cmbWCS_Coverages").options[document.getElementById("cmbWCS_Coverages").selectedIndex].value;

    var c_s = wcs_s.coverage_list.Item(c_id);

		var re = /[?]/i;
		if(wcs_s.dc_url.search(re) != -1)
		{
      //sloz XML request
      
      dc_url = wcs_s.dc_url + "&REQUEST=DescribeCoverage";
      
      if(get_string(dc_url, 'SERVICE') == '')
      {
        dc_url = replace_string(dc_url, 'SERVICE', 'WCS');
        
        if(get_string(dc_url, 'SERVICE') == '')
        {
          dc_url = dc_url + "&SERVICE=WCS";
        }
      }

      if(get_string(dc_url, 'VERSION') == '')
      {
        dc_url = replace_string(dc_url, 'VERSION', "1.0.0");
        
        if(get_string(dc_url, 'VERSION') == '')
        {
          dc_url = dc_url + "&VERSION=" + "1.0.0";
        }
      }

		}
		else
		{
        //sloz XML request
      dc_url = wcs_s.dc_url + "?REQUEST=DescribeCoverage";
      
      if(get_string(dc_url, 'SERVICE') == '')
      {
        dc_url = replace_string(dc_url, 'SERVICE', 'WCS');
        
        if(get_string(dc_url, 'SERVICE') == '')
        {
          dc_url = dc_url + "&SERVICE=WCS";
        }
      }
      if(get_string(dc_url, 'VERSION') == '')
      {
        dc_url = replace_string(dc_url, 'VERSION', "1.0.0");
        
        if(get_string(dc_url, 'VERSION') == '')
        {
          dc_url = dc_url + "&VERSION=" + "1.0.0";
        }
      }
		}

    window.open(dc_url + "&COVERAGE=" + c_s.name);

}

function btnWCS_ShowCoverage_Click()
{
    var gc_url = "";
    
    var id = document.getElementById("cmbWCS_Servers").options[document.getElementById("cmbWCS_Servers").selectedIndex].value;
    
    var wcs_id = map_list.maps.Item(map_list.map_id).Get_WCS_Id(id);
    
    var wcs_s = map_list.maps.Item(map_list.map_id).wcs_list.Item(wcs_id);

    var c_id = document.getElementById("cmbWCS_Coverages").options[document.getElementById("cmbWCS_Coverages").selectedIndex].value;

    var c_s = wcs_s.coverage_list.Item(c_id);

    gc_url = wcs_s.gc_url + "?REQUEST=GetCoverage&SERVICE=WCS&VERSION=1.0.0&FORMAT=PNG&WIDTH=" + map_list.maps.Item(map_list.map_id).map_width + "&HEIGHT=" + map_list.maps.Item(map_list.map_id).map_height;
    gc_url = gc_url + "&BBOX=" + map_list.maps.Item(map_list.map_id).bbox + ",0,0" + "&CRS=" + map_list.maps.Item(map_list.map_id).srs + "&COVERAGE=" + c_s.name;

    document.getElementById("imgWCS").src = gc_url;
   
   document.getElementById("cmbWCS_Coverages").disabled = true;
 
}

function btnWCS_HideCoverage_Click()
{

  document.getElementById("imgWCS").style.display = "none";
  document.getElementById("imgWCS").src = "";

  document.getElementById("btnWCS_ShowCoverage").disabled = false;
  document.getElementById("btnWCS_HideCoverage").disabled = true;
  
  document.getElementById("cmbWCS_Coverages").disabled = false;

}

function imgWCS_Load()
{
  document.getElementById("imgWCS").style.display = "";

  document.getElementById("btnWCS_ShowCoverage").disabled = true;
  document.getElementById("btnWCS_HideCoverage").disabled = false;
  
  ViewSwitch('OknoMapa');
  
}

function NSResolver(prefix) {
  switch (prefix)
  {
    case 'wms':
          return 'http://www.opengis.net/wms';
          break;
    case 'xlink':
          return 'http://www.w3.org/1999/xlink';
          break;
    case 'xsi':
          return 'http://www.w3.org/2001/XMLSchema-instance';
          break;
    default:
          return 'http://www.opengis.net/wms';
          break;
  }
}

