[Mapbender-commits] r2665 - branches/testbaudson_dev/http/html

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Jul 17 08:03:59 EDT 2008


Author: christoph
Date: 2008-07-17 08:03:59 -0400 (Thu, 17 Jul 2008)
New Revision: 2665

Modified:
   branches/testbaudson_dev/http/html/mod_treefolder2.php
Log:


Modified: branches/testbaudson_dev/http/html/mod_treefolder2.php
===================================================================
--- branches/testbaudson_dev/http/html/mod_treefolder2.php	2008-07-17 12:03:26 UTC (rev 2664)
+++ branches/testbaudson_dev/http/html/mod_treefolder2.php	2008-07-17 12:03:59 UTC (rev 2665)
@@ -1,609 +1,610 @@
-<?php
-# $Id$
-# http://www.mapbender.org/index.php/Mod_treefolder2.php
-# Copyright (C) 2007 Melchior Moos
-# 
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
-$gui_id = $_SESSION["mb_user_gui"];
-?>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<HTML>
-<HEAD>
-<?php
-echo '<meta http-equiv="Content-Type" content="text/html; charset='.CHARSET.'">';	
-?>
-<TITLE>Treefolder</TITLE>
-<?php
- include '../include/dyn_css.php';
-?>
-<script language='JavaScript'>
-
-function openwindow(Adresse) {
-Fenster1 = window.open(Adresse, "Informationen", "width=500,height=500,left=100,top=100,scrollbars=yes,resizable=no");
-Fenster1.focus();
-}
-</script>
-<script src="../javascripts/jsTree.js" type="text/javascript" language="JavaScript"></script>
-<?php
-echo "<script language='JavaScript'>";
-   $sql = "SELECT e_target FROM gui_element WHERE e_id = $1 AND fkey_gui_id = $2";
-   $v = array($_REQUEST['e_id_css'],$_SESSION["mb_user_gui"]);
-   $t = array('s','s');
-   $res = db_prep_query($sql,$v,$t);
-   $e_target = db_result($res,0,"e_target");   
-   echo "mod_treeGDE_map = '".$e_target."';";   
-echo "</script>";
-?>
-<SCRIPT language="JavaScript" type="text/javascript">
-
-var jst_container = "document.getElementById('treeContainer')";
-var jst_image_folder = imagedir;
-var jst_display_root = false;
-var defaultTarget = 'examplemain';
-var lock=false;
-var lock_update=false;
-var lock_check=false;
-var selectedMap=-1;
-var selectedWMS=-1;
-var selectedLayer=-1;
-var init=false;
-var errors = 0;
-var state=Array();
-var treeState = "";
-var arrNodes = 
-[
-	['root_id', ['Layer','javascript:_foo()']
-
-	]
-];
-function _foo(){}
-
-// some defaults
-try{if (reverse){}}catch(e){reverse = 'false';}
-try{if (switchwms){}}catch(e){switchwms = 'true';}
-try{if (ficheckbox){}}catch(e){ficheckbox = 'false';}
-try{if (metadatalink){}}catch(e){metadatalink = 'false';}
-try{if (wmsbuttons){}}catch(e){wmsbuttons = 'false';}
-try{if (showstatus){}}catch(e){showstatus = 'false';}
-try{if (alerterror){}}catch(e){alerterror = 'false';}
-try{if (openfolder){}}catch(e){openfolder = 'false';}
-try{if (handlesublayer){}}catch(e){handlesublayer = 'false';}
-try{if (menu){}}catch(e){menu = '';}
-try {
-	if (redirectToMetadataUrl) {
-		if (redirectToMetadataUrl == "false") {
-			redirectToMetadataUrl = false;
-		}
-		else {
-			redirectToMetadataUrl = true;
-		}
-	}
-}
-catch (e) {
-	var redirectToMetadataUrl = true;
-}
-var defaultMetadataUrl = '../php/mod_layerMetadata.php?';
-if (redirectToMetadataUrl) {
-	defaultMetadataUrl += 'redirectToMetadataUrl=1';
-}
-else {
-	defaultMetadataUrl += 'redirectToMetadataUrl=0';
-}
-
-//menu elements
-var menu_move_up = ['menu_move_up', ['Move up&nbsp;','javascript:var sd = "{@strData}";var ids=eval(sd.substr(0, sd.length-6))[1][7];move_up(ids[0],ids[1],ids[2]);',,'move_up.png']];
-var menu_move_down = ['menu_move_down', ['Move down&nbsp;', 'javascript:var sd = "{@strData}";var ids=eval(sd.substr(0, sd.length-6))[1][7];move_down(ids[0],ids[1],ids[2]);',,'move_down.png']];
-var menu_delete = ['menu_delete', ['Remove&nbsp;', 'javascript:var sd = "{@strData}";var ids=eval(sd.substr(0, sd.length-6))[1][7];remove_wms(ids[0],ids[1],ids[2]);',,'delete_wms.png']];
-var menu_opacity_up = ['menu_opacity_up', ['Opacity up&nbsp;','javascript:var sd = "{@strData}";var ids=eval(sd.substr(0, sd.length-6))[1][7];opacity_up(ids[0],ids[1],ids[2]);',,'move_up.png']];
-var menu_opacity_down = ['menu_opacity_down', ['Opacity down&nbsp;','javascript:var sd = "{@strData}";var ids=eval(sd.substr(0, sd.length-6))[1][7];opacity_down(ids[0],ids[1],ids[2]);',,'move_down.png']];
-var menu_metalink = ['menu_metalink', ['Information&nbsp;', 'javascript:var sd = "{@strData}";var ids=eval(sd.substr(0, sd.length-6))[1][7];openwindow(defaultMetadataUrl + "&id="+parent.mb_mapObj[ids[0]].wms[ids[1]].objLayer[ids[2]].layer_uid);',,'info.png']];
-var menu_zoom = ['menu_zoom', ['Zoom&nbsp;', 'javascript:var sd = "{@strData}";var ids=eval(sd.substr(0, sd.length-6))[1][7];zoomToLayer(ids[0],ids[1],ids[2]);',,'zoom.png']];
-var menu_hide = ['menu_hide', ['Hide menu&nbsp;', 'javascript:hideMenu()',,'hide.png']];
-//var menu_wms_switch = ['menu_zoom', ['Zoom&nbsp;', 'javascript:var sd = "{@strData}";eval(eval(sd.substr(0, sd.length-6))[1][1]);openwindow(defaultMetadataUrl + "&id="+parent.mb_mapObj[selectedMap].wms[selectedWMS].objLayer[selectedLayer].layer_uid);',,'info.png']];
-//var menu_layer_switch = ['menu_zoom', ['Zjjj&nbsp;', 'javascript:var sd = "{@strData}";eval(eval(sd.substr(0, sd.length-6))[1][1]);openwindow(defaultMetadataUrl + "&id="+parent.mb_mapObj[selectedMap].wms[selectedWMS].objLayer[selectedLayer].layer_uid);',,'info.png']];
-//var menu_info_switch = ['menu_zoom', ['Zmn&nbsp;', 'javascript:var sd = "{@strData}";eval(eval(sd.substr(0, sd.length-6))[1][1]);openwindow(defaultMetadataUrl + "&id="+parent.mb_mapObj[selectedMap].wms[selectedWMS].objLayer[selectedLayer].layer_uid);',,'info.png']];
-
-parent.mb_registerloadWmsSubFunctions("window.frames['treeGDE'].reloadTree();");
-parent.mb_registerInitFunctions("window.frames['treeGDE'].loadTree();");
+<?php
+# $Id$
+# http://www.mapbender.org/index.php/Mod_treefolder2.php
+# Copyright (C) 2007 Melchior Moos
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+$gui_id = $_SESSION["mb_user_gui"];
+require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
+?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
+<HTML>
+<HEAD>
+<?php
+echo '<meta http-equiv="Content-Type" content="text/html; charset='.CHARSET.'">';
+?>
+<TITLE>Treefolder</TITLE>
+<?php
+ include '../include/dyn_css.php';
+?>
+<script language='JavaScript'>
+
+function openwindow(Adresse) {
+Fenster1 = window.open(Adresse, "Informationen", "width=500,height=500,left=100,top=100,scrollbars=yes,resizable=no");
+Fenster1.focus();
+}
+</script>
+<script src="../javascripts/jsTree.js" type="text/javascript" language="JavaScript"></script>
+<?php
+echo "<script language='JavaScript'>";
+   $sql = "SELECT e_target FROM gui_element WHERE e_id = $1 AND fkey_gui_id = $2";
+   $v = array($_REQUEST['e_id_css'],$_SESSION["mb_user_gui"]);
+   $t = array('s','s');
+   $res = db_prep_query($sql,$v,$t);
+   $e_target = db_result($res,0,"e_target");
+   echo "mod_treeGDE_map = '".$e_target."';";
+echo "</script>";
+?>
+<SCRIPT language="JavaScript" type="text/javascript">
+
+var jst_container = "document.getElementById('treeContainer')";
+var jst_image_folder = imagedir;
+var jst_display_root = false;
+var defaultTarget = 'examplemain';
+var lock=false;
+var lock_update=false;
+var lock_check=false;
+var selectedMap=-1;
+var selectedWMS=-1;
+var selectedLayer=-1;
+var init=false;
+var errors = 0;
+var state=Array();
+var treeState = "";
+var arrNodes =
+[
+	['root_id', ['Layer','javascript:_foo()']
+
+	]
+];
+function _foo(){}
+
+// some defaults
+try{if (reverse){}}catch(e){reverse = 'false';}
+try{if (switchwms){}}catch(e){switchwms = 'true';}
+try{if (ficheckbox){}}catch(e){ficheckbox = 'false';}
+try{if (metadatalink){}}catch(e){metadatalink = 'false';}
+try{if (wmsbuttons){}}catch(e){wmsbuttons = 'false';}
+try{if (showstatus){}}catch(e){showstatus = 'false';}
+try{if (alerterror){}}catch(e){alerterror = 'false';}
+try{if (openfolder){}}catch(e){openfolder = 'false';}
+try{if (handlesublayer){}}catch(e){handlesublayer = 'false';}
+try{if (menu){}}catch(e){menu = '';}
+try {
+	if (redirectToMetadataUrl) {
+		if (redirectToMetadataUrl == "false") {
+			redirectToMetadataUrl = false;
+		}
+		else {
+			redirectToMetadataUrl = true;
+		}
+	}
+}
+catch (e) {
+	var redirectToMetadataUrl = true;
+}
+var defaultMetadataUrl = '../php/mod_layerMetadata.php?';
+if (redirectToMetadataUrl) {
+	defaultMetadataUrl += 'redirectToMetadataUrl=1';
+}
+else {
+	defaultMetadataUrl += 'redirectToMetadataUrl=0';
+}
+
+//menu elements
+var menu_move_up = ['menu_move_up', ['Move up&nbsp;','javascript:var sd = "{@strData}";var ids=eval(sd.substr(0, sd.length-6))[1][7];move_up(ids[0],ids[1],ids[2]);',,'move_up.png']];
+var menu_move_down = ['menu_move_down', ['Move down&nbsp;', 'javascript:var sd = "{@strData}";var ids=eval(sd.substr(0, sd.length-6))[1][7];move_down(ids[0],ids[1],ids[2]);',,'move_down.png']];
+var menu_delete = ['menu_delete', ['Remove&nbsp;', 'javascript:var sd = "{@strData}";var ids=eval(sd.substr(0, sd.length-6))[1][7];remove_wms(ids[0],ids[1],ids[2]);',,'delete_wms.png']];
+var menu_opacity_up = ['menu_opacity_up', ['Opacity up&nbsp;','javascript:var sd = "{@strData}";var ids=eval(sd.substr(0, sd.length-6))[1][7];opacity_up(ids[0],ids[1],ids[2]);',,'move_up.png']];
+var menu_opacity_down = ['menu_opacity_down', ['Opacity down&nbsp;','javascript:var sd = "{@strData}";var ids=eval(sd.substr(0, sd.length-6))[1][7];opacity_down(ids[0],ids[1],ids[2]);',,'move_down.png']];
+var menu_metalink = ['menu_metalink', ['Information&nbsp;', 'javascript:var sd = "{@strData}";var ids=eval(sd.substr(0, sd.length-6))[1][7];openwindow(defaultMetadataUrl + "&id="+parent.mb_mapObj[ids[0]].wms[ids[1]].objLayer[ids[2]].layer_uid);',,'info.png']];
+var menu_zoom = ['menu_zoom', ['Zoom&nbsp;', 'javascript:var sd = "{@strData}";var ids=eval(sd.substr(0, sd.length-6))[1][7];zoomToLayer(ids[0],ids[1],ids[2]);',,'zoom.png']];
+var menu_hide = ['menu_hide', ['Hide menu&nbsp;', 'javascript:hideMenu()',,'hide.png']];
+//var menu_wms_switch = ['menu_zoom', ['Zoom&nbsp;', 'javascript:var sd = "{@strData}";eval(eval(sd.substr(0, sd.length-6))[1][1]);openwindow(defaultMetadataUrl + "&id="+parent.mb_mapObj[selectedMap].wms[selectedWMS].objLayer[selectedLayer].layer_uid);',,'info.png']];
+//var menu_layer_switch = ['menu_zoom', ['Zjjj&nbsp;', 'javascript:var sd = "{@strData}";eval(eval(sd.substr(0, sd.length-6))[1][1]);openwindow(defaultMetadataUrl + "&id="+parent.mb_mapObj[selectedMap].wms[selectedWMS].objLayer[selectedLayer].layer_uid);',,'info.png']];
+//var menu_info_switch = ['menu_zoom', ['Zmn&nbsp;', 'javascript:var sd = "{@strData}";eval(eval(sd.substr(0, sd.length-6))[1][1]);openwindow(defaultMetadataUrl + "&id="+parent.mb_mapObj[selectedMap].wms[selectedWMS].objLayer[selectedLayer].layer_uid);',,'info.png']];
+
+parent.eventAfterLoadWMS.register(reloadTree);
+parent.eventInit.register(loadTree);
 if(showstatus=='true'||alerterror=='true'){
-	parent.mb_registerSubFunctions("window.frames['treeGDE'].init_mapcheck();");
-	init_mapcheck();
-}
-parent.mb_registerSubFunctions("window.frames['treeGDE'].updateScale();");
-if(wmsbuttons != "true")
-	jst_highlight = false;
-
-function select(i,ii,iii){
-	//ignore if selected
-	if(selectedMap==i && selectedWMS==ii && selectedLayer==iii)return;
-	if(selectedMap==-1 && selectedWMS==-1 && selectedLayer==-1){
-		selectedMap=i;
-		selectedWMS=ii;
-		selectedLayer=iii;		
-		return;
-	}
-	//scalehints
-	var scale = parseInt(parent.mb_getScale(mod_treeGDE_map));	
-	if(scale < parseInt(parent.mb_mapObj[selectedMap].wms[selectedWMS].objLayer[selectedLayer].gui_layer_minscale) && parseInt(parent.mb_mapObj[selectedMap].wms[selectedWMS].objLayer[selectedLayer].gui_layer_minscale) != 0){
-		if(selectedLayer==0)
-		   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[selectedMap].wms[selectedWMS].wms_id, '#999999');
-		else
-		   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[selectedMap].wms[selectedWMS].wms_id+"|"+parent.mb_mapObj[selectedMap].wms[selectedWMS].objLayer[selectedLayer].layer_id, '#999999');
-	}
-	else if(scale > parseInt(parent.mb_mapObj[selectedMap].wms[selectedWMS].objLayer[selectedLayer].gui_layer_maxscale) && parseInt(parent.mb_mapObj[selectedMap].wms[selectedWMS].objLayer[selectedLayer].gui_layer_maxscale) != 0){
-		if(selectedLayer==0)
-		   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[selectedMap].wms[selectedWMS].wms_id, '#999999');
-		else
-		   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[selectedMap].wms[selectedWMS].wms_id+"|"+parent.mb_mapObj[selectedMap].wms[selectedWMS].objLayer[selectedLayer].layer_id, '#999999');
-	}
-	else{
-		if(selectedLayer==0)
-		   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[selectedMap].wms[selectedWMS].wms_id, '');
-		else
-		   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[selectedMap].wms[selectedWMS].wms_id+"|"+parent.mb_mapObj[selectedMap].wms[selectedWMS].objLayer[selectedLayer].layer_id, '');
-	}
-
-	selectedMap=i;
-	selectedWMS=ii;
-	selectedLayer=iii;
-}
-
-function updateScale(){
-	if(!init)return;
-	for(var i=0; i<parent.mb_mapObj.length; i++){
-		var scale = parseInt(parent.mb_getScale(mod_treeGDE_map));
-		if(parent.mb_mapObj[i].frameName == mod_treeGDE_map){ 
-			for(var ii=0; ii<parent.mb_mapObj[i].wms.length; ii++){
-				for(var iii=1; iii<parent.mb_mapObj[i].wms[ii].objLayer.length; iii++){
-					if(scale < parseInt(parent.mb_mapObj[i].wms[ii].objLayer[iii].gui_layer_minscale) && parseInt(parent.mb_mapObj[i].wms[ii].objLayer[iii].gui_layer_minscale) != 0){                    
-						if(iii==0)
-						   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[i].wms[ii].wms_id, '#999999');
-						else
-						   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[i].wms[ii].wms_id+"|"+parent.mb_mapObj[i].wms[ii].objLayer[iii].layer_id, '#999999');
-					}
-					else if(scale > parseInt(parent.mb_mapObj[i].wms[ii].objLayer[iii].gui_layer_maxscale) && parseInt(parent.mb_mapObj[i].wms[ii].objLayer[iii].gui_layer_maxscale) != 0){
-						if(iii==0)
-						   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[i].wms[ii].wms_id, '#999999');
-						else
-						   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[i].wms[ii].wms_id+"|"+parent.mb_mapObj[i].wms[ii].objLayer[iii].layer_id, '#999999');
-					}
-					else{
-						if(iii==0)
-						   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[i].wms[ii].wms_id, '');
-						else
-						   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[i].wms[ii].wms_id+"|"+parent.mb_mapObj[i].wms[ii].objLayer[iii].layer_id, '');
-					}
-				}
-			}
-		}
-	}	
-}
-
-function operaLoad(){
-	initArray();
-	renderTree();
-	setTimeout('initWmsCheckboxen();updateScale();',100);	
-}
-
-function loadTree(){
-	if(window.opera){
-		setTimeout('operaLoad()',200);	
-		return;
-	}
-	initArray();
-	renderTree();
-	initWmsCheckboxen();
-	updateScale();
-}
-
-function reloadTree(){
-	if(!init) return;
-	selectedMap=-1;
-	selectedWMS=-1;
-	selectedLayer=-1;
-	init=false;
-	arrNodes = [['root_id', ['Layer','javascript:_foo()']]];
-	initArray();
-	if(showstatus=='true'||alerterror=='true')
-		init_mapcheck();
-	renderTree();
-	if(window.opera)
-		setTimeout('initWmsCheckboxen();updateScale();',100);	
-	else{
-		initWmsCheckboxen();
-		updateScale();
-	}
-}
-
-function imgerror(){
-	var map=parent.getMapObjIndexByName(mod_treeGDE_map);
-	var wms=Number(this.id.substr(4));
-	this.onerror=null;
-	this.onabort=null;
-	if(state[wms]!=-1 && alerterror=='true'){
-		state[wms]=-1;	
-		if(confirm('Failed to Load WMS "'+parent.mb_mapObj[map].wms[wms].objLayer[0].layer_title+'" from Server "'+parent.mb_mapObj[map].wms[wms].wms_getmap.substr(0,parent.mb_mapObj[map].wms[wms].wms_getmap.length-1)+'"\nDo you want to try to load it in a new window?')){
-			window.open(this.src,"");
-		}
-	}
-	state[wms]=-1;
-	errors++;
-	if(showstatus=='true')
-		setNodeImage(arrNodes[0][0]+"|"+parent.mb_mapObj[map].wms[wms].wms_id, "error_folder.png");
-}
-
-function checkComplete(wms, map, img, first){
-	var ind=parent.getMapObjIndexByName(mod_treeGDE_map);
-	if(parent.mb_mapObj[ind].wms[wms].mapURL == false || parent.frames[mod_treeGDE_map].document.getElementById(map).complete){
-		if(state[wms]!=-1){
-			for(var i=1;i<parent.mb_mapObj[ind].wms[wms].objLayer.length;i++){
-				if(parent.mb_mapObj[ind].wms[wms].objLayer[i].gui_layer_visible==1){
-					state[wms]=1;
-					if(showstatus=='true')
-						setNodeImage(img);
-					break;
-				}
-			}
-		}
-	}
-	else{
-		if(first){
-			state[wms]=0;
-			parent.frames[mod_treeGDE_map].document.getElementById(map).onerror=imgerror;
-			parent.frames[mod_treeGDE_map].document.getElementById(map).onabort=imgerror;
-	
-			if(showstatus=='true')
-				setNodeImage(img, "loading_folder.gif");
-		}
-
-		if(state[wms]!=-1)
-			setTimeout('checkComplete('+wms+', "'+map+'", "'+img+'");',100);		
-	}
-}
-
-//parent.mb_registerWmsLoadErrorFunctions("window.frames['treeGDE'].imgerror();");
-
-function init_mapcheck(){
-	if(!init)return;
-	errors = 0;
-	var ind = parent.getMapObjIndexByName(mod_treeGDE_map);
-	if(!parent.mb_mapObj[ind]||!init){
-		setTimeout("init_mapcheck();",100);
-		return;
-	}
-	for(var wms=0;wms<parent.mb_mapObj[ind].wms.length;wms++){
-		var wmsimgid="map_"+wms;
-		if(parent.frames[mod_treeGDE_map].document.getElementById(wmsimgid)){
-			checkComplete(wms, wmsimgid, arrNodes[0][0]+'|'+parent.mb_mapObj[ind].wms[wms].wms_id, true);
-		}
-	}
-}
-
-function handleSelectedLayer(mapObj,wms_id,layername,type,status){
-	if(lock_update||lock_check)return;
-	var ind = parent.getMapObjIndexByName(mapObj);
-	for(var i=0; i<parent.mb_mapObj[ind].wms.length; i++){
-		if(parent.mb_mapObj[ind].wms[i].wms_id == wms_id){
-			parent.mb_mapObj[ind].wms[i].handleLayer(layername, type, status);
-			break;
-		}
-	}
-}
-
-function zoomToLayer(j,k,l){
-	if(!j&&!k&&!l){
-		j=selectedMap;
-		k=selectedWMS;
-		l=selectedLayer;
-	}
-	var my=parent.mb_mapObj[j].wms[k].objLayer[l].layer_epsg;
-	for (var i=0;i<my.length;i++){
-		if(my[i]["epsg"]==parent.mb_mapObj[j].epsg){
-			parent.mb_calculateExtent(mod_treeGDE_map,my[i]["minx"],my[i]["miny"],my[i]["maxx"],my[i]["maxy"]);
-			var arrayExt = parent.mb_mapObj[j].extent.split(",");
-			parent.mb_repaint(mod_treeGDE_map,arrayExt[0],arrayExt[1],arrayExt[2],arrayExt[3]);
-			break;
-		}
-	}
-}
-
-
-//---begin------------- opacity --------------------
-
-var opacityIncrement = 20;
-
-function opacity_up(j, k, l) {
-	handleOpacity(j, k, opacityIncrement);
-}
-
-function opacity_down(j, k, l) {
-	handleOpacity(j, k, -opacityIncrement);
-}
-
-function handleOpacity(mapObj_id, wms_id, increment) {
-	var opacity = parent.mb_mapObj[mapObj_id].wms[wms_id].gui_wms_mapopacity*100 + increment;
-	parent.mb_mapObj[mapObj_id].wms[wms_id].setOpacity(opacity);
-	reloadTree();
-}
-
-//---end------------- opacity --------------------
-
-function move_up(j,k,l){
-	if(isNaN(j)&&isNaN(k)&&isNaN(l)){
-		j=selectedMap;
-		k=selectedWMS;
-		l=selectedLayer;
-	}
-	if(j==-1||k==-1||l==-1){
-		alert("You have to select the WMS you want to move up!")		
-		return;
-	}
-	var lid=parent.mb_mapObj[j].wms[k].objLayer[l].layer_id;
-	if(!parent.mb_mapObj[j].move(parent.mb_mapObj[j].wms[k].wms_id,lid,(reverse=="true")?false:true)){
-		alert("Illegal move operation");
-		return;
-	}
-	treeState = getState();
-	parent.zoom(parent.mb_mapObj[j].frameName, true, 1.0);
-	parent.mb_execloadWmsSubFunctions();
-	//find layer and select
-	for(k=0;k<parent.mb_mapObj[j].wms.length;k++){
-		for(l=0;l<parent.mb_mapObj[j].wms[k].objLayer.length;l++){
-			if(parent.mb_mapObj[j].wms[k].objLayer[l].layer_id==lid){
-				select(j,k,l);
-				if(l!=0)
-					selectNode(String(lid));
-				else
-					selectNode(String(parent.mb_mapObj[j].wms[k].wms_id));
-			}
-		}
-	}
-}
-
-function move_down(j,k,l){
-	if(isNaN(j)&&isNaN(k)&&isNaN(l)){
-		j=selectedMap;
-		k=selectedWMS;
-		l=selectedLayer;
-	}
-	if(j==-1||k==-1||l==-1){
-		alert("You have to select the WMS you want to move down!")		
-		return;
-	}
-	var lid=parent.mb_mapObj[j].wms[k].objLayer[l].layer_id;
-	if(!parent.mb_mapObj[j].move(parent.mb_mapObj[j].wms[k].wms_id,lid,(reverse=="true")?true:false)){
-		alert("Illegal move operation");
-		return;
-	}
-	treeState = getState();
-	parent.zoom(parent.mb_mapObj[j].frameName, true, 1.0);
-	parent.mb_execloadWmsSubFunctions();	
-	//find layer and select
-	for(k=0;k<parent.mb_mapObj[j].wms.length;k++){
-		for(l=0;l<parent.mb_mapObj[j].wms[k].objLayer.length;l++){
-			if(parent.mb_mapObj[j].wms[k].objLayer[l].layer_id==lid){
-				select(j,k,l);
-				if(l!=0)
-					selectNode(String(lid));
-				else
-					selectNode(String(parent.mb_mapObj[j].wms[k].wms_id));
-			}
-		}
-	}
-}
-
-function remove_wms(j,k,l){
-	if(isNaN(j)&&isNaN(k)&&isNaN(l)){
-		j=selectedMap;
-		k=selectedWMS;
-		l=selectedLayer;
-	}
-	if(j==-1||k==-1||l==-1){
-		alert("You have to select the WMS you want to delete!")		
-		return;
-	}
-	if(l!=0){
-		alert("It is not possible to delete a single layer, please select a WMS!")
-		return;
-	}
-	var visibleWMS=0;
-	for(var i=0;i<parent.mb_mapObj[j].wms.length;i++)
-		if(parent.mb_mapObj[j].wms[i].gui_wms_visible=='1'||parent.mb_mapObj[j].wms[i].gui_wms_visible==1)
-			visibleWMS++;
-	if(visibleWMS<=1){
-		alert ("Last WMS can't be removed.\n(Der letzte WMS kann nicht entfernt werden.)");
-		return;
-	}
-	if(confirm('Are you sure you want to remove "'+parent.mb_mapObj[j].wms[k].objLayer[l].layer_title+'"?')){
-  		parent.mb_mapObjremoveWMS(j,k); 
-		parent.zoom(parent.mb_mapObj[j].frameName, true, 1.0);
-		parent.mb_execloadWmsSubFunctions();	
-	}
-}
-
-function updateParent(path){
-	if(lock_check)return;
-	var reset_lock=!lock_update; 
-	lock_update=true;
-	var state=getChildrenCheckState(path, 0);
-	//enableCheckbox(path, (state!=-1)); //3rd state
-	checkNode(path, 0, (state==1));
-	if(state==0 && showstatus=='true' && path.split(jst_delimiter[0]).length == 2){
-		setTimeout('setNodeImage("'+path+'", "error_folder.png");', 100);
-	}
-	if(reset_lock)
-		lock_update=false;
-}
-
-function handleSelectedWMS(path){
-	if(lock_update)return;
-	var t = path.split("|");
-	var reset_lock=!lock_check; 
-	var ind = parent.getMapObjIndexByName(mod_treeGDE_map);
-	var layername = parent.mb_mapObj[ind].wms[parent.getWMSIndexById(mod_treeGDE_map,t[t.length-1])].objLayer[0].layer_name;
-	var bChk = IsChecked(path, 0);	
-	handleSelectedLayer(mod_treeGDE_map,t[t.length-1],layername,"visible",bChk?"1":"0");
-	lock_check=true;
-	checkChildren(path, 0, bChk);
-	if(ficheckbox)checkChildren(path, 1, bChk);
-	if(bChk==false && showstatus=='true')
-		setTimeout('setNodeImage("'+path+'", "error_folder.png");', 100);
-	if(reset_lock)
-	{
-		lock_check=false;
-		parent.mb_restateLayers(mod_treeGDE_map,t[t.length-1]);
-		parent.setSingleMapRequest(mod_treeGDE_map,t[t.length-1]);
-	}
-}
-
-function handleSelection(path){
-	if(lock_update)return;
-	var reset_lock=!lock_check; 
-	lock_check=true;
-	var bChk = IsChecked(path, 0);	
-//	enableCheckbox(path, 0, true);
-	checkChildren(path, 0, bChk);
-	if(reset_lock){
-		var t = path.split("|");
-		lock_check=false;
-		parent.mb_restateLayers(mod_treeGDE_map,t[1]);
-		parent.setSingleMapRequest(mod_treeGDE_map,t[1]);
-	}
-}
-
-function initArray(){
-	var parentObj = "";
-	var controls="";
-	if(parent.mb_mapObj.length > 0){
-		for(var i=0; i<parent.mb_mapObj.length; i++){
-			if(parent.mb_mapObj[i].frameName == mod_treeGDE_map){ 
-				for(var ii=0; ii<parent.mb_mapObj[i].wms.length; ii++){
-					if(parent.mb_mapObj[i].wms[ii].gui_wms_visible == '1' || parent.mb_mapObj[i].wms[ii].gui_wms_visible == 1){
-						for(var iii=0; iii<parent.mb_mapObj[i].wms[ii].objLayer.length; iii++){          
-							var temp = parent.mb_mapObj[i].wms[ii].objLayer[iii];     
-							if(parent.mb_mapObj[i].wms[ii].objLayer[iii].layer_parent == ""){ 
-								if(!temp.gui_layer_selectable == '1' && !temp.gui_layer_queryable == '1')
-									continue;				
-								var c_menu="[";
-								if(reverse=="true"){
-									if(menu.indexOf("wms_down")!=-1 && ii!=parent.mb_mapObj[i].wms.length-1)c_menu+="menu_move_up,";
-									if(menu.indexOf("wms_up")!=-1 && parentObj!="")c_menu+="menu_move_down,";
-								}
-								else{
-									if(menu.indexOf("wms_up")!=-1 && parentObj!="")c_menu+="menu_move_up,";
-									if(menu.indexOf("wms_down")!=-1 && ii!=parent.mb_mapObj[i].wms.length-1)c_menu+="menu_move_down,";
-								}
-								if(menu.indexOf("remove")!=-1)c_menu+="menu_delete,";
-//								if(menu.indexOf("wms_switch")!=-1)c_menu+="menu_wms_switch,";
-								if(menu.indexOf("opacity_up")!=-1 && parseFloat(parent.mb_mapObj[i].wms[ii].gui_wms_mapopacity) < 1)c_menu+="menu_opacity_up,";
-								if(menu.indexOf("opacity_down")!=-1 && parseFloat(parent.mb_mapObj[i].wms[ii].gui_wms_mapopacity) > 0)c_menu+="menu_opacity_down,";
-								if(menu.indexOf("hide")!=-1)c_menu+="menu_hide";
-								c_menu+="]";
-								controls=null;
-								if(switchwms=='true')controls='<INPUT type="checkbox" checked onclick="handleSelectedWMS(\''+arrNodes[0][0]+'|'+parent.mb_mapObj[i].wms[ii].wms_id+'\');" />';
-								if(wmsbuttons == 'true'&&metadatalink == 'true')controls+='<a href="'+'javascript:openwindow(\''+ defaultMetadataUrl + '&id='+temp.layer_uid+'\');'+'"><img src="'+imagedir+'/info.png" /></a>';
-								addNode(arrNodes[0][0],[parent.mb_mapObj[i].wms[ii].wms_id,[temp.layer_title,((metadatalink=='true'&&wmsbuttons != 'true')?('javascript:openwindow(\"'+ defaultMetadataUrl + '&id='+temp.layer_uid+'\");'):"javascript:select("+i+","+ii+","+iii+");"),,,temp.layer_title,eval(c_menu),controls,[i,ii,iii]]],false,false,reverse=="true");
-								parentObj = arrNodes[0][0]+"|"+parent.mb_mapObj[i].wms[ii].wms_id;              
-							}
-							if(parent.mb_mapObj[i].wms[ii].objLayer[iii].layer_parent && (handlesublayer=="true"||parent.mb_mapObj[i].wms[ii].objLayer[iii].layer_parent=="0")){
-								var parentLayer = "";
-								var j = iii;
-								while(parent.mb_mapObj[i].wms[ii].objLayer[j].layer_parent!="0"){
-									//find parent
-									for(var jj=0; jj < parent.mb_mapObj[i].wms[ii].objLayer.length; jj++){
-										if(parent.mb_mapObj[i].wms[ii].objLayer[jj].layer_pos==parseInt(parent.mb_mapObj[i].wms[ii].objLayer[j].layer_parent)){
-											j=jj;
-											break;
-										}										
-									}									
-									parentLayer = "|" + parent.mb_mapObj[i].wms[ii].objLayer[j].layer_id + parentLayer;
-								}
-								if(temp.gui_layer_selectable == '1' || temp.gui_layer_queryable == '1'){
-									var c_menu="[";
-									if(reverse=="true"){
-										if(menu.indexOf("layer_down")!=-1 && iii!=parent.mb_mapObj[i].wms[ii].objLayer.length-1)c_menu+="menu_move_up,";
-										if(menu.indexOf("layer_up")!=-1 && iii!=1)c_menu+="menu_move_down,";
-									}
-									else{
-										if(menu.indexOf("layer_up")!=-1 && iii!=1)c_menu+="menu_move_up,";
-										if(menu.indexOf("layer_down")!=-1 && iii!=parent.mb_mapObj[i].wms[ii].objLayer.length-1)c_menu+="menu_move_down,";
-									}
-									if(menu.indexOf("metainfo")!=-1)c_menu+="menu_metalink,";
-									if(menu.indexOf("zoom")!=-1 && temp.layer_epsg.length>0)c_menu+="menu_zoom,";
-//									if(menu.indexOf("layer_switch")!=-1)c_menu+="menu_layer_switch,";
-//									if(menu.indexOf("info_switch")!=-1)c_menu+="menu_info_switch,";
-									if(menu.indexOf("hide")!=-1)c_menu+="menu_hide";
-									c_menu+="]";
-									
-									controls='<input type="checkbox" '+(temp.layer_name==""?'style="display:none;" ':"")+((temp.gui_layer_visible=='1')?'checked ':'')+(temp.gui_layer_selectable!='1'?'disabled ':'')+"onclick=\"handleSelectedLayer('"+mod_treeGDE_map+"','"+parent.mb_mapObj[i].wms[ii].wms_id+"','"+temp.layer_name+"','visible',this.checked?1:0);handleSelection('"+parentObj+parentLayer+"|"+temp.layer_id+"');updateParent('"+parentObj+parentLayer+"');"+((ficheckbox == 'false')?"handleSelectedLayer('"+mod_treeGDE_map+"','"+parent.mb_mapObj[i].wms[ii].wms_id+"','"+temp.layer_name+"','querylayer',this.checked?1:0)":"")+"\" />";
-									if(ficheckbox == 'true')controls+='<input type="checkbox" '+(temp.gui_layer_querylayer=='1'?'checked ':'')+(temp.gui_layer_queryable!='1'?'disabled ':'')+"onclick=\"handleSelectedLayer('"+mod_treeGDE_map+"','"+parent.mb_mapObj[i].wms[ii].wms_id+"','"+temp.layer_name+"','querylayer',this.checked?1:0);checkChildren('"+parentObj+parentLayer+"|"+temp.layer_id+"', 1, this.checked?1:0)\" />";
-									if(wmsbuttons == 'true'&&metadatalink == 'true')controls+='<a href="'+'javascript:openwindow(\''+ defaultMetadataUrl + '&id='+temp.layer_uid+'\');'+'"><img src="'+imagedir+'/info.png" /></a>';
-									addNode(parentObj + parentLayer, [temp.layer_id,[temp.layer_title,((metadatalink=='true'&&wmsbuttons != 'true')?('javascript:openwindow(\"'+ defaultMetadataUrl + '&id='+temp.layer_uid+'\");'):"javascript:select("+i+","+ii+","+iii+");"),,((c_menu!='[]'&&temp.layer_name!="")?'menu.png':null),temp.layer_title,eval(c_menu),controls,[i,ii,iii]]],false,false,reverse=="true");
-								}
-							}
-						}
-					}
-				}
-			}
-		}
-	}
-	init=true;   
-}
-
-function initWmsCheckboxen(){
-	var hidden=0;
-	if(parent.mb_mapObj.length > 0){
-		for(var i=0; i<parent.mb_mapObj.length; i++){
-			if(parent.mb_mapObj[i].frameName == mod_treeGDE_map){ 
-				for(var ii=0; ii<parent.mb_mapObj[i].wms.length; ii++){
-					if(parent.mb_mapObj[i].wms[ii].gui_wms_visible == '1' || parent.mb_mapObj[i].wms[ii].gui_wms_visible == 1){
-						for(var iii=0; iii<parent.mb_mapObj[i].wms[ii].objLayer.length; iii++){          
-							var temp = parent.mb_mapObj[i].wms[ii].objLayer[iii];     
-							if(parent.mb_mapObj[i].wms[ii].objLayer[iii].layer_parent == ""){                    
-								updateParent(arrNodes[0][0]+"|"+parent.mb_mapObj[i].wms[ii].wms_id);                  
-							}
-						}
-					}
-					else if(ii<=parent.parseInt(openfolder)+hidden)
-						hidden++;
-				}
-				closeAll()
-				if(treeState!='')
-					setState(treeState);
-				else if(openfolder!='false')
-					setState(arrNodes[0][0]+"|"+parent.mb_mapObj[i].wms[parent.parseInt(openfolder)+hidden].wms_id);
-			}
-		}
-	}
-}
-//-->  
-  </SCRIPT>
-</HEAD>
-<BODY VLINK="#000000" ALINK="#000000" LINK="#000000" BGCOLOR="#ffffff" TEXT="#000000"
- MARGINHEIGHT="0" MARGINWIDTH="0" LEFTMARGIN="0" TOPMARGIN="0">
-<SCRIPT language="JavaScript" type="text/javascript">
-if(wmsbuttons=='true'){
-	document.writeln("<div>"); 
-	document.writeln('<a href="javascript:move_up()"><img src="'+imagedir+'/move_up.png" alt="move up" style="position:relative;top:0px;left:0px;"/></a>'); 
-	document.writeln('<a href="javascript:move_down()"><img src="'+imagedir+'/move_down.png" alt="move down" style="position:relative;top:0px;left:-3px"/></a>'); 
-	document.writeln('<a href="javascript:remove_wms()"><img src="'+imagedir+'/delete_wms.png" alt="remove wms" style="position:relative;top:0px;left:-6px"/></a>'); 
-	document.writeln("</div>"); 
-}
-</SCRIPT>
-<DIV id="treeContainer"></DIV>
-</BODY>
-</HTML>
+	parent.eventAfterMapRequest.register(init_mapcheck);
+	init_mapcheck();
+}
+parent.eventAfterMapRequest.register(updateScale);
+if(wmsbuttons != "true")
+	jst_highlight = false;
+
+function select(i,ii,iii){
+	//ignore if selected
+	if(selectedMap==i && selectedWMS==ii && selectedLayer==iii)return;
+	if(selectedMap==-1 && selectedWMS==-1 && selectedLayer==-1){
+		selectedMap=i;
+		selectedWMS=ii;
+		selectedLayer=iii;
+		return;
+	}
+	//scalehints
+	var scale = parseInt(parent.mb_getScale(mod_treeGDE_map));
+	if(scale < parseInt(parent.mb_mapObj[selectedMap].wms[selectedWMS].objLayer[selectedLayer].gui_layer_minscale) && parseInt(parent.mb_mapObj[selectedMap].wms[selectedWMS].objLayer[selectedLayer].gui_layer_minscale) != 0){
+		if(selectedLayer==0)
+		   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[selectedMap].wms[selectedWMS].wms_id, '#999999');
+		else
+		   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[selectedMap].wms[selectedWMS].wms_id+"|"+parent.mb_mapObj[selectedMap].wms[selectedWMS].objLayer[selectedLayer].layer_id, '#999999');
+	}
+	else if(scale > parseInt(parent.mb_mapObj[selectedMap].wms[selectedWMS].objLayer[selectedLayer].gui_layer_maxscale) && parseInt(parent.mb_mapObj[selectedMap].wms[selectedWMS].objLayer[selectedLayer].gui_layer_maxscale) != 0){
+		if(selectedLayer==0)
+		   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[selectedMap].wms[selectedWMS].wms_id, '#999999');
+		else
+		   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[selectedMap].wms[selectedWMS].wms_id+"|"+parent.mb_mapObj[selectedMap].wms[selectedWMS].objLayer[selectedLayer].layer_id, '#999999');
+	}
+	else{
+		if(selectedLayer==0)
+		   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[selectedMap].wms[selectedWMS].wms_id, '');
+		else
+		   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[selectedMap].wms[selectedWMS].wms_id+"|"+parent.mb_mapObj[selectedMap].wms[selectedWMS].objLayer[selectedLayer].layer_id, '');
+	}
+
+	selectedMap=i;
+	selectedWMS=ii;
+	selectedLayer=iii;
+}
+
+function updateScale(){
+	if(!init)return;
+	for(var i=0; i<parent.mb_mapObj.length; i++){
+		var scale = parseInt(parent.mb_getScale(mod_treeGDE_map));
+		if(parent.mb_mapObj[i].frameName == mod_treeGDE_map){
+			for(var ii=0; ii<parent.mb_mapObj[i].wms.length; ii++){
+				for(var iii=1; iii<parent.mb_mapObj[i].wms[ii].objLayer.length; iii++){
+					if(scale < parseInt(parent.mb_mapObj[i].wms[ii].objLayer[iii].gui_layer_minscale) && parseInt(parent.mb_mapObj[i].wms[ii].objLayer[iii].gui_layer_minscale) != 0){
+						if(iii==0)
+						   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[i].wms[ii].wms_id, '#999999');
+						else
+						   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[i].wms[ii].wms_id+"|"+parent.mb_mapObj[i].wms[ii].objLayer[iii].layer_id, '#999999');
+					}
+					else if(scale > parseInt(parent.mb_mapObj[i].wms[ii].objLayer[iii].gui_layer_maxscale) && parseInt(parent.mb_mapObj[i].wms[ii].objLayer[iii].gui_layer_maxscale) != 0){
+						if(iii==0)
+						   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[i].wms[ii].wms_id, '#999999');
+						else
+						   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[i].wms[ii].wms_id+"|"+parent.mb_mapObj[i].wms[ii].objLayer[iii].layer_id, '#999999');
+					}
+					else{
+						if(iii==0)
+						   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[i].wms[ii].wms_id, '');
+						else
+						   	setNodeColor(arrNodes[0][0]+"|"+parent.mb_mapObj[i].wms[ii].wms_id+"|"+parent.mb_mapObj[i].wms[ii].objLayer[iii].layer_id, '');
+					}
+				}
+			}
+		}
+	}
+}
+
+function operaLoad(){
+	initArray();
+	renderTree();
+	setTimeout('initWmsCheckboxen();updateScale();',100);
+}
+
+function loadTree(){
+	if(window.opera){
+		setTimeout('operaLoad()',200);
+		return;
+	}
+	initArray();
+	renderTree();
+	initWmsCheckboxen();
+	updateScale();
+}
+
+function reloadTree(){
+	if(!init) return;
+	selectedMap=-1;
+	selectedWMS=-1;
+	selectedLayer=-1;
+	init=false;
+	arrNodes = [['root_id', ['Layer','javascript:_foo()']]];
+	initArray();
+	if(showstatus=='true'||alerterror=='true')
+		init_mapcheck();
+	renderTree();
+	if(window.opera)
+		setTimeout('initWmsCheckboxen();updateScale();',100);
+	else{
+		initWmsCheckboxen();
+		updateScale();
+	}
+}
+
+function imgerror(){
+	var map=parent.getMapObjIndexByName(mod_treeGDE_map);
+	var wms=Number(this.id.substr(4));
+	this.onerror=null;
+	this.onabort=null;
+	if(state[wms]!=-1 && alerterror=='true'){
+		state[wms]=-1;
+		if(confirm('Failed to Load WMS "'+parent.mb_mapObj[map].wms[wms].objLayer[0].layer_title+'" from Server "'+parent.mb_mapObj[map].wms[wms].wms_getmap.substr(0,parent.mb_mapObj[map].wms[wms].wms_getmap.length-1)+'"\nDo you want to try to load it in a new window?')){
+			window.open(this.src,"");
+		}
+	}
+	state[wms]=-1;
+	errors++;
+	if(showstatus=='true')
+		setNodeImage(arrNodes[0][0]+"|"+parent.mb_mapObj[map].wms[wms].wms_id, "error_folder.png");
+}
+
+function checkComplete(wms, map, img, first){
+	var ind=parent.getMapObjIndexByName(mod_treeGDE_map);
+	if(parent.mb_mapObj[ind].wms[wms].mapURL == false || parent.frames[mod_treeGDE_map].document.getElementById(map).complete){
+		if(state[wms]!=-1){
+			for(var i=1;i<parent.mb_mapObj[ind].wms[wms].objLayer.length;i++){
+				if(parent.mb_mapObj[ind].wms[wms].objLayer[i].gui_layer_visible==1){
+					state[wms]=1;
+					if(showstatus=='true')
+						setNodeImage(img);
+					break;
+				}
+			}
+		}
+	}
+	else{
+		if(first){
+			state[wms]=0;
+			parent.frames[mod_treeGDE_map].document.getElementById(map).onerror=imgerror;
+			parent.frames[mod_treeGDE_map].document.getElementById(map).onabort=imgerror;
+
+			if(showstatus=='true')
+				setNodeImage(img, "loading_folder.gif");
+		}
+
+		if(state[wms]!=-1)
+			setTimeout('checkComplete('+wms+', "'+map+'", "'+img+'");',100);
+	}
+}
+
+//parent.mb_registerWmsLoadErrorFunctions("window.frames['treeGDE'].imgerror();");
+
+function init_mapcheck(){
+	if(!init)return;
+	errors = 0;
+	var ind = parent.getMapObjIndexByName(mod_treeGDE_map);
+	if(!parent.mb_mapObj[ind]||!init){
+		setTimeout("init_mapcheck();",100);
+		return;
+	}
+	for(var wms=0;wms<parent.mb_mapObj[ind].wms.length;wms++){
+		var wmsimgid="map_"+wms;
+		if(parent.frames[mod_treeGDE_map].document.getElementById(wmsimgid)){
+			checkComplete(wms, wmsimgid, arrNodes[0][0]+'|'+parent.mb_mapObj[ind].wms[wms].wms_id, true);
+		}
+	}
+}
+
+function handleSelectedLayer(mapObj,wms_id,layername,type,status){
+	if(lock_update||lock_check)return;
+	var ind = parent.getMapObjIndexByName(mapObj);
+	for(var i=0; i<parent.mb_mapObj[ind].wms.length; i++){
+		if(parent.mb_mapObj[ind].wms[i].wms_id == wms_id){
+			parent.mb_mapObj[ind].wms[i].handleLayer(layername, type, status);
+			break;
+		}
+	}
+}
+
+function zoomToLayer(j,k,l){
+	if(!j&&!k&&!l){
+		j=selectedMap;
+		k=selectedWMS;
+		l=selectedLayer;
+	}
+	var my=parent.mb_mapObj[j].wms[k].objLayer[l].layer_epsg;
+	for (var i=0;i<my.length;i++){
+		if(my[i]["epsg"]==parent.mb_mapObj[j].epsg){
+			parent.mb_calculateExtent(mod_treeGDE_map,my[i]["minx"],my[i]["miny"],my[i]["maxx"],my[i]["maxy"]);
+			var arrayExt = parent.mb_mapObj[j].extent.split(",");
+			parent.mb_repaint(mod_treeGDE_map,arrayExt[0],arrayExt[1],arrayExt[2],arrayExt[3]);
+			break;
+		}
+	}
+}
+
+
+//---begin------------- opacity --------------------
+
+var opacityIncrement = 20;
+
+function opacity_up(j, k, l) {
+	handleOpacity(j, k, opacityIncrement);
+}
+
+function opacity_down(j, k, l) {
+	handleOpacity(j, k, -opacityIncrement);
+}
+
+function handleOpacity(mapObj_id, wms_id, increment) {
+	var opacity = parent.mb_mapObj[mapObj_id].wms[wms_id].gui_wms_mapopacity*100 + increment;
+	parent.mb_mapObj[mapObj_id].wms[wms_id].setOpacity(opacity);
+	reloadTree();
+}
+
+//---end------------- opacity --------------------
+
+function move_up(j,k,l){
+	if(isNaN(j)&&isNaN(k)&&isNaN(l)){
+		j=selectedMap;
+		k=selectedWMS;
+		l=selectedLayer;
+	}
+	if(j==-1||k==-1||l==-1){
+		alert("You have to select the WMS you want to move up!")
+		return;
+	}
+	var lid=parent.mb_mapObj[j].wms[k].objLayer[l].layer_id;
+	if(!parent.mb_mapObj[j].move(parent.mb_mapObj[j].wms[k].wms_id,lid,(reverse=="true")?false:true)){
+		alert("Illegal move operation");
+		return;
+	}
+	treeState = getState();
+	parent.zoom(parent.mb_mapObj[j].frameName, true, 1.0);
+	parent.mb_execloadWmsSubFunctions();
+	//find layer and select
+	for(k=0;k<parent.mb_mapObj[j].wms.length;k++){
+		for(l=0;l<parent.mb_mapObj[j].wms[k].objLayer.length;l++){
+			if(parent.mb_mapObj[j].wms[k].objLayer[l].layer_id==lid){
+				select(j,k,l);
+				if(l!=0)
+					selectNode(String(lid));
+				else
+					selectNode(String(parent.mb_mapObj[j].wms[k].wms_id));
+			}
+		}
+	}
+}
+
+function move_down(j,k,l){
+	if(isNaN(j)&&isNaN(k)&&isNaN(l)){
+		j=selectedMap;
+		k=selectedWMS;
+		l=selectedLayer;
+	}
+	if(j==-1||k==-1||l==-1){
+		alert("You have to select the WMS you want to move down!")
+		return;
+	}
+	var lid=parent.mb_mapObj[j].wms[k].objLayer[l].layer_id;
+	if(!parent.mb_mapObj[j].move(parent.mb_mapObj[j].wms[k].wms_id,lid,(reverse=="true")?true:false)){
+		alert("Illegal move operation");
+		return;
+	}
+	treeState = getState();
+	parent.zoom(parent.mb_mapObj[j].frameName, true, 1.0);
+	parent.mb_execloadWmsSubFunctions();
+	//find layer and select
+	for(k=0;k<parent.mb_mapObj[j].wms.length;k++){
+		for(l=0;l<parent.mb_mapObj[j].wms[k].objLayer.length;l++){
+			if(parent.mb_mapObj[j].wms[k].objLayer[l].layer_id==lid){
+				select(j,k,l);
+				if(l!=0)
+					selectNode(String(lid));
+				else
+					selectNode(String(parent.mb_mapObj[j].wms[k].wms_id));
+			}
+		}
+	}
+}
+
+function remove_wms(j,k,l){
+	if(isNaN(j)&&isNaN(k)&&isNaN(l)){
+		j=selectedMap;
+		k=selectedWMS;
+		l=selectedLayer;
+	}
+	if(j==-1||k==-1||l==-1){
+		alert("You have to select the WMS you want to delete!")
+		return;
+	}
+	if(l!=0){
+		alert("It is not possible to delete a single layer, please select a WMS!")
+		return;
+	}
+	var visibleWMS=0;
+	for(var i=0;i<parent.mb_mapObj[j].wms.length;i++)
+		if(parent.mb_mapObj[j].wms[i].gui_wms_visible=='1'||parent.mb_mapObj[j].wms[i].gui_wms_visible==1)
+			visibleWMS++;
+	if(visibleWMS<=1){
+		alert ("Last WMS can't be removed.\n(Der letzte WMS kann nicht entfernt werden.)");
+		return;
+	}
+	if(confirm('Are you sure you want to remove "'+parent.mb_mapObj[j].wms[k].objLayer[l].layer_title+'"?')){
+  		parent.mb_mapObjremoveWMS(j,k);
+		parent.zoom(parent.mb_mapObj[j].frameName, true, 1.0);
+		parent.mb_execloadWmsSubFunctions();
+	}
+}
+
+function updateParent(path){
+	if(lock_check)return;
+	var reset_lock=!lock_update;
+	lock_update=true;
+	var state=getChildrenCheckState(path, 0);
+	//enableCheckbox(path, (state!=-1)); //3rd state
+	checkNode(path, 0, (state==1));
+	if(state==0 && showstatus=='true' && path.split(jst_delimiter[0]).length == 2){
+		setTimeout('setNodeImage("'+path+'", "error_folder.png");', 100);
+	}
+	if(reset_lock)
+		lock_update=false;
+}
+
+function handleSelectedWMS(path){
+	if(lock_update)return;
+	var t = path.split("|");
+	var reset_lock=!lock_check;
+	var ind = parent.getMapObjIndexByName(mod_treeGDE_map);
+	var layername = parent.mb_mapObj[ind].wms[parent.getWMSIndexById(mod_treeGDE_map,t[t.length-1])].objLayer[0].layer_name;
+	var bChk = IsChecked(path, 0);
+	handleSelectedLayer(mod_treeGDE_map,t[t.length-1],layername,"visible",bChk?"1":"0");
+	lock_check=true;
+	checkChildren(path, 0, bChk);
+	if(ficheckbox)checkChildren(path, 1, bChk);
+	if(bChk==false && showstatus=='true')
+		setTimeout('setNodeImage("'+path+'", "error_folder.png");', 100);
+	if(reset_lock)
+	{
+		lock_check=false;
+		parent.mb_restateLayers(mod_treeGDE_map,t[t.length-1]);
+		parent.setSingleMapRequest(mod_treeGDE_map,t[t.length-1]);
+	}
+}
+
+function handleSelection(path, box){
+	if(lock_update)return;
+	var reset_lock=!lock_check;
+	lock_check=true;
+	var bChk = IsChecked(path, box);	
+//	enableCheckbox(path, 0, true);
+	checkChildren(path, box, bChk);
+	if(reset_lock){
+		var t = path.split("|");
+		lock_check=false;
+		parent.mb_restateLayers(mod_treeGDE_map,t[1]);
+		if(box==0)
+		parent.setSingleMapRequest(mod_treeGDE_map,t[1]);
+	}
+}
+
+function initArray(){
+	var parentObj = "";
+	var controls="";
+	if(parent.mb_mapObj.length > 0){
+		for(var i=0; i<parent.mb_mapObj.length; i++){
+			if(parent.mb_mapObj[i].frameName == mod_treeGDE_map){
+				for(var ii=0; ii<parent.mb_mapObj[i].wms.length; ii++){
+					if(parent.mb_mapObj[i].wms[ii].gui_wms_visible == '1' || parent.mb_mapObj[i].wms[ii].gui_wms_visible == 1){
+						for(var iii=0; iii<parent.mb_mapObj[i].wms[ii].objLayer.length; iii++){
+							var temp = parent.mb_mapObj[i].wms[ii].objLayer[iii];
+							if(parent.mb_mapObj[i].wms[ii].objLayer[iii].layer_parent == ""){
+								if(!temp.gui_layer_selectable == '1' && !temp.gui_layer_queryable == '1')
+									continue;
+								var c_menu="[";
+								if(reverse=="true"){
+									if(menu.indexOf("wms_down")!=-1 && ii!=parent.mb_mapObj[i].wms.length-1)c_menu+="menu_move_up,";
+									if(menu.indexOf("wms_up")!=-1 && parentObj!="")c_menu+="menu_move_down,";
+								}
+								else{
+									if(menu.indexOf("wms_up")!=-1 && parentObj!="")c_menu+="menu_move_up,";
+									if(menu.indexOf("wms_down")!=-1 && ii!=parent.mb_mapObj[i].wms.length-1)c_menu+="menu_move_down,";
+								}
+								if(menu.indexOf("remove")!=-1)c_menu+="menu_delete,";
+//								if(menu.indexOf("wms_switch")!=-1)c_menu+="menu_wms_switch,";
+								if(menu.indexOf("opacity_up")!=-1 && parseFloat(parent.mb_mapObj[i].wms[ii].gui_wms_mapopacity) < 1)c_menu+="menu_opacity_up,";
+								if(menu.indexOf("opacity_down")!=-1 && parseFloat(parent.mb_mapObj[i].wms[ii].gui_wms_mapopacity) > 0)c_menu+="menu_opacity_down,";
+								if(menu.indexOf("hide")!=-1)c_menu+="menu_hide";
+								c_menu+="]";
+								controls=null;
+								if(switchwms=='true')controls='<INPUT type="checkbox" checked onclick="handleSelectedWMS(\''+arrNodes[0][0]+'|'+parent.mb_mapObj[i].wms[ii].wms_id+'\');" />';
+								if(wmsbuttons == 'true'&&metadatalink == 'true')controls+='<a href="'+'javascript:openwindow(\''+ defaultMetadataUrl + '&id='+temp.layer_uid+'\');'+'"><img src="'+imagedir+'/info.png" /></a>';
+								addNode(arrNodes[0][0],[parent.mb_mapObj[i].wms[ii].wms_id,[temp.layer_title,((metadatalink=='true'&&wmsbuttons != 'true')?('javascript:openwindow(\"'+ defaultMetadataUrl + '&id='+temp.layer_uid+'\");'):"javascript:select("+i+","+ii+","+iii+");"),,,temp.layer_title,eval(c_menu),controls,[i,ii,iii]]],false,false,reverse=="true");
+								parentObj = arrNodes[0][0]+"|"+parent.mb_mapObj[i].wms[ii].wms_id;
+							}
+							if(parent.mb_mapObj[i].wms[ii].objLayer[iii].layer_parent && (handlesublayer=="true"||parent.mb_mapObj[i].wms[ii].objLayer[iii].layer_parent=="0")){
+								var parentLayer = "";
+								var j = iii;
+								while(parent.mb_mapObj[i].wms[ii].objLayer[j].layer_parent!="0"){
+									//find parent
+									for(var jj=0; jj < parent.mb_mapObj[i].wms[ii].objLayer.length; jj++){
+										if(parent.mb_mapObj[i].wms[ii].objLayer[jj].layer_pos==parseInt(parent.mb_mapObj[i].wms[ii].objLayer[j].layer_parent)){
+											j=jj;
+											break;
+										}
+									}
+									parentLayer = "|" + parent.mb_mapObj[i].wms[ii].objLayer[j].layer_id + parentLayer;
+								}
+								if(temp.gui_layer_selectable == '1' || temp.gui_layer_queryable == '1'){
+									var c_menu="[";
+									if(reverse=="true"){
+										if(menu.indexOf("layer_down")!=-1 && iii!=parent.mb_mapObj[i].wms[ii].objLayer.length-1)c_menu+="menu_move_up,";
+										if(menu.indexOf("layer_up")!=-1 && iii!=1)c_menu+="menu_move_down,";
+									}
+									else{
+										if(menu.indexOf("layer_up")!=-1 && iii!=1)c_menu+="menu_move_up,";
+										if(menu.indexOf("layer_down")!=-1 && iii!=parent.mb_mapObj[i].wms[ii].objLayer.length-1)c_menu+="menu_move_down,";
+									}
+									if(menu.indexOf("metainfo")!=-1)c_menu+="menu_metalink,";
+									if(menu.indexOf("zoom")!=-1 && temp.layer_epsg.length>0)c_menu+="menu_zoom,";
+//									if(menu.indexOf("layer_switch")!=-1)c_menu+="menu_layer_switch,";
+//									if(menu.indexOf("info_switch")!=-1)c_menu+="menu_info_switch,";
+									if(menu.indexOf("hide")!=-1)c_menu+="menu_hide";
+									c_menu+="]";
+
+									controls='<input type="checkbox" '+(temp.layer_name==""?'style="display:none;" ':"")+((temp.gui_layer_visible=='1')?'checked ':'')+(temp.gui_layer_selectable!='1'?'disabled ':'')+"onclick=\"handleSelectedLayer('"+mod_treeGDE_map+"','"+parent.mb_mapObj[i].wms[ii].wms_id+"','"+temp.layer_name+"','visible',this.checked?1:0);handleSelection('"+parentObj+parentLayer+"|"+temp.layer_id+"', 0);updateParent('"+parentObj+parentLayer+"');"+((ficheckbox == 'false')?"handleSelectedLayer('"+mod_treeGDE_map+"','"+parent.mb_mapObj[i].wms[ii].wms_id+"','"+temp.layer_name+"','querylayer',this.checked?1:0)":"")+"\" />";
+									if(ficheckbox == 'true')controls+='<input type="checkbox" '+(temp.gui_layer_querylayer=='1'?'checked ':'')+(temp.gui_layer_queryable!='1'?'disabled ':'')+"onclick=\"handleSelectedLayer('"+mod_treeGDE_map+"','"+parent.mb_mapObj[i].wms[ii].wms_id+"','"+temp.layer_name+"','querylayer',this.checked?1:0);handleSelection('"+parentObj+parentLayer+"|"+temp.layer_id+"', 1)\" />";
+									if(wmsbuttons == 'true'&&metadatalink == 'true')controls+='<a href="'+'javascript:openwindow(\''+ defaultMetadataUrl + '&id='+temp.layer_uid+'\');'+'"><img src="'+imagedir+'/info.png" /></a>';
+									addNode(parentObj + parentLayer, [temp.layer_id,[temp.layer_title,((metadatalink=='true'&&wmsbuttons != 'true')?('javascript:openwindow(\"'+ defaultMetadataUrl + '&id='+temp.layer_uid+'\");'):"javascript:select("+i+","+ii+","+iii+");"),,((c_menu!='[]'&&temp.layer_name!="")?'menu.png':null),temp.layer_title,eval(c_menu),controls,[i,ii,iii]]],false,false,reverse=="true");
+								}
+							}
+						}
+					}
+				}
+			}
+		}
+	}
+	init=true;
+}
+
+function initWmsCheckboxen(){
+	var hidden=0;
+	if(parent.mb_mapObj.length > 0){
+		for(var i=0; i<parent.mb_mapObj.length; i++){
+			if(parent.mb_mapObj[i].frameName == mod_treeGDE_map){
+				for(var ii=0; ii<parent.mb_mapObj[i].wms.length; ii++){
+					if(parent.mb_mapObj[i].wms[ii].gui_wms_visible == '1' || parent.mb_mapObj[i].wms[ii].gui_wms_visible == 1){
+						for(var iii=0; iii<parent.mb_mapObj[i].wms[ii].objLayer.length; iii++){
+							var temp = parent.mb_mapObj[i].wms[ii].objLayer[iii];
+							if(parent.mb_mapObj[i].wms[ii].objLayer[iii].layer_parent == ""){
+								updateParent(arrNodes[0][0]+"|"+parent.mb_mapObj[i].wms[ii].wms_id);
+							}
+						}
+					}
+					else if(ii<=parent.parseInt(openfolder)+hidden)
+						hidden++;
+				}
+				closeAll()
+				if(treeState!='')
+					setState(treeState);
+				else if(openfolder!='false')
+					setState(arrNodes[0][0]+"|"+parent.mb_mapObj[i].wms[parent.parseInt(openfolder)+hidden].wms_id);
+			}
+		}
+	}
+}
+//-->
+  </SCRIPT>
+</HEAD>
+<BODY VLINK="#000000" ALINK="#000000" LINK="#000000" BGCOLOR="#ffffff" TEXT="#000000"
+ MARGINHEIGHT="0" MARGINWIDTH="0" LEFTMARGIN="0" TOPMARGIN="0">
+<SCRIPT language="JavaScript" type="text/javascript">
+if(wmsbuttons=='true'){
+	document.writeln("<div>");
+	document.writeln('<a href="javascript:move_up()"><img src="'+imagedir+'/move_up.png" alt="move up" style="position:relative;top:0px;left:0px;"/></a>');
+	document.writeln('<a href="javascript:move_down()"><img src="'+imagedir+'/move_down.png" alt="move down" style="position:relative;top:0px;left:-3px"/></a>');
+	document.writeln('<a href="javascript:remove_wms()"><img src="'+imagedir+'/delete_wms.png" alt="remove wms" style="position:relative;top:0px;left:-6px"/></a>');
+	document.writeln("</div>");
+}
+</SCRIPT>
+<DIV id="treeContainer"></DIV>
+</BODY>
+</HTML>
\ No newline at end of file



More information about the Mapbender_commits mailing list