[Mapbender-commits] r1380 - trunk/mapbender/http/javascripts

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed May 30 04:32:16 EDT 2007


Author: christoph
Date: 2007-05-30 04:32:16 -0400 (Wed, 30 May 2007)
New Revision: 1380

Added:
   trunk/mapbender/http/javascripts/map.js
Modified:
   trunk/mapbender/http/javascripts/map.php
Log:
moved js code in new file map.js

-> JSDoc
-> compression

Added: trunk/mapbender/http/javascripts/map.js
===================================================================
--- trunk/mapbender/http/javascripts/map.js	                        (rev 0)
+++ trunk/mapbender/http/javascripts/map.js	2007-05-30 08:32:16 UTC (rev 1380)
@@ -0,0 +1,1725 @@
+var ie = document.all?1:0;
+var n6 = document.getElementById&&!document.all?1:0;
+var n4 = document.layers?1:0;
+
+var mb_feature_count = 100;
+
+var mb_resolution = 28.35;
+var mb_mapObj = new Array();
+var mb_fiWin = null;
+var mb_panActive = false;
+var clickX;
+var clickY;
+var mb_start_x = 0;
+var mb_start_y = 0;
+var mb_end_x = 0;
+var mb_end_y = 0;
+var mb_offset_top = 0;
+var mb_offset_right = 0;
+var mb_offset_bottom = 0;
+var mb_offset_left = 0;
+var mb_log = null;
+
+var mb_PanSubElements = new Array();
+function mb_registerPanSubElement(elName){
+	var ind = mb_PanSubElements.length;
+	mb_PanSubElements[ind] = elName;
+}
+
+var mb_vendorSpecific = new Array();
+function mb_registerVendorSpecific(stringFunction){
+	mb_vendorSpecific[mb_vendorSpecific.length] = stringFunction;
+}
+
+var mb_security_proxy = "http://wms1.ccgis.de/mapbender/tools/security_proxy.php?mb_ows_security_proxy=";
+
+var mb_trans = new Image; 
+mb_trans.src = "../img/transparent.gif";
+/*END OF GLOBALS*/
+
+
+function init(){
+	for(var i=0; i<mb_InitFunctions.length; i++){
+		eval(mb_InitFunctions[i]);
+	}
+	for(var i=0; i<mb_mapObj.length; i++){
+		setMapRequest(mb_mapObj[i].frameName);
+	}      	
+}
+
+function deleteWmsObject() {
+	wms = new Array();
+	wms_layer_count = 0;
+}
+
+function deleteMapObj() {
+	mb_mapObj = new Array();
+}
+
+function mb_registerMapObj(frameName, elementName,wms_index,width, height){
+	mb_mapObj[mb_mapObj.length] = new mb_mapObj_const(frameName, elementName, width, height, wms_index);    
+}
+
+function mb_mapObj_const(frameName, elementName, width, height, wms_index){
+
+   this.width = width;
+   this.height = height;
+   this.frameName = frameName;
+   this.elementName = elementName;
+   this.layers = new Array();
+   this.styles = new Array();
+   this.querylayers = new Array();
+   this.geom = "";
+   this.gml = ""; 
+   if(wms_index != null){
+      this.wms = new Array();
+      this.wms[0] = wms[wms_index];
+      this.wms[0].mapURL = false;
+      var cnt_layers = 0;
+      var cnt_querylayers = 0;
+      var styles = "";
+      var layers = "";
+      var querylayers = "";
+      for(var ii=0; ii<this.wms[0].objLayer.length; ii++){
+         if(this.wms[0].objLayer[ii].gui_layer_visible == 1 && ii>0){
+            if(cnt_layers > 0){layers += ","; styles += ","; }
+            layers += this.wms[0].objLayer[ii].layer_name; 
+            styles += ""; 
+            cnt_layers++;
+         }   
+         if(this.wms[0].objLayer[ii].gui_layer_querylayer == 1 && ii>0){
+            if(cnt_querylayers > 0){querylayers += ",";}
+            querylayers += this.wms[0].objLayer[ii].layer_name; 
+            cnt_querylayers++;
+         }                      
+      }
+      this.layers[0] = layers;
+      this.styles[0] = styles;
+      this.querylayers[0] = querylayers;   
+   }
+   else{
+	this.wms = new Array();
+	for(i=0; i<wms.length; i++){
+		this.wms[i] = wms[i];
+		this.wms[i].mapURL = false;
+	}
+      for(var i=0; i< this.wms.length; i++){
+         var cnt_layers = 0;
+         var cnt_querylayers = 0;
+         var styles = "";
+         var layers = "";
+         var querylayers = "";
+         for(var ii=0; ii<this.wms[i].objLayer.length; ii++){
+            if(this.wms[i].objLayer[ii].gui_layer_visible == 1 && ii>0){
+               if(cnt_layers > 0){layers += ","; styles += ","; }
+               layers += wms[i].objLayer[ii].layer_name; 
+               styles += ""; 
+               cnt_layers++;
+            }            
+            if(this.wms[i].objLayer[ii].gui_layer_querylayer == 1 && ii>0){
+               if(cnt_querylayers > 0){querylayers += ",";}
+               querylayers += wms[i].objLayer[ii].layer_name; 
+               cnt_querylayers++;
+            }                          
+         }
+         this.layers[i] = layers;
+         this.styles[i] = styles;
+         this.querylayers[i] = querylayers;
+      }
+   }
+   this.epsg = wms[0].gui_wms_epsg;
+   this.extent = setExtent(this.width,this.height,this.epsg);
+   this.mapURL = new Array();
+   for(var i=0; i<mb_MapObjectSubFunctions.length; i++){
+      eval(mb_MapObjectSubFunctions[i]);
+   }  
+}
+
+
+function mb_getConjunctionCharacter(onlineresource){
+	if(onlineresource.indexOf("?") > -1){ 
+		if(onlineresource.charAt(onlineresource.length-1) == "?"){ 
+			nextvalue = "";
+		}else if(onlineresource.charAt(onlineresource.length-1) == "&"){
+			nextvalue = "";
+		}else{
+			nextvalue = "&";
+		}
+	}
+	if(onlineresource.indexOf("?") == -1){
+		nextvalue = "?";
+	} 
+	return nextvalue;  
+}
+
+
+function mb_moveWmsById (mapObj_ind, wms_id, toIndex) {
+	return mb_wmsMoveByIndex(mapObj_ind, getWMSIndexById(mapObj_ind, wms_id), toIndex);
+}
+
+function mb_wmsMoveByIndex(mapObj_ind, fromIndex, toIndex) {
+	if (fromIndex != toIndex && fromIndex >= 0 && fromIndex < mb_mapObj[mapObj_ind].wms.length && toIndex >= 0 && toIndex < mb_mapObj[mapObj_ind].wms.length) {
+		var changed = false;
+
+		if (fromIndex > toIndex) {
+			for (var i = fromIndex; i > toIndex ; i--) {
+				var result = mb_swapWmsByIndex(mapObj_ind, i-1, i);
+				if (result == true) changed = true;
+			}
+		}
+		else {
+			for (var i = fromIndex; i < toIndex ; i++) {
+				var result = mb_swapWmsByIndex(mapObj_ind, i, i+1);
+				if (result == true) changed = true;
+			}
+		}
+		return changed;
+	}
+	else {
+		return false;
+	}
+}
+
+function mb_swapWmsById(mapObj_ind, wms1_id, wms2_id) {
+	return mb_swapWmsByIndex(mapObj_ind, getWMSIndexById(mapObj_ind, wms1_id), getWMSIndexById(mapObj_ind, wms2_id));
+}
+
+function mb_swapWmsByIndex(mapObj_ind, indexA, indexB) {
+	if (indexA != indexB && indexA >= 0 && indexA < mb_mapObj[mapObj_ind].wms.length && indexB >= 0 && indexB < mb_mapObj[mapObj_ind].wms.length) {
+		upper = mb_mapObj[mapObj_ind].wms[indexA];
+		mb_mapObj[mapObj_ind].wms[indexA] = mb_mapObj[mapObj_ind].wms[indexB];
+		mb_mapObj[mapObj_ind].wms[indexB] = upper;
+		var upperLayers = mb_mapObj[mapObj_ind].layers[indexA];
+		var upperStyles = mb_mapObj[mapObj_ind].styles[indexA];
+		var upperQuerylayers = mb_mapObj[mapObj_ind].querylayers[indexA];
+		mb_mapObj[mapObj_ind].layers[indexA] = mb_mapObj[mapObj_ind].layers[indexB];
+		mb_mapObj[mapObj_ind].styles[indexA] = mb_mapObj[mapObj_ind].styles[indexB];
+		mb_mapObj[mapObj_ind].querylayers[indexA] = mb_mapObj[mapObj_ind].querylayers[indexB];
+		mb_mapObj[mapObj_ind].layers[indexB] = upperLayers;
+		mb_mapObj[mapObj_ind].styles[indexB] = upperStyles;
+		mb_mapObj[mapObj_ind].querylayers[indexB] = upperQuerylayers;
+		return true;
+	}
+	else {
+		return false;
+	}
+}
+
+function mb_moveUpWmsByIndex(mapObj_ind, index) {
+	if (index > 0 && index < wms.length) {
+		return mb_swapWmsByIndex(mapObj_ind, index-1, index);
+	}
+	else {
+		return false;
+	}
+}
+
+function mb_moveDownWmsByIndex(mapObj_ind, index) {
+	if (index >= 0 && index < wms.length-1) {
+		return mb_swapWmsByIndex(mapObj_ind, index, index+1);
+	}
+	else {
+		return false;
+	}
+}
+
+function mb_mapObjaddWMS(obj){
+	var cnt_layers = 0;
+	var cnt_querylayers = 0;
+	var styles = "";
+	var layers = "";
+	var querylayers = "";
+	var ind = getMapObjIndexByName(obj);
+	//is the id valid?
+	for( var i=0; i<(wms.length-1); i++){
+		if(parseInt(wms[i].wms_id) >= parseInt(wms[wms.length-1].wms_id)){
+			wms[wms.length-1].wms_id = parseInt(mb_mapObj[ind].wms[i].wms_id) + 1;
+		}
+	} 
+	mb_mapObj[ind].wms[mb_mapObj[ind].wms.length] = wms[wms.length-1];
+	mb_mapObj[ind].layers[mb_mapObj[ind].layers.length] = layers;
+	mb_mapObj[ind].styles[mb_mapObj[ind].styles.length] = styles;
+	mb_mapObj[ind].querylayers[mb_mapObj[ind].querylayers.length] = querylayers;  
+	mb_execloadWmsSubFunctions();
+	return true; 
+}
+//CB
+function mb_mapObjaddWMSwithLayers(obj,layers,querylayers){
+	var cnt_layers = 0;
+	var cnt_querylayers = 0;
+	var styles = "";
+	var ind = getMapObjIndexByName(obj);
+	mb_mapObj[ind].wms[mb_mapObj[ind].wms.length] = wms[wms.length-1];
+	mb_mapObj[ind].layers[mb_mapObj[ind].layers.length] = layers;
+	mb_mapObj[ind].styles[mb_mapObj[ind].styles.length] = styles;
+	mb_mapObj[ind].querylayers[mb_mapObj[ind].querylayers.length] = querylayers;   
+}
+function mb_mapObjremoveWMS(objind,wmsind){
+	var wms_ID = null;
+	
+	var new_wmsarray = new Array();
+	var new_layerarray = new Array();
+	var new_querylayerarray = new Array();
+	var new_stylesarray = new Array();
+	var new_mapURLarray = new Array();
+	
+	for	(var i=0;i<mb_mapObj[objind].wms.length; i++){
+		if(i != wmsind){
+			new_wmsarray[new_wmsarray.length] = mb_mapObj[objind].wms[i];
+			new_layerarray[new_layerarray.length] = mb_mapObj[objind].layers[i];
+			new_querylayerarray[new_querylayerarray.length] = mb_mapObj[objind].querylayers[i];
+			new_stylesarray[new_stylesarray.length] = mb_mapObj[objind].styles[i];
+			new_mapURLarray[new_mapURLarray.length] = mb_mapObj[objind].mapURL[i] 
+		}
+		else {
+			wms_ID = mb_mapObj[objind].wms[i].wms_id;
+		}
+	}
+	mb_mapObj[objind].wms = new_wmsarray; 
+	mb_mapObj[objind].layers = new_layerarray; 
+	mb_mapObj[objind].querylayers = new_querylayerarray; 
+	mb_mapObj[objind].styles = new_stylesarray; 
+	mb_mapObj[objind].mapURL = new_mapURLarray;
+
+	var another_new_wmsarray = new Array();
+	for	(var i=0;i<wms.length; i++){
+		if(wms[i].wms_id != wms_ID){
+			another_new_wmsarray[another_new_wmsarray.length] = wms[i]; 
+		}
+	}
+	wms = another_new_wmsarray; 
+}
+function setExtent(width,height,epsg){
+   for(var i=0; i < wms[0].gui_epsg.length; i++){
+      if(wms[0].gui_epsg[i] == epsg){      
+         var bbox_minx = parseFloat(wms[0].gui_minx[i]);
+         var bbox_miny = parseFloat(wms[0].gui_miny[i]);
+         var bbox_maxx = parseFloat(wms[0].gui_maxx[i]);
+         var bbox_maxy = parseFloat(wms[0].gui_maxy[i]);     
+   
+         var extenty = bbox_maxy - bbox_miny;
+         var extentx = bbox_maxx - bbox_minx;
+
+         var relation_px_x = width / height;
+         var relation_px_y = height / width;
+         var relation_bbox_x = extentx / extenty;         
+         var centerx = bbox_minx + (extentx/2);
+         var centery = bbox_miny + (extenty/2);
+         if(relation_bbox_x <= relation_px_x){                
+                bbox_minx = centerx - relation_px_x * extenty / 2;
+                bbox_maxx = centerx + relation_px_x * extenty / 2;
+         }
+        
+         if(relation_bbox_x > relation_px_x){                
+                bbox_miny = centery - relation_px_y * extentx / 2;
+                bbox_maxy = centery + relation_px_y * extentx / 2;
+         }
+        return bbox_minx  +","+ bbox_miny +","+ bbox_maxx  +","+ bbox_maxy;
+     }
+   }
+}
+function setMapRequest(frameName){
+	var functionName = 'setMapRequest';
+	var ts = mb_timestamp();
+
+	for(var i=0; i<mb_MapRequestPreFunctions.length; i++){
+		var ret = eval(mb_MapRequestPreFunctions[i]);
+		if(ret == false){
+			return true;
+		}
+	}
+	for(var i=0; i<mb_mapObj.length; i++){
+		var newMapRequest = "";
+		if(mb_mapObj[i].frameName == frameName){
+			for(var ii=0; ii<mb_mapObj[i].wms.length; ii++){
+				if(mb_mapObj[i].wms[ii].gui_wms_visible > 0){
+					var myDivId = "div_" + ii;          
+					var myMapId = "map_" + ii;
+					//disable Layer which are out of scale
+					var str_LayerStyles = mb_checkScale(frameName,i,ii);
+					if(mb_mapObj[i].layers[ii] != "" && str_LayerStyles[0] != ''){
+						var newMapURL = "";
+
+// replaced by opacity version 
+//						newMapRequest += "<div id='"+myDivId+"' style='position:absolute; top:0px; left:0px; z-index:'"+ii+"'>";
+
+ 						var cadenaOpacity = "opacity:"+mb_mapObj[i].wms[ii].gui_wms_mapopacity+"; Filter: Alpha(Opacity="+mb_mapObj[i].wms[ii].gui_wms_mapopacity*100+"); -moz-opacity:"+mb_mapObj[i].wms[ii].gui_wms_mapopacity+" ; -khtml-opacity:"+mb_mapObj[i].wms[ii].gui_wms_mapopacity;
+ 						newMapRequest += "<div id='"+myDivId+"' style=\"position:absolute; top:0px; left:0px; z-index:"+ii+";"+cadenaOpacity+"\">";
+
+						newMapRequest += "<img id='"+myMapId+"' name='mapimage' src='";
+						newMapURL += mb_mapObj[i].wms[ii].wms_getmap;   
+						
+						newMapURL += mb_getConjunctionCharacter(mb_mapObj[i].wms[ii].wms_getmap);
+						
+						if(mb_mapObj[i].wms[ii].wms_version == "1.0.0"){newMapURL += "WMTVER="+mb_mapObj[i].wms[ii].wms_version+"&REQUEST=map&";}
+						if(mb_mapObj[i].wms[ii].wms_version != "1.0.0"){newMapURL += "VERSION="+mb_mapObj[i].wms[ii].wms_version+"&REQUEST=GetMap&SERVICE=WMS&";} 
+						
+						newMapURL += "LAYERS="+str_LayerStyles[0]+"&";
+						newMapURL += "STYLES="+str_LayerStyles[1]+"&";
+		
+						newMapURL += "SRS="+mb_mapObj[i].epsg+"&";
+						newMapURL += "BBOX="+mb_mapObj[i].extent+"&";
+						newMapURL += "WIDTH="+mb_mapObj[i].width+"&";
+						newMapURL += "HEIGHT="+mb_mapObj[i].height+"&";
+						newMapURL += "FORMAT="+mb_mapObj[i].wms[ii].gui_wms_mapformat+"&";
+						newMapURL += "BGCOLOR=0xffffff&";
+						if(mb_mapObj[i].wms[ii].gui_wms_mapformat.search(/gif/i)>-1 || mb_mapObj[i].wms[ii].gui_wms_mapformat.search(/png/i)>-1){
+							newMapURL += "TRANSPARENT=TRUE&";
+						}
+						newMapURL += "EXCEPTIONS="+mb_mapObj[i].wms[ii].gui_wms_exceptionformat;
+						// add vendor-specifics
+						for(var v=0; v < mb_vendorSpecific.length; v++){
+							var vendorSpecificString = eval(mb_vendorSpecific[v]); 
+
+							// if eval doesn't evaluate a function, the result is undefined.
+							// Sometimes it is necessary not to evaluate a function, for
+							// example if you want to change a variable from the current
+							// scope (see mod_addSLD.php) 
+							if (typeof(vendorSpecificString) != "undefined") {
+								newMapURL += "&" + vendorSpecificString; 
+							}
+						}           
+						// add Filter
+						if(mb_mapObj[i].wms[ii].wms_filter != ""){
+							var tmp = mb_mapObj[i].wms[ii].wms_filter +"?id="+ mb_styleID;
+
+							var temp = "&SLD=" + tmp+ "&";
+							newMapURL += temp;
+						}
+						if(mb_log){
+							var tmp = eval(mb_log + "('" + newMapURL + "','" + ts + "')");
+						}
+						newMapRequest += newMapURL;
+						mb_mapObj[i].mapURL[ii] = newMapURL;	
+						mb_mapObj[i].wms[ii].mapURL = newMapURL;
+						newMapRequest += "' width='"+mb_mapObj[i].width+"' height='"+mb_mapObj[i].height+"' border='0'></div>";   
+					}
+					else{
+						mb_mapObj[i].mapURL[ii] = false;
+						mb_mapObj[i].wms[ii].mapURL = false;
+						newMapRequest += "<div id='" + myDivId + "' style='position:absolute; top:0px; left:0px; z-index:" + ii + "'>";
+						newMapRequest += "<img id='"+myMapId+"' name='mapimage' src='" + mb_trans.src;
+						newMapRequest += "' width='"+mb_mapObj[i].width+"' height='"+mb_mapObj[i].height+"' border='0'>";
+						newMapRequest +="</div>";
+					}
+				}
+			}
+			//prompt("",newMapRequest);
+			writeTag(mb_mapObj[i].frameName,mb_mapObj[i].elementName,newMapRequest);
+		}
+	}
+	for(var i=0; i<mb_MapRequestSubFunctions.length; i++){
+		eval(mb_MapRequestSubFunctions[i]);
+	}
+}
+function setSingleMapRequest(frameName,wms_id){
+	var functionName = 'setSingleMapRequest';
+	var ts = mb_timestamp();	
+	
+	for(var i=0; i<mb_MapRequestPreFunctions.length; i++){
+		eval(mb_MapRequestPreFunctions[i]);
+	}	
+	for(var i=0; i<mb_mapObj.length; i++){
+		var newMapRequest = "";
+		if(mb_mapObj[i].frameName == frameName){
+			for(var ii=0; ii<mb_mapObj[i].wms.length; ii++){ 
+				var myDivId = "div_" + ii;
+				var myMapId = "map_" + ii;
+				if(mb_mapObj[i].wms[ii].wms_id == wms_id){  
+					var newMapURL = "";
+					newMapRequest += "<img id='"+myMapId+"' name='mapimage' src='";
+					newMapURL += mb_mapObj[i].wms[ii].wms_getmap; 
+
+					newMapURL += mb_getConjunctionCharacter(mb_mapObj[i].wms[ii].wms_getmap);
+						
+					if(mb_mapObj[i].wms[ii].wms_version == "1.0.0"){newMapURL += "WMTVER="+mb_mapObj[i].wms[ii].wms_version+"&REQUEST=map&";}
+					if(mb_mapObj[i].wms[ii].wms_version != "1.0.0"){newMapURL += "VERSION="+mb_mapObj[i].wms[ii].wms_version+"&REQUEST=GetMap&SERVICE=WMS&";}             
+					
+					//disable Layer which are out of scale
+					var str_LayerStyles = mb_checkScale(frameName,i,ii); 
+
+					newMapURL += "LAYERS="+str_LayerStyles[0]+"&";
+					newMapURL += "STYLES="+str_LayerStyles[1]+"&";
+         
+					newMapURL += "SRS="+mb_mapObj[i].epsg+"&";
+					newMapURL += "BBOX="+mb_mapObj[i].extent+"&";
+					newMapURL += "WIDTH="+mb_mapObj[i].width+"&";
+					newMapURL += "HEIGHT="+mb_mapObj[i].height+"&";
+					newMapURL += "FORMAT="+mb_mapObj[i].wms[ii].gui_wms_mapformat+"&";
+					newMapURL += "BGCOLOR=0xffffff&";
+					if(mb_mapObj[i].wms[ii].gui_wms_mapformat.search(/gif/i)>-1 || mb_mapObj[i].wms[ii].gui_wms_mapformat.search(/png/i)>-1){
+						newMapURL += "TRANSPARENT=TRUE&";
+					}
+					newMapURL += "EXCEPTIONS="+mb_mapObj[i].wms[ii].gui_wms_exceptionformat;
+					// add vendor-specific
+					for (var v = 0; v < mb_vendorSpecific.length; v++) {
+						var vendorSpecificString = eval(mb_vendorSpecific[v]); 
+						// if eval doesn't evaluate a function, the result is undefined.
+						// Sometimes it is necessary not to evaluate a function, for
+						// example if you want to change a variable from the current
+						// scope (see mod_addSLD.php) 
+						if (typeof(vendorSpecificString) != "undefined") {
+							newMapURL += "&" + vendorSpecificString;
+						} 
+					}
+					// add Filter
+					if(mb_mapObj[i].wms[ii].wms_filter != ""){
+						var tmp = mb_mapObj[i].wms[ii].wms_filter +"?id="+ mb_styleID;
+						//prompt("",tmp);;
+						var temp = "&SLD=" + tmp+ "&";
+						newMapURL += temp;
+					}
+					//prompt("",newMapURL);
+					if(mb_mapObj[i].layers[ii] != "" && str_LayerStyles[0] != ""){
+						newMapRequest += newMapURL;
+						mb_mapObj[i].mapURL[ii] = newMapURL;
+						mb_mapObj[i].wms[ii].mapURL = newMapURL;
+						newMapRequest += "' width='"+mb_mapObj[i].width+"' height='"+mb_mapObj[i].height+"' border='0'>";
+					}
+					else{
+						mb_mapObj[i].mapURL[ii] = false;
+						mb_mapObj[i].wms[ii].mapURL = false;
+						newMapRequest = "<img id='"+myMapId+"' name='mapimage' src='" + mb_trans.src;
+						newMapRequest += "' width='"+mb_mapObj[i].width+"' height='"+mb_mapObj[i].height+"' border='0'>";
+					}        
+					//prompt("",newMapRequest);
+					if(mb_log){
+						var tmp = eval(mb_log + "('" + newMapURL + "','" + ts + "')");
+					}
+					writeTag(mb_mapObj[i].frameName,myDivId,newMapRequest);
+				}                            
+			}           
+		}      
+	}   
+	for(var i=0; i<mb_MapRequestSubFunctions.length; i++){
+		eval(mb_MapRequestSubFunctions[i]);
+	}  
+}
+function mb_restateLayers(frameName,wms_id){
+	//alert(frameName + " / " + wms_id);
+	var ind = getMapObjIndexByName(frameName);	
+	for(var i=0; i<mb_mapObj[ind].wms.length; i++){
+		if(mb_mapObj[ind].wms[i].wms_id == wms_id){
+			var cnt_layers = 0;
+			var cnt_querylayers = 0;
+			var layers = "";
+			var styles = "";
+			var querylayers = "";
+			for(var ii=0; ii<mb_mapObj[ind].wms[i].objLayer.length; ii++){
+				if(mb_mapObj[ind].wms[i].objLayer[ii].gui_layer_visible == 1 && ii>0){
+					if(cnt_layers > 0){layers += ","; styles += ","; }
+					layers += mb_mapObj[ind].wms[i].objLayer[ii].layer_name;
+					//alert(mb_mapObj[ind].wms[i].objLayer[ii].layer_name); 
+					styles += ""; 
+					cnt_layers++;
+				}            
+				if(mb_mapObj[ind].wms[i].objLayer[ii].gui_layer_querylayer == 1 && ii>0){
+					if(cnt_querylayers > 0){querylayers += ",";}
+					querylayers += mb_mapObj[ind].wms[i].objLayer[ii].layer_name; 
+					cnt_querylayers++;
+				}
+				mb_mapObj[ind].layers[i] = layers;
+				mb_mapObj[ind].querylayers[i] = querylayers;
+				mb_mapObj[ind].styles[i] = styles;
+			}
+		}
+	}
+}
+
+function mb_checkScale(frameName,mObj,wmsObj){
+	var thisLayer = mb_mapObj[mObj].layers[wmsObj].split(",");
+	var thisScale = mb_getScale(frameName);  
+	var str_layer = "";
+	var str_styles = "";
+	var str_titles = "";
+	var str_legendurls = "";
+	var str_parent = "";
+	var cnt_layer = 0;
+	for(var i=0; i<mb_mapObj[mObj].wms[wmsObj].objLayer.length; i++){  
+		var myLayername = mb_mapObj[mObj].wms[wmsObj].objLayer[i].layer_name;
+		var myMinscale = mb_mapObj[mObj].wms[wmsObj].objLayer[i].gui_layer_minscale;
+		var myMaxscale = mb_mapObj[mObj].wms[wmsObj].objLayer[i].gui_layer_maxscale;
+		for(var ii=0; ii<thisLayer.length; ii++){
+			var minscaleOK = false;
+			var maxscaleOK = false;   
+			if(thisLayer[ii] == myLayername){
+				if(myMinscale == 0 || thisScale >= myMinscale){minscaleOK = true;}
+				if(myMaxscale == 0 || thisScale <= myMaxscale){maxscaleOK = true;}
+				if(maxscaleOK == true && minscaleOK == true ){
+					if(cnt_layer > 0){str_layer += ","; str_styles += ","; str_titles += ",";str_parent += ","; str_legendurls += ",";}
+					str_layer += thisLayer[ii];
+					str_styles += "";
+					str_titles += mb_mapObj[mObj].wms[wmsObj].objLayer[i].layer_title;
+					str_parent += mb_mapObj[mObj].wms[wmsObj].objLayer[i].layer_parent;
+					if(mb_mapObj[mObj].wms[wmsObj].objLayer[i].layer_style.length>0){
+					 	str_legendurls += mb_mapObj[mObj].wms[wmsObj].objLayer[i].layer_style[0]["legendurl"] ;
+					}
+					cnt_layer++;
+				}
+			}
+		}
+	}
+	var str_layerstyles = new Array();
+	str_layerstyles[0] = str_layer;
+	str_layerstyles[1] = str_styles;
+	str_layerstyles[2] = str_titles;
+	str_layerstyles[3] = str_legendurls;
+	str_layerstyles[4] = str_parent;
+	return str_layerstyles;
+}
+function setFeatureInfoRequest(fName,x,y, path) {
+	var functionName = 'setFeatureInfoRequest';
+	var ts = mb_timestamp();
+	for(var i=0; i<mb_FeatureInfoPreFunctions.length; i++){
+		eval(mb_FeatureInfoPreFunctions[i]);
+	}   
+	var cnt_fi = 0;
+	for(var i=0; i<mb_mapObj.length; i++){
+		if(mb_mapObj[i].frameName == fName){
+			for(var ii=0; ii<mb_mapObj[i].wms.length; ii++){
+				var newfeatureInfoRequest = "";
+				var requestParams = "";
+				var validation = false;
+				newfeatureInfoRequest += mb_mapObj[i].wms[ii].wms_getfeatureinfo;          
+            	newfeatureInfoRequest += mb_getConjunctionCharacter(mb_mapObj[i].wms[ii].wms_getfeatureinfo);
+            	
+				if(mb_mapObj[i].wms[ii].wms_version == "1.0.0"){requestParams += "WMTVER="+mb_mapObj[i].wms[ii].wms_version+"&REQUEST=feature_info&";}
+				if(mb_mapObj[i].wms[ii].wms_version != "1.0.0"){requestParams += "VERSION="+mb_mapObj[i].wms[ii].wms_version+"&REQUEST=GetFeatureInfo&SERVICE=WMS&";}
+				requestParams += "SRS="+mb_mapObj[i].epsg+"&";
+				requestParams += "BBOX="+mb_mapObj[i].extent+"&";
+				requestParams += "WIDTH="+mb_mapObj[i].width+"&";
+				requestParams += "HEIGHT="+mb_mapObj[i].height+"&";
+				requestParams += "LAYERS="+mb_mapObj[i].layers[ii]+"&";
+				requestParams += "STYLES="+mb_mapObj[i].styles[ii]+"&";
+				requestParams += "FORMAT="+mb_mapObj[i].wms[ii].gui_wms_mapformat+"&";
+				requestParams += "INFO_FORMAT="+mb_mapObj[i].wms[ii].gui_wms_featureinfoformat+"&";
+				requestParams += "EXCEPTIONS=application/vnd.ogc.se_xml&";
+				if(mb_feature_count > 0){             
+					requestParams += "FEATURE_COUNT="+mb_feature_count+"&";
+				}
+				requestParams += "QUERY_LAYERS="+mb_mapObj[i].querylayers[ii]+"&";
+				requestParams += "X=" + x  + "&";
+				requestParams += "Y=" + y;
+				
+				if(mb_mapObj[i].querylayers[ii] != "" && mb_mapObj[i].layers[ii] != ""){
+					validation = true;
+				}
+				//add vendor-specific
+				for(var v=0; v < mb_vendorSpecific.length; v++){
+					var vendorSpecificString = eval(mb_vendorSpecific[v]); 
+					requestParams += "&" + vendorSpecificString; 
+				}
+				if(mb_log && validation){
+					var tmp = eval(mb_log + "('" + newfeatureInfoRequest + requestParams + "','" + ts + "')");
+				}
+				if(document.getElementById("FeatureInfoRedirect") && validation){
+					newfeatureInfoRequest += requestParams;
+					if(path){
+						window.frames["FeatureInfoRedirect"].document.getElementById(mb_mapObj[i].wms[ii].wms_id).src = path + "?url=" + escape(newfeatureInfoRequest)+"&"+mb_nr;
+					}
+					else{
+						window.frames["FeatureInfoRedirect"].document.getElementById(mb_mapObj[i].wms[ii].wms_id).src = newfeatureInfoRequest;
+					}
+					cnt_fi++;
+            	}
+				else if(path && validation){
+					newfeatureInfoRequest += requestParams
+					window.open(path + "?url=" + escape(newfeatureInfoRequest)+"&"+mb_nr, "" , "width=300,height=400,scrollbars=yes,resizable=yes");
+					cnt_fi++;
+				}
+				else if(validation){
+					newfeatureInfoRequest += requestParams;
+					window.open(newfeatureInfoRequest, "" , "width=300,height=400,scrollbars=yes,resizable=yes");
+					cnt_fi++;          
+				}      
+			}
+		}
+	}
+   	if(cnt_fi == 0){alert(unescape("Please select a layer! \n Bitte waehlen Sie eine Ebene zur Abfrage aus!"));}
+}
+function writeTag(frameName, elName, tagSource) {
+  if(frameName && frameName != ""){
+     window.frames[frameName].document.getElementById(elName).innerHTML = tagSource;
+  }
+  else if(!frameName || frameName == ""){
+       document.getElementById(elName).innerHTML = tagSource;
+  }
+}
+function zoom(frameName,in_, factor,x,y) {
+  var x = parseFloat(x);
+  var y = parseFloat(y);
+  var ind = getMapObjIndexByName(frameName);
+  var arrayBBox = mb_mapObj[ind].extent.split(",");
+  var xtentx = parseFloat(arrayBBox[2]) - parseFloat(arrayBBox[0]);
+  var xtenty =  parseFloat(arrayBBox[3]) - parseFloat(arrayBBox[1]);
+  var centerx = parseFloat(arrayBBox[0]) + xtentx/2;
+  var centery = parseFloat(arrayBBox[1]) + xtenty/2;
+  var factor = parseFloat(factor);
+  if(x){
+   centerx = x;
+   centery = y;
+  }
+  if (!in_) {factor = 1 / factor;}
+  var new_xtentx = xtentx / factor;
+  var new_xtenty = xtenty / factor;
+  var minx = centerx - new_xtentx / 2;
+  var miny = centery - new_xtenty / 2;
+  var maxx = centerx + new_xtentx / 2;
+  var maxy = centery + new_xtenty / 2;
+  mb_mapObj[ind].extent = minx + "," + miny + "," + maxx + "," + maxy;
+  setMapRequest(frameName);
+}
+function mb_panMap(frameName,dir){
+   var ind = getMapObjIndexByName(frameName);
+   var arrayBBox = mb_mapObj[ind].extent.split(",");
+   var minx = parseFloat(arrayBBox[0]);
+   var miny = parseFloat(arrayBBox[1]);
+   var maxx = parseFloat(arrayBBox[2]);
+   var maxy = parseFloat(arrayBBox[3]);
+   var xtentx = parseFloat(arrayBBox[2]) - parseFloat(arrayBBox[0]);
+   var xtenty =  parseFloat(arrayBBox[3]) - parseFloat(arrayBBox[1]);
+
+   if(dir == "NW"){minx = minx - (xtentx/2); maxx = maxx - (xtentx/2); miny = miny + (xtenty/2); maxy = maxy + (xtenty/2);}
+   if(dir == "N"){miny = miny + (xtenty/2); maxy = maxy + (xtenty/2);}
+   if(dir == "NE"){minx = minx + (xtentx/2); maxx = maxx + (xtentx/2); miny = miny + (xtenty/2); maxy = maxy + (xtenty/2);}
+   if(dir == "W"){minx = minx - (xtentx/2); maxx = maxx - (xtentx/2);}
+   if(dir == "E"){minx = minx + (xtentx/2); maxx = maxx + (xtentx/2);}
+   if(dir == "SW"){minx = minx - (xtentx/2); maxx = maxx - (xtentx/2); miny = miny - (xtenty/2); maxy = maxy - (xtenty/2);}
+   if(dir == "S"){miny = miny - (xtenty/2); maxy = maxy - (xtenty/2);}
+   if(dir == "SE"){minx = minx + (xtentx/2); maxx = maxx + (xtentx/2); miny = miny - (xtenty/2); maxy = maxy - (xtenty/2);}
+  mb_mapObj[ind].extent = minx + "," + miny + "," + maxx + "," + maxy;
+  setMapRequest(frameName);
+}
+
+function handleSelectedLayer (frameName, wms_title, layerName, type, status) {
+//	alert(frameName + " , " +wms_title + " , " +layerName + " , " +type + " , " +status);
+//	type = {visible || querylayer] status = {0 || 1}
+	for (var i=0; i < mb_mapObj.length; i++) {
+		if (mb_mapObj[i].frameName == frameName) {
+			var cnt_layer = 0;
+			var str_layer = "";
+			var myMapObj = i;
+			for (var ii = 0; ii < mb_mapObj[i].wms.length; ii++) {
+				if (mb_mapObj[i].wms[ii].wms_title == wms_title) { //ii is true
+					var myWMS = ii; 
+					if (type == "visible") {
+						var arrayLayer = mb_mapObj[i].layers[ii].split(",");
+					}
+					if (type == "querylayer") {
+						var arrayLayer = mb_mapObj[i].querylayers[ii].split(",");
+					}
+					for (var iii = 1; iii < mb_mapObj[i].wms[ii].objLayer.length; iii++) {
+						var layer_name = mb_mapObj[i].wms[ii].objLayer[iii].layer_name;
+						if (type == "querylayer") {
+							if (layer_name == layerName && status == 1 && mb_mapObj[i].wms[ii].objLayer[iii].layer_queryable == 1){
+								if (cnt_layer > 0) {
+									str_layer += ",";
+								}
+								str_layer += layer_name;
+								cnt_layer++;                   
+							}
+						}
+						else if (type == "visible") {
+							if (layer_name == layerName && status == 1) {
+								if (cnt_layer > 0) {
+									str_layer += ",";
+								}
+								str_layer += layer_name;
+								cnt_layer++;                   
+							}
+						}
+						for (var iiii = 0; iiii < arrayLayer.length; iiii++) {
+							if (layer_name == arrayLayer[iiii] && layer_name != layerName) {
+								if (cnt_layer > 0) {
+									str_layer += ",";
+								}
+								str_layer += layer_name;
+								cnt_layer++;             
+							}
+						}
+					}
+				}   
+			}         
+		}
+	}
+	if (type == "visible") {
+		mb_mapObj[myMapObj].layers[myWMS] = str_layer;
+		var array_str_layer = str_layer.split(",");
+		var str_styles = "";
+		for (var cnt=0; cnt < array_str_layer.length; cnt++) {
+			if (cnt > 0) {
+				str_styles += ",";
+			}
+			str_styles += "";
+		}
+		mb_mapObj[myMapObj].styles[myWMS] = str_styles;
+	}
+	if (type == "querylayer") {
+		mb_mapObj[myMapObj].querylayers[myWMS] = str_layer;
+	}
+/*
+	if(type == 'visible'){
+		setSingleMapRequest(frameName,wms_title);
+	}
+*/
+}
+
+function handleSelectedLayer_array(mapObj, array_wms, array_layer, type, status){
+	//alert(mapObj+" / "+array_wms[0]+" / "+ array_layer[0]+" / "+ type+" / "+ status);
+	var ind = getMapObjIndexByName(mapObj);
+	for(var j=0; j<array_wms.length; j++){
+		for(var i=0; i<mb_mapObj[ind].wms.length; i++){
+			if(mb_mapObj[ind].wms[i].wms_id == array_wms[j]){
+				var check = false;
+				for(var ii=0; ii<mb_mapObj[ind].wms[i].objLayer.length; ii++){
+					if(mb_mapObj[ind].wms[i].wms_id == array_wms[j] && mb_mapObj[ind].wms[i].objLayer[ii].layer_name == array_layer[j]){
+						if(type == "visible"){
+							mb_mapObj[ind].wms[i].objLayer[ii].gui_layer_visible = parseInt(status);
+							//alert(mb_mapObj[ind].wms[i].objLayer[ii].layer_name);
+							check = true;
+						}
+                        if(type == "querylayer" && (mb_mapObj[ind].wms[i].objLayer[ii].gui_layer_queryable == "1" || mb_mapObj[ind].wms[i].objLayer[ii].gui_layer_queryable == 1)){
+							mb_mapObj[ind].wms[i].objLayer[ii].gui_layer_querylayer = parseInt(status);
+						}
+					}
+				}
+                mb_restateLayers(mapObj, array_wms[j]);
+                //alert('restate');
+                /*
+                * hier noch checken, welche wms sich geaendert haben und disctinct eine singleRequest aufrufen:
+                */ 
+                if(check == true){					
+                    
+                    if(mb_mapObj[ind].wms[i].gui_wms_visible == 1){
+						setSingleMapRequest(mapObj,mb_mapObj[ind].wms[i].wms_id);
+                        //alert('sSMR');
+					}
+				}
+			}
+		}
+	}
+}
+
+function makeClickPos2RealWorldPos(frameName, myClickX, myClickY) {
+	var ind = getMapObjIndexByName(frameName);
+	var width = parseInt(mb_mapObj[ind].width);
+	var height = parseInt(mb_mapObj[ind].height);
+	var arrayBBox = mb_mapObj[ind].extent.split(",");
+	var minX = parseFloat(arrayBBox[0]);
+	var minY = parseFloat(arrayBBox[1]);
+	var maxX = parseFloat(arrayBBox[2]);
+	var maxY = parseFloat(arrayBBox[3]);
+	var deltaX = (maxX - minX)/width;
+	var deltaY = (maxY - minY)/height;
+	if(deltaX > 0){
+		var roundx = 1/Math.pow(10,(Math.round(Math.log(deltaX)/Math.log(10))));
+	}
+	else{
+		var roundx =  Math.pow(10,(Math.round(Math.log(deltaX)/Math.log(10))));
+	}
+	if(deltaY > 0){
+		var roundy = 1/Math.pow(10,(Math.round(Math.log(deltaY)/Math.log(10))));
+	}
+	else{
+		var roundy =  Math.pow(10,(Math.round(Math.log(deltaY)/Math.log(10))));
+	}	
+	var xtentx = maxX - minX;
+	var xtenty =  maxY - minY;
+	var posX = parseFloat(minX + (myClickX / width) * xtentx);
+	var posY = parseFloat(maxY - (myClickY / height) * xtenty);
+	posX = Math.round(posX * roundx)/roundx;
+	posY = Math.round(posY * roundy)/roundy;
+	return new Array(posX, posY);
+}
+function makeRealWorld2mapPos(frameName,rw_posx, rw_posy){
+   var ind = getMapObjIndexByName(frameName);
+   var arrayBBox = mb_mapObj[ind].extent.split(",");
+   var minX = parseFloat(arrayBBox[0]);
+   var minY = parseFloat(arrayBBox[1]);
+   var maxX = parseFloat(arrayBBox[2]);
+   var maxY = parseFloat(arrayBBox[3]);
+   var xtentx = parseFloat(arrayBBox[2]) - parseFloat(arrayBBox[0]);
+   var xtenty =  parseFloat(arrayBBox[3]) - parseFloat(arrayBBox[1]);
+   var width = mb_mapObj[ind].width;
+   var height = mb_mapObj[ind].height;
+   pixPos_x = Math.round(parseFloat(((rw_posx - minX)/xtentx)*width));
+   pixPos_y = Math.round(parseFloat(((maxY - rw_posy)/xtenty)*height));
+   return new Array(pixPos_x, pixPos_y);
+}
+
+function mb_arrangeElement(frameName, elName, left, top) {
+   if(frameName != ""){
+      window.frames[frameName].document.getElementById(elName).style.top = top;
+      window.frames[frameName].document.getElementById(elName).style.left = left;
+   }
+   else{
+      document.getElementById(elName).style.top = top;
+      document.getElementById(elName).style.left = left;   
+   }
+}
+
+/***********************Drag & Drop***********************/
+function mb_getMousePos(e,fName){
+if(fName){
+     if(ie){
+        clickX = window.frames[fName].event.clientX;
+        clickY = window.frames[fName].event.clientY;
+     }
+     else{
+        clickX = e.pageX;
+        clickY = e.pageY;
+     }
+  }
+  else{
+       if(ie){
+        clickX = event.clientX;
+        clickY = event.clientY;
+     }
+     else{
+        clickX = e.pageX;
+        clickY = e.pageY;
+     }
+  }
+  var pos = new Array(clickX,clickY);
+  return pos;
+}
+// function for object-identification 
+function getMapObjIndexByName(frameName){
+	for(var i=0; i<mb_mapObj.length; i++){
+		if(mb_mapObj[i].frameName == frameName){
+			return i;
+		}
+	}   
+}
+function mb_getLayerTitleByName(map_index, wms_index, myLayer_name){
+	for(var i=0; i<mb_mapObj[map_index].wms[wms_index].objLayer.length; i++){
+		if(mb_mapObj[map_index].wms[wms_index].objLayer[i].layer_name == myLayer_name){
+			return mb_mapObj[map_index].wms[wms_index].objLayer[i].layer_title;
+		}
+	}
+}
+function getWMSIDByTitle(frameName,wms_title){
+   var ind = getMapObjIndexByName(frameName);
+   for(var i=0; i< mb_mapObj[ind].wms.length; i++){
+      if(mb_mapObj[ind].wms[i].wms_title == wms_title){
+         //return i;
+         return mb_mapObj[ind].wms[i].wms_id;
+      }
+   }
+}
+function getWMSIndexByTitle(frameName,wms_title){
+   var ind = getMapObjIndexByName(frameName);
+   for(var i=0; i< mb_mapObj[ind].wms.length; i++){
+      if(mb_mapObj[ind].wms[i].wms_title == wms_title){
+         return i;
+      }
+   }
+}
+function getWMSIndexById(frameName,wms_id){
+   var ind = getMapObjIndexByName(frameName);
+   for(var i=0; i< mb_mapObj[ind].wms.length; i++){
+      if(mb_mapObj[ind].wms[i].wms_id == wms_id){
+         return i;
+      }
+   }
+}
+//scale
+function mb_getScale(frameName) {
+   for(var i=0; i<mb_GetScalePreFunctions.length; i++){
+		var myScale = eval(mb_GetScalePreFunctions[i]);
+	}
+   if(myScale){
+      var Y_str = myScale;
+   }
+   else{
+      var ind = getMapObjIndexByName(frameName);
+      var arrayBBox = mb_mapObj[ind].extent.split(",");
+      var xtenty =  parseFloat(arrayBBox[3]) - parseFloat(arrayBBox[1]);
+      var scaleY = (xtenty / mb_mapObj[ind].height) *(mb_resolution * 100);
+      if (scaleY<1){
+      	var Y_str = scaleY;
+      }else{
+      	var Y_str = Math.round(scaleY);
+      }
+   }   
+   return Y_str;   
+}
+
+function mb_repaintScale(frameName, x, y, scale){
+   var ind = getMapObjIndexByName(frameName);
+   if(x == null && y == null){
+      var arrayBBox = mb_mapObj[ind].extent.split(",");
+      x = parseFloat(arrayBBox[0]) + ((parseFloat(arrayBBox[2]) - parseFloat(arrayBBox[0]))/2);
+      y = parseFloat(arrayBBox[1]) + ((parseFloat(arrayBBox[3]) - parseFloat(arrayBBox[1]))/2);
+   }
+   var minx = parseFloat(x) - (mb_mapObj[ind].width / (mb_resolution * 100 *2) * scale);
+   var miny = parseFloat(y) -  (mb_mapObj[ind].height / (mb_resolution * 100 *2) * scale);
+   var maxx = parseFloat(x) + (mb_mapObj[ind].width / (mb_resolution * 100 *2) * scale);
+   var maxy = parseFloat(y) +  (mb_mapObj[ind].height / (mb_resolution * 100 *2) * scale);
+   mb_repaint(frameName,minx, miny, maxx, maxy);
+}
+function mb_repaint(frameName,minx,miny,maxx,maxy){
+   var ind = getMapObjIndexByName(frameName);
+   mb_mapObj[ind].extent = minx + "," + miny + "," + maxx + "," + maxy;
+   setMapRequest(frameName);
+}
+function mb_calculateExtent(frameName,minx,miny,maxx,maxy){
+  var ind = getMapObjIndexByName(frameName);
+  
+  var extenty = parseFloat(maxy) - parseFloat(miny);
+  var extentx = parseFloat(maxx) - parseFloat(minx);
+
+  var relation_px_x = mb_mapObj[ind].width / mb_mapObj[ind].height;
+  var relation_px_y = mb_mapObj[ind].height / mb_mapObj[ind].width;
+  var relation_bbox_x = extentx / extenty;     
+  var centerx = parseFloat(minx) + (extentx/2);
+  var centery = parseFloat(miny) + (extenty/2);
+  if(relation_bbox_x <= relation_px_x){                
+    minx = centerx - relation_px_x * extenty / 2;
+    maxx = centerx + relation_px_x * extenty / 2;
+  }
+  if(relation_bbox_x > relation_px_x){                
+    miny = centery - relation_px_y * extentx / 2;
+    maxy = centery + relation_px_y * extentx / 2;
+  }
+  mb_mapObj[ind].extent = minx  +","+ miny +","+ maxx  +","+ maxy;
+}
+
+function mb_showHighlight(frameName,x,y){
+   var pos = makeRealWorld2mapPos(frameName,x, y);
+   mb_arrangeElement(frameName,"highlight",pos[0]-7, pos[1]-7);
+   window.frames[frameName].document.getElementById("highlight").style.visibility = 'visible';
+}
+function mb_hideHighlight(frameName){
+   mb_arrangeElement(frameName,"highlight",-20, -20);
+   mb_arrangeElement(frameName,"highlight",-20, -20);
+   window.frames[frameName].document.getElementById("highlight").style.visibility = 'hidden';
+}
+function mb_permanentHighlight(frameName,x,y){   
+   var pos = makeRealWorld2mapPos(frameName,x, y);
+   mb_arrangeElement(frameName,"permanent",pos[0]-7, pos[1]-7);
+   window.frames[frameName].document.getElementById("permanent").style.visibility = 'visible';
+}
+// framename, commaseparated coordinates, commaseparated rgb values (color)
+//new: coords is array!
+function mb_markResult(frameName,geom,col){
+	var x = "";
+	var y = "";
+	var tmp = new Array();
+	var ind = getMapObjIndexByName(frameName);
+	for(var i=0; i < geom.length; i++){
+		if(i > 0){
+			x += ":";
+			y += ":";
+		}
+		tmp = geom[i].split(",");
+		for(var ii=0; ii < tmp.length; ii+=2){			
+			var pos = makeRealWorld2mapPos(frameName,tmp[ii], tmp[ii+1]);
+			if(ii>0){
+				x += ",";
+				y += ",";
+			}
+			x += pos[0];
+			y += pos[1];
+		}      
+	}
+	var source = "<img src='../extensions/markResult.php?x=" + x + "&y=" + y + "&width=" + mb_mapObj[ind].width + "&height=" + mb_mapObj[ind].height + "&color="+col+"'>";
+	//prompt("",source);
+	writeTag(frameName,"markResult",source);   
+}
+function mb_disableResult(frameName){
+   writeTag(frameName,"markResult","");
+}
+
+function mb_registerGML(frameName,obj){
+	var ind = getMapObjIndexByName(frameName);
+	mb_mapObj[ind].geom = obj;
+}
+function mb_timestamp(){
+	var d = new Date();
+	var ts = Math.round(Date.parse(d)/1000);
+	return ts;
+}
+function mb_getlayerposbyname(objInd,wmsInd,lname){
+	var t = mb_mapObj[objInd].wms[wmsInd];
+	for(var i=0; i < t.objLayer.length; i++){
+		if(t.objLayer[i].layer_name == lname){
+			return t.objLayer[i].layer_pos;
+		}
+	}
+}
+function mb_getLayerObjByName(fname,wms_id,layer_name){
+	var ind = getMapObjIndexByName(fname);
+	var wmsInd = getWMSIndexById(fname,wms_id);
+	var t = mb_mapObj[ind].wms[wmsInd];
+	for(var i=0; i < t.objLayer.length; i++){
+		if(t.objLayer[i].layer_name == layer_name){
+			return t.objLayer[i];
+		}
+	}
+}
+function mb_getchildsbyname(objInd,wmsInd,lname){
+	var t = mb_mapObj[objInd].wms[wmsInd];
+	var pos = mb_getlayerposbyname(objInd, wmsInd,lname);
+	var l = new Array();
+	l["name"] = new Array();
+	l["title"] = new Array();
+	l["legendurl"] = new Array();
+	for(var i=0; i < t.objLayer.length; i++){
+		if(t.objLayer[i].layer_parent == pos){
+			l["name"][l["name"].length] = t.objLayer[i].layer_name;
+			l["title"][l["title"].length] = t.objLayer[i].layer_title;
+			if(t.objLayer[i].layer_style.length>0){
+				l["legendurl"][l["legendurl"].length] = t.objLayer[i].layer_style[0]["legendurl"] ;
+			}else{
+				l["legendurl"][l["legendurl"].length] = 0 ;
+			}
+		}
+	}
+	if(l["name"].length > 0){
+		return l;
+	}
+	else{
+		return false;
+	}
+}
+
+/*
+ ***************************************************************************************
+ *   div tag
+ ***************************************************************************************
+ */
+
+function DivTag (aTagName, aFrameName, aStyle) {
+	this.exists = function () { 
+		return (rootNode.getElementById(tagName)) ? true : false;
+	};
+	
+	var determineRootNode = function () {
+		node = document;
+		if (frameName !== "") {
+			if (checkFrame()) {node = window.frames[frameName].document;}
+			else {var e = new Mb_exception("frame "+frameName+" doesn't exist.");}
+		}
+		return node;	
+	};
+	
+	var toCamelCase = function(aString) {
+		var newString = "";
+		for (var i = 0; i < aString.length; i++) {
+			if (aString.substr(i,1) != "-") {
+				newString += aString.substr(i,1); 
+			}
+			else {
+				i++;
+				newString += aString.substr(i,1).toUpperCase();
+			}
+		}
+		return newString;
+	}
+	
+	var setStyle = function () {
+		if (that.exists()) {
+			var node = rootNode.getElementById(tagName);
+			node.setAttribute("style", "");
+			
+			for (var attr in tagStyle) {
+				if (typeof(tagStyle[attr]) != "function" && typeof(tagStyle[attr]) != "object") {
+					var evalString = "node.style."+toCamelCase(attr)+" = \"" + tagStyle[attr] + "\";"; 
+					eval(evalString);				
+				}
+			}
+		}
+	}
+	
+	var create = function () {
+		if (!that.exists()) {
+			var divTag = rootNode.createElement("div");
+			var divTagAppended = rootNode.getElementsByTagName("body")[0].appendChild(divTag);
+			divTagAppended.id = tagName;
+		}
+		else {
+			that.clean();
+		}
+		setStyle();
+	};
+	var checkFrame = function () {
+		if (frameName !== "") {
+			return (typeof(window.frames[frameName]) != 'undefined');
+		}
+		return true;
+	};
+	
+	this.getTag = function() {
+		return rootNode.getElementById(tagName);
+	};
+	
+	var that = this;
+	var tagName = aTagName;
+	var frameName = aFrameName;
+	var rootNode = determineRootNode();
+	var tagStyle = aStyle;
+
+	create();
+}
+
+DivTag.prototype.write = function (someText) {
+	if (this.exists()) {
+		this.getTag().innerHTML = someText;
+	}
+};
+DivTag.prototype.clean = function () {
+	this.write("");
+};
+
+
+/*
+ ***************************************************************************************
+ *   Javascript exception handling
+ ***************************************************************************************
+ */
+
+/**
+ * @class An abstract class, logs JavaScript events like errors, warnings etc.
+ *
+ * @constructor
+ */
+var Mb_log = function() {
+	var that = this;
+	
+	var levelArray = global_log_levels.split(",");
+	var log_level = global_mb_log_level;
+	var log_js = global_mb_log_js;
+	
+	var indexOfLevel = function(aLevel) {
+		for (var i = 0; i < levelArray.length; i++) {
+			if (aLevel == levelArray[i])  {
+				return i;
+			}
+		}
+		return false;
+	};
+	var isValidLevel = function(aLevel) {
+		var isNotOff = typeof(log_js) != 'undefined' && log_js != "off";
+		var levelIndex = indexOfLevel(aLevel);
+		var isAppropriate = (typeof(levelIndex)=='number' && levelIndex < indexOfLevel(log_level));
+		return (isNotOff && isAppropriate);
+	};
+	var throwException = function (message, level) {
+		if (isValidLevel(level)) {
+			if (log_js == "on") {
+				try {
+					mb_ajaxWrap_post('../php/mb_js_exception.php', {level:level,text:message});
+				}
+				catch(e) {
+					alert(e + ": " + message);
+				}
+			}
+			else if (log_js == "alert") {
+				alert(message);
+			}
+			else if (log_js == "console") {
+				console.log("%s", message);
+			}
+		}
+	};
+}	
+
+/**
+ *  class for exception logging
+ *
+ * @extends {@link Mb_log}
+ * @param message the message that is being logged
+ */	
+function Mb_exception(message) {
+	this.level = "error";
+	this.throwException(message, this.level);
+}
+Mb_exception.prototype = new Mb_log();
+
+/**
+ *  class for warning logging
+ *
+ * @extends {@link Mb_log}
+ * @param message the message that is being logged
+ */	
+function Mb_warning(message) {
+	this.level = "warning";
+	this.throwException(message, this.level);
+}
+Mb_warning.prototype = new Mb_log();
+
+/*
+ ***************************************************************************************
+ *   AJAX wrapper functions
+ ***************************************************************************************
+ */
+/**
+ * A wrapper for an AJAX request via GET 
+ *
+ * @param {String} url the URL of a (presumably a server side) script.
+ * @param {Object} An object containing parameters, f.e. {name1:value1, name2:value2}
+ * @param {Function} A function that is called when the server side script has been processed. The function is called with two parameters, result and status. Result is the output of the server side script (XML, HTML, whatever), status is a {String}, either "success" or "error". 
+ */
+function mb_ajax_get(url, param, callback) {
+	try {
+		mb_ajaxWrap_get(url, param, callback);
+	}
+	catch(e) {
+		alert('map.php: mb_ajax_get:'+e);
+	}
+}	
+
+/**
+ * A wrapper for an AJAX request via POST 
+ *
+ * @param {String} url the URL of a (presumably a server side) script.
+ * @param {Object} An object containing parameters, f.e. {name1:value1, name2:value2}
+ * @param {Function} A function that is called when the server side script has been processed. The function is called with two parameters, result and status. Result is the output of the server side script (XML, HTML, whatever), status is a {String}, either "success" or "error". 
+ */
+function mb_ajax_post(url, param, callback) {
+	try {
+		mb_ajaxWrap_post(url, param, callback);
+	}
+	catch(e) {
+		alert('map.php: mb_ajax_post:'+e);
+	}
+}	
+	
+/**
+ * A wrapper for an AJAX request via GET 
+ *
+ * @param {String} url the URL of a (presumably a server side) script.
+ * @param {Object} An object containing parameters, f.e. {name1:value1, name2:value2}
+ * @param {Function} A function that is called when the server side script has been processed. The function is called with two parameters, result and status. Result is the output of the server side script (a JavaScript Object, not a String!), status is a {String}, either "success" or "error". 
+ */
+function mb_ajax_json(url, param, callback) {
+	try {
+		mb_ajaxWrap_json(url, param, callback);
+	}
+	catch(e) {
+		alert('map.php: mb_ajax_json:'+e);
+	}
+}	
+	
+/*
+ ***************************************************************************************
+ *   button handling
+ ***************************************************************************************
+ */
+ 
+var mb_button = new Array();
+
+function mb_regButton_frame(wii, frameName, param){
+	var ind = mb_button.length;
+	mb_button[ind] = new mb_conButton(wii, ind);
+	if (frameName == null) {
+		if (param == null) {
+			eval(wii+"("+ind+")");
+		}
+		else {
+			eval(wii+"("+ind+", "+param+")");
+		}
+	}
+	else if (param == null) {
+		eval("window.frames['" + frameName + "']."+wii+"("+ind+")");
+	}
+	else {
+		eval("window.frames['" + frameName + "']."+wii+"("+ind+", "+param+")");
+	}
+	mb_button[ind].prev = mb_button[ind].src;
+	mb_button[ind].src = mb_button[ind].img_off;
+	mb_button[ind].onmouseover = new Function("mb_button_over("+ind+")");
+	mb_button[ind].onmouseout = new Function("mb_button_out("+ind+")");
+	mb_button[ind].onclick = new Function("mb_button_click("+ind+")");
+	if (frameName==null) {
+		mb_button[ind].frameName = "";
+	}
+	else {
+		mb_button[ind].frameName = frameName;
+	}
+}
+
+function mb_regButton(wii){
+	mb_regButton_frame(wii, null, null);
+}
+
+function mb_conButton(wii, ind){
+   this.wii = wii;
+   return true;
+}
+function mb_button_over(ind){
+   if(mb_button[ind].status == 0){
+      mb_button[ind].prev = mb_button[ind].src;
+      mb_button[ind].src = mb_button[ind].img_over;
+   }
+}
+function mb_button_out(ind){
+   mb_button[ind].src = mb_button[ind].prev;
+}
+function mb_button_click(ind){
+   var mbStatus = mb_button[ind].status;
+   if(mbStatus == 0){
+      mb_disableButton(mb_button[ind].elName);
+      mb_button[ind].prev = mb_button[ind].img_on;
+      mb_button[ind].src = mb_button[ind].img_on;
+      mb_button[ind].status = 1;
+      if (mb_button[ind].frameName != "") {
+          window.frames[mb_button[ind].frameName].document.getElementById(mb_button[ind].elName).go();
+      }
+      else {
+	      document.getElementById(mb_button[ind].elName).go();
+      }
+   }
+   else{
+      mb_button[ind].prev = mb_button[ind].img_off;
+      mb_button[ind].src = mb_button[ind].img_off;
+      mb_button[ind].status = 0;      
+      if (mb_button[ind].frameName != "") {
+          window.frames[mb_button[ind].frameName].document.getElementById(mb_button[ind].elName).stop();
+      }
+      else {
+	      document.getElementById(mb_button[ind].elName).stop();
+      }
+   }
+}
+function mb_disableButton(elName){
+   for(var i=0; i<mb_button.length; i++){
+      if(mb_button[i].elName != elName && mb_button[i].status == 1){
+            mb_button[i].status = 0;
+		      if (mb_button[i].frameName != "") {
+    	        window.frames[mb_button[i].frameName].document.getElementById(mb_button[i].elName).src = mb_button[i].img_off;
+	            window.frames[mb_button[i].frameName].document.getElementById(mb_button[i].elName).stop();
+		      }
+		      else {
+    	        document.getElementById(mb_button[i].elName).src = mb_button[i].img_off;
+	            document.getElementById(mb_button[i].elName).stop();
+		      }
+            return true;
+       
+      }
+   }
+}
+function mb_disableThisButton(elName){
+   for(var i=0; i<mb_button.length; i++){
+      if(mb_button[i].elName == elName && mb_button[i].status == 1){
+      		//alert(mb_button[i].elName);
+            mb_button[i].status = 0;
+		      if (mb_button[i].frameName != "") {
+    	        window.frames[mb_button[i].frameName].document.getElementById(mb_button[i].elName).src = mb_button[i].img_off;
+	            window.frames[mb_button[i].frameName].document.getElementById(mb_button[i].elName).stop();
+		      }
+		      else {
+        	    document.getElementById(mb_button[i].elName).src = mb_button[i].img_off;
+		        document.getElementById(mb_button[i].elName).stop();
+		      }
+            return true;
+       
+      }
+   }
+}
+
+/*
+ ***************************************************************************************
+ *   miscellaneous functions
+ ***************************************************************************************
+ */
+
+function cloneObject(someObject){
+	var clone = [];
+	
+	for (attribute in someObject) {
+
+		var currentElement = someObject[attribute];
+
+		if (typeof(currentElement) == "object") {
+			clone[attribute] = cloneObject(currentElement);
+		}
+		else {
+			clone[attribute] = currentElement;
+		}
+	}	
+	return clone;
+}
+
+
+/**
+ * @class A List object is an array of arbitrary objects with additional methods. 
+ *
+ * @constructor
+ */
+var List = function() {
+	
+	/**
+	 * gets the number of elements in this {@link List}
+	 *
+	 * @member List
+	 * @returns number of elements in this {@link List}
+	 * @type Integer
+	 */
+	this.count = function() {
+		return this.list.length;
+	};
+
+	/**
+	 * deletes the object at index i; -1 refers to the last object in this {@link List}
+	 *
+	 * @member List
+	 * @param {Integer} i index
+	 */
+	this.del = function(i){
+		i = this.getIndex(i);
+		for(var z = i; z < this.count() - 1; z++){
+			this.list[z] = this.list[z+1];
+		}
+		this.list.length -= 1;
+	};
+
+	/**
+	 * empties this {@link List}
+	 *
+	 * @member List
+	 */
+	this.empty = function() {
+		while (this.list != null && this.count() > 0) {
+			this.list.pop();
+		}
+	}
+	
+	/**
+	 * @member List
+	 * @param {Integer} i index
+	 * @returns the object at index i; -1 refers to the last object in this {@link List}
+	 * @type Integer or false
+	 */
+	this.get = function(i) {
+		i = this.getIndex(i);
+		if (i !== false) {return this.list[i];}
+		return false;		
+	};
+	/**
+	 * adds a reference to item to this {@link List}.
+	 *
+	 * @member List
+	 * @param {Object} item an object
+	 */
+	this.add = function(item) {
+		this.list.push(item);
+	};
+	/**
+	 * adds a copy of item to this {@link List}.
+	 *
+	 * @member List
+	 * @param {Object} item an object
+	 */
+	this.addCopy = function(item) {
+		this.list.push(cloneObject(item));
+	};
+	/**
+	 * attaches the {@link List} aList to this {@link List}
+	 *
+	 * @member List
+	 * @param {List} aList another list
+	 */
+	this.union = function(aList) {
+		for (var i=0; i < aList.count(); i++) {this.addCopy(aList.get(i));}
+	};
+	/**
+	 * checks if the index is valid and returns it if it is; if i == -1, the correct index is retrieved.
+	 *
+	 * @member List
+	 * @private
+	 * @return Integer or false
+	 * @type Integer
+	 */
+	this.getIndex = function(i){ 
+		if ((i >= 0 && i < this.list.length) || (i*(-1)>0 && i*(-1) <= this.list.length)){
+			if (i >= 0) {return i;} else {return this.list.length+i;}
+		}
+		else {
+			var e = new Mb_exception("class List: function getIndex: member index " + i + " is not valid");
+			return false;
+		}
+	};
+	/**
+	 * @member List
+	 * @returns a {String} representation of this List
+	 * @type String
+	 */
+	this.toString = function(){
+		var str = "";
+		for (var i =0 ; i < this.count() ; i++){
+			str += this.get(i).toString();
+		}
+		return str;	
+	};	
+	
+	this.list = null;
+};
+
+
+
+/*
+ ***************************************************************************************
+ *   register functions
+ ***************************************************************************************
+ */
+
+var mb_MapRequestSubFunctions = new Array();
+var mb_WfsReadSubFunctions = new Array();
+var mb_WfsWriteSubFunctions = new Array();
+var mb_MapRequestPreFunctions = new Array();
+var mb_FeatureInfoPreFunctions = new Array();
+var mb_InitFunctions = new Array();
+var mb_MapObjectSubFunctions = new Array();
+var mb_GetScalePreFunctions = new Array();
+var mb_loadWmsSubFunctions = new Array();
+
+function mb_registerInitFunctions(stringFunction){
+	mb_InitFunctions[mb_InitFunctions.length] = stringFunction;
+}
+function mb_registerPreFunctions(stringFunction){
+	mb_MapRequestPreFunctions[mb_MapRequestPreFunctions.length] = stringFunction;
+}
+function mb_registerFeatureInfoPreFunctions(stringFunction){
+	mb_FeatureInfoPreFunctions[mb_FeatureInfoPreFunctions.length] = stringFunction;
+}
+function mb_registerSubFunctions(stringFunction){
+	mb_MapRequestSubFunctions[mb_MapRequestSubFunctions.length] = stringFunction;
+}
+function mb_registerMapObjectSubFunctions(stringFunction){
+	mb_MapObjectSubFunctions[mb_MapObjectSubFunctions.length] = stringFunction;
+}
+function mb_registerGetScalePreFunctions(stringFunction){
+	mb_GetScalePreFunctions[mb_GetScalePreFunctions.length] = stringFunction;
+}
+function mb_registerloadWmsSubFunctions(stringFunction){
+	mb_loadWmsSubFunctions[mb_loadWmsSubFunctions.length] = stringFunction;
+}
+function mb_registerWfsReadSubFunctions(stringFunction){
+	mb_WfsReadSubFunctions[mb_WfsReadSubFunctions.length] = stringFunction;
+}
+function mb_registerWfsWriteSubFunctions(stringFunction){
+	mb_WfsWriteSubFunctions[mb_WfsWriteSubFunctions.length] = stringFunction;
+}
+function mb_removeFunctionFromArray(arrayname,stringFunction){
+	var length = eval(arrayname+".length");
+	for(var i=0; i<length; i++){
+		if(eval(arrayname+"["+i+"]") == stringFunction){
+			var newArray1 = eval(arrayname+".slice(0, "+(i-1)+")");
+			var newArray2 = eval(arrayname+".slice("+(i+1)+", "+length+")");
+			eval(arrayname + " = newArray1.concat(newArray2)");
+			i--;
+			length--;
+		}
+	}
+}
+ 
+function mb_execloadWmsSubFunctions(){
+	for(var i=0; i<mb_loadWmsSubFunctions.length; i++){
+		eval(mb_loadWmsSubFunctions[i]); 	 
+	} 	 
+}
+
+function mb_execWfsReadSubFunctions(geom) { 	 
+	for(var i=0; i<mb_WfsReadSubFunctions.length; i++){ 	 
+		mb_WfsReadSubFunctions[i](geom); 	 
+	} 	 
+}
+
+function mb_execWfsWriteSubFunctions() { 	 
+	for(var i=0; i<mb_WfsWriteSubFunctions.length; i++){
+		mb_WfsWriteSubFunctions[i](); 	 
+	} 	 
+}
+
+/*
+ * first draft of a redesign
+ *
+var FunctionArray = function() {
+	this.list = [];
+
+	this.register = function (aFunction) {
+		this.add(aFunction);
+	}
+	this.execute = function () {
+		for (var i = 0; i < this.count(); i++) {
+			var aFunction = this.get(i);
+			if (typeof(aFunction) == 'function') {
+				aFunction();
+			}
+			else if (typeof(aFunction) == 'string') {
+				eval(aFunction);
+			}
+			else {
+				var e = new mb_exception("FunctionArray.execute: Invalid parameter: " + aFunction);
+			}
+		}
+	}
+	this.remove = function (functionString) {
+		var listLength = this.count();
+		for (var i = listLength - 1; i >= 0; i--) {
+			if (this.get(i) == functionString){
+				this.del(i);
+			}
+		}
+	}
+}
+
+FunctionArray.prototype = new List();
+
+var mbInitFunctions = new FunctionArray();
+var mbMapRequestSubFunctions = new FunctionArray();
+var mbWfsReadSubFunctions = new FunctionArray();
+var mbWfsWriteSubFunctions = new FunctionArray();
+var mbMapRequestPreFunctions = new FunctionArray();
+var mbFeatureInfoPreFunctions = new FunctionArray();
+var mbInitFunctions = new FunctionArray();
+var mbMapObjectSubFunctions = new FunctionArray();
+var mbGetScalePreFunctions = new FunctionArray();
+var mbloadWmsSubFunctions = new FunctionArray();
+
+*/
+
+/*
+ ***************************************************************************************
+ *   deprecated functions
+ ***************************************************************************************
+ */
+
+// only used in mod_perimeter.php
+// previously used in mod_initWmc.php, mod_digitize_tab.php, mod_geometryArray.js
+function mb_checkTag(frameName, tagName, elementId, appendAtTagName, attributes){
+	var oldElement;
+	var newElement;
+	var prefix;
+	if(frameName && frameName != ""){
+		prefix = window.frames[frameName].document;
+	}
+	else if(!frameName || frameName == ""){
+		prefix = document;
+	}
+	oldElement = prefix.getElementById(elementId);
+	if (oldElement == null) {
+		newElement = prefix.createElement(tagName);
+		newElement = prefix.getElementsByTagName(appendAtTagName)[0].appendChild(newElement);
+	}
+	else {
+		if (oldElement.nodeName.toLowerCase() == tagName.toLowerCase()) {
+			for (var i=0; i<attributes.length; i++) {
+				oldElement.setAttribute(attributes[i][0], attributes[i][1]);
+			}
+			return oldElement;
+		}
+		else {
+			return false;
+		}
+	}
+	var newElementAttributeNode = document.createAttribute("id");
+	newElementAttributeNode.value = elementId;
+	newElement.setAttributeNode(newElementAttributeNode);
+	for (var i=0; i<attributes.length; i++) {
+		newElement.setAttribute(attributes[i][0], attributes[i][1]);
+	}
+	return newElement;
+}
\ No newline at end of file

Modified: trunk/mapbender/http/javascripts/map.php
===================================================================
--- trunk/mapbender/http/javascripts/map.php	2007-05-30 07:54:43 UTC (rev 1379)
+++ trunk/mapbender/http/javascripts/map.php	2007-05-30 08:32:16 UTC (rev 1380)
@@ -30,1733 +30,9 @@
 echo "var global_mb_log_js = '".LOG_JS."';";
 echo "var global_mb_log_level = '".LOG_LEVEL."';";
 echo "var global_log_levels = '".LOG_LEVEL_LIST."';";
-?>
-var ie = document.all?1:0;
-var n6 = document.getElementById&&!document.all?1:0;
-var n4 = document.layers?1:0;
 
-var mb_feature_count = 100;
+include("map.js");
 
-var mb_resolution = 28.35;
-var mb_mapObj = new Array();
-var mb_fiWin = null;
-var mb_panActive = false;
-var clickX;
-var clickY;
-var mb_start_x = 0;
-var mb_start_y = 0;
-var mb_end_x = 0;
-var mb_end_y = 0;
-var mb_offset_top = 0;
-var mb_offset_right = 0;
-var mb_offset_bottom = 0;
-var mb_offset_left = 0;
-var mb_log = null;
-
-var mb_PanSubElements = new Array();
-function mb_registerPanSubElement(elName){
-	var ind = mb_PanSubElements.length;
-	mb_PanSubElements[ind] = elName;
-}
-
-var mb_vendorSpecific = new Array();
-function mb_registerVendorSpecific(stringFunction){
-	mb_vendorSpecific[mb_vendorSpecific.length] = stringFunction;
-}
-
-var mb_security_proxy = "http://wms1.ccgis.de/mapbender/tools/security_proxy.php?mb_ows_security_proxy=";
-
-var mb_trans = new Image; 
-mb_trans.src = "../img/transparent.gif";
-/*END OF GLOBALS*/
-
-
-function init(){
-	for(var i=0; i<mb_InitFunctions.length; i++){
-		eval(mb_InitFunctions[i]);
-	}
-	for(var i=0; i<mb_mapObj.length; i++){
-		setMapRequest(mb_mapObj[i].frameName);
-	}      	
-}
-
-function deleteWmsObject() {
-	wms = new Array();
-	wms_layer_count = 0;
-}
-
-function deleteMapObj() {
-	mb_mapObj = new Array();
-}
-
-function mb_registerMapObj(frameName, elementName,wms_index,width, height){
-	mb_mapObj[mb_mapObj.length] = new mb_mapObj_const(frameName, elementName, width, height, wms_index);    
-}
-
-function mb_mapObj_const(frameName, elementName, width, height, wms_index){
-
-   this.width = width;
-   this.height = height;
-   this.frameName = frameName;
-   this.elementName = elementName;
-   this.layers = new Array();
-   this.styles = new Array();
-   this.querylayers = new Array();
-   this.geom = "";
-   this.gml = ""; 
-   if(wms_index != null){
-      this.wms = new Array();
-      this.wms[0] = wms[wms_index];
-      this.wms[0].mapURL = false;
-      var cnt_layers = 0;
-      var cnt_querylayers = 0;
-      var styles = "";
-      var layers = "";
-      var querylayers = "";
-      for(var ii=0; ii<this.wms[0].objLayer.length; ii++){
-         if(this.wms[0].objLayer[ii].gui_layer_visible == 1 && ii>0){
-            if(cnt_layers > 0){layers += ","; styles += ","; }
-            layers += this.wms[0].objLayer[ii].layer_name; 
-            styles += ""; 
-            cnt_layers++;
-         }   
-         if(this.wms[0].objLayer[ii].gui_layer_querylayer == 1 && ii>0){
-            if(cnt_querylayers > 0){querylayers += ",";}
-            querylayers += this.wms[0].objLayer[ii].layer_name; 
-            cnt_querylayers++;
-         }                      
-      }
-      this.layers[0] = layers;
-      this.styles[0] = styles;
-      this.querylayers[0] = querylayers;   
-   }
-   else{
-	this.wms = new Array();
-	for(i=0; i<wms.length; i++){
-		this.wms[i] = wms[i];
-		this.wms[i].mapURL = false;
-	}
-      for(var i=0; i< this.wms.length; i++){
-         var cnt_layers = 0;
-         var cnt_querylayers = 0;
-         var styles = "";
-         var layers = "";
-         var querylayers = "";
-         for(var ii=0; ii<this.wms[i].objLayer.length; ii++){
-            if(this.wms[i].objLayer[ii].gui_layer_visible == 1 && ii>0){
-               if(cnt_layers > 0){layers += ","; styles += ","; }
-               layers += wms[i].objLayer[ii].layer_name; 
-               styles += ""; 
-               cnt_layers++;
-            }            
-            if(this.wms[i].objLayer[ii].gui_layer_querylayer == 1 && ii>0){
-               if(cnt_querylayers > 0){querylayers += ",";}
-               querylayers += wms[i].objLayer[ii].layer_name; 
-               cnt_querylayers++;
-            }                          
-         }
-         this.layers[i] = layers;
-         this.styles[i] = styles;
-         this.querylayers[i] = querylayers;
-      }
-   }
-   this.epsg = wms[0].gui_wms_epsg;
-   this.extent = setExtent(this.width,this.height,this.epsg);
-   this.mapURL = new Array();
-   for(var i=0; i<mb_MapObjectSubFunctions.length; i++){
-      eval(mb_MapObjectSubFunctions[i]);
-   }  
-}
-
-
-function mb_getConjunctionCharacter(onlineresource){
-	if(onlineresource.indexOf("?") > -1){ 
-		if(onlineresource.charAt(onlineresource.length-1) == "?"){ 
-			nextvalue = "";
-		}else if(onlineresource.charAt(onlineresource.length-1) == "&"){
-			nextvalue = "";
-		}else{
-			nextvalue = "&";
-		}
-	}
-	if(onlineresource.indexOf("?") == -1){
-		nextvalue = "?";
-	} 
-	return nextvalue;  
-}
-
-
-function mb_moveWmsById (mapObj_ind, wms_id, toIndex) {
-	return mb_wmsMoveByIndex(mapObj_ind, getWMSIndexById(mapObj_ind, wms_id), toIndex);
-}
-
-function mb_wmsMoveByIndex(mapObj_ind, fromIndex, toIndex) {
-	if (fromIndex != toIndex && fromIndex >= 0 && fromIndex < mb_mapObj[mapObj_ind].wms.length && toIndex >= 0 && toIndex < mb_mapObj[mapObj_ind].wms.length) {
-		var changed = false;
-
-		if (fromIndex > toIndex) {
-			for (var i = fromIndex; i > toIndex ; i--) {
-				var result = mb_swapWmsByIndex(mapObj_ind, i-1, i);
-				if (result == true) changed = true;
-			}
-		}
-		else {
-			for (var i = fromIndex; i < toIndex ; i++) {
-				var result = mb_swapWmsByIndex(mapObj_ind, i, i+1);
-				if (result == true) changed = true;
-			}
-		}
-		return changed;
-	}
-	else {
-		return false;
-	}
-}
-
-function mb_swapWmsById(mapObj_ind, wms1_id, wms2_id) {
-	return mb_swapWmsByIndex(mapObj_ind, getWMSIndexById(mapObj_ind, wms1_id), getWMSIndexById(mapObj_ind, wms2_id));
-}
-
-function mb_swapWmsByIndex(mapObj_ind, indexA, indexB) {
-	if (indexA != indexB && indexA >= 0 && indexA < mb_mapObj[mapObj_ind].wms.length && indexB >= 0 && indexB < mb_mapObj[mapObj_ind].wms.length) {
-		upper = mb_mapObj[mapObj_ind].wms[indexA];
-		mb_mapObj[mapObj_ind].wms[indexA] = mb_mapObj[mapObj_ind].wms[indexB];
-		mb_mapObj[mapObj_ind].wms[indexB] = upper;
-		var upperLayers = mb_mapObj[mapObj_ind].layers[indexA];
-		var upperStyles = mb_mapObj[mapObj_ind].styles[indexA];
-		var upperQuerylayers = mb_mapObj[mapObj_ind].querylayers[indexA];
-		mb_mapObj[mapObj_ind].layers[indexA] = mb_mapObj[mapObj_ind].layers[indexB];
-		mb_mapObj[mapObj_ind].styles[indexA] = mb_mapObj[mapObj_ind].styles[indexB];
-		mb_mapObj[mapObj_ind].querylayers[indexA] = mb_mapObj[mapObj_ind].querylayers[indexB];
-		mb_mapObj[mapObj_ind].layers[indexB] = upperLayers;
-		mb_mapObj[mapObj_ind].styles[indexB] = upperStyles;
-		mb_mapObj[mapObj_ind].querylayers[indexB] = upperQuerylayers;
-		return true;
-	}
-	else {
-		return false;
-	}
-}
-
-function mb_moveUpWmsByIndex(mapObj_ind, index) {
-	if (index > 0 && index < wms.length) {
-		return mb_swapWmsByIndex(mapObj_ind, index-1, index);
-	}
-	else {
-		return false;
-	}
-}
-
-function mb_moveDownWmsByIndex(mapObj_ind, index) {
-	if (index >= 0 && index < wms.length-1) {
-		return mb_swapWmsByIndex(mapObj_ind, index, index+1);
-	}
-	else {
-		return false;
-	}
-}
-
-function mb_mapObjaddWMS(obj){
-	var cnt_layers = 0;
-	var cnt_querylayers = 0;
-	var styles = "";
-	var layers = "";
-	var querylayers = "";
-	var ind = getMapObjIndexByName(obj);
-	//is the id valid?
-	for( var i=0; i<(wms.length-1); i++){
-		if(parseInt(wms[i].wms_id) >= parseInt(wms[wms.length-1].wms_id)){
-			wms[wms.length-1].wms_id = parseInt(mb_mapObj[ind].wms[i].wms_id) + 1;
-		}
-	} 
-	mb_mapObj[ind].wms[mb_mapObj[ind].wms.length] = wms[wms.length-1];
-	mb_mapObj[ind].layers[mb_mapObj[ind].layers.length] = layers;
-	mb_mapObj[ind].styles[mb_mapObj[ind].styles.length] = styles;
-	mb_mapObj[ind].querylayers[mb_mapObj[ind].querylayers.length] = querylayers;  
-	mb_execloadWmsSubFunctions();
-	return true; 
-}
-//CB
-function mb_mapObjaddWMSwithLayers(obj,layers,querylayers){
-	var cnt_layers = 0;
-	var cnt_querylayers = 0;
-	var styles = "";
-	var ind = getMapObjIndexByName(obj);
-	mb_mapObj[ind].wms[mb_mapObj[ind].wms.length] = wms[wms.length-1];
-	mb_mapObj[ind].layers[mb_mapObj[ind].layers.length] = layers;
-	mb_mapObj[ind].styles[mb_mapObj[ind].styles.length] = styles;
-	mb_mapObj[ind].querylayers[mb_mapObj[ind].querylayers.length] = querylayers;   
-}
-function mb_mapObjremoveWMS(objind,wmsind){
-	var wms_ID = null;
-	
-	var new_wmsarray = new Array();
-	var new_layerarray = new Array();
-	var new_querylayerarray = new Array();
-	var new_stylesarray = new Array();
-	var new_mapURLarray = new Array();
-	
-	for	(var i=0;i<mb_mapObj[objind].wms.length; i++){
-		if(i != wmsind){
-			new_wmsarray[new_wmsarray.length] = mb_mapObj[objind].wms[i];
-			new_layerarray[new_layerarray.length] = mb_mapObj[objind].layers[i];
-			new_querylayerarray[new_querylayerarray.length] = mb_mapObj[objind].querylayers[i];
-			new_stylesarray[new_stylesarray.length] = mb_mapObj[objind].styles[i];
-			new_mapURLarray[new_mapURLarray.length] = mb_mapObj[objind].mapURL[i] 
-		}
-		else {
-			wms_ID = mb_mapObj[objind].wms[i].wms_id;
-		}
-	}
-	mb_mapObj[objind].wms = new_wmsarray; 
-	mb_mapObj[objind].layers = new_layerarray; 
-	mb_mapObj[objind].querylayers = new_querylayerarray; 
-	mb_mapObj[objind].styles = new_stylesarray; 
-	mb_mapObj[objind].mapURL = new_mapURLarray;
-
-	var another_new_wmsarray = new Array();
-	for	(var i=0;i<wms.length; i++){
-		if(wms[i].wms_id != wms_ID){
-			another_new_wmsarray[another_new_wmsarray.length] = wms[i]; 
-		}
-	}
-	wms = another_new_wmsarray; 
-}
-function setExtent(width,height,epsg){
-   for(var i=0; i < wms[0].gui_epsg.length; i++){
-      if(wms[0].gui_epsg[i] == epsg){      
-         var bbox_minx = parseFloat(wms[0].gui_minx[i]);
-         var bbox_miny = parseFloat(wms[0].gui_miny[i]);
-         var bbox_maxx = parseFloat(wms[0].gui_maxx[i]);
-         var bbox_maxy = parseFloat(wms[0].gui_maxy[i]);     
-   
-         var extenty = bbox_maxy - bbox_miny;
-         var extentx = bbox_maxx - bbox_minx;
-
-         var relation_px_x = width / height;
-         var relation_px_y = height / width;
-         var relation_bbox_x = extentx / extenty;         
-         var centerx = bbox_minx + (extentx/2);
-         var centery = bbox_miny + (extenty/2);
-         if(relation_bbox_x <= relation_px_x){                
-                bbox_minx = centerx - relation_px_x * extenty / 2;
-                bbox_maxx = centerx + relation_px_x * extenty / 2;
-         }
-        
-         if(relation_bbox_x > relation_px_x){                
-                bbox_miny = centery - relation_px_y * extentx / 2;
-                bbox_maxy = centery + relation_px_y * extentx / 2;
-         }
-        return bbox_minx  +","+ bbox_miny +","+ bbox_maxx  +","+ bbox_maxy;
-     }
-   }
-}
-function setMapRequest(frameName){
-	var functionName = 'setMapRequest';
-	var ts = mb_timestamp();
-
-	for(var i=0; i<mb_MapRequestPreFunctions.length; i++){
-		var ret = eval(mb_MapRequestPreFunctions[i]);
-		if(ret == false){
-			return true;
-		}
-	}
-	for(var i=0; i<mb_mapObj.length; i++){
-		var newMapRequest = "";
-		if(mb_mapObj[i].frameName == frameName){
-			for(var ii=0; ii<mb_mapObj[i].wms.length; ii++){
-				if(mb_mapObj[i].wms[ii].gui_wms_visible > 0){
-					var myDivId = "div_" + ii;          
-					var myMapId = "map_" + ii;
-					//disable Layer which are out of scale
-					var str_LayerStyles = mb_checkScale(frameName,i,ii);
-					if(mb_mapObj[i].layers[ii] != "" && str_LayerStyles[0] != ''){
-						var newMapURL = "";
-
-// replaced by opacity version 
-//						newMapRequest += "<div id='"+myDivId+"' style='position:absolute; top:0px; left:0px; z-index:'"+ii+"'>";
-
- 						var cadenaOpacity = "opacity:"+mb_mapObj[i].wms[ii].gui_wms_mapopacity+"; Filter: Alpha(Opacity="+mb_mapObj[i].wms[ii].gui_wms_mapopacity*100+"); -moz-opacity:"+mb_mapObj[i].wms[ii].gui_wms_mapopacity+" ; -khtml-opacity:"+mb_mapObj[i].wms[ii].gui_wms_mapopacity;
- 						newMapRequest += "<div id='"+myDivId+"' style=\"position:absolute; top:0px; left:0px; z-index:"+ii+";"+cadenaOpacity+"\">";
-
-						newMapRequest += "<img id='"+myMapId+"' name='mapimage' src='";
-						newMapURL += mb_mapObj[i].wms[ii].wms_getmap;   
-						
-						newMapURL += mb_getConjunctionCharacter(mb_mapObj[i].wms[ii].wms_getmap);
-						
-						if(mb_mapObj[i].wms[ii].wms_version == "1.0.0"){newMapURL += "WMTVER="+mb_mapObj[i].wms[ii].wms_version+"&REQUEST=map&";}
-						if(mb_mapObj[i].wms[ii].wms_version != "1.0.0"){newMapURL += "VERSION="+mb_mapObj[i].wms[ii].wms_version+"&REQUEST=GetMap&SERVICE=WMS&";} 
-						
-						newMapURL += "LAYERS="+str_LayerStyles[0]+"&";
-						newMapURL += "STYLES="+str_LayerStyles[1]+"&";
-		
-						newMapURL += "SRS="+mb_mapObj[i].epsg+"&";
-						newMapURL += "BBOX="+mb_mapObj[i].extent+"&";
-						newMapURL += "WIDTH="+mb_mapObj[i].width+"&";
-						newMapURL += "HEIGHT="+mb_mapObj[i].height+"&";
-						newMapURL += "FORMAT="+mb_mapObj[i].wms[ii].gui_wms_mapformat+"&";
-						newMapURL += "BGCOLOR=0xffffff&";
-						if(mb_mapObj[i].wms[ii].gui_wms_mapformat.search(/gif/i)>-1 || mb_mapObj[i].wms[ii].gui_wms_mapformat.search(/png/i)>-1){
-							newMapURL += "TRANSPARENT=TRUE&";
-						}
-						newMapURL += "EXCEPTIONS="+mb_mapObj[i].wms[ii].gui_wms_exceptionformat;
-						// add vendor-specifics
-						for(var v=0; v < mb_vendorSpecific.length; v++){
-							var vendorSpecificString = eval(mb_vendorSpecific[v]); 
-
-							// if eval doesn't evaluate a function, the result is undefined.
-							// Sometimes it is necessary not to evaluate a function, for
-							// example if you want to change a variable from the current
-							// scope (see mod_addSLD.php) 
-							if (typeof(vendorSpecificString) != "undefined") {
-								newMapURL += "&" + vendorSpecificString; 
-							}
-						}           
-						// add Filter
-						if(mb_mapObj[i].wms[ii].wms_filter != ""){
-							var tmp = mb_mapObj[i].wms[ii].wms_filter +"?id="+ mb_styleID;
-
-							var temp = "&SLD=" + tmp+ "&";
-							newMapURL += temp;
-						}
-						if(mb_log){
-							var tmp = eval(mb_log + "('" + newMapURL + "','" + ts + "')");
-						}
-						newMapRequest += newMapURL;
-						mb_mapObj[i].mapURL[ii] = newMapURL;	
-						mb_mapObj[i].wms[ii].mapURL = newMapURL;
-						newMapRequest += "' width='"+mb_mapObj[i].width+"' height='"+mb_mapObj[i].height+"' border='0'></div>";   
-					}
-					else{
-						mb_mapObj[i].mapURL[ii] = false;
-						mb_mapObj[i].wms[ii].mapURL = false;
-						newMapRequest += "<div id='" + myDivId + "' style='position:absolute; top:0px; left:0px; z-index:" + ii + "'>";
-						newMapRequest += "<img id='"+myMapId+"' name='mapimage' src='" + mb_trans.src;
-						newMapRequest += "' width='"+mb_mapObj[i].width+"' height='"+mb_mapObj[i].height+"' border='0'>";
-						newMapRequest +="</div>";
-					}
-				}
-			}
-			//prompt("",newMapRequest);
-			writeTag(mb_mapObj[i].frameName,mb_mapObj[i].elementName,newMapRequest);
-		}
-	}
-	for(var i=0; i<mb_MapRequestSubFunctions.length; i++){
-		eval(mb_MapRequestSubFunctions[i]);
-	}
-}
-function setSingleMapRequest(frameName,wms_id){
-	var functionName = 'setSingleMapRequest';
-	var ts = mb_timestamp();	
-	
-	for(var i=0; i<mb_MapRequestPreFunctions.length; i++){
-		eval(mb_MapRequestPreFunctions[i]);
-	}	
-	for(var i=0; i<mb_mapObj.length; i++){
-		var newMapRequest = "";
-		if(mb_mapObj[i].frameName == frameName){
-			for(var ii=0; ii<mb_mapObj[i].wms.length; ii++){ 
-				var myDivId = "div_" + ii;
-				var myMapId = "map_" + ii;
-				if(mb_mapObj[i].wms[ii].wms_id == wms_id){  
-					var newMapURL = "";
-					newMapRequest += "<img id='"+myMapId+"' name='mapimage' src='";
-					newMapURL += mb_mapObj[i].wms[ii].wms_getmap; 
-
-					newMapURL += mb_getConjunctionCharacter(mb_mapObj[i].wms[ii].wms_getmap);
-						
-					if(mb_mapObj[i].wms[ii].wms_version == "1.0.0"){newMapURL += "WMTVER="+mb_mapObj[i].wms[ii].wms_version+"&REQUEST=map&";}
-					if(mb_mapObj[i].wms[ii].wms_version != "1.0.0"){newMapURL += "VERSION="+mb_mapObj[i].wms[ii].wms_version+"&REQUEST=GetMap&SERVICE=WMS&";}             
-					
-					//disable Layer which are out of scale
-					var str_LayerStyles = mb_checkScale(frameName,i,ii); 
-
-					newMapURL += "LAYERS="+str_LayerStyles[0]+"&";
-					newMapURL += "STYLES="+str_LayerStyles[1]+"&";
-         
-					newMapURL += "SRS="+mb_mapObj[i].epsg+"&";
-					newMapURL += "BBOX="+mb_mapObj[i].extent+"&";
-					newMapURL += "WIDTH="+mb_mapObj[i].width+"&";
-					newMapURL += "HEIGHT="+mb_mapObj[i].height+"&";
-					newMapURL += "FORMAT="+mb_mapObj[i].wms[ii].gui_wms_mapformat+"&";
-					newMapURL += "BGCOLOR=0xffffff&";
-					if(mb_mapObj[i].wms[ii].gui_wms_mapformat.search(/gif/i)>-1 || mb_mapObj[i].wms[ii].gui_wms_mapformat.search(/png/i)>-1){
-						newMapURL += "TRANSPARENT=TRUE&";
-					}
-					newMapURL += "EXCEPTIONS="+mb_mapObj[i].wms[ii].gui_wms_exceptionformat;
-					// add vendor-specific
-					for (var v = 0; v < mb_vendorSpecific.length; v++) {
-						var vendorSpecificString = eval(mb_vendorSpecific[v]); 
-						// if eval doesn't evaluate a function, the result is undefined.
-						// Sometimes it is necessary not to evaluate a function, for
-						// example if you want to change a variable from the current
-						// scope (see mod_addSLD.php) 
-						if (typeof(vendorSpecificString) != "undefined") {
-							newMapURL += "&" + vendorSpecificString;
-						} 
-					}
-					// add Filter
-					if(mb_mapObj[i].wms[ii].wms_filter != ""){
-						var tmp = mb_mapObj[i].wms[ii].wms_filter +"?id="+ mb_styleID;
-						//prompt("",tmp);;
-						var temp = "&SLD=" + tmp+ "&";
-						newMapURL += temp;
-					}
-					//prompt("",newMapURL);
-					if(mb_mapObj[i].layers[ii] != "" && str_LayerStyles[0] != ""){
-						newMapRequest += newMapURL;
-						mb_mapObj[i].mapURL[ii] = newMapURL;
-						mb_mapObj[i].wms[ii].mapURL = newMapURL;
-						newMapRequest += "' width='"+mb_mapObj[i].width+"' height='"+mb_mapObj[i].height+"' border='0'>";
-					}
-					else{
-						mb_mapObj[i].mapURL[ii] = false;
-						mb_mapObj[i].wms[ii].mapURL = false;
-						newMapRequest = "<img id='"+myMapId+"' name='mapimage' src='" + mb_trans.src;
-						newMapRequest += "' width='"+mb_mapObj[i].width+"' height='"+mb_mapObj[i].height+"' border='0'>";
-					}        
-					//prompt("",newMapRequest);
-					if(mb_log){
-						var tmp = eval(mb_log + "('" + newMapURL + "','" + ts + "')");
-					}
-					writeTag(mb_mapObj[i].frameName,myDivId,newMapRequest);
-				}                            
-			}           
-		}      
-	}   
-	for(var i=0; i<mb_MapRequestSubFunctions.length; i++){
-		eval(mb_MapRequestSubFunctions[i]);
-	}  
-}
-function mb_restateLayers(frameName,wms_id){
-	//alert(frameName + " / " + wms_id);
-	var ind = getMapObjIndexByName(frameName);	
-	for(var i=0; i<mb_mapObj[ind].wms.length; i++){
-		if(mb_mapObj[ind].wms[i].wms_id == wms_id){
-			var cnt_layers = 0;
-			var cnt_querylayers = 0;
-			var layers = "";
-			var styles = "";
-			var querylayers = "";
-			for(var ii=0; ii<mb_mapObj[ind].wms[i].objLayer.length; ii++){
-				if(mb_mapObj[ind].wms[i].objLayer[ii].gui_layer_visible == 1 && ii>0){
-					if(cnt_layers > 0){layers += ","; styles += ","; }
-					layers += mb_mapObj[ind].wms[i].objLayer[ii].layer_name;
-					//alert(mb_mapObj[ind].wms[i].objLayer[ii].layer_name); 
-					styles += ""; 
-					cnt_layers++;
-				}            
-				if(mb_mapObj[ind].wms[i].objLayer[ii].gui_layer_querylayer == 1 && ii>0){
-					if(cnt_querylayers > 0){querylayers += ",";}
-					querylayers += mb_mapObj[ind].wms[i].objLayer[ii].layer_name; 
-					cnt_querylayers++;
-				}
-				mb_mapObj[ind].layers[i] = layers;
-				mb_mapObj[ind].querylayers[i] = querylayers;
-				mb_mapObj[ind].styles[i] = styles;
-			}
-		}
-	}
-}
-
-function mb_checkScale(frameName,mObj,wmsObj){
-	var thisLayer = mb_mapObj[mObj].layers[wmsObj].split(",");
-	var thisScale = mb_getScale(frameName);  
-	var str_layer = "";
-	var str_styles = "";
-	var str_titles = "";
-	var str_legendurls = "";
-	var str_parent = "";
-	var cnt_layer = 0;
-	for(var i=0; i<mb_mapObj[mObj].wms[wmsObj].objLayer.length; i++){  
-		var myLayername = mb_mapObj[mObj].wms[wmsObj].objLayer[i].layer_name;
-		var myMinscale = mb_mapObj[mObj].wms[wmsObj].objLayer[i].gui_layer_minscale;
-		var myMaxscale = mb_mapObj[mObj].wms[wmsObj].objLayer[i].gui_layer_maxscale;
-		for(var ii=0; ii<thisLayer.length; ii++){
-			var minscaleOK = false;
-			var maxscaleOK = false;   
-			if(thisLayer[ii] == myLayername){
-				if(myMinscale == 0 || thisScale >= myMinscale){minscaleOK = true;}
-				if(myMaxscale == 0 || thisScale <= myMaxscale){maxscaleOK = true;}
-				if(maxscaleOK == true && minscaleOK == true ){
-					if(cnt_layer > 0){str_layer += ","; str_styles += ","; str_titles += ",";str_parent += ","; str_legendurls += ",";}
-					str_layer += thisLayer[ii];
-					str_styles += "";
-					str_titles += mb_mapObj[mObj].wms[wmsObj].objLayer[i].layer_title;
-					str_parent += mb_mapObj[mObj].wms[wmsObj].objLayer[i].layer_parent;
-					if(mb_mapObj[mObj].wms[wmsObj].objLayer[i].layer_style.length>0){
-					 	str_legendurls += mb_mapObj[mObj].wms[wmsObj].objLayer[i].layer_style[0]["legendurl"] ;
-					}
-					cnt_layer++;
-				}
-			}
-		}
-	}
-	var str_layerstyles = new Array();
-	str_layerstyles[0] = str_layer;
-	str_layerstyles[1] = str_styles;
-	str_layerstyles[2] = str_titles;
-	str_layerstyles[3] = str_legendurls;
-	str_layerstyles[4] = str_parent;
-	return str_layerstyles;
-}
-function setFeatureInfoRequest(fName,x,y, path) {
-	var functionName = 'setFeatureInfoRequest';
-	var ts = mb_timestamp();
-	for(var i=0; i<mb_FeatureInfoPreFunctions.length; i++){
-		eval(mb_FeatureInfoPreFunctions[i]);
-	}   
-	var cnt_fi = 0;
-	for(var i=0; i<mb_mapObj.length; i++){
-		if(mb_mapObj[i].frameName == fName){
-			for(var ii=0; ii<mb_mapObj[i].wms.length; ii++){
-				var newfeatureInfoRequest = "";
-				var requestParams = "";
-				var validation = false;
-				newfeatureInfoRequest += mb_mapObj[i].wms[ii].wms_getfeatureinfo;          
-            	newfeatureInfoRequest += mb_getConjunctionCharacter(mb_mapObj[i].wms[ii].wms_getfeatureinfo);
-            	
-				if(mb_mapObj[i].wms[ii].wms_version == "1.0.0"){requestParams += "WMTVER="+mb_mapObj[i].wms[ii].wms_version+"&REQUEST=feature_info&";}
-				if(mb_mapObj[i].wms[ii].wms_version != "1.0.0"){requestParams += "VERSION="+mb_mapObj[i].wms[ii].wms_version+"&REQUEST=GetFeatureInfo&SERVICE=WMS&";}
-				requestParams += "SRS="+mb_mapObj[i].epsg+"&";
-				requestParams += "BBOX="+mb_mapObj[i].extent+"&";
-				requestParams += "WIDTH="+mb_mapObj[i].width+"&";
-				requestParams += "HEIGHT="+mb_mapObj[i].height+"&";
-				requestParams += "LAYERS="+mb_mapObj[i].layers[ii]+"&";
-				requestParams += "STYLES="+mb_mapObj[i].styles[ii]+"&";
-				requestParams += "FORMAT="+mb_mapObj[i].wms[ii].gui_wms_mapformat+"&";
-				requestParams += "INFO_FORMAT="+mb_mapObj[i].wms[ii].gui_wms_featureinfoformat+"&";
-				requestParams += "EXCEPTIONS=application/vnd.ogc.se_xml&";
-				if(mb_feature_count > 0){             
-					requestParams += "FEATURE_COUNT="+mb_feature_count+"&";
-				}
-				requestParams += "QUERY_LAYERS="+mb_mapObj[i].querylayers[ii]+"&";
-				requestParams += "X=" + x  + "&";
-				requestParams += "Y=" + y;
-				
-				if(mb_mapObj[i].querylayers[ii] != "" && mb_mapObj[i].layers[ii] != ""){
-					validation = true;
-				}
-				//add vendor-specific
-				for(var v=0; v < mb_vendorSpecific.length; v++){
-					var vendorSpecificString = eval(mb_vendorSpecific[v]); 
-					requestParams += "&" + vendorSpecificString; 
-				}
-				if(mb_log && validation){
-					var tmp = eval(mb_log + "('" + newfeatureInfoRequest + requestParams + "','" + ts + "')");
-				}
-				if(document.getElementById("FeatureInfoRedirect") && validation){
-					newfeatureInfoRequest += requestParams;
-					if(path){
-						window.frames["FeatureInfoRedirect"].document.getElementById(mb_mapObj[i].wms[ii].wms_id).src = path + "?url=" + escape(newfeatureInfoRequest)+"&"+mb_nr;
-					}
-					else{
-						window.frames["FeatureInfoRedirect"].document.getElementById(mb_mapObj[i].wms[ii].wms_id).src = newfeatureInfoRequest;
-					}
-					cnt_fi++;
-            	}
-				else if(path && validation){
-					newfeatureInfoRequest += requestParams
-					window.open(path + "?url=" + escape(newfeatureInfoRequest)+"&"+mb_nr, "" , "width=300,height=400,scrollbars=yes,resizable=yes");
-					cnt_fi++;
-				}
-				else if(validation){
-					newfeatureInfoRequest += requestParams;
-					window.open(newfeatureInfoRequest, "" , "width=300,height=400,scrollbars=yes,resizable=yes");
-					cnt_fi++;          
-				}      
-			}
-		}
-	}
-   	if(cnt_fi == 0){alert(unescape("Please select a layer! \n Bitte waehlen Sie eine Ebene zur Abfrage aus!"));}
-}
-function writeTag(frameName, elName, tagSource) {
-  if(frameName && frameName != ""){
-     window.frames[frameName].document.getElementById(elName).innerHTML = tagSource;
-  }
-  else if(!frameName || frameName == ""){
-       document.getElementById(elName).innerHTML = tagSource;
-  }
-}
-function zoom(frameName,in_, factor,x,y) {
-  var x = parseFloat(x);
-  var y = parseFloat(y);
-  var ind = getMapObjIndexByName(frameName);
-  var arrayBBox = mb_mapObj[ind].extent.split(",");
-  var xtentx = parseFloat(arrayBBox[2]) - parseFloat(arrayBBox[0]);
-  var xtenty =  parseFloat(arrayBBox[3]) - parseFloat(arrayBBox[1]);
-  var centerx = parseFloat(arrayBBox[0]) + xtentx/2;
-  var centery = parseFloat(arrayBBox[1]) + xtenty/2;
-  var factor = parseFloat(factor);
-  if(x){
-   centerx = x;
-   centery = y;
-  }
-  if (!in_) {factor = 1 / factor;}
-  var new_xtentx = xtentx / factor;
-  var new_xtenty = xtenty / factor;
-  var minx = centerx - new_xtentx / 2;
-  var miny = centery - new_xtenty / 2;
-  var maxx = centerx + new_xtentx / 2;
-  var maxy = centery + new_xtenty / 2;
-  mb_mapObj[ind].extent = minx + "," + miny + "," + maxx + "," + maxy;
-  setMapRequest(frameName);
-}
-function mb_panMap(frameName,dir){
-   var ind = getMapObjIndexByName(frameName);
-   var arrayBBox = mb_mapObj[ind].extent.split(",");
-   var minx = parseFloat(arrayBBox[0]);
-   var miny = parseFloat(arrayBBox[1]);
-   var maxx = parseFloat(arrayBBox[2]);
-   var maxy = parseFloat(arrayBBox[3]);
-   var xtentx = parseFloat(arrayBBox[2]) - parseFloat(arrayBBox[0]);
-   var xtenty =  parseFloat(arrayBBox[3]) - parseFloat(arrayBBox[1]);
-
-   if(dir == "NW"){minx = minx - (xtentx/2); maxx = maxx - (xtentx/2); miny = miny + (xtenty/2); maxy = maxy + (xtenty/2);}
-   if(dir == "N"){miny = miny + (xtenty/2); maxy = maxy + (xtenty/2);}
-   if(dir == "NE"){minx = minx + (xtentx/2); maxx = maxx + (xtentx/2); miny = miny + (xtenty/2); maxy = maxy + (xtenty/2);}
-   if(dir == "W"){minx = minx - (xtentx/2); maxx = maxx - (xtentx/2);}
-   if(dir == "E"){minx = minx + (xtentx/2); maxx = maxx + (xtentx/2);}
-   if(dir == "SW"){minx = minx - (xtentx/2); maxx = maxx - (xtentx/2); miny = miny - (xtenty/2); maxy = maxy - (xtenty/2);}
-   if(dir == "S"){miny = miny - (xtenty/2); maxy = maxy - (xtenty/2);}
-   if(dir == "SE"){minx = minx + (xtentx/2); maxx = maxx + (xtentx/2); miny = miny - (xtenty/2); maxy = maxy - (xtenty/2);}
-  mb_mapObj[ind].extent = minx + "," + miny + "," + maxx + "," + maxy;
-  setMapRequest(frameName);
-}
-
-function handleSelectedLayer (frameName, wms_title, layerName, type, status) {
-//	alert(frameName + " , " +wms_title + " , " +layerName + " , " +type + " , " +status);
-//	type = {visible || querylayer] status = {0 || 1}
-	for (var i=0; i < mb_mapObj.length; i++) {
-		if (mb_mapObj[i].frameName == frameName) {
-			var cnt_layer = 0;
-			var str_layer = "";
-			var myMapObj = i;
-			for (var ii = 0; ii < mb_mapObj[i].wms.length; ii++) {
-				if (mb_mapObj[i].wms[ii].wms_title == wms_title) { //ii is true
-					var myWMS = ii; 
-					if (type == "visible") {
-						var arrayLayer = mb_mapObj[i].layers[ii].split(",");
-					}
-					if (type == "querylayer") {
-						var arrayLayer = mb_mapObj[i].querylayers[ii].split(",");
-					}
-					for (var iii = 1; iii < mb_mapObj[i].wms[ii].objLayer.length; iii++) {
-						var layer_name = mb_mapObj[i].wms[ii].objLayer[iii].layer_name;
-						if (type == "querylayer") {
-							if (layer_name == layerName && status == 1 && mb_mapObj[i].wms[ii].objLayer[iii].layer_queryable == 1){
-								if (cnt_layer > 0) {
-									str_layer += ",";
-								}
-								str_layer += layer_name;
-								cnt_layer++;                   
-							}
-						}
-						else if (type == "visible") {
-							if (layer_name == layerName && status == 1) {
-								if (cnt_layer > 0) {
-									str_layer += ",";
-								}
-								str_layer += layer_name;
-								cnt_layer++;                   
-							}
-						}
-						for (var iiii = 0; iiii < arrayLayer.length; iiii++) {
-							if (layer_name == arrayLayer[iiii] && layer_name != layerName) {
-								if (cnt_layer > 0) {
-									str_layer += ",";
-								}
-								str_layer += layer_name;
-								cnt_layer++;             
-							}
-						}
-					}
-				}   
-			}         
-		}
-	}
-	if (type == "visible") {
-		mb_mapObj[myMapObj].layers[myWMS] = str_layer;
-		var array_str_layer = str_layer.split(",");
-		var str_styles = "";
-		for (var cnt=0; cnt < array_str_layer.length; cnt++) {
-			if (cnt > 0) {
-				str_styles += ",";
-			}
-			str_styles += "";
-		}
-		mb_mapObj[myMapObj].styles[myWMS] = str_styles;
-	}
-	if (type == "querylayer") {
-		mb_mapObj[myMapObj].querylayers[myWMS] = str_layer;
-	}
-/*
-	if(type == 'visible'){
-		setSingleMapRequest(frameName,wms_title);
-	}
-*/
-}
-
-function handleSelectedLayer_array(mapObj, array_wms, array_layer, type, status){
-	//alert(mapObj+" / "+array_wms[0]+" / "+ array_layer[0]+" / "+ type+" / "+ status);
-	var ind = getMapObjIndexByName(mapObj);
-	for(var j=0; j<array_wms.length; j++){
-		for(var i=0; i<mb_mapObj[ind].wms.length; i++){
-			if(mb_mapObj[ind].wms[i].wms_id == array_wms[j]){
-				var check = false;
-				for(var ii=0; ii<mb_mapObj[ind].wms[i].objLayer.length; ii++){
-					if(mb_mapObj[ind].wms[i].wms_id == array_wms[j] && mb_mapObj[ind].wms[i].objLayer[ii].layer_name == array_layer[j]){
-						if(type == "visible"){
-							mb_mapObj[ind].wms[i].objLayer[ii].gui_layer_visible = parseInt(status);
-							//alert(mb_mapObj[ind].wms[i].objLayer[ii].layer_name);
-							check = true;
-						}
-                        if(type == "querylayer" && (mb_mapObj[ind].wms[i].objLayer[ii].gui_layer_queryable == "1" || mb_mapObj[ind].wms[i].objLayer[ii].gui_layer_queryable == 1)){
-							mb_mapObj[ind].wms[i].objLayer[ii].gui_layer_querylayer = parseInt(status);
-						}
-					}
-				}
-                mb_restateLayers(mapObj, array_wms[j]);
-                //alert('restate');
-                /*
-                * hier noch checken, welche wms sich geaendert haben und disctinct eine singleRequest aufrufen:
-                */ 
-                if(check == true){					
-                    
-                    if(mb_mapObj[ind].wms[i].gui_wms_visible == 1){
-						setSingleMapRequest(mapObj,mb_mapObj[ind].wms[i].wms_id);
-                        //alert('sSMR');
-					}
-				}
-			}
-		}
-	}
-}
-
-function makeClickPos2RealWorldPos(frameName, myClickX, myClickY) {
-	var ind = getMapObjIndexByName(frameName);
-	var width = parseInt(mb_mapObj[ind].width);
-	var height = parseInt(mb_mapObj[ind].height);
-	var arrayBBox = mb_mapObj[ind].extent.split(",");
-	var minX = parseFloat(arrayBBox[0]);
-	var minY = parseFloat(arrayBBox[1]);
-	var maxX = parseFloat(arrayBBox[2]);
-	var maxY = parseFloat(arrayBBox[3]);
-	var deltaX = (maxX - minX)/width;
-	var deltaY = (maxY - minY)/height;
-	if(deltaX > 0){
-		var roundx = 1/Math.pow(10,(Math.round(Math.log(deltaX)/Math.log(10))));
-	}
-	else{
-		var roundx =  Math.pow(10,(Math.round(Math.log(deltaX)/Math.log(10))));
-	}
-	if(deltaY > 0){
-		var roundy = 1/Math.pow(10,(Math.round(Math.log(deltaY)/Math.log(10))));
-	}
-	else{
-		var roundy =  Math.pow(10,(Math.round(Math.log(deltaY)/Math.log(10))));
-	}	
-	var xtentx = maxX - minX;
-	var xtenty =  maxY - minY;
-	var posX = parseFloat(minX + (myClickX / width) * xtentx);
-	var posY = parseFloat(maxY - (myClickY / height) * xtenty);
-	posX = Math.round(posX * roundx)/roundx;
-	posY = Math.round(posY * roundy)/roundy;
-	return new Array(posX, posY);
-}
-function makeRealWorld2mapPos(frameName,rw_posx, rw_posy){
-   var ind = getMapObjIndexByName(frameName);
-   var arrayBBox = mb_mapObj[ind].extent.split(",");
-   var minX = parseFloat(arrayBBox[0]);
-   var minY = parseFloat(arrayBBox[1]);
-   var maxX = parseFloat(arrayBBox[2]);
-   var maxY = parseFloat(arrayBBox[3]);
-   var xtentx = parseFloat(arrayBBox[2]) - parseFloat(arrayBBox[0]);
-   var xtenty =  parseFloat(arrayBBox[3]) - parseFloat(arrayBBox[1]);
-   var width = mb_mapObj[ind].width;
-   var height = mb_mapObj[ind].height;
-   pixPos_x = Math.round(parseFloat(((rw_posx - minX)/xtentx)*width));
-   pixPos_y = Math.round(parseFloat(((maxY - rw_posy)/xtenty)*height));
-   return new Array(pixPos_x, pixPos_y);
-}
-
-function mb_arrangeElement(frameName, elName, left, top) {
-   if(frameName != ""){
-      window.frames[frameName].document.getElementById(elName).style.top = top;
-      window.frames[frameName].document.getElementById(elName).style.left = left;
-   }
-   else{
-      document.getElementById(elName).style.top = top;
-      document.getElementById(elName).style.left = left;   
-   }
-}
-
-/***********************Drag & Drop***********************/
-function mb_getMousePos(e,fName){
-if(fName){
-     if(ie){
-        clickX = window.frames[fName].event.clientX;
-        clickY = window.frames[fName].event.clientY;
-     }
-     else{
-        clickX = e.pageX;
-        clickY = e.pageY;
-     }
-  }
-  else{
-       if(ie){
-        clickX = event.clientX;
-        clickY = event.clientY;
-     }
-     else{
-        clickX = e.pageX;
-        clickY = e.pageY;
-     }
-  }
-  var pos = new Array(clickX,clickY);
-  return pos;
-}
-// function for object-identification 
-function getMapObjIndexByName(frameName){
-	for(var i=0; i<mb_mapObj.length; i++){
-		if(mb_mapObj[i].frameName == frameName){
-			return i;
-		}
-	}   
-}
-function mb_getLayerTitleByName(map_index, wms_index, myLayer_name){
-	for(var i=0; i<mb_mapObj[map_index].wms[wms_index].objLayer.length; i++){
-		if(mb_mapObj[map_index].wms[wms_index].objLayer[i].layer_name == myLayer_name){
-			return mb_mapObj[map_index].wms[wms_index].objLayer[i].layer_title;
-		}
-	}
-}
-function getWMSIDByTitle(frameName,wms_title){
-   var ind = getMapObjIndexByName(frameName);
-   for(var i=0; i< mb_mapObj[ind].wms.length; i++){
-      if(mb_mapObj[ind].wms[i].wms_title == wms_title){
-         //return i;
-         return mb_mapObj[ind].wms[i].wms_id;
-      }
-   }
-}
-function getWMSIndexByTitle(frameName,wms_title){
-   var ind = getMapObjIndexByName(frameName);
-   for(var i=0; i< mb_mapObj[ind].wms.length; i++){
-      if(mb_mapObj[ind].wms[i].wms_title == wms_title){
-         return i;
-      }
-   }
-}
-function getWMSIndexById(frameName,wms_id){
-   var ind = getMapObjIndexByName(frameName);
-   for(var i=0; i< mb_mapObj[ind].wms.length; i++){
-      if(mb_mapObj[ind].wms[i].wms_id == wms_id){
-         return i;
-      }
-   }
-}
-//scale
-function mb_getScale(frameName) {
-   for(var i=0; i<mb_GetScalePreFunctions.length; i++){
-		var myScale = eval(mb_GetScalePreFunctions[i]);
-	}
-   if(myScale){
-      var Y_str = myScale;
-   }
-   else{
-      var ind = getMapObjIndexByName(frameName);
-      var arrayBBox = mb_mapObj[ind].extent.split(",");
-      var xtenty =  parseFloat(arrayBBox[3]) - parseFloat(arrayBBox[1]);
-      var scaleY = (xtenty / mb_mapObj[ind].height) *(mb_resolution * 100);
-      if (scaleY<1){
-      	var Y_str = scaleY;
-      }else{
-      	var Y_str = Math.round(scaleY);
-      }
-   }   
-   return Y_str;   
-}
-
-function mb_repaintScale(frameName, x, y, scale){
-   var ind = getMapObjIndexByName(frameName);
-   if(x == null && y == null){
-      var arrayBBox = mb_mapObj[ind].extent.split(",");
-      x = parseFloat(arrayBBox[0]) + ((parseFloat(arrayBBox[2]) - parseFloat(arrayBBox[0]))/2);
-      y = parseFloat(arrayBBox[1]) + ((parseFloat(arrayBBox[3]) - parseFloat(arrayBBox[1]))/2);
-   }
-   var minx = parseFloat(x) - (mb_mapObj[ind].width / (mb_resolution * 100 *2) * scale);
-   var miny = parseFloat(y) -  (mb_mapObj[ind].height / (mb_resolution * 100 *2) * scale);
-   var maxx = parseFloat(x) + (mb_mapObj[ind].width / (mb_resolution * 100 *2) * scale);
-   var maxy = parseFloat(y) +  (mb_mapObj[ind].height / (mb_resolution * 100 *2) * scale);
-   mb_repaint(frameName,minx, miny, maxx, maxy);
-}
-function mb_repaint(frameName,minx,miny,maxx,maxy){
-   var ind = getMapObjIndexByName(frameName);
-   mb_mapObj[ind].extent = minx + "," + miny + "," + maxx + "," + maxy;
-   setMapRequest(frameName);
-}
-function mb_calculateExtent(frameName,minx,miny,maxx,maxy){
-  var ind = getMapObjIndexByName(frameName);
-  
-  var extenty = parseFloat(maxy) - parseFloat(miny);
-  var extentx = parseFloat(maxx) - parseFloat(minx);
-
-  var relation_px_x = mb_mapObj[ind].width / mb_mapObj[ind].height;
-  var relation_px_y = mb_mapObj[ind].height / mb_mapObj[ind].width;
-  var relation_bbox_x = extentx / extenty;     
-  var centerx = parseFloat(minx) + (extentx/2);
-  var centery = parseFloat(miny) + (extenty/2);
-  if(relation_bbox_x <= relation_px_x){                
-    minx = centerx - relation_px_x * extenty / 2;
-    maxx = centerx + relation_px_x * extenty / 2;
-  }
-  if(relation_bbox_x > relation_px_x){                
-    miny = centery - relation_px_y * extentx / 2;
-    maxy = centery + relation_px_y * extentx / 2;
-  }
-  mb_mapObj[ind].extent = minx  +","+ miny +","+ maxx  +","+ maxy;
-}
-
-function mb_showHighlight(frameName,x,y){
-   var pos = makeRealWorld2mapPos(frameName,x, y);
-   mb_arrangeElement(frameName,"highlight",pos[0]-7, pos[1]-7);
-   window.frames[frameName].document.getElementById("highlight").style.visibility = 'visible';
-}
-function mb_hideHighlight(frameName){
-   mb_arrangeElement(frameName,"highlight",-20, -20);
-   mb_arrangeElement(frameName,"highlight",-20, -20);
-   window.frames[frameName].document.getElementById("highlight").style.visibility = 'hidden';
-}
-function mb_permanentHighlight(frameName,x,y){   
-   var pos = makeRealWorld2mapPos(frameName,x, y);
-   mb_arrangeElement(frameName,"permanent",pos[0]-7, pos[1]-7);
-   window.frames[frameName].document.getElementById("permanent").style.visibility = 'visible';
-}
-// framename, commaseparated coordinates, commaseparated rgb values (color)
-//new: coords is array!
-function mb_markResult(frameName,geom,col){
-	var x = "";
-	var y = "";
-	var tmp = new Array();
-	var ind = getMapObjIndexByName(frameName);
-	for(var i=0; i < geom.length; i++){
-		if(i > 0){
-			x += ":";
-			y += ":";
-		}
-		tmp = geom[i].split(",");
-		for(var ii=0; ii < tmp.length; ii+=2){			
-			var pos = makeRealWorld2mapPos(frameName,tmp[ii], tmp[ii+1]);
-			if(ii>0){
-				x += ",";
-				y += ",";
-			}
-			x += pos[0];
-			y += pos[1];
-		}      
-	}
-	var source = "<img src='../extensions/markResult.php?x=" + x + "&y=" + y + "&width=" + mb_mapObj[ind].width + "&height=" + mb_mapObj[ind].height + "&color="+col+"'>";
-	//prompt("",source);
-	writeTag(frameName,"markResult",source);   
-}
-function mb_disableResult(frameName){
-   writeTag(frameName,"markResult","");
-}
-
-function mb_registerGML(frameName,obj){
-	var ind = getMapObjIndexByName(frameName);
-	mb_mapObj[ind].geom = obj;
-}
-function mb_timestamp(){
-	var d = new Date();
-	var ts = Math.round(Date.parse(d)/1000);
-	return ts;
-}
-function mb_getlayerposbyname(objInd,wmsInd,lname){
-	var t = mb_mapObj[objInd].wms[wmsInd];
-	for(var i=0; i < t.objLayer.length; i++){
-		if(t.objLayer[i].layer_name == lname){
-			return t.objLayer[i].layer_pos;
-		}
-	}
-}
-function mb_getLayerObjByName(fname,wms_id,layer_name){
-	var ind = getMapObjIndexByName(fname);
-	var wmsInd = getWMSIndexById(fname,wms_id);
-	var t = mb_mapObj[ind].wms[wmsInd];
-	for(var i=0; i < t.objLayer.length; i++){
-		if(t.objLayer[i].layer_name == layer_name){
-			return t.objLayer[i];
-		}
-	}
-}
-function mb_getchildsbyname(objInd,wmsInd,lname){
-	var t = mb_mapObj[objInd].wms[wmsInd];
-	var pos = mb_getlayerposbyname(objInd, wmsInd,lname);
-	var l = new Array();
-	l["name"] = new Array();
-	l["title"] = new Array();
-	l["legendurl"] = new Array();
-	for(var i=0; i < t.objLayer.length; i++){
-		if(t.objLayer[i].layer_parent == pos){
-			l["name"][l["name"].length] = t.objLayer[i].layer_name;
-			l["title"][l["title"].length] = t.objLayer[i].layer_title;
-			if(t.objLayer[i].layer_style.length>0){
-				l["legendurl"][l["legendurl"].length] = t.objLayer[i].layer_style[0]["legendurl"] ;
-			}else{
-				l["legendurl"][l["legendurl"].length] = 0 ;
-			}
-		}
-	}
-	if(l["name"].length > 0){
-		return l;
-	}
-	else{
-		return false;
-	}
-}
-
-/*
- ***************************************************************************************
- *   div tag
- ***************************************************************************************
- */
-
-function DivTag (aTagName, aFrameName, aStyle) {
-	this.exists = function () { 
-		return (rootNode.getElementById(tagName)) ? true : false;
-	};
-	
-	var determineRootNode = function () {
-		node = document;
-		if (frameName !== "") {
-			if (checkFrame()) {node = window.frames[frameName].document;}
-			else {var e = new Mb_exception("frame "+frameName+" doesn't exist.");}
-		}
-		return node;	
-	};
-	
-	var toCamelCase = function(aString) {
-		var newString = "";
-		for (var i = 0; i < aString.length; i++) {
-			if (aString.substr(i,1) != "-") {
-				newString += aString.substr(i,1); 
-			}
-			else {
-				i++;
-				newString += aString.substr(i,1).toUpperCase();
-			}
-		}
-		return newString;
-	}
-	
-	var setStyle = function () {
-		if (that.exists()) {
-			var node = rootNode.getElementById(tagName);
-			node.setAttribute("style", "");
-			
-			for (var attr in tagStyle) {
-				if (typeof(tagStyle[attr]) != "function" && typeof(tagStyle[attr]) != "object") {
-					var evalString = "node.style."+toCamelCase(attr)+" = \"" + tagStyle[attr] + "\";"; 
-					eval(evalString);				
-				}
-			}
-		}
-	}
-	
-	var create = function () {
-		if (!that.exists()) {
-			var divTag = rootNode.createElement("div");
-			var divTagAppended = rootNode.getElementsByTagName("body")[0].appendChild(divTag);
-			divTagAppended.id = tagName;
-		}
-		else {
-			that.clean();
-		}
-		setStyle();
-	};
-	var checkFrame = function () {
-		if (frameName !== "") {
-			return (typeof(window.frames[frameName]) != 'undefined');
-		}
-		return true;
-	};
-	
-	this.getTag = function() {
-		return rootNode.getElementById(tagName);
-	};
-	
-	var that = this;
-	var tagName = aTagName;
-	var frameName = aFrameName;
-	var rootNode = determineRootNode();
-	var tagStyle = aStyle;
-
-	create();
-}
-
-DivTag.prototype.write = function (someText) {
-	if (this.exists()) {
-		this.getTag().innerHTML = someText;
-	}
-};
-DivTag.prototype.clean = function () {
-	this.write("");
-};
-
-
-/*
- ***************************************************************************************
- *   Javascript exception handling
- ***************************************************************************************
- */
-
-/**
- * @class An abstract class, logs JavaScript events like errors, warnings etc.
- *
- * @constructor
- */
-var Mb_log = function() {
-	var that = this;
-	
-	var levelArray = global_log_levels.split(",");
-	var log_level = global_mb_log_level;
-	var log_js = global_mb_log_js;
-	
-	var indexOfLevel = function(aLevel) {
-		for (var i = 0; i < levelArray.length; i++) {
-			if (aLevel == levelArray[i])  {
-				return i;
-			}
-		}
-		return false;
-	};
-	var isValidLevel = function(aLevel) {
-		var isNotOff = typeof(log_js) != 'undefined' && log_js != "off";
-		var levelIndex = indexOfLevel(aLevel);
-		var isAppropriate = (typeof(levelIndex)=='number' && levelIndex < indexOfLevel(log_level));
-		return (isNotOff && isAppropriate);
-	};
-	var throwException = function (message, level) {
-		if (isValidLevel(level)) {
-			if (log_js == "on") {
-				try {
-					mb_ajaxWrap_post('../php/mb_js_exception.php', {level:level,text:message});
-				}
-				catch(e) {
-					alert(e + ": " + message);
-				}
-			}
-			else if (log_js == "alert") {
-				alert(message);
-			}
-			else if (log_js == "console") {
-				console.log("%s", message);
-			}
-		}
-	};
-}	
-
-/**
- *  class for exception logging
- *
- * @extends {@link Mb_log}
- * @param message the message that is being logged
- */	
-function Mb_exception(message) {
-	this.level = "error";
-	this.throwException(message, this.level);
-}
-Mb_exception.prototype = new Mb_log();
-
-/**
- *  class for warning logging
- *
- * @extends {@link Mb_log}
- * @param message the message that is being logged
- */	
-function Mb_warning(message) {
-	this.level = "warning";
-	this.throwException(message, this.level);
-}
-Mb_warning.prototype = new Mb_log();
-
-/*
- ***************************************************************************************
- *   AJAX wrapper functions
- ***************************************************************************************
- */
-/**
- * A wrapper for an AJAX request via GET 
- *
- * @param {String} url the URL of a (presumably a server side) script.
- * @param {Object} An object containing parameters, f.e. {name1:value1, name2:value2}
- * @param {Function} A function that is called when the server side script has been processed. The function is called with two parameters, result and status. Result is the output of the server side script (XML, HTML, whatever), status is a {String}, either "success" or "error". 
- */
-function mb_ajax_get(url, param, callback) {
-	try {
-		mb_ajaxWrap_get(url, param, callback);
-	}
-	catch(e) {
-		alert('map.php: mb_ajax_get:'+e);
-	}
-}	
-
-/**
- * A wrapper for an AJAX request via POST 
- *
- * @param {String} url the URL of a (presumably a server side) script.
- * @param {Object} An object containing parameters, f.e. {name1:value1, name2:value2}
- * @param {Function} A function that is called when the server side script has been processed. The function is called with two parameters, result and status. Result is the output of the server side script (XML, HTML, whatever), status is a {String}, either "success" or "error". 
- */
-function mb_ajax_post(url, param, callback) {
-	try {
-		mb_ajaxWrap_post(url, param, callback);
-	}
-	catch(e) {
-		alert('map.php: mb_ajax_post:'+e);
-	}
-}	
-	
-/**
- * A wrapper for an AJAX request via GET 
- *
- * @param {String} url the URL of a (presumably a server side) script.
- * @param {Object} An object containing parameters, f.e. {name1:value1, name2:value2}
- * @param {Function} A function that is called when the server side script has been processed. The function is called with two parameters, result and status. Result is the output of the server side script (a JavaScript Object, not a String!), status is a {String}, either "success" or "error". 
- */
-function mb_ajax_json(url, param, callback) {
-	try {
-		mb_ajaxWrap_json(url, param, callback);
-	}
-	catch(e) {
-		alert('map.php: mb_ajax_json:'+e);
-	}
-}	
-	
-/*
- ***************************************************************************************
- *   button handling
- ***************************************************************************************
- */
- 
-var mb_button = new Array();
-
-function mb_regButton_frame(wii, frameName, param){
-	var ind = mb_button.length;
-	mb_button[ind] = new mb_conButton(wii, ind);
-	if (frameName == null) {
-		if (param == null) {
-			eval(wii+"("+ind+")");
-		}
-		else {
-			eval(wii+"("+ind+", "+param+")");
-		}
-	}
-	else if (param == null) {
-		eval("window.frames['" + frameName + "']."+wii+"("+ind+")");
-	}
-	else {
-		eval("window.frames['" + frameName + "']."+wii+"("+ind+", "+param+")");
-	}
-	mb_button[ind].prev = mb_button[ind].src;
-	mb_button[ind].src = mb_button[ind].img_off;
-	mb_button[ind].onmouseover = new Function("mb_button_over("+ind+")");
-	mb_button[ind].onmouseout = new Function("mb_button_out("+ind+")");
-	mb_button[ind].onclick = new Function("mb_button_click("+ind+")");
-	if (frameName==null) {
-		mb_button[ind].frameName = "";
-	}
-	else {
-		mb_button[ind].frameName = frameName;
-	}
-}
-
-function mb_regButton(wii){
-	mb_regButton_frame(wii, null, null);
-}
-
-function mb_conButton(wii, ind){
-   this.wii = wii;
-   return true;
-}
-function mb_button_over(ind){
-   if(mb_button[ind].status == 0){
-      mb_button[ind].prev = mb_button[ind].src;
-      mb_button[ind].src = mb_button[ind].img_over;
-   }
-}
-function mb_button_out(ind){
-   mb_button[ind].src = mb_button[ind].prev;
-}
-function mb_button_click(ind){
-   var mbStatus = mb_button[ind].status;
-   if(mbStatus == 0){
-      mb_disableButton(mb_button[ind].elName);
-      mb_button[ind].prev = mb_button[ind].img_on;
-      mb_button[ind].src = mb_button[ind].img_on;
-      mb_button[ind].status = 1;
-      if (mb_button[ind].frameName != "") {
-          window.frames[mb_button[ind].frameName].document.getElementById(mb_button[ind].elName).go();
-      }
-      else {
-	      document.getElementById(mb_button[ind].elName).go();
-      }
-   }
-   else{
-      mb_button[ind].prev = mb_button[ind].img_off;
-      mb_button[ind].src = mb_button[ind].img_off;
-      mb_button[ind].status = 0;      
-      if (mb_button[ind].frameName != "") {
-          window.frames[mb_button[ind].frameName].document.getElementById(mb_button[ind].elName).stop();
-      }
-      else {
-	      document.getElementById(mb_button[ind].elName).stop();
-      }
-   }
-}
-function mb_disableButton(elName){
-   for(var i=0; i<mb_button.length; i++){
-      if(mb_button[i].elName != elName && mb_button[i].status == 1){
-            mb_button[i].status = 0;
-		      if (mb_button[i].frameName != "") {
-    	        window.frames[mb_button[i].frameName].document.getElementById(mb_button[i].elName).src = mb_button[i].img_off;
-	            window.frames[mb_button[i].frameName].document.getElementById(mb_button[i].elName).stop();
-		      }
-		      else {
-    	        document.getElementById(mb_button[i].elName).src = mb_button[i].img_off;
-	            document.getElementById(mb_button[i].elName).stop();
-		      }
-            return true;
-       
-      }
-   }
-}
-function mb_disableThisButton(elName){
-   for(var i=0; i<mb_button.length; i++){
-      if(mb_button[i].elName == elName && mb_button[i].status == 1){
-      		//alert(mb_button[i].elName);
-            mb_button[i].status = 0;
-		      if (mb_button[i].frameName != "") {
-    	        window.frames[mb_button[i].frameName].document.getElementById(mb_button[i].elName).src = mb_button[i].img_off;
-	            window.frames[mb_button[i].frameName].document.getElementById(mb_button[i].elName).stop();
-		      }
-		      else {
-        	    document.getElementById(mb_button[i].elName).src = mb_button[i].img_off;
-		        document.getElementById(mb_button[i].elName).stop();
-		      }
-            return true;
-       
-      }
-   }
-}
-
-/*
- ***************************************************************************************
- *   miscellaneous functions
- ***************************************************************************************
- */
-
-function cloneObject(someObject){
-	var clone = [];
-	
-	for (attribute in someObject) {
-
-		var currentElement = someObject[attribute];
-
-		if (typeof(currentElement) == "object") {
-			clone[attribute] = cloneObject(currentElement);
-		}
-		else {
-			clone[attribute] = currentElement;
-		}
-	}	
-	return clone;
-}
-
-
-/**
- * @class A List object is an array of arbitrary objects with additional methods. 
- *
- * @constructor
- */
-var List = function() {
-	
-	/**
-	 * gets the number of elements in this {@link List}
-	 *
-	 * @member List
-	 * @returns number of elements in this {@link List}
-	 * @type Integer
-	 */
-	this.count = function() {
-		return this.list.length;
-	};
-
-	/**
-	 * deletes the object at index i; -1 refers to the last object in this {@link List}
-	 *
-	 * @member List
-	 * @param {Integer} i index
-	 */
-	this.del = function(i){
-		i = this.getIndex(i);
-		for(var z = i; z < this.count() - 1; z++){
-			this.list[z] = this.list[z+1];
-		}
-		this.list.length -= 1;
-	};
-
-	/**
-	 * empties this {@link List}
-	 *
-	 * @member List
-	 */
-	this.empty = function() {
-		while (this.list != null && this.count() > 0) {
-			this.list.pop();
-		}
-	}
-	
-	/**
-	 * @member List
-	 * @param {Integer} i index
-	 * @returns the object at index i; -1 refers to the last object in this {@link List}
-	 * @type Integer or false
-	 */
-	this.get = function(i) {
-		i = this.getIndex(i);
-		if (i !== false) {return this.list[i];}
-		return false;		
-	};
-	/**
-	 * adds a reference to item to this {@link List}.
-	 *
-	 * @member List
-	 * @param {Object} item an object
-	 */
-	this.add = function(item) {
-		this.list.push(item);
-	};
-	/**
-	 * adds a copy of item to this {@link List}.
-	 *
-	 * @member List
-	 * @param {Object} item an object
-	 */
-	this.addCopy = function(item) {
-		this.list.push(cloneObject(item));
-	};
-	/**
-	 * attaches the {@link List} aList to this {@link List}
-	 *
-	 * @member List
-	 * @param {List} aList another list
-	 */
-	this.union = function(aList) {
-		for (var i=0; i < aList.count(); i++) {this.addCopy(aList.get(i));}
-	};
-	/**
-	 * checks if the index is valid and returns it if it is; if i == -1, the correct index is retrieved.
-	 *
-	 * @member List
-	 * @private
-	 * @return Integer or false
-	 * @type Integer
-	 */
-	this.getIndex = function(i){ 
-		if ((i >= 0 && i < this.list.length) || (i*(-1)>0 && i*(-1) <= this.list.length)){
-			if (i >= 0) {return i;} else {return this.list.length+i;}
-		}
-		else {
-			var e = new Mb_exception("class List: function getIndex: member index " + i + " is not valid");
-			return false;
-		}
-	};
-	/**
-	 * @member List
-	 * @returns a {String} representation of this List
-	 * @type String
-	 */
-	this.toString = function(){
-		var str = "";
-		for (var i =0 ; i < this.count() ; i++){
-			str += this.get(i).toString();
-		}
-		return str;	
-	};	
-	
-	this.list = null;
-};
-
-
-
-/*
- ***************************************************************************************
- *   register functions
- ***************************************************************************************
- */
-
-var mb_MapRequestSubFunctions = new Array();
-var mb_WfsReadSubFunctions = new Array();
-var mb_WfsWriteSubFunctions = new Array();
-var mb_MapRequestPreFunctions = new Array();
-var mb_FeatureInfoPreFunctions = new Array();
-var mb_InitFunctions = new Array();
-var mb_MapObjectSubFunctions = new Array();
-var mb_GetScalePreFunctions = new Array();
-var mb_loadWmsSubFunctions = new Array();
-
-function mb_registerInitFunctions(stringFunction){
-	mb_InitFunctions[mb_InitFunctions.length] = stringFunction;
-}
-function mb_registerPreFunctions(stringFunction){
-	mb_MapRequestPreFunctions[mb_MapRequestPreFunctions.length] = stringFunction;
-}
-function mb_registerFeatureInfoPreFunctions(stringFunction){
-	mb_FeatureInfoPreFunctions[mb_FeatureInfoPreFunctions.length] = stringFunction;
-}
-function mb_registerSubFunctions(stringFunction){
-	mb_MapRequestSubFunctions[mb_MapRequestSubFunctions.length] = stringFunction;
-}
-function mb_registerMapObjectSubFunctions(stringFunction){
-	mb_MapObjectSubFunctions[mb_MapObjectSubFunctions.length] = stringFunction;
-}
-function mb_registerGetScalePreFunctions(stringFunction){
-	mb_GetScalePreFunctions[mb_GetScalePreFunctions.length] = stringFunction;
-}
-function mb_registerloadWmsSubFunctions(stringFunction){
-	mb_loadWmsSubFunctions[mb_loadWmsSubFunctions.length] = stringFunction;
-}
-function mb_registerWfsReadSubFunctions(stringFunction){
-	mb_WfsReadSubFunctions[mb_WfsReadSubFunctions.length] = stringFunction;
-}
-function mb_registerWfsWriteSubFunctions(stringFunction){
-	mb_WfsWriteSubFunctions[mb_WfsWriteSubFunctions.length] = stringFunction;
-}
-function mb_removeFunctionFromArray(arrayname,stringFunction){
-	var length = eval(arrayname+".length");
-	for(var i=0; i<length; i++){
-		if(eval(arrayname+"["+i+"]") == stringFunction){
-			var newArray1 = eval(arrayname+".slice(0, "+(i-1)+")");
-			var newArray2 = eval(arrayname+".slice("+(i+1)+", "+length+")");
-			eval(arrayname + " = newArray1.concat(newArray2)");
-			i--;
-			length--;
-		}
-	}
-}
- 
-function mb_execloadWmsSubFunctions(){
-	for(var i=0; i<mb_loadWmsSubFunctions.length; i++){
-		eval(mb_loadWmsSubFunctions[i]); 	 
-	} 	 
-}
-
-function mb_execWfsReadSubFunctions(geom) { 	 
-	for(var i=0; i<mb_WfsReadSubFunctions.length; i++){ 	 
-		mb_WfsReadSubFunctions[i](geom); 	 
-	} 	 
-}
-
-function mb_execWfsWriteSubFunctions() { 	 
-	for(var i=0; i<mb_WfsWriteSubFunctions.length; i++){
-		mb_WfsWriteSubFunctions[i](); 	 
-	} 	 
-}
-
-/*
- * first draft of a redesign
- *
-var FunctionArray = function() {
-	this.list = [];
-
-	this.register = function (aFunction) {
-		this.add(aFunction);
-	}
-	this.execute = function () {
-		for (var i = 0; i < this.count(); i++) {
-			var aFunction = this.get(i);
-			if (typeof(aFunction) == 'function') {
-				aFunction();
-			}
-			else if (typeof(aFunction) == 'string') {
-				eval(aFunction);
-			}
-			else {
-				var e = new mb_exception("FunctionArray.execute: Invalid parameter: " + aFunction);
-			}
-		}
-	}
-	this.remove = function (functionString) {
-		var listLength = this.count();
-		for (var i = listLength - 1; i >= 0; i--) {
-			if (this.get(i) == functionString){
-				this.del(i);
-			}
-		}
-	}
-}
-
-FunctionArray.prototype = new List();
-
-var mbInitFunctions = new FunctionArray();
-var mbMapRequestSubFunctions = new FunctionArray();
-var mbWfsReadSubFunctions = new FunctionArray();
-var mbWfsWriteSubFunctions = new FunctionArray();
-var mbMapRequestPreFunctions = new FunctionArray();
-var mbFeatureInfoPreFunctions = new FunctionArray();
-var mbInitFunctions = new FunctionArray();
-var mbMapObjectSubFunctions = new FunctionArray();
-var mbGetScalePreFunctions = new FunctionArray();
-var mbloadWmsSubFunctions = new FunctionArray();
-
-*/
-
-/*
- ***************************************************************************************
- *   deprecated functions
- ***************************************************************************************
- */
-
-// only used in mod_perimeter.php
-// previously used in mod_initWmc.php, mod_digitize_tab.php, mod_geometryArray.js
-function mb_checkTag(frameName, tagName, elementId, appendAtTagName, attributes){
-	var oldElement;
-	var newElement;
-	var prefix;
-	if(frameName && frameName != ""){
-		prefix = window.frames[frameName].document;
-	}
-	else if(!frameName || frameName == ""){
-		prefix = document;
-	}
-	oldElement = prefix.getElementById(elementId);
-	if (oldElement == null) {
-		newElement = prefix.createElement(tagName);
-		newElement = prefix.getElementsByTagName(appendAtTagName)[0].appendChild(newElement);
-	}
-	else {
-		if (oldElement.nodeName.toLowerCase() == tagName.toLowerCase()) {
-			for (var i=0; i<attributes.length; i++) {
-				oldElement.setAttribute(attributes[i][0], attributes[i][1]);
-			}
-			return oldElement;
-		}
-		else {
-			return false;
-		}
-	}
-	var newElementAttributeNode = document.createAttribute("id");
-	newElementAttributeNode.value = elementId;
-	newElement.setAttributeNode(newElementAttributeNode);
-	for (var i=0; i<attributes.length; i++) {
-		newElement.setAttribute(attributes[i][0], attributes[i][1]);
-	}
-	return newElement;
-}
-<?php
 $con = db_connect($DBSERVER,$OWNER,$PW);
 db_select_db(DB,$con);
 



More information about the Mapbender_commits mailing list