[Mapbender-commits] r4471 - in branches/print_dev/http: classes css javascripts php print

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Aug 4 07:51:01 EDT 2009


Author: mschulz
Date: 2009-08-04 07:51:01 -0400 (Tue, 04 Aug 2009)
New Revision: 4471

Added:
   branches/print_dev/http/print/mod_printPDF_div.js
   branches/print_dev/http/print/printbox.js
Removed:
   branches/print_dev/http/classes/class_monitor.php
   branches/print_dev/http/javascripts/mod_digitize_tab_category.php
   branches/print_dev/http/javascripts/mod_loadwmc_list.php
   branches/print_dev/http/javascripts/mod_log.php
   branches/print_dev/http/javascripts/mod_reload.php
   branches/print_dev/http/javascripts/mod_resize_mapsize.php
   branches/print_dev/http/javascripts/mod_sandclock.php
   branches/print_dev/http/javascripts/mod_sandclock2.php
   branches/print_dev/http/javascripts/mod_scalebar.php
   branches/print_dev/http/javascripts/mod_zoomFull.php
   branches/print_dev/http/php/mod_map1.php
   branches/print_dev/http/php/mod_mapOV.php
Modified:
   branches/print_dev/http/css/print_div.css
   branches/print_dev/http/javascripts/map.php
   branches/print_dev/http/print/mod_printPDF_div.php
   branches/print_dev/http/print/print_functions.php
   branches/print_dev/http/print/testConfigTemplate.json
Log:
printPDF as MB module and printbox first integration (no rotation yet ...)

Deleted: branches/print_dev/http/classes/class_monitor.php
===================================================================
--- branches/print_dev/http/classes/class_monitor.php	2009-08-04 11:47:46 UTC (rev 4470)
+++ branches/print_dev/http/classes/class_monitor.php	2009-08-04 11:51:01 UTC (rev 4471)
@@ -1,495 +0,0 @@
-<?php
-# $Id$
-# http://www.mapbender.org/index.php/
-# Copyright (C) 2002 CCGIS 
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-require_once(dirname(__FILE__)."/../../core/globalSettings.php");
-
-require_once(dirname(__FILE__)."/../classes/class_wms.php");
-require_once(dirname(__FILE__)."/../classes/class_bbox.php");
-
-require_once(dirname(__FILE__)."/../extensions/DifferenceEngine.php");
-
-define("MONITOR_DEFAULT_SCALE", 500000);
-define("MONITOR_IMG_WIDTH", 20);
-define("MONITOR_IMG_HEIGHT", 20);
-define("MB_RESOLUTION", 28.35);
-
-class Monitor {
-	/**
-	 *  1 = reachable and in sync with db
-	 *  0 = reachable and out of sync with db
-	 * -1 = unreachable
-	 * -2 = monitoring in progress
-	 * 
-	 */
-	var $result = -1;
-
-	/**
-	 * 1  = the get map request DEFINITELY returns a valid map image
-	 * 0  = the WMS doesn't support XML error format. Who knows if the image is really a map?
-	 * -1 = the get map request doesn't return an image
-	 */
-	var $returnsImage;
-
-	var $comment = "";
-	var $updated = "0";
-	var $supportsXMLException = false;
-	
-	var $timestamp;
-	var $capabilitiesURL;
-	var $mapURL;
-	
-	var $remoteXML;
-	var $localXML;
-	var $capabilitiesDiff;
-	
-	function __construct($wmsId, $uploadId, $autoUpdate) {
-		$this->wmsId = $wmsId;
-		$this->uploadId = $uploadId;
-		$this->autoUpdate = $autoUpdate;
-
-		$this->capabilitiesURL = $this->getUploadURL($this->wmsId, $this->uploadId);
-
-		set_time_limit(TIME_LIMIT);
-		
-		
-		$this->timestamp = time();
-		
-		if ($this->capabilitiesURL) {
-		
-			$remoteWms = new wms();
-			$remoteWms->createObjFromXML($this->capabilitiesURL);
-			$this->remoteXML = $remoteWms->wms_getcapabilities_doc;  
-			$this->localXML = $this->getCapabilitiesDocByWMS($this->wmsId);
-
-			// service unreachable
-			if (!$this->remoteXML) {
-				$this->result = -1;
-				$this->comment = "Connection failed.";
-			}
-			/*
-			 * service available;
-			 * no local copy of capabilities file,
-			 * so it has to be updated anyway
-			 */
-			elseif (!$this->localXML) {
-				$this->result = 0;
-			}
-			/*
-			 * service available;
-			 * check if local copy is different
-			 * to remote capabilties document
-			 */
-			else {
-				/*
-				 * compare to local capabilities document
-				 */
-				// capabilities files match
-				if ($this->localXML == $this->remoteXML) {
-					$this->result = 1;
-					$this->comment = "WMS is stable.";
-				}
-				// capabilities files don't match
-				else {
-					$this->result = 0;
-					$localXMLArray = explode("\n", htmlentities($this->localXML));
-					$remoteXMLArray = explode("\n", htmlentities($this->remoteXML));
-					$this->capabilitiesDiff = $this->outputDiffHtml($localXMLArray,$remoteXMLArray);
-				}
-			}
-			/*
-			 * if the WMS is available,
-			 * 1) get a map image
-			 * 2) update the local backup of the capabilities doc if necessary
-			 */
-			if ($this->result != -1) {
-				
-				$this->mapURL = $this->getMapRequest($this->wmsId);
-				
-				if ($this->isImage($this->mapURL)) {
-					$this->returnsImage = 1;
-				}
-				else {
-					$this->returnsImage = -1;
-				}
-		
-				/*
-				 * if the local backup of the capabilities document
-				 * is deprecated, update the local backup
-				 */
-				if ($this->result == 0) {
-					$mywms = new wms();
-		
-					/* 
-					 * if the capabilities document is valid,
-					 * update it OR mark it as "not up to date"
-					 */ 
-					if ($mywms->createObjFromXML($this->capabilitiesURL)) {
-						if ($this->autoUpdate) {
-							$mywms->updateObjInDB($this->wmsId);
-							$this->updated = "1";
-							$this->comment = "WMS has been updated.";
-						}
-						else {
-							$this->comment = "WMS is not up to date.";
-						}
-					}
-					// capabilities document is invalid
-					else {
-						$this->result = -1;
-						$this->comment = "Invalid getCapabilities request/document or service exception.";
-					}    
-				}
-			}
-		}
-		else {
-			$this->result = -1;
-			$this->comment = "Invalid upload URL.";
-		}
-		$e = new mb_notice("class_monitor: constructor: result = " . $this->result);
-		$e = new mb_notice("class_monitor: constructor: comment = " . $this->comment);
-		$e = new mb_notice("class_monitor: constructor: returnsImage = " . $this->returnsImage);
-	}
-	
-	/**
-	 * 
-	 */
-	public function __toString() {
-		$str = "";
-		$str .= "wmsid: " . $this->wmsId . "\nupload_id: " . $this->uploadId . "\n";
-		$str .= "autoupdate: " . $this->autoUpdate . "\n";
-		$str .= "result: " . $this->result . "\ncomment: " . $this->comment . "\n";
-		$str .= "timestamp: " . $this->timestamp . " (".date("F j, Y, G:i:s", $this->timestamp).")\n";
-		$str .= "getCapabilities URL: " . $this->capabilitiesURL . "\nupdated: " . $this->updated . "\n\n";
-		$str .= "getMap URL: " . $this->mapURL . "\nis image: " . $this->returnsImage . "\n\n";
-		$str .= "-------------------------------------------------------------------\n";
-		$str .= "remote XML:\n\n" . $this->remoteXML . "\n\n";
-		$str .= "-------------------------------------------------------------------\n";
-		$str .= "local XML:\n\n" . $this->localXML . "\n\n";
-		$str .= "-------------------------------------------------------------------\n";
-		$str .= "diff:\n\n" . $this->capabilitiesDiff . "\n\n";
-		$str .= "-------------------------------------------------------------------\n";		
-		return (string) $str;
-	}
-
-	/**
-	 * Update database
-	 */
-	function updateInDB() {
-		$sql = "UPDATE mb_monitor SET updated = $1, status = $2, image = $3, status_comment = $4, upload_url = $5, timestamp_end = $6, map_url = $7, timestamp_begin = $8, caps_diff = $9 WHERE upload_id = $10 AND fkey_wms_id = $11";
-		$v = array($this->updated, $this->result, $this->returnsImage, $this->comment, $this->capabilitiesURL, time(), $this->mapURL, $this->timestamp, $this->capabilitiesDiff, $this->uploadId, $this->wmsId);
-		$t = array('s', 'i', 'i', 's', 's', 's', 's', 's', 's', 's', 'i');
-		$res = db_prep_query($sql,$v,$t);		
-	}
-
-	/*
-	 * Checks if the mapUrl returns an image or an exception
-	 */
-	private function isImage($url) {
-		$headers = get_headers($url, 1);
-		$e = new mb_notice("class_monitor: isImage: map URL is " . $url);
-		$e = new mb_notice("class_monitor: isImage: Content-Type is " . $headers["Content-Type"]);
-		if (preg_match("/xml/", $headers["Content-Type"])) {
-			return false;
-		}
-		return true;
-	}
-
-	/**
-	 * Returns the upload url of some WMS
- 	 */
-	private function getUploadURL($wmsId, $upload_id) {
-		$e = new mb_notice("class_monitor: getUploadURL: wms = " . $wmsId);
-		$e = new mb_notice("class_monitor: getUploadURL: upload_id = " . $upload_id);
-		$sql = "SELECT upload_url FROM mb_monitor WHERE fkey_wms_id = $1 AND upload_id = $2";
-		$v = array($wmsId, $upload_id);
-		$t = array('i', 'i');
-		$res = db_prep_query($sql,$v,$t);
-		$someArray = db_fetch_array($res);
-		$e = new mb_notice("class_monitor: getUploadURL: url = " . $someArray["upload_url"]);
-		return $someArray["upload_url"];
-	}
-	
-	/**
-	 * Returns the character that needs to be appended to 
-	 * a given online resource, in order to append other GET 
-	 * parameters.
-	 * 
-	 * Possible characters: "?", "&", ""
-	 */
-	private function mb_getConjunctionCharacter($onlineresource){
-		// index of character ? in online resource
-		$indexOfChar = mb_strpos($onlineresource,"?");
-	
-		if($indexOfChar) {
-			// no conjunction character needed
-			if($indexOfChar == mb_strlen($onlineresource)-1){ 
-				return "";
-			}
-			// no conjunction character needed
-			else if (mb_substr($onlineresource, mb_strlen($onlineresource)-1) == "&") {
-				return "";
-			}
-			else{
-				return "&";
-			}
-		}
-		return "?";
-	}
-	
-	/**
-	 * retrieves all information necessary to build a map request, 
-	 * concatenates them and returns a valid get map request
-	 */
-	private function getMapRequest($wmsId) {
-	
-		// get map (wms_getmap)
-		// version (wms_version)
-		$sql = "SELECT wms_getmap, wms_version FROM wms WHERE wms_id = $1";
-		$res = db_prep_query($sql, array($wmsId), array('i'));
-		$row = db_fetch_array($res);
-		$getmap = $row["wms_getmap"];
-		$version = $row["wms_version"];
-		
-		//map format
-		$sql = "SELECT * FROM wms_format WHERE data_type = 'map' AND fkey_wms_id = $1";
-		$res = db_prep_query($sql, array($wmsId), array('i'));
-		$row = db_fetch_array($res);
-		$mapFormat = "";
-		while ($row = db_fetch_array($res)) {
-			$mapFormat = urlencode($row["data_format"]);
-			if (preg_match("/png/", $mapFormat) || preg_match("/gif/", $mapFormat) || preg_match("/jp.{1}g/", $mapFormat)) {
-				break;
-			}
-		}
-	
-		// layers (all layers)
-		$sql = "SELECT layer_name FROM layer WHERE fkey_wms_id = $1 AND layer_parent <> '' AND layer_pos > 0";
-		$res = db_prep_query($sql, array($wmsId), array('i'));
-		$layerArray = array();
-		while ($row = db_fetch_array($res)) {
-			array_push($layerArray, urlencode($row["layer_name"]));
-		}
-		$layerList = implode(",", $layerArray);
-		
-		// srs (layer_epsg: epsg)
-		// bbox (layer_epsg: minx, miny, maxx, maxy)
-		$sql = "SELECT epsg, minx, miny, maxx, maxy ";
-		$sql .= "FROM layer_epsg, (SELECT fkey_wms_id, layer_id FROM layer WHERE fkey_wms_id = $1 AND layer_parent = '' AND layer_pos = 0) AS l ";
-		$sql .= "WHERE l.layer_id = layer_epsg.fkey_layer_id AND l.fkey_wms_id = $1";
-		$res = db_prep_query($sql, array($wmsId), array('i'));
-		$bboxArray = array();
-		while ($row = db_fetch_array($res)) {
-			array_push($bboxArray, new Mapbender_bbox($row["minx"], $row["miny"], $row["maxx"], $row["maxy"], $row["epsg"]));
-		}
-	
-		// get a bbox in a preferably non WGS84 epsg to use the scalehints
-		for ($i=0; $i < count($bboxArray); $i++) {
-			$bbox = $bboxArray[$i];			
-			if ($bboxArray[$i]->epsg != "EPSG:4326") {
-				break;
-			}
-		}
-		
-		/*
-		 * transform to 31466 if is 4326
-		 * TODO: extend to other EPSG apart from 31466
-		 */
-		if ($bbox->epsg == "EPSG:4326") {
-			$bbox->transform("EPSG:31466");
-		}
-		
-		/*
-		 * get map and check if result is image 
-		 */
-		// check if this WMS supports exception type XML
-		$sql = "SELECT data_format FROM wms_format WHERE fkey_wms_id = $1 AND data_type = 'exception'";
-		$v = array($wmsId);
-		$t = array('i');
-		$res = db_prep_query($sql,$v,$t);
-		while ($row = db_fetch_array($res)) {
-			$exceptionFormat = $row["data_format"];
-			// set the exception type to xml (if possible)
-			if (preg_match('/xml/', $exceptionFormat)) {
-				$this->supportsXMLException = true;
-				break; 
-			}
-		}
-
-		// correct bbox according to scale
-		$scale = $this->getScaleForWMS($wmsId);
-		$bbox = $this->getBBoxInScale($bbox, $scale);
-
-		return $this->concatenateMapRequest($getmap, $version, $mapFormat, $layerList, $bbox, MONITOR_IMG_WIDTH, MONITOR_IMG_HEIGHT, $exceptionFormat);			 
-	}
-	
-	/**
-	 * updates a given BBox according to a given scale
-	 * 
-	 * @param bbox 
-	 * @param scale 
-	 */
-	private function getBBoxInScale($bbox, $scale) {
-		$e = new mb_notice("class_monitor: getMapRequest: old bbox = " . $bbox);
-		$e = new mb_notice("class_monitor: getMapRequest: old bbox = " . $bbox->min->x . "," . $bbox->min->y . "," . $bbox->max->x . "," . $bbox->max->y);
-		$e = new mb_notice("class_monitor: getMapRequest: scale = " . $scale);
-		if ($scale) {
-			$center = $bbox->min->plus($bbox->max)->times(0.5);
-			$e = new mb_notice("class_monitor: getMapRequest: center = " . $center);
-			
-			/*
-			 * TODO: this formula should have documentation
-			 */
-			$offset =  MONITOR_IMG_WIDTH / (MB_RESOLUTION * 100 * 2) * $scale;
-			$offsetPoint = new Mapbender_point($offset, $offset, $bbox->epsg);
-			$min = $center->minus($offsetPoint);
-			$max = $center->plus($offsetPoint);
-			$bbox->min = $min;
-			$bbox->max = $max;
-			$e = new mb_notice("class_monitor: getMapRequest: new bbox = " . $bbox);
-			$e = new mb_notice("class_monitor: getMapRequest: new bbox = " . $bbox->min->x . "," . $bbox->min->y . "," . $bbox->max->x . "," . $bbox->max->y);
-		}
-		return $bbox;
-	}
-	
-	
-	/**
-	 * Returns an online resource representing a get map request
-	 */
-	private function concatenateMapRequest(	$getmap, $wmsVersion, $mapFormat, $layerList, 
-							$bbox, $width, $height, $exceptionFormat) {
-		/*
-		 * getMap URL
-		 */
-		$mapRequest = $getmap;
-		$mapRequest .= $this->mb_getConjunctionCharacter($getmap);
-		
-		/*
-		 * WMS version
-		 */
-		if ($wmsVersion == "1.0.0") {
-			$mapRequest .= "WMTVER=" . $wmsVersion . "&REQUEST=map&";
-		}
-		else {
-			$mapRequest .= "VERSION=" . $wmsVersion . "&REQUEST=GetMap&SERVICE=WMS&";
-		}
-		
-		/*
-		 * Layer list
-		 */
-		$mapRequest .= "LAYERS=" . $layerList . "&";
-		
-		/*
-		 * Format
-		 */
-		 $mapRequest .= "FORMAT=" . $mapFormat . "&";
-		 
-		/*
-		 * SRS and BBox
-		 */
-		$mapRequest .= "SRS=" . $bbox->epsg . "&";
-		$mapRequest .= "BBOX=" . $bbox->min->x . "," . $bbox->min->y . "," . $bbox->max->x . "," . $bbox->max->y . "&";
-		 
-		/*
-		 * Width and height
-		 */
-		$mapRequest .= "WIDTH=" . $width . "&";
-		$mapRequest .= "HEIGHT=" . $height . "&";
-		 
-		/*
-		 * BGColor
-		 */
-		$mapRequest .= "BGCOLOR=0xffffff&";
-	
-		/*
-		 * Transparency
-		 */
-		if (preg_match("/png/", $mapFormat) || preg_match("/gif/", $mapFormat)) {
-			$mapRequest .= "TRANSPARENT=TRUE&";
-		}
-		 
-		/*
-		 * Exception format
-		 */
-		$mapRequest .= "EXCEPTIONS=" . $exceptionFormat . "&";
-		
-//		return urlencode($mapRequest);	
-		return $mapRequest;	
-	}
-	
-	/**
-	 * Checks if the given WMS has ScaleHints. If yes, a scale is selected and returned.
-	 */
-	private function getScaleForWMS($wmsId) {
-		// get the scalehints
-		$sql = "SELECT layer_minscale, layer_maxscale FROM layer WHERE fkey_wms_id = $1 AND layer_pos = 0 AND layer_parent = '' AND layer_minscale <> layer_maxscale LIMIT 1";
-		$v = array($wmsId);
-		$t = array('i');
-		$res = db_prep_query($sql,$v,$t);
-		$scaleHintArray = db_fetch_array($res);
-		
-		/*
-		 *  determine the scalehint
-		 */
-		// if a scalehint exists 
-		if ($scaleHintArray) {
-			// if upper boundary
-			if ($scaleHintArray["layer_minscale"] < $scaleHintArray["layer_maxscale"]) {
-				// TODO: find a better algorithm with a less obscure scale
-				$scaleHint = round($scaleHintArray["layer_maxscale"] - $scaleHintArray["layer_minscale"]) / 2;				
-			}
-			// if lower boundary
-			else {
-				if ($scaleHintArray["layer_minscale"] < MONITOR_DEFAULT_SCALE) {
-					$scaleHint = MONITOR_DEFAULT_SCALE;
-				}
-				else {
-					// TODO: find a better algorithm with a less obscure scale
-					$scaleHint = $scaleHintArray["layer_minscale"] + 1000;
-				}
-			}
-		}
-		// otherwise, use a default value
-		else {
-			$scaleHint = MONITOR_DEFAULT_SCALE;
-		}
-		return $scaleHint;
-	}
-	
-	/**
-	 * Returns the local backup of the given WMS' capabilities document
-	 */
-	private function getCapabilitiesDocByWMS($wmsId) {
-		$sql = "SELECT wms_getcapabilities_doc FROM wms WHERE wms_id = $1";
-		$v = array($wmsId);
-		$t = array('i');
-		$res = db_prep_query($sql,$v,$t);
-		$someArray = db_fetch_array($res);
-		return $someArray["wms_getcapabilities_doc"];
-	}
-	/*
-	* creates a html diff of the xml documents
-	*/
-	private function outputDiffHtml($localXMLArray,$remoteXMLArray) {
-		$diffObj = new Diff($localXMLArray,$remoteXMLArray);
-		$dft = new TableDiffFormatter();
-		return $dft->format($diffObj);
-	}		
-	
-}
-?>

Modified: branches/print_dev/http/css/print_div.css
===================================================================
--- branches/print_dev/http/css/print_div.css	2009-08-04 11:47:46 UTC (rev 4470)
+++ branches/print_dev/http/css/print_div.css	2009-08-04 11:51:01 UTC (rev 4471)
@@ -1,6 +1,6 @@
 @CHARSET "ISO-8859-1";
 
-#printPDF label,input,select,textarea {
+#printPDF label, #printPDF input, #printPDF select, #printPDF textarea {
 	display: block;
 	width: 120px;
 	float: left;

Modified: branches/print_dev/http/javascripts/map.php
===================================================================
--- branches/print_dev/http/javascripts/map.php	2009-08-04 11:47:46 UTC (rev 4470)
+++ branches/print_dev/http/javascripts/map.php	2009-08-04 11:51:01 UTC (rev 4471)
@@ -31,22 +31,22 @@
 $gui_changed=0;
 $new_wmc=0;
 
-if (!$_REQUEST["layer_preview"] && isset($_SESSION["mb_user_gui"]) && $_SESSION["mb_user_gui"] != $_REQUEST["gui_id"]) {
+if (!$_REQUEST["layer_preview"] && Mapbender::session()->get("mb_user_gui") && Mapbender::session()->get("mb_user_gui") != $_REQUEST["gui_id"]) {
 	$gui_changed=1;
 }
 
-if (!isset($_SESSION['mb_wmc']) || ($gui_changed==1) ||	($_REQUEST['layer_preview'] && $_REQUEST['portal_services'])) {
+if (!Mapbender::session()->get('mb_wmc') || ($gui_changed==1) ||	($_REQUEST['layer_preview'] && $_REQUEST['portal_services'])) {
 	$new_wmc=1;
 }
 
 if (isset($_REQUEST['layer_preview']) && $_REQUEST['layer_preview'] != 0) {
-	$_SESSION['layer_preview'] = $_REQUEST['portal_services'];
+	Mapbender::session()->set('layer_preview',$_REQUEST['portal_services');
 }
 else {
-	$_SESSION['layer_preview'] = 0;
+	Mapbender::session()->set('layer_preview',0);
 }
 */
-$_SESSION["mb_user_gui"] = $gui_id;
+Mapbender::session()->set("mb_user_gui", $gui_id);
 
 ob_start();
 header('Content-type: application/x-javascript');
@@ -55,15 +55,14 @@
 //
 echo "var mb_nr = '".session_id()."';";
 echo "var mb_session_name = '".session_name()."';";
-echo "var mb_myLogin = '".$_SESSION["mb_login"]."';";
-echo "var mb_styleID = '".md5($_SESSION["mb_user_name"])."';";
-echo "var mb_myBBOX = '".$_SESSION["mb_myBBOX"]."';";
-echo "Mapbender.locale = '" . $_SESSION["mb_locale"] . "';";
-echo "Mapbender.languageId = '" . $_SESSION["mb_lang"] . "';";
+echo "var mb_myLogin = '".Mapbender::session()->get("mb_login")."';";
+echo "var mb_styleID = '".md5(Mapbender::session()->get("mb_user_name"))."';";
+echo "var mb_myBBOX = '".Mapbender::session()->get("mb_myBBOX")."';";
+echo "Mapbender.locale = '" . Mapbender::session()->get("mb_locale") . "';";
+echo "Mapbender.languageId = '" . Mapbender::session()->get("mb_lang") . "';";
 echo "Mapbender.versionNumber = '" . MB_VERSION_NUMBER . "';";
 echo "Mapbender.versionAppendix = '" . MB_VERSION_APPENDIX . "';";
 echo "Mapbender.releaseDate = new Date(".date("Y",MB_RELEASE_DATE).",".date("n",MB_RELEASE_DATE).",".date("j",MB_RELEASE_DATE).");";
-echo "Mapbender.zoomMousewheel = " . ZOOM_MOUSEWHEEL . ";";
 echo "var owsproxy = '".OWSPROXY."';";
 echo "var global_mb_log_js = '".LOG_JS."';";
 echo "var global_mb_log_level = '".LOG_LEVEL."';";
@@ -76,9 +75,8 @@
 // Load external JavaScript libraries
 //
 $extPath = dirname(__FILE__) . "/../extensions/";
-$extFileArray = array(  "jquery-1.2.6.min.js", 
+$extFileArray = array(  "jquery-1.3.2.min.js", 
 						"jqjson.js", 
-						"jquery.mousewheel.min.js",
 						"jquery.form.js");
 
 for ($i = 0; $i < count($extFileArray); $i++) {
@@ -94,8 +92,10 @@
 }
 
 ?>
+// this replaces the old init function
 $(function () {
-	new Mb_notice("new jquery init function");
+	initModules();
+	
 	// creates the map objects (mapframe1, overview...)
 	eventInitMap.trigger();
 
@@ -105,6 +105,7 @@
 	eventInit.trigger();
 	
 	eventAfterInit.trigger();
+	
 });
 <?php
 //
@@ -118,7 +119,10 @@
 						"list.js",
 						"point.js",
 						"style.js",
-						"button.js");
+						"button.js",
+						"extent.js",
+						"backwards_compatibility_to_2.6.js"
+);
 
 for ($i = 0; $i < count($libFileArray); $i++) {
 	$currentFile = $libPath . $libFileArray[$i];
@@ -164,10 +168,10 @@
 
 $modulesNotRelyingOnGlobalsArray = explode(",", MODULES_NOT_RELYING_ON_GLOBALS);
 ?>
-Mapbender.Modules = {};
+Mapbender.modules = {};
 Mapbender.addModule = function (name, obj) {
-	if (name && !Mapbender.Modules[name]) {	
-		Mapbender.Modules[name] = obj;
+	if (name && !Mapbender.modules[name]) {	
+		Mapbender.modules[name] = obj;
 		return true;
 	}
 	return false;
@@ -181,69 +185,89 @@
 $mb_v = array($gui_id);
 $mb_t = array("s");
 $mb_res = db_prep_query($mb_sql, $mb_v, $mb_t);
-while($row_js = db_fetch_array($mb_res)){
-	if($row_js["e_js_file"] != ""){
-		$jsArray = explode(",", $row_js["e_js_file"]);
-		for ($i = 0; $i < count($jsArray); $i++) {
-			$e_id = isset($row_js["e_id"]) ? $row_js["e_id"] : "";
-			$e_src = $row_js["e_src"];
-			$e_require = $row_js["e_requires"];
-			$e_target = explode(",",$row_js["e_target"]);
-			$e_width = intval($row_js["e_width"]);
-			$e_height = intval($row_js["e_height"]);
-			$e_top = intval($row_js["e_top"]);
-			$e_left = intval($row_js["e_left"]);
-			$currentFile = trim($jsArray[$i]);
-			if (!file_exists($currentFile)) {
-				$e = new mb_exception("Javascript not found: " . $currentFile);
-				echo "var e = new Mb_exception('Javascript not found: " . $currentFile . "');";
-				die;
-			}
-			if (in_array($e_id, $modulesNotRelyingOnGlobalsArray)) {
-				ob_start();
-				echo "var options = {" . 
-					"id:'$e_id'," . 
-					"target:" . ($e_target[0] != "" ? $json->encode($e_target) : "[]") . "," .
-					"top:$e_top," . 
-					"left:$e_left," . 
-					"width:$e_width," . 
-					"height:$e_height," . 
-					"src:'$e_src'" . 
-					"};";
+while ($row_js = db_fetch_array($mb_res)) {
+		
+	//
+	// Create element properties
+	//
+	$e_id = isset($row_js["e_id"]) ? 
+		str_replace(" ", "", $row_js["e_id"]) : "";
+	$e_src = $row_js["e_src"];
+	$e_require = $row_js["e_requires"];
+	$e_target = explode(",",$row_js["e_target"]);
+	$e_width = intval($row_js["e_width"]);
+	$e_height = intval($row_js["e_height"]);
+	$e_top = intval($row_js["e_top"]);
+	$e_left = intval($row_js["e_left"]);
 
-				include "../include/dyn_js_object.php";
-				echo <<<JS
-				
-$.fn.$e_id = function (options) {
-	return this.each(function () {
+	$elementAttributes = "{" . 
+		"id:'$e_id'," . 
+		"target:" . ($e_target[0] != "" ? $json->encode($e_target) : "[]") . "," .
+		"url:'$e_url'," .
+		"top:$e_top," . 
+		"left:$e_left," . 
+		"width:$e_width," . 
+		"height:$e_height," . 
+		"src:'$e_src'" . 
+		"}";
 
-JS;
+	echo "Mapbender.modules." . $e_id . " = " . $elementAttributes . ";\n";
+
+	//
+	// Include JavaScript files
+	//
+	$jsFileString = $row_js["e_js_file"];
+	if ($jsFileString){
+		if (in_array($e_id, $modulesNotRelyingOnGlobalsArray)) {
+			//
+			// Create the jQuery plugin in output buffer
+			//
+			ob_start();
+			echo "var options = " . $elementAttributes . ";";
+			
+			// extend the options variable by JS element vars 
+			include "../include/dyn_js_object.php";
+	
+			echo "$.fn.$e_id = function (options) {" . 
+				"return this.each(function () {";
+	
+			$jsArray = explode(",", $jsFileString);
+			for ($i = 0; $i < count($jsArray); $i++) {
+				$currentFile = trim($jsArray[$i]);
+		
+				if (!file_exists($currentFile)) {
+					$e = new mb_exception("Javascript not found: " . $currentFile);
+					echo "var e = new Mb_exception('Javascript not found: " . $currentFile . "');";
+					continue;
+				}
+				$e = new mb_notice("LOADING JS : " . $currentFile);
 				require($currentFile);
-				echo <<<JS
+			}	
 
-	});
-}
-
-JS;
-				echo "$('#$e_id').$e_id(options);";
-				$executeJsPluginsArray[] = ob_get_contents();
-				ob_end_clean();
-				echo "Mapbender.Modules.$e_id = {};\n";
-				
-			}
-			else {
-				echo "Mapbender.Modules." . $e_id . " = {\n";
-				echo "id:'".$row_js["e_id"]."',";
-				echo "url:'".$row_js["e_url"]."',";
-				echo "top:'".$row_js["e_top"]."',";
-				echo "left:'".$row_js["e_left"]."',";
-				echo "width:'".$row_js["e_width"]."',";
-				echo "height:'".$row_js["e_height"]."'";
-				echo "};\n";
+			echo "});};";
+	
+			echo "$('#$e_id').$e_id(options);";
+			$executeJsPluginsArray[] = ob_get_contents();
+			ob_end_clean();
+		}
+		else {
+			$jsArray = explode(",", $jsFileString);
+			for ($i = 0; $i < count($jsArray); $i++) {
+				$currentFile = trim($jsArray[$i]);
+		
+				if (!file_exists($currentFile)) {
+					$e = new mb_exception("Javascript not found: " . $currentFile);
+					echo "var e = new Mb_exception('Javascript not found: " . $currentFile . "');";
+					continue;
+				}
+				$e = new mb_notice("LOADING JS : " . $currentFile);
 				require($currentFile);
 			}
 		}
 	}
 }
+
+echo "function initModules () {";
 echo implode("\n", $executeJsPluginsArray);
+echo "}\n";
 ?>
\ No newline at end of file

Deleted: branches/print_dev/http/javascripts/mod_digitize_tab_category.php
===================================================================
--- branches/print_dev/http/javascripts/mod_digitize_tab_category.php	2009-08-04 11:47:46 UTC (rev 4470)
+++ branches/print_dev/http/javascripts/mod_digitize_tab_category.php	2009-08-04 11:51:01 UTC (rev 4471)
@@ -1,2206 +0,0 @@
-<?php
-# $Id: mod_digitize_tab.php 3939 2009-05-12 19:43:45Z marc $
-# http://www.mapbender.org/index.php/mod_digitize_tab.php
-# Copyright (C) 2002 CCGIS 
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-require_once(dirname(__FILE__) . "/../php/mb_validateSession.php");
-
-$e_target = $_GET["e_target"];
-?>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-<head>
-<meta http-equiv="cache-control" content="no-cache">
-<meta http-equiv="pragma" content="no-cache">
-<meta http-equiv="expires" content="0">
-<?php
-echo '<meta http-equiv="Content-Type" content="text/html; charset='.CHARSET.'">';	
-?>
-<title>Digitize</title>
-<?php
-$digitize_conf_filename = "digitize_default.conf";
-include '../include/dyn_css.php';
-?>
-<script language='JavaScript'>
-
-
-
-// Returns a form with the elements of a selected WFS grouped in tabs
-// (if the original WFS is the selected WFS, the values are set too)
-var initialTab = false;
-function buildTabbedElementForm(elementCategories,wfsConfIndex,memberIndex) {
-	var featureTypeMismatch = false;
-	if (parseInt(d.get(memberIndex).wfs_conf) != parseInt(wfsConfIndex)) {featureTypeMismatch = true;}
-	var str = "";
-	var hasGeometryColumn = false;
-	var featureTypeArray = wfsConf[wfsConfIndex];
-	var memberElements;
-	var fid = false;
-
-	if (!featureTypeMismatch) {
-		memberElements = d.get(memberIndex).e;
-		fid = memberElements.getElementValueByName('fid');
-	}
-	
-	if (typeof(featureTypeArray["element"]) !== "undefined") {
-		featureTypeElementArray = featureTypeArray["element"];
-		
-		elementCategories.sort();
-
-		str += "<form id='"+featureTypeElementFormId+"'>\n\t\n";
-		
-		initialTab = elementCategories[0];
-		for(var currentCategory = 0; currentCategory < elementCategories.length; currentCategory++) {
-			str += '<a href="#" id="tabheader_' + elementCategories[currentCategory] + '" class="tabheader" onclick="return window.opener.toggleTabs(\'' + elementCategories[currentCategory] + '\')">' + elementCategories[currentCategory] + '</a>';
-		}
-		
-		for(var currentCategory = 0; currentCategory < elementCategories.length; currentCategory++) {
-		
-			//
-			// 2. add rows to form 
-			//
-			for (var i = 0 ; i < featureTypeElementArray.length ; i++) {
-				var featureTypeElement = featureTypeElementArray[i];
-
-				var elementName = featureTypeElement['element_name'];
-				var elementType = featureTypeElement['element_type'];
-				var isEditable = (parseInt(featureTypeElement['f_edit']) == 1); 
-				var isMandatory = (parseInt(featureTypeElement['f_mandatory']) == 1); 
-				var isGeomColumn = (parseInt(featureTypeElement['f_geom']) == 1); 
-
-				if(featureTypeElement.f_category_name != elementCategories[currentCategory] && !isGeomColumn) {
-					continue;
-				}
-			
-				str += '<div id="tab_' + elementCategories[currentCategory] + '" class="tabcontent">';
-				str += '<table>';
-
-
-				var elementLabelExists = (featureTypeElement['f_label'] != "");
-				var elementLabel = ""; 
-				if (elementLabelExists) {
-					elementLabel = featureTypeElement['f_label'];
-				}
-				var elementLabelStyle = featureTypeElement['f_label_id'];
-
-				if (!isGeomColumn) {
-					if (isEditable) {
-						str += "\t\t<tr>\n";
-						if(elementLabelExists) {
-							str += "\t\t\t<td>\n\t\t\t\t<div class = '"+elementLabelStyle+"''>" + elementLabel + "</div>\n\t\t\t</td>\n";
-							str += "\t\t\t<td>\n";
-						}
-						else {
-							str += '<td colspan="2">';
-						}
-
-						var elementValue = "";
-						if (!featureTypeMismatch) {
-							for (var j = 0 ; j < memberElements.count() ; j ++) {
-								if (memberElements.getName(j) == featureTypeElement['element_name']) {
-									elementValue = memberElements.getValue(j);
-								}
-							}
-						}
-						var formElementHtml = featureTypeElement['f_form_element_html']; 
-						if (!formElementHtml) {
-							mandatoryHint = '';
-							var mandatoryHint = (parseInt(featureTypeElement['f_mandatory']) == 1) ? ' style="border:1px solid red;"' : '';
-						
-							str += "\t\t\t\t<input id = 'datatype_" + elementName + "' name='datatype' type='hidden' value = '" + elementType + "'>\n";
-							str += "\t\t\t\t<input id = 'mandatory_" + elementName + "' name='mandatory' type='hidden' value = '" + isMandatory + "'>\n";
-							str += "\t\t\t\t<input category='"+elementCategories[currentCategory]+"' id = '" + elementName + "' name='" + elementLabel + "' type='text' " + mandatoryHint + " class = '"+featureTypeElement['f_style_id']+"' size=20 value = '" + elementValue + "'>\n";
-						}
-						else {
-							while (formElementHtml.match(/\\/)) {
-								formElementHtml = formElementHtml.replace(/\\/, "");
-							} 
-							
-							var isMandatory = (parseInt(featureTypeElement['f_mandatory']) == 1);
-
-							var patternString = "<select";
-							pattern = new RegExp(patternString);
-							if (pattern.test(formElementHtml)) {
-								formElementHtml = prepareSelectBox(formElementHtml, "", isMandatory, elementLabel, elementValue);
-							}
-							var patternString = "hasdatepicker";
-							pattern = new RegExp(patternString);
-							if (pattern.test(formElementHtml)) {
-								formElementHtml = prepareDatepicker(formElementHtml, "", isMandatory, elementLabel, elementValue);
-							}
-							var patternString = "<textarea";
-							pattern = new RegExp(patternString);
-							if (pattern.test(formElementHtml)) {
-								formElementHtml = prepareTextArea(formElementHtml, "", isMandatory, elementLabel, elementValue);
-							}
-							str += formElementHtml;
-						}
-						
-						if(featureTypeElement.f_helptext.length > 0) {
-							str += ' <a href="#" onclick="return window.opener.showHelptext(' + i + ')"><img src="../x_geoportal/img/help.png" width="16" height="16" alt="?" /></a> ';
-							str += '<div id="helptext' +i+ '" class="helptext">';
-							str += '<p>';
-							str += featureTypeElement.f_helptext.replace(/(http:\/\/\S*)/g,'<a href="$1" target="blank">$1<\/a>');
-							str += '<a href="#" class="close" onclick="return window.opener.hideHelptext(' + i + ')">close</a>';
-							str += '</p>';
-							str += '</div>';
-						}
-						
-						str += "\t\t\t</td>\n\t\t</tr>\n";
-					}
-				}
-				else {
-					hasGeometryColumn = true;
-				}
-			}
-			str += '</table>';
-			str += '</div>';
-		}
-
-		//
-		// 3. add buttons "save", "update", "delete"
-		//
-		str += "<table>";
-		var isTransactional = (featureTypeArray['wfs_transaction']); 
-		if (isTransactional) {
-			str += "\t\t<tr>\n";
-
-			var options = ["save", "update", "delete", "abort"];
-			for (var i = 0 ; i < options.length ; i++) {
-				var onClickText = "this.disabled=true;var result = window.opener.formCorrect(document, '"+featureTypeElementFormId+"');";
-				onClickText += 	"if (result.isCorrect) {";
-				onClickText += 		"window.opener.dbGeom('"+options[i]+"', "+memberIndex+"); ";
-//				onClickText +=      "window.close();";
-				onClickText += 	"}";
-				onClickText += 	"else {";
-				onClickText += 		"alert(result.errorMessage);this.disabled=false;"
-				onClickText += 	"}";
-				
-				if (options[i] == "save" && hasGeometryColumn && (!fid || showSaveButtonForExistingGeometries)) {
-					str += "\t\t\t<td><input type='button' name='saveButton' value='"+buttonLabelSaveGeometry[selectedLanguage]+"' onclick=\""+onClickText+"\" /></td>\n";
-				}
-				
-				if (!featureTypeMismatch && fid) {
-					if (options[i] == "update" && hasGeometryColumn) {
-						str += "\t\t\t<td><input type='button' name='updateButton' value='"+buttonLabelUpdateGeometry[selectedLanguage]+"' onclick=\""+onClickText+"\"/></td>\n";
-					}
-					if (options[i] == "delete"){ 
-						var deleteOnClickText = "var deltrans = confirm('"+messageConfirmDeleteGeomFromDb[selectedLanguage]+"');";
-						deleteOnClickText += "if (deltrans){";
-						deleteOnClickText += onClickText + "}";
-						str += "\t\t\t<td><input type='button' name='deleteButton' value='"+buttonLabelDeleteGeometry[selectedLanguage]+"' onclick=\""+deleteOnClickText+"\"/></td>\n";
-					}
-				}
-				if (options[i] == "abort") {
-					str += "\t\t\t<td><input type='button' name='abortButton' value='"+buttonLabelAbort[selectedLanguage]+"' onclick=\"window.close();\" /></td>\n";
-				}
-			}
-			str += "\t\t</tr>\n";
-		}
-		str += "\t</table>\n";
-		str += "<input type='hidden' id='fid' value='"+fid+"'>";
-//			str += "<input type='text' name='mb_wfs_conf'>";
-		str += "</form>\n";
-	}
-	return str;
-}
-
-
-
-	
-//
-// Buttons
-//
-function addButtonDig(id, isOn, src, titleOff, titleOn, x, y) {
-	buttonDig_id.push(id);
-	buttonDig_on.push(isOn);
-	buttonDig_src.push(src);
-	buttonDig_title_off.push(titleOff);
-	buttonDig_title_on.push(titleOn);
-	buttonDig_x.push(x);
-	buttonDig_y.push(y);
-}
-
-function htmlspecialchars(p_string) {
-	p_string = p_string.replace(/&/g, '&amp;');
-	p_string = p_string.replace(/</g, '&lt;');
-	p_string = p_string.replace(/>/g, '&gt;');
-	p_string = p_string.replace(/"/g, '&quot;');
-	//	p_string = p_string.replace(/'/g, '&#039;');
-	return p_string;
-};
-   
-//default definition of image directory for digitize buttons, might
-//be overwritten with digitize conf data
-var buttonDig_imgdir = "../img/button_digitize/";
-var buttonDig_id = [];
-var buttonDig_on = [];
-var buttonDig_src = [];
-var buttonDig_title_off = [];
-var buttonDig_title_on = [];
-var buttonDig_x = [];
-var buttonDig_y = [];	
-
-var mapWindow;
-var mapDomElement;
-var mapType = "";
-
-parent.eventInit.register(function () {
-	var mapIndex = parent.getMapObjIndexByName(mod_digitize_target);
-	mapDomElement = parent.mb_mapObj[mapIndex].getDomElement();
-	mapType = mapDomElement.tagName.toUpperCase();
-	if (mapType == "DIV") {
-		mapWindow = parent.window;
-	}
-	else if (mapType == "IFRAME") {
-		mapWindow = mapDomElement.window;
-	}
-	else {
-		new parent.Mb_warning("Could not set CSS for map in digitizing module.");
-	}
-});
-
-
-<?php
-echo "var mod_digitize_target = '".$e_target."';";
-$digitizeConfFilenameAndPath = dirname(__FILE__) . "/../../conf/" . $digitize_conf_filename;
-if ($digitize_conf_filename && file_exists($digitizeConfFilenameAndPath)) {
-	include($digitizeConfFilenameAndPath);
-}
-?>
-
-var wfsWindow;	
-var wfsConf = [];
-var d;
-var mod_digitize_width;
-var mod_digitize_height;
-var mod_digitizeEvent = false;
-var nonTransactionalHighlight;
-
-var button_point = "Point";
-var button_line = "Line";
-var button_polygon = "Polygon";
-var button_move = "dragBasePoint";
-var button_insert = "setBasePoint";
-var button_delete = "delBasePoint";
-var button_clear = "clear";
-var button_split = "digitizeSplit";
-var button_merge = "digitizeMerge";
-var button_difference = "digitizeDifference";
-
-var digitizeDivTag;
-
-var GeometryArray;
-var MultiGeometry = parent.MultiGeometry;
-var Geometry;
-var Point;
-var geomType;
-
-var msgObj;
-var featureTypeElementFormId = "featureTypeElementForm";
-
-try {if(mod_digitize_elName){}}catch(e) {mod_digitize_elName = "digitize";}
-try {if(nonTransactionalEditable){}}catch(e) {nonTransactionalEditable = false;}
-try {if(addCloneGeometryButton){}}catch(e) {addCloneGeometryButton = false;}
-
-function toggleTabs(tabId) {
-	if(!initialTab) {
-		return;
-	}
-
-	var tabHeaders = wfsWindow.document.getElementsByTagName('a');
-	var tabs       = wfsWindow.document.getElementsByTagName('div');
-	
-	for(var i = 0; i < tabHeaders.length; i++) {
-		if(tabHeaders[i].id.indexOf('tabheader') != -1) {
-			tabHeaders[i].className = 'tabheader';
-		}
-	}
-	
-	for(var i = 0; i < tabs.length; i++) {
-		if(tabs[i].className === 'tabcontent') {
-			tabs[i].style.visibility = 'hidden';
-			tabs[i].style.display    = 'none';
-		}
-	}
-	
-	wfsWindow.document.getElementById('tabheader_' + tabId).className += ' active';
-	
-	wfsWindow.document.getElementById('tab_' + tabId).style.visibility = 'visible';
-	wfsWindow.document.getElementById('tab_' + tabId).style.display    = 'block';
-	
-	return false;
-}
-
-function showHelptext(helptextId) {
-	hideHelptext();
-	wfsWindow.document.getElementById('helptext' + helptextId).style.visibility = 'visible';
-	wfsWindow.document.getElementById('helptext' + helptextId).style.display    = 'block';
-
-	return false;
-}
-
-function hideHelptext(helptextId) {
-	if(helptextId) {
-		wfsWindow.document.getElementById('helptext' + helptextId).style.visibility = 'hidden';
-		wfsWindow.document.getElementById('helptext' + helptextId).style.display    = 'none';
-	}
-
-	var helptext = wfsWindow.document.getElementsByTagName('div');
-	
-	for(var i = 0; i < helptext.length; i++) {
-		if(helptext[i].className === 'helptext') {
-			helptext[i].style.visibility = 'hidden';
-			helptext[i].style.display    = 'none';
-		}
-	}
-
-	return false;
-}
-
-function getMousePosition(e) {
-	parent.mb_getMousePos(e, mod_digitize_target);
-	var currentPos = null;
-	if (mapType == "DIV") {
-		currentPos = new parent.Point(
-			parent.clickX - parseInt(mapDomElement.style.left), 
-			parent.clickY - parseInt(mapDomElement.style.top)
-		);
-	}
-	else {
-		currentPos = new parent.Point(
-			parent.clickX, 
-			parent.clickY
-		);
-	}
-	return currentPos;
-}
-
-
-function initializeDigitize () {
-	d = new parent.GeometryArray();
-	GeometryArray = parent.GeometryArray;
-	Geometry = parent.Geometry;
-	Point = parent.Point;
-	geomType = parent.geomType;
-}
-
-/**
- * Append geometries from KML when KML has been loaded
- */
-function appendGeometryArrayFromKML () {
-	try {
-		parent.kmlHasLoaded.register(function(properties){
-			d = new parent.GeometryArray();
-			d.importGeoJSON(properties);		
-//			d = parent.geoJsonToGeometryArray(properties);
-			executeDigitizeSubFunctions();
-		});
-	}
-	catch (e) {
-		var exc = new parent.Mb_warning(e);
-	}
-}
-
-
-// ------------------------------------------------------------------------------------------------------------------------
-// --- polygon, line, point insertion (begin) ----------------------------------------------------------------------------------------------
-
-function appendGeometryArray(obj) {
-	executeDigitizePreFunctions();
-	for (i=0; i<obj.count(); i++) {
-		d.addCopy(obj.get(i));
-	}
-	executeDigitizeSubFunctions();
-}
-
-function mod_digitize_go(e){
-	// ie workaround
-	if (e == undefined) {
-		e = mapWindow.event;
-	}
-	if (e) {
-		// track mouse position
-		var currentPos = getMousePosition(e);
-		
-		s.check(currentPos);
-	}
-	else {
-//		s.clean();
-	}
-
-	var el = mapDomElement;
-	el.onmousedown = mod_digitize_start;
-}
-
-function mod_digitize_timeout(){
-	var el = mapDomElement;
-	el.onmousedown = null;
-	el.onmouseup = null;
-	el.onmousemove = null;
-}
-
-function mod_digitize_start(e){
-	// check if a proper geometry is selected	
-	if (d.getGeometry(-1,-1).isComplete() || d.count() == 0){
-		
-		if (mod_digitizeEvent != false) {
-			alert(msgObj.errorMessageNoGeometrySelected);
-		}
-		return false;
-	}
-	
-	var realWorldPos;
-	if (s.isSnapped()) {
-		realWorldPos = s.getSnappedPoint(); 
-		s.clean();
-	}
-	else {
-		var currentPos = getMousePosition(e);
-		realWorldPos = parent.mapToReal(mod_digitize_target,currentPos);
-	}
-	
-	if (d.get(-1).geomType == parent.geomType.polygon && d.getGeometry(-1,-1).count() > 1 && d.getGeometry(-1,-1).get(0).equals(realWorldPos)) {
-				
-		// close the polygon
-		d.close();
-		parent.mb_disableThisButton(button_polygon);
-		return true;
-	}
-	else if (d.get(-1).geomType == parent.geomType.line && d.getGeometry(-1,-1).count() > 1 && d.getGeometry(-1,-1).get(-1).equals(realWorldPos)) {
-		// close the line
-		d.close();
-		parent.mb_disableThisButton(button_line);
-		return true;
-	}
-	else {
-		// set the calculated real world position as point of the geometry
-		d.getGeometry(-1,-1).addPoint(realWorldPos);
-		var mapIndex = parent.getMapObjIndexByName(mod_digitize_target);
-
-		d.getGeometry(-1,-1).setEpsg(parent.mb_mapObj[mapIndex].epsg);
-		
-		if(d.get(-1).geomType == parent.geomType.point){
-			d.close();
-			parent.mb_disableThisButton(button_point);
-			return true;
-		}
-		
-		// add first point of polygon to snapping list (if three points have been inserted).
-		else if (d.get(-1).geomType == parent.geomType.polygon && d.getGeometry(-1,-1).count() == 3) {
-			s.add(d.getPoint(-1, -1, 0));
-		}
-
-		// add last point of line to snapping list (if at least two points have been inserted).
-		else if (d.get(-1).geomType == parent.geomType.line && d.getGeometry(-1,-1).count() >= 2) {
-			if (mod_digitizeEvent != button_move) {
-				s.store(d);
-			}
-			s.add(d.getPoint(-1, -1, -1));
-		}
-	}
-	executeDigitizeSubFunctions();
-	return true;
-}
-// --- polygon, line, point insertion (begin) ----------------------------------------------------------------------------------------------
-// ------------------------------------------------------------------------------------------------------------------------
-
-// ------------------------------------------------------------------------------------------------------------------------
-// --- basepoint handling (begin) -----------------------------------------------------------------------------------------
-
-var basepointObject = false;
-var basepointMemberIndex = null;
-var basepointGeometryIndex = null;
-var basepointRingIndex = null;
-var basepointPointIndex = null;
-var basepointDragActive = false;
-
-function handleBasepoint(obj,memberIndex, geometryIndex, ringIndex, pointIndex){
-	if (!(
-		mod_digitizeEvent == button_move || 
-		mod_digitizeEvent == button_insert || 
-		mod_digitizeEvent == button_delete)
-	) { 
-		return false; 
-	}
-	
-	basepointObject = obj;
-	basepointMemberIndex = memberIndex;
-	basepointGeometryIndex = geometryIndex;
-
-	if (pointIndex == undefined) {
-		pointIndex = ringIndex;
-		basepointRingIndex = undefined;
-	}
-	else {
-		basepointRingIndex = ringIndex;
-	}
-	basepointPointIndex = pointIndex;
-	
-	if(mod_digitizeEvent == button_move){
-		mod_digitize_timeout();
-		basepointObject.style.cursor = 'move';
-		basepointObject.onmousedown = parent.frames[mod_digitize_elName].selectBasepoint;
-	}
-
-	if(mod_digitizeEvent == button_delete){
-		mod_digitize_timeout();
-		basepointObject.style.cursor = 'crosshair';
-		basepointObject.onmousedown = parent.frames[mod_digitize_elName].deleteBasepoint;
-	}
-}
-
-function convertLinepointToBasepoint(obj, memberIndex, geomIndex, ringIndex, pointIndex){
-	if(!(mod_digitizeEvent == button_insert)){ return false; }
-	
-	if(mod_digitizeEvent == button_insert){
-		mod_digitize_timeout();
-		obj.style.cursor = 'crosshair';
-		obj.onclick = insertBasepoint;
-
-		basepointObject = obj;
-		basepointMemberIndex = memberIndex;
-		basepointGeometryIndex = geomIndex;
-		basepointRingIndex = ringIndex;
-		basepointPointIndex = pointIndex;
-	}
-}
-
-function insertBasepoint(e){
-	var i = basepointMemberIndex;
-	var j = basepointGeometryIndex;
-	var k = basepointRingIndex;
-	var l = basepointPointIndex;
-	
-	var currentPos = getMousePosition(e);
-
-	var ind = parent.getMapObjIndexByName(mod_digitize_target);
-	var p = parent.mb_mapObj[ind].convertPixelToReal(new Point(currentPos.x, currentPos.y));
-
-	if (k == undefined) {
-		d.getGeometry(i,j).addPointAtIndex(p, l);
-	}
-	else {
-		d.getGeometry(i,j).innerRings.get(k).addPointAtIndex(p, l);
-	}
-
-	executeDigitizeSubFunctions();
-}
-
-function deleteBasepoint(){
-	var i = basepointMemberIndex;
-	var j = basepointGeometryIndex;
-	var k = basepointRingIndex;
-	var l = basepointPointIndex;
-
-	if (k != undefined) {
-		d.delAllPointsLike(d.getPoint(i, j, k, l));
-	}
-	else {
-		d.delAllPointsLike(d.getPoint(i, j, l));
-	}
-
-	executeDigitizeSubFunctions();
-}
-
-function selectBasepoint(e){
-	if(!basepointDragActive && mod_digitizeEvent == button_move){
-		basepointDragActive = true;
-		s.store(d, d.getPoint(basepointMemberIndex, basepointGeometryIndex, basepointPointIndex));
-		// replace basepoint by transparent blob
-		basepointObject.style.width = mod_digitize_width;
-		basepointObject.style.height = mod_digitize_height;
-		basepointObject.style.left = 0;
-		basepointObject.style.top = 0;
-			
-		if (parent.ie) {
-			// ie cannot handle backgroundColor = 'transparent'
-			basepointObject.style.background = "url(../img/transparent.gif)";
-		}
-		else{
-			basepointObject.style.backgroundColor = 'transparent';
-		}
-
-		basepointObject.onmouseup = releaseBasepoint;
-		basepointObject.onmousemove = dragBasepoint;
-	}
-}
-
-function dragBasepoint(e){
-	if(basepointDragActive){
-		var currentPos = getMousePosition(e);
-		var res = s.check(currentPos);
-
-	}
-}
-	
-function updateAllPointsOfNonTransactionalLike(oldP, newP){ 
-	for (var i = 0; i < d.count(); i++) {
-		if (isTransactional(d.get(i))) {
-			d.get(i).updateAllPointsLike(oldP, newP);
-		}
-	}
-}
-
-	
-function releaseBasepoint(e){
-	
-	var i = basepointMemberIndex;
-	var j = basepointGeometryIndex;
-	var k = basepointRingIndex;
-	var l = basepointPointIndex;
-	basepointDragActive = false;
-	
-	var currentPos = getMousePosition(e);
-	var basepointDragEnd = currentPos;
-	basepointObject.onmousedown = null;
-	var ind = parent.getMapObjIndexByName(mod_digitize_target);
-	var p = parent.mb_mapObj[ind].convertPixelToReal(new Point(basepointDragEnd.x, basepointDragEnd.y));
-
-	var oldPoint;
-	if (k == undefined) {
-		oldPoint = parent.cloneObject(d.getPoint(i,j,l));
-	} 
-	else {
-		oldPoint = parent.cloneObject(d.getPoint(i,j,k,l));
-	}
-	if (s.isSnapped()) {
-		var snappedPoint = parent.cloneObject(s.getSnappedPoint());
-		if (!nonTransactionalEditable) {
-			updateAllPointsOfNonTransactionalLike(oldPoint, snappedPoint);
-		}
-		else {
-			d.updateAllPointsLike(oldPoint, snappedPoint);
-		}
-		s.clean();
-	}
-	else {
-		if (!nonTransactionalEditable) {
-			updateAllPointsOfNonTransactionalLike(oldPoint, p);
-		}
-		else {
-			d.updateAllPointsLike(oldPoint, p);
-		}
-	}
-	basepointMemberIndex = null;
-	basepointGeometryIndex = null;
-	basepointPointIndex = null;	
-		
-	executeDigitizeSubFunctions();
-}
-// --- basepoint handling (end) -----------------------------------------------------------------------------------------
-// ------------------------------------------------------------------------------------------------------------------------
-	
-// ------------------------------------------------------------------------------------------------------------------------
-// --- registered functions (begin) ---------------------------------------------------------------------------------------
-
-function registerDigitizePreFunctions(stringFunction){
-	mod_digitizePreFunctions[mod_digitizePreFunctions.length] = stringFunction;
-}
-
-function registerDigitizeSubFunctions(stringFunction){
-	mod_digitizeSubFunctions[mod_digitizeSubFunctions.length] = stringFunction;
-}
-
-function executeDigitizeSubFunctions(){
-	for(var i=0; i<mod_digitizeSubFunctions.length; i++){
-		eval(mod_digitizeSubFunctions[i]);
-	}
-}
-
-function executeDigitizePreFunctions(){
-	for(var i=0; i<mod_digitizePreFunctions.length; i++){
-		eval(mod_digitizePreFunctions[i]);
-	}
-}
-
-function registerFunctions(){
-	mod_digitizePreFunctions = [];
-	mod_digitizeSubFunctions = [];
-	registerDigitizePreFunctions("updateExtent()");
-	registerDigitizePreFunctions("drawDashedLine()");
-	registerDigitizeSubFunctions("updateListOfGeometries()");
-	registerDigitizeSubFunctions("drawDashedLine()");
-	parent.eventInit.register(function () {
-		initializeDigitize();
-		setStyleForTargetFrame();
-		checkDigitizeTag();
-		initialiseSnapping();
-//		appendGeometryArrayFromKML();
-		if (!nonTransactionalEditable) {
-			initialiseHighlight();
-		}
-		initialiseMeasure();
-		getMessages();
-	});
-	parent.eventLocalize.register(function() {
-		getMessages();
-	});
-
-	parent.eventAfterMapRequest.register(function () {
-		updateExtent();
-	});
-	parent.mb_registerWfsWriteSubFunctions(function(){parent.zoom(mod_digitize_target, true, 0.999);});
-}
-
-function checkDigitizeTag(){
-	var digitizeTagName = "digitizeDiv";
-	var digitizeTagStyle;
-	
-
-	if (mapType == "DIV") {
-		
-		digitizeTagStyle = {"z-index":digitizeTransactionalZIndex, "font-size":"10px"};
-		digitizeDivTag = new parent.DivTag(digitizeTagName, "", digitizeTagStyle, mapDomElement);
-	}	 
-	else {
-		digitizeTagStyle = {"position":"absolute", "top":"0px", "left":"0px", "z-index":digitizeTransactionalZIndex, "font-size":"10px"};
-		digitizeDivTag = new parent.DivTag(digitizeTagName, mod_digitize_target, digitizeTagStyle);
-	}
-	parent.mb_registerPanSubElement(digitizeTagName);
-	parent.mb_registerSubFunctions("window.frames['"+ mod_digitize_elName + "'].drawDashedLine()");
-}
-
-
-function setStyleForTargetFrame(){
-	var cssLink = mapWindow.document.createElement("link");
-	var cssHead = mapWindow.document.getElementsByTagName("head")[0]; 
-	cssLink.setAttribute("href", cssUrl); 
-	cssLink.setAttribute("type", "text/css"); 
-	cssLink.setAttribute("rel", "stylesheet"); 
-	cssHead.appendChild(cssLink);
-}
-
-function initialiseSnapping(){
-	s = new parent.Snapping(mod_digitize_target, snappingTolerance, snappingColor, snappingHighlightZIndex);
-}
-function initialiseHighlight(){
-	nonTransactionalHighlight = new parent.Highlight([mod_digitize_target], "nonTransactional", {"position":"absolute", "top":"0px", "left":"0px", "z-index":digitizeNonTransactionalZIndex}, nonTransactionalLineWidth);
-}
-function initialiseMeasure(){
-	if (mapType == "DIV") {
-		measureDivTag = new parent.DivTag(measureTagName, "", measureTagStyle);
-	}
-	else {
-		measureDivTag = new parent.DivTag(measureTagName, measureTagTarget, measureTagStyle);
-	}
-	parent.mb_registerSubFunctions("window.frames['"+ mod_digitize_elName + "'].updateMeasureTag()");
-}
-// --- registered functions (end) -----------------------------------------------------------------------------------------
-// ------------------------------------------------------------------------------------------------------------------------
-
-
-function updateMeasureTag () {
-	if (d.count() > 0 ) {
-		if (d.get(-1).count() > 0) {
-			if (d.getGeometry(-1, -1).count() > 0) {
-				if (mod_digitizeEvent == button_line || mod_digitizeEvent == button_polygon) {
-					var measureString = "";
-					measureString += msgObj.measureTagLabelCurrent + d.getGeometry(-1, -1).getCurrentDist(measureNumberOfDigits) + "<br>";
-					measureString += msgObj.measureTagLabelTotal + d.getGeometry(-1, -1).getTotalDist(measureNumberOfDigits);
-					measureDivTag.write(measureString);
-					return true;
-				}
-			}
-		}
-	}
-	measureDivTag.clean();
-}
-
-
-
-// ------------------------------------------------------------------------------------------------------------------------
-// --- button handling (begin) --------------------------------------------------------------------------------------------
-
-function displayButtons(){
-	for (var i = 0 ; i < buttonDig_id.length ; i ++) {
-		if (parseInt(buttonDig_on[i])==1) {
-			var divTag = document.createElement("div");
-			divTag.setAttribute("id", "div_" + buttonDig_id[i]);
-// FIREFOX 
-			document.getElementById("digButtons").appendChild(divTag);
-
-//IE WORKAROUND, WORKS ALSO FOR FIREFOX
-			var tagContent = "<div style='position:absolute; top:"+buttonDig_y[i]+"px; left:"+buttonDig_x[i]+"px;'><img name=\""+buttonDig_id[i]+"\" onmouseover=\"parent.mb_regButton_frame('initDigButton', mod_digitize_elName, "+i+");\" id=\""+buttonDig_id[i]+"\" title=\""+buttonDig_title_off[i]+"\" src=\""+buttonDig_imgdir+buttonDig_src[i]+"\"></div>";
-			parent.writeTag(mod_digitize_elName,"div_" + buttonDig_id[i],tagContent);
-		}
-	}
-}
-
-function updateButtons() {
-	for (var i = 0 ; i < buttonDig_id.length ; i ++) {
-		if (parseInt(buttonDig_on[i])==1) {
-			var currentButton = document.getElementById(buttonDig_id[i]);
-			var currentStatus = buttonDig_id[i].status;
-			var currentTitle = "";
-			switch (buttonDig_id[i]) {
-				case "Point":
-					if (currentStatus == 1) {
-						currentTitle = msgObj.buttonLabelPointOn;
-					}
-					else {
-						currentTitle = msgObj.buttonLabelPointOff;
-					}
-					break;
-				case "Line":
-					if (currentStatus == 1) {
-						currentTitle = msgObj.buttonLabelLineOn;
-					}
-					else {
-						currentTitle = msgObj.buttonLabelLineOff;
-					}
-					break;
-				case "Polygon":
-					if (currentStatus == 1) {
-						currentTitle = msgObj.buttonLabelPolygonOn;
-					}
-					else {
-						currentTitle = msgObj.buttonLabelPolygonOff;
-					}
-					break;
-				case "dragBasePoint":
-					if (currentStatus == 1) {
-						currentTitle = msgObj.buttonLabelMoveBasepointOn;
-					}
-					else {
-						currentTitle = msgObj.buttonLabelMoveBasepointOff;
-					}
-					break;
-				case "setBasePoint":
-					if (currentStatus == 1) {
-						currentTitle = msgObj.buttonLabelInsertBasepointOn;
-					}
-					else {
-						currentTitle = msgObj.buttonLabelInsertBasepointOff;
-					}
-					break;
-				case "delBasePoint":
-					if (currentStatus == 1) {
-						currentTitle = msgObj.buttonLabelDeleteBasepointOn;
-					}
-					else {
-						currentTitle = msgObj.buttonLabelDeleteBasepointOff;
-					}
-					break;
-				case "clear":
-					if (currentStatus == 1) {
-						currentTitle = msgObj.buttonLabelClearListOn;
-					}
-					else {
-						currentTitle = msgObj.buttonLabelClearListOff;
-					}
-					break;
-				case "digitizeSplit":
-					if (currentStatus == 1) {
-						currentTitle = msgObj.buttonLabelSplitOn;
-					}
-					else {
-						currentTitle = msgObj.buttonLabelSplitOff;
-					}
-					break;
-				case "digitizeMerge":
-					if (currentStatus == 1) {
-						currentTitle = msgObj.buttonLabelMergeOn;
-					}
-					else {
-						currentTitle = msgObj.buttonLabelMergeOff;
-					}
-					break;
-				case "digitizeDifference":
-					if (currentStatus == 1) {
-						currentTitle = msgObj.buttonLabelDifferenceOn;
-					}
-					else {
-						currentTitle = msgObj.buttonLabelDifferenceOff;
-					}
-					break;
-			}
-			currentButton.title = currentTitle;
-		}
-	}
-}
-
-function initDigButton(ind, pos){
-	parent.mb_button[ind] = document.getElementById(buttonDig_id[pos]);
-	parent.mb_button[ind].img_over = buttonDig_imgdir + buttonDig_src[pos].replace(/_off/,"_over");
-	parent.mb_button[ind].img_on = buttonDig_imgdir + buttonDig_src[pos].replace(/_off/,"_on");
-	parent.mb_button[ind].img_off = buttonDig_imgdir + buttonDig_src[pos];
-	parent.mb_button[ind].title_on = buttonDig_title_on[pos];
-	parent.mb_button[ind].title_off = buttonDig_title_off[pos];
-	parent.mb_button[ind].status = 0;
-	parent.mb_button[ind].elName = buttonDig_id[pos];
-	parent.mb_button[ind].fName = "";
-	parent.mb_button[ind].go = new Function ("digitizeEnable(parent.mb_button["+ind+"])");
-	parent.mb_button[ind].stop = new Function ("digitizeDisable(parent.mb_button["+ind+"])");
-}	
-
-function digitizeEnable(obj) {
-	if (obj.id == button_move || obj.id == button_insert || obj.id == button_delete) {
-		mod_digitizeEvent = obj.id;
-		executeDigitizePreFunctions();
-	}
-	else if (obj.id == button_point || obj.id == button_line || 
-				obj.id == button_polygon || obj.id == button_clear || 
-				obj.id == button_split || obj.id == button_merge ||
-				obj.id == button_difference){
-					
-		var el = mapDomElement;
-		el.onmousemove = mod_digitize_go;
-
-		mod_digitizeEvent = obj.id;
-
-		if (mod_digitizeEvent == button_point || mod_digitizeEvent == button_line || mod_digitizeEvent == button_polygon || mod_digitizeEvent == button_insert ) {
-			s.store(d);
-		}
-
-		executeDigitizePreFunctions();
-		obj.title = obj.title_on;
-		if (obj.id == button_point) {
-			if (d.count() > 0 && d.get(-1).count() > 0 && !d.get(-1).get(-1).isComplete()) {
-				if (d.get(-1).geomType != parent.geomType.point) {
-					d.close();
-					executeDigitizeSubFunctions();
-				}
-				else {
-					s.add(d.getPoint(-1, -1, 0));
-				}
-			}
-			if (d.count() == 0 || (d.count() > 0 && d.get(-1).count() > 0 && d.get(-1).get(-1).isComplete())) {
-				d.addMember(parent.geomType.point);
-				d.get(-1).addGeometry();
-			}
-			else {
-/*
-//
-// delete existing line or polygon
-//	
-				d.del(-1);
-				d.addMember(parent.geomType.point);
-				d.get(-1).addGeometry();
-*/
-			}
-		}
-		else if (obj.id == button_polygon) {
-			if (d.count() > 0 && d.get(-1).count() > 0 && !d.get(-1).get(-1).isComplete()) {
-				if (d.get(-1).geomType != parent.geomType.polygon) {
-					d.close();
-					executeDigitizeSubFunctions();
-				}
-				else {
-					s.add(d.getPoint(-1, -1, 0));
-				}
-			}
-			if (d.count() == 0 || (d.count() > 0 && d.get(-1).count() > 0 && d.get(-1).get(-1).isComplete())) {
-				// new geometry
-				d.addMember(parent.geomType.polygon);
-				d.get(-1).addGeometry();
-			}
-			else {
-/*
-//
-// continue a line as a polygon
-//	
-				if (d.get(-1).geomType != parent.geomType.polygon) {
-					var geometryTemplate = parent.cloneObject(d.get(-1));
-					d.del(-1);
-					d.addMember(parent.geomType.polygon);
-					for (var i = 0; i < geometryTemplate.count(); i++) {
-						d.get(-1).addGeometry();
-						for (var j = 0; j < geometryTemplate.get(i).count(); j++) {
-							d.get(-1).get(-1).addPoint(geometryTemplate.get(i).get(j));
-						}
-					}
-				}
-				s.add(d.getPoint(-1, -1, 0));
-*/
-			}
-		}
-		else if (obj.id == button_line) {
-			if (d.count() > 0 && d.get(-1).count() > 0 && !d.get(-1).get(-1).isComplete()) {
-				if (d.get(-1).geomType != parent.geomType.line) {
-					d.close();
-					executeDigitizeSubFunctions();
-				}
-				else {
-					s.add(d.getPoint(-1, -1, 0));
-				}
-			}
-			if (d.count() == 0 || (d.count() > 0 && d.get(-1).count() > 0 && d.get(-1).get(-1).isComplete())) {
-				d.addMember(parent.geomType.line);
-				d.get(-1).addGeometry();
-			}
-			else {
-/*
-//
-// continue a polygon as a line
-//	
-				if (d.get(-1).geomType != parent.geomType.line) {
-					var geometryTemplate = parent.cloneObject(d.get(-1));
-					d.del(-1);
-					d.addMember(parent.geomType.line);
-					for (var i = 0; i < geometryTemplate.count(); i++) {
-						d.get(-1).addGeometry();
-						for (var j = 0; j < geometryTemplate.get(i).count(); j++) {
-							d.get(-1).get(-1).addPoint(geometryTemplate.get(i).get(j));
-						}
-					}
-				}
-*/
-			}
-		}
-		else if (obj.id == button_clear) {
-			var clear = confirm(msgObj.messageConfirmDeleteAllGeomFromList);
-			if (clear) {
-				d = new parent.GeometryArray();
-				parent.mb_disableThisButton(button_clear);
-			}
-		}
-		else if (obj.id == button_merge) {
-			var applicable = (d.count() > 1);
-
-			var polygonTextArray = [];
-			for (var i = 0; i < d.count(); i++) {
-				if (d.get(i).geomType != parent.geomType.polygon) {
-					applicable = false;
-					polygonTextArray = [];
-					break;
-				}
-				polygonTextArray.push(d.get(i).toText());
-			}
-
-			if (!applicable) {
-				alert(msgObj.messageErrorMergeNotApplicable);
-				parent.mb_disableThisButton(button_merge);
-				return false;
-			}
-			
-			parent.mb_ajax_post("../php/mod_digitize_mergePolygon.php", {polygons: polygonTextArray.join(";")}, function(json, status) {
-				var response = eval('(' + json + ')');
-				var polygon = response.polygon;
-				var mapIndex = parent.getMapObjIndexByName(mod_digitize_target);
-				d.importGeometryFromText(polygon, parent.mb_mapObj[mapIndex].epsg);
-
-				// remove the original polygons
-				var len = d.count();
-				for (var i = 0; i < len-1; i++) {
-					d.del(0);
-				}
-				parent.mb_disableThisButton(button_merge);
-			});
-		}
-		else if (obj.id == button_split) {
-			var applicable = (d.count() == 2) && 
-							(d.get(0).geomType == parent.geomType.polygon) &&
-							(d.get(1).geomType == parent.geomType.line);
-			if (!applicable) {
-				alert(msgObj.messageErrorSplitNotApplicable);
-				parent.mb_disableThisButton(button_split);
-				return false;
-			}
-			
-			var polygonText = d.get(0).toText();
-			var lineText = d.get(1).toText();
-			
-			parent.mb_ajax_post("../php/mod_digitize_splitPolygon.php", {polygon: polygonText, line: lineText}, function(json, status) {
-				var response = eval('(' + json + ')');
-				var polygonArray = response.polygons;
-				var wfsConfId = d.get(0).wfs_conf;
-				var mapIndex = parent.getMapObjIndexByName(mod_digitize_target);
-				for (var i in polygonArray) {
-					d.importGeometryFromText(polygonArray[i], parent.mb_mapObj[mapIndex].epsg);
-					d.get(-1).wfs_conf = wfsConfId;
-				}
-				// remove the original polygon and the temporary line
-				d.del(0);
-				d.del(0);
-				parent.mb_disableThisButton(button_split);
-			});
-		}
-		else if (obj.id == button_difference) {
-			var applicable = (d.count() == 2) && 
-							(d.get(0).geomType == parent.geomType.polygon) &&
-							(d.get(1).geomType == parent.geomType.polygon);
-			if (!applicable) {
-				alert(msgObj.messageErrorDifferenceNotApplicable);
-				parent.mb_disableThisButton(button_difference);
-				return false;
-			}
-			
-			var polygon1Text = d.get(0).toText();
-			var polygon2Text = d.get(1).toText();
-			
-			parent.mb_ajax_post("../php/mod_digitize_differencePolygon.php", {polygon1: polygon1Text, polygon2: polygon2Text}, function(json, status) {
-				var response = eval('(' + json + ')');
-				var polygonArray = response.polygons;
-				var wfsConfId = d.get(0).wfs_conf;
-				var wfsProperties = d.get(0).e;
-				var mapIndex = parent.getMapObjIndexByName(mod_digitize_target);
-				for (var i in polygonArray) {
-					d.importGeometryFromText(polygonArray[i], parent.mb_mapObj[mapIndex].epsg);
-					d.get(-1).wfs_conf = wfsConfId;
-					d.get(-1).e = wfsProperties;
-				}
-				// remove the original and the temporary polygon
-				d.del(0);
-				d.del(0);
-				parent.mb_disableThisButton(button_difference);
-			});
-		}
-	}
-}
-
-function digitizeDisable(obj) {
-	if (obj.id == button_point || obj.id == button_line || obj.id == button_polygon){
-		obj.title = obj.title_off;
-		if (d.get(-1).get(-1).count() == 0) {
-			d.delGeometry(-1,-1);
-		}
-		mod_digitize_timeout();
-		executeDigitizeSubFunctions();
-	}
-	else if (obj.id == button_clear) {
-		mod_digitize_timeout();
-		executeDigitizeSubFunctions();
-	}
-	else if (obj.id == button_merge) {
-		mod_digitize_timeout();
-		executeDigitizeSubFunctions();
-	}
-	else if (obj.id == button_split) {
-		mod_digitize_timeout();
-		executeDigitizeSubFunctions();
-	}
-	else if (obj.id == button_difference) {
-		mod_digitize_timeout();
-		executeDigitizeSubFunctions();
-	}
-	mod_digitizeEvent = false;
-}
-// --- button handling (end) ----------------------------------------------------------------------------------------------
-// ------------------------------------------------------------------------------------------------------------------------
-
-// -----------------------------------------------------------------------------------------------------------
-// --- display (begin) -----------------------------------------------------------------------------------------
-
-function updateExtent() {
-	var anInd = parent.getMapObjIndexByName(mod_digitize_target);
-	var change = false;
-	if (typeof(mod_digitize_width) == 'undefined' || mod_digitize_width != parent.mb_mapObj[anInd].width) {
-		mod_digitize_width = parent.mb_mapObj[anInd].width;
-		change = true;
-	}
-	if (typeof(mod_digitize_height) == 'undefined' || mod_digitize_height != parent.mb_mapObj[anInd].height) {
-		mod_digitize_height = parent.mb_mapObj[anInd].height;
-		change = true;
-	}
-	if (typeof(mod_digitize_epsg) == 'undefined' || mod_digitize_epsg != parent.mb_mapObj[anInd].epsg) {
-		mod_digitize_epsg = parent.mb_mapObj[anInd].epsg;
-		change = true;
-	}
-//	if (change) {
-//		drawDashedLine();
-//	}
-}
-
-function drawDashedLine(){
-	if (!nonTransactionalEditable) {
-		nonTransactionalHighlight.clean();
-	}
-	var smP = "";
-	smP += "<div class='t_img'>";
-	smP += "<img src='"+parent.mb_trans.src+"' width='"+mod_digitize_width+"' height='0'></div>";
-	smP += "<div class='t_img'>";
-	smP += "<img src='"+parent.mb_trans.src+"' width='0' height='"+mod_digitize_height+"'></div>";
-
-	if (!nonTransactionalEditable) {
-		nonTransactionalHighlight.clean();
-	}
-	var smPArray = [];
-	smPArray[smPArray.length] = "<div class='t_img'>"
-			+ "<img src='"+parent.mb_trans.src+"' width='"+mod_digitize_width+"' height='0'></div>"
-			+ "<div class='t_img'>"
-			+ "<img src='"+parent.mb_trans.src+"' width='0' height='"+mod_digitize_height+"'></div>";
-	
-	var mapObj = parent.mb_mapObj[parent.getMapObjIndexByName(mod_digitize_target)];
-	var width = mapObj.width;
-	var height = mapObj.height;
-	var arrayBBox = mapObj.extent.split(",")
-	var minX = parseFloat(arrayBBox[0]);
-	var minY = parseFloat(arrayBBox[1]);
-	var maxX = parseFloat(arrayBBox[2]);
-	var maxY = parseFloat(arrayBBox[3]);
-	var cx = width/(maxX - minX);
-	var cy = height/(maxY - minY);
-	var isMoveOrInsertOrDelete = mod_digitizeEvent == button_move || mod_digitizeEvent == button_insert || mod_digitizeEvent == button_delete;
-	var minDist = 6;
-
-	for(var i=0, lenGeomArray = d.count(); i < lenGeomArray; i++){
-		var currentGeomArray = d.get(i);
-
-		if (!nonTransactionalEditable && !isTransactional(currentGeomArray)) {
-			nonTransactionalHighlight.add(currentGeomArray, nonTransactionalColor);
-		}
-		else {
-			for(var j=0, lenGeom = currentGeomArray.count(); j < lenGeom ; j++){
-				var currentGeometry = d.getGeometry(i,j);
-				var isPolygon = currentGeomArray.geomType == parent.geomType.polygon;
-				var isLine = currentGeomArray.geomType == parent.geomType.line;
-				var isComplete = currentGeometry.isComplete();
-				var lastPaintedPoint = false;
-
-				for(var k = 0, lenPoint = currentGeometry.count(); k < lenPoint; k++){
-					var currentPoint = currentGeometry.get(k);
-					var currentPointMap = new Point(Math.round((currentPoint.x - minX)*cx), Math.round((maxY - currentPoint.y)*cy));
-					
-//					var isTooCloseToPrevious = lastPaintedPoint && (k > 0) && Math.abs(currentPointMap.x-lastPaintedPoint.x) <= minDist && Math.abs(currentPointMap.y-lastPaintedPoint.y) <= minDist;
-//					if (!isTooCloseToPrevious) {
-						var currentPointIsVisible = currentPointMap.x > 0 && currentPointMap.x < width && currentPointMap.y > 0 && currentPointMap.y < height;
-						if (currentPointIsVisible) {
-							if (!isComplete && ((k == 0 && isPolygon) || (k == lenPoint-1 && isLine))) {
-								smPArray[smPArray.length] = "<div class='bp' style='top:"+
-									(currentPointMap.y-2)+"px;left:"+(currentPointMap.x-2)+"px;z-index:"+
-									digitizeTransactionalZIndex+";background-color:"+linepointColor+"'";
-							}
-							else {
-								smPArray[smPArray.length] = "<div class='bp' style='top:"+(currentPointMap.y-2)+"px;left:"+(currentPointMap.x-2)+"px;z-index:"+digitizeTransactionalZIndex+";'";
-							}
-							if(k==0 && isPolygon && !isComplete){
-								smPArray[smPArray.length] = " title='"+msgObj.closePolygon_title+"' ";
-							}
-							if(isMoveOrInsertOrDelete) {
-								smPArray[smPArray.length] = " onmouseover='parent.window.frames[\""+mod_digitize_elName+"\"].handleBasepoint(this,"+i+","+j+","+k+")' ;";
-							}
-							smPArray[smPArray.length] = "></div>";
-							lastPaintedPoint = currentPointMap;
-						}
-						if (k > 0) {
-							points = parent.calculateVisibleDash(currentPointMap, previousPointMap, width, height);
-							if (points != false) {
-								smPArray[smPArray.length] = evaluateDashes(points[0], points[1], i, j, k);
-							}
-						}
-//					}
-					var previousPointMap = currentPointMap;
-				}
-				if (isPolygon && currentGeometry.innerRings.count() > 0) {
-					// draw inner rings
-
-					for (var l = 0, lenRings = currentGeometry.innerRings.count(); l < lenRings; l++) {
-						var currentRing = currentGeometry.innerRings.get(l);
-						var lastPaintedPoint = false;
-						
-						for (var m = 0, lenPoint = currentRing.count(); m < lenPoint; m++) {
-							var currentPoint = currentRing.get(m);
-							var currentPointMap = new Point(Math.round((currentPoint.x - minX) * cx), Math.round((maxY - currentPoint.y) * cy));
-							
-							//					var isTooCloseToPrevious = lastPaintedPoint && (k > 0) && Math.abs(currentPointMap.x-lastPaintedPoint.x) <= minDist && Math.abs(currentPointMap.y-lastPaintedPoint.y) <= minDist;
-							//					if (!isTooCloseToPrevious) {
-							var currentPointIsVisible = currentPointMap.x > 0 && currentPointMap.x < width && currentPointMap.y > 0 && currentPointMap.y < height;
-							if (currentPointIsVisible) {
-								if (!isComplete && ((k == 0 && isPolygon) || (k == lenPoint - 1 && isLine))) {
-									smPArray[smPArray.length] = "<div class='bp' style='top:" +
-									(currentPointMap.y - 2) +
-									"px;left:" +
-									(currentPointMap.x - 2) +
-									"px;z-index:" +
-									digitizeTransactionalZIndex +
-									";background-color:" +
-									linepointColor +
-									"'";
-								}
-								else {
-									smPArray[smPArray.length] = "<div class='bp' style='top:" + (currentPointMap.y - 2) + "px;left:" + (currentPointMap.x - 2) + "px;z-index:" + digitizeTransactionalZIndex + ";'";
-								}
-								if (m == 0 && isPolygon && !isComplete) {
-									smPArray[smPArray.length] = " title='" + msgObj.closePolygon_title + "' ";
-								}
-								if (isMoveOrInsertOrDelete) {
-									smPArray[smPArray.length] = " onmouseover='parent.window.frames[\"" + mod_digitize_elName + "\"].handleBasepoint(this," + i + "," + j + "," + l + "," + m + ")' ;";
-								}
-								smPArray[smPArray.length] = "></div>";
-								lastPaintedPoint = currentPointMap;
-							}
-							if (m > 0) {
-								points = parent.calculateVisibleDash(currentPointMap, previousPointMap, width, height);
-								if (points != false) {
-									smPArray[smPArray.length] = evaluateDashes(points[0], points[1], i, j, l, m);
-								}
-							}
-							//					}
-							var previousPointMap = currentPointMap;
-						}
-					}
-				}
-			}
-		}
-	}
-	digitizeDivTag.write(smPArray.join(""));
-}
-
-function evaluateDashes(start, end, memberIndex, geomIndex, ringIndex, pointIndex){
-	if (pointIndex == undefined) {
-		pointIndex = ringIndex;
-		ringIndex = undefined;
-	}
-	
-	var strArray = [];
-	var delta = new parent.Point(end.x - start.x, end.y - start.y);
-	var lastGeomIsComplete = d.getGeometry(-1,-1).isComplete(); 
-	 
-	var vecLength = start.dist(end);
-	var n = Math.round(vecLength/dotDistance);
-	if (n > 0) {
-		var step = delta.dividedBy(n);
-	}
-	for(var i=1; i < n; i++){
-		var x = Math.round(start.x + i * step.x) - 2;
-		var y = Math.round(start.y + i * step.y) - 2;
-		if(x >= 0 && x <= mod_digitize_width && y >= 0 && y <= mod_digitize_height){
-			if (memberIndex == d.count()-1 && !lastGeomIsComplete) {
-				strArray[strArray.length] = "<div class='lp' style='top:"+y+"px;left:"+x+"px;z-index:"+digitizeTransactionalZIndex+";background-color:"+linepointColor+"' ";
-			}
-			else {
-				strArray[strArray.length] = "<div class='lp' style='top:"+y+"px;left:"+x+"px;z-index:"+digitizeTransactionalZIndex+";' ";
-			}
-			if(mod_digitizeEvent == button_insert) {
-				strArray[strArray.length] = "onmouseover='parent.window.frames[\""+mod_digitize_elName+"\"].convertLinepointToBasepoint(this,"+memberIndex+","+geomIndex+","+ringIndex+","+pointIndex+")'";
-			}
-			strArray[strArray.length] = "></div>";
-		}
-	}
-	return strArray.join("");
-}
-
-function isTransactional(geom) {
-//	alert(typeof(geom.wfs_conf) + " " + geom.wfs_conf + " " + wfsConf.length);
-	if (typeof(geom.wfs_conf) == 'number') {
-		if (geom.wfs_conf >= 0 && geom.wfs_conf < wfsConf.length) {			
-			var isTransactionalGeom = (wfsConf[geom.wfs_conf]['wfs_transaction'] != "" && wfsConf[geom.wfs_conf]['fkey_featuretype_id'] != "");
-			if (isTransactionalGeom) {
-				return true;
-			}
-			else{
-				return false;
-			}
-		}
-	}
-	else if (typeof(geom.wfs_conf) == 'undefined') {
-		return true;
-	}
-}
-
-function isValidWfsConfIndex (wfsConf, wfsConfIndex) {
-	return (typeof(wfsConfIndex) == "number" && wfsConfIndex >=0 && wfsConfIndex < wfsConf.length);
-}
-
-function getName (geom) {
-	wfsConfId = geom.wfs_conf;
-	wfsConf = parent.get_complete_wfs_conf();
-	if (isValidWfsConfIndex(wfsConf, wfsConfId)) {
-		var resultName = "";
-		for (var i = 0 ; i < wfsConf[wfsConfId]['element'].length ; i++) {
-			if (wfsConf[wfsConfId]['element'][i]['f_show'] == 1) {
-				resultName += geom.e.getElementValueByName(wfsConf[wfsConfId]['element'][i]['element_name']) + " ";
-			}
-		}
-		if (resultName == "") {
-			resultName = wfsConf[wfsConfId]['g_label'];
-		}
-		return resultName;
-	}
-	else if (geom.e.getElementValueByName("name")) {
-		return geom.e.getElementValueByName("name");
-	}
-	else {
-		return msgObj.digitizeDefaultGeometryName;
-	}
-}
-
-function updateListOfGeometries(){
-	var listOfGeom = "<ul>";
-	if (d.count() > 0) {
-		wfsConf = parent.get_complete_wfs_conf();
-		for (var i = 0 ; i < d.count(); i ++) {
-
-			if (d.get(i).get(-1).isComplete() && (nonTransactionalEditable || isTransactional(d.get(i)))) {
-	
-				// for the geometries from a kml, there is another save dialogue
-				if (d.get(i).isFromKml()) {
-					// if the kml is in the db (id = id in database)
-					if (d.get(i).e.getElementValueByName("Mapbender:id")) {
-						// button: geometry information, update kml
-						listOfGeom += "<li>";
-						listOfGeom += "<img src = '"+buttonDig_imgdir+buttonDig_wfs_src+"' title='"+msgObj.buttonDig_wfs_title+"' onclick='showWfsKml("+i+")'>";
-					}
-				}
-				else {
-					// button: geometry information, save, update, delete
-					listOfGeom += "<li>";
-					if (wfsExistsForGeom(d.get(i), wfsConf)) {
-						listOfGeom += "<img src = '"+buttonDig_imgdir+buttonDig_wfs_src+"' title='"+msgObj.buttonDig_wfs_title+"' onclick='showWfs("+i+")'>";
-					}
-
-					// button: remove this geometry
-					listOfGeom += "<img src = '"+buttonDig_imgdir+buttonDig_remove_src+"' title='"+msgObj.buttonDig_remove_title+"' onclick='parent.mb_disableThisButton(mod_digitizeEvent);d.del("+i+");executeDigitizeSubFunctions();'>";
-
-					// button clone this geometry
-					if (addCloneGeometryButton === true) {
-						listOfGeom += "<img src = '"+buttonDig_imgdir+buttonDig_clone_src+"' title='"+msgObj.buttonDig_clone_title+"' onclick='d.addCopy(d.get("+i+"));d.get(-1).e.delElement(\"fid\");executeDigitizeSubFunctions();'>";
-					}
-				}
-					
-				// button: remove geometry from database
-				if (d.get(i).e.getElementValueByName('fid')) {
-					listOfGeom += "<img src = '"+buttonDig_imgdir+buttonDig_removeDb_src+"' title='"+msgObj.buttonDig_removeDb_title+"' onclick=\"var deltrans = confirm('"+msgObj.messageConfirmDeleteGeomFromDb+"');if (deltrans) dbGeom('delete', "+i+")\">";
-				}
-				listOfGeom += "<div class='digitizeGeometryListItem' onmouseover='parent.mb_wfs_perform(\"over\",d.get("+i+"),\""+geomHighlightColour+"\");' ";
-				listOfGeom += " onmouseout='parent.mb_wfs_perform(\"out\",d.get("+i+"),\""+geomHighlightColour+"\")' ";
-				listOfGeom += " onclick='parent.mb_wfs_perform(\"click\",d.get("+i+"),\""+geomHighlightColour+"\");' ";
-				var geomName = getName(d.get(i)); 
-				var currentGeomType;
-				if (d.get(i).geomType == parent.geomType.polygon) {
-					currentGeomType = msgObj.messageDescriptionPolygon;
-				}
-				else if (d.get(i).geomType == parent.geomType.line) {
-					currentGeomType = msgObj.messageDescriptionLine;
-				}
-				else if (d.get(i).geomType == parent.geomType.point) {
-					currentGeomType = msgObj.messageDescriptionPoint;
-				}
-				var multi = "";
-				if (d.get(i).count() > 1) {
-					multi = "multi";
-				}
-				listOfGeom += ">" + htmlspecialchars(geomName) +" (" + multi + currentGeomType + ")</div>";
-				
-				// multigeometries
-				listOfGeom += "<ul>";
-				for (var j = 0; j < d.get(i).count(); j++) {
-					var currentGeom = d.get(i).get(j);
-					if (d.get(i).count() > 1 || (d.get(i).geomType == geomType.polygon && 
-						d.get(i).get(j).innerRings && 
-						d.get(i).get(j).innerRings.count() > 0)) {
-						listOfGeom += "<li>";
-						listOfGeom += "<img src = '"+buttonDig_imgdir+buttonDig_remove_src+"' title='"+msgObj.buttonDig_remove_title+"' onclick='parent.mb_disableThisButton(mod_digitizeEvent);d.get("+i+").del(" + j + ");executeDigitizeSubFunctions();'>";
-						listOfGeom += "<div class='digitizeGeometryListItem' onmouseover='parent.mb_wfs_perform(\"over\",d.get("+i+").get("+j+"),\""+geomHighlightColour+"\");' ";
-						listOfGeom += " onmouseout='parent.mb_wfs_perform(\"out\",d.get("+i+").get("+j+"),\""+geomHighlightColour+"\")' ";
-						listOfGeom += " onclick='parent.mb_wfs_perform(\"click\",d.get("+i+").get("+j+"),\""+geomHighlightColour+"\");' ";
-						listOfGeom += ">" + currentGeomType + "#" + (j+1) +"</div></li>";
-					}
-					if (d.get(i).geomType == geomType.polygon && 
-						d.get(i).get(j).innerRings && 
-						d.get(i).get(j).innerRings.count() > 0) {
-						listOfGeom += "<ul>";
-						for (var k = 0; k < d.get(i).get(j).innerRings.count(); k++) {
-							var currentRing = d.get(i).get(j).innerRings.get(k);
-							listOfGeom += "<li>";
-							listOfGeom += "<img src = '"+buttonDig_imgdir+buttonDig_remove_src+"' title='"+msgObj.buttonDig_remove_title+"' onclick='parent.mb_disableThisButton(mod_digitizeEvent);d.get("+i+").get(" + j + ").innerRings.del(" + k + ");executeDigitizeSubFunctions();'>";
-							listOfGeom += "<div class='digitizeGeometryListItem' onmouseover='parent.mb_wfs_perform(\"over\",d.getGeometry("+i+","+j+").innerRings.get(" + k + "),\""+geomHighlightColour+"\");' ";
-							listOfGeom += " onmouseout='parent.mb_wfs_perform(\"out\",d.getGeometry("+i+","+j+").innerRings.get(" + k + "),\""+geomHighlightColour+"\")' ";
-							listOfGeom += " onclick='parent.mb_wfs_perform(\"click\",d.getGeometry("+i+","+j+").innerRings.get(" + k + "),\""+geomHighlightColour+"\");' ";
-							listOfGeom += ">inner ring #" + (k+1) +"</div></li>";
-							
-						}
-						listOfGeom += "</ul>";
-					}
-				}
-				listOfGeom += "</ul>";
-				listOfGeom += "</li>";
-			}
-		}
-	}
-	listOfGeom += "<ul>";
-	parent.writeTag(mod_digitize_elName,"listOfGeometries",listOfGeom);
-}
-// --- display (end) -----------------------------------------------------------------------------------------
-// -----------------------------------------------------------------------------------------------------------
-
-
-// -----------------------------------------------------------------------------------------------------------
-// --- wfs window (begin) -----------------------------------------------------------------------------------------
-
-// -----------------------------------------------------------------------------------------------------------
-// --- wfs window form check (begin) -----------------------------------------------------------------------------------------
-
-function formCorrect(doc, formId) {
-	var isCorrect = true;
-	var errorMessage = "";
-	var result;
-	var form = doc.getElementById(formId);
-	
-	result = mandatoryFieldsNotEmpty(doc, form);
-	isCorrect = isCorrect && result.isCorrect;
-	errorMessage += result.errorMessage;
-
-	//select box is now checked within function mandatoryFieldsNotEmpty
-	//result = validBoxEntrySelected(form);
-	//isCorrect = isCorrect && result.isCorrect;
-	//errorMessage += result.errorMessage;
-
-	result = dataTypeIsCorrect(doc, form);
-	isCorrect = isCorrect && result.isCorrect;
-	errorMessage += result.errorMessage;
-
-	return {"isCorrect":isCorrect, "errorMessage":errorMessage};
-}
-
-function validBoxEntrySelected(form){
-	var isCorrect = true;
-	var errorMessage = "";
-	for (var i = 0; i < form.childNodes.length && isCorrect; i++) {
-		if (form.childNodes[i].nodeName.toUpperCase() == "SELECT") {
-			if (parseInt(form.childNodes[i].selectedIndex) == 0) {
-				return {"isCorrect":false, "errorMessage":errorMessage};
-			}
-		}
-		else if (form.childNodes[i].hasChildNodes()) {
-			isCorrect = validBoxEntrySelected(form.childNodes[i]).isCorrect;
-		}
-	}
-	if (!isCorrect) {
-		errorMessage = msgObj.messageSelectAnOption + "\n";
-	}
-	return {"isCorrect":isCorrect, "errorMessage":errorMessage};
-}
-
-function mandatoryFieldsNotEmpty(doc, node){
-	var isCorrect = true;
-	var errorMessage = "";
-	
-	nodeArray = doc.getElementsByName("mandatory");
-	for (var i = 0; i < nodeArray.length && isCorrect; i++) {
-		if (nodeArray[i].nodeName.toUpperCase() == "INPUT" && nodeArray[i].type == "hidden" && nodeArray[i].id.substr(0,10) == "mandatory_") {
-			var nodeId = nodeArray[i].id.substr(10);
-			if (nodeArray[i].value == "true") {
-				if (doc.getElementById(nodeId).value == "") {
-					isCorrect = false;
-					errorMessage += "'"+ doc.getElementById(nodeId).name +"': "+ msgObj.messageErrorFieldIsEmpty +"\n";
-				}
-			}
-		}
-		if (nodeArray[i].nodeName.toUpperCase() == "SELECT" && nodeArray[i].type == "hidden" && nodeArray[i].id.substr(0,10) == "mandatory_") {
-			var nodeId = nodeArray[i].id.substr(10);
-			if (nodeArray[i].value == "true") {
-				if (parseInt(form.childNodes[i].selectedIndex) == 0) {
-					isCorrect = false;
-					errorMessage += "'"+ doc.getElementById(nodeId).name +"': "+ msgObj.messageErrorFieldIsEmpty +"\n";
-				}
-			}
-		}
-	}
-	return {"isCorrect":isCorrect, "errorMessage":errorMessage};
-}
-
-function isInteger(str) {
-	if (str.match(/^\d*$/)) {
-		return true;
-	}
-	return false;
-}
-
-function isFloat(str) {
-	if (isInteger(str)) {
-		return true;
-	}
-	if (str.match(/^\d+\.\d+$/)) {
-		return true;
-	}
-	return false;
-}
-
-function replaceCommaByDecimalPoint(str) {
-	var patternString = ",";
-	var pattern = new RegExp(patternString);
-	while (str.match(pattern)) {
-		str = str.replace(pattern, ".");
-	}
-	return str;
-}
-
-function dataTypeIsCorrect(doc, node){
-	var isCorrect = true;
-	var errorMessage = "";
-	
-	nodeArray = doc.getElementsByName("datatype");
-	for (var i = 0; i < nodeArray.length ; i++) {
-		if (nodeArray[i].nodeName.toUpperCase() == "INPUT" && nodeArray[i].type == "hidden" && nodeArray[i].id.substr(0,9) == "datatype_") {
-			var nodeId = nodeArray[i].id.substr(9);
-			var nodeValue = doc.getElementById(nodeId).value;
-			
-			if (nodeArray[i].value == "int") {
-				if (!isInteger(nodeValue)) {
-					isCorrect = false;
-					errorMessage += "'"+doc.getElementById(nodeId).name+"': "+ msgObj.messageErrorNotAnInteger + "\n";
-				}
-			}
-			else if (nodeArray[i].value == "double") {
-				nodeValue = replaceCommaByDecimalPoint(nodeValue);
-				if (!isFloat(nodeValue)) {
-					isCorrect = false;
-					errorMessage += "'"+doc.getElementById(nodeId).name+"': "+ msgObj.messageErrorNotAFloat + "\n";
-				}
-				else {
-					doc.getElementById(nodeId).value = nodeValue;
-				}
-			}
-		}
-	}
-	return {"isCorrect":isCorrect, "errorMessage":errorMessage};
-}
-// --- wfs window form check (end) -----------------------------------------------------------------------------------------
-// -----------------------------------------------------------------------------------------------------------
-
-function getAvailableWfsForGeom(geom, wfsConf) {
-	var wfsConfIndices = [];
-	
-	for (var attr in wfsConf) {
-		var isTrans = (wfsConf[attr]['wfs_transaction'] != "");
-		if (!isTrans) {
-			continue;
-		}
-		if (isValidWfsConfIndex(wfsConf, parseInt(geom.wfs_conf))) {
-			
-			if (parseInt(geom.wfs_conf) == parseInt(attr)) {
-				wfsConfIndices.push(attr);
-			}
-		}
-		else {
-			for (var elementIndex = 0; elementIndex < wfsConf[attr]['element'].length ; elementIndex++) {
-				var isGeomColumn = (parseInt(wfsConf[attr]['element'][elementIndex]['f_geom']) == 1); 
-				if (isGeomColumn) {
-					var isMultiPolygon = (
-						geom.geomType == parent.geomType.polygon && 
-						(
-						wfsConf[attr]['element'][elementIndex]['element_type'] == 'MultiPolygonPropertyType' ||
-						wfsConf[attr]['element'][elementIndex]['element_type'] == 'MultiSurfacePropertyType'
-						)
-					);
-					var isPolygon = (
-						geom.geomType == parent.geomType.polygon && 
-						geom.count() == 1 && 
-						(
-						wfsConf[attr]['element'][elementIndex]['element_type'] == 'PolygonPropertyType' ||
-						wfsConf[attr]['element'][elementIndex]['element_type'] == 'SurfacePropertyType'
-						)
-					);
-					var isMultiLine = (
-						geom.geomType == parent.geomType.line && 
-						(
-						wfsConf[attr]['element'][elementIndex]['element_type'] == 'MultiLineStringPropertyType' ||
-						wfsConf[attr]['element'][elementIndex]['element_type'] == 'MultiCurvePropertyType'
-						)
-					);
-					var isLine = (
-						geom.geomType == parent.geomType.line && 
-						geom.count() == 1 && 
-						(
-						wfsConf[attr]['element'][elementIndex]['element_type'] == 'LineStringPropertyType' ||
-						wfsConf[attr]['element'][elementIndex]['element_type'] == 'CurvePropertyType'
-						)
-					);
-					var isPoint = (geom.geomType == parent.geomType.point && wfsConf[attr]['element'][elementIndex]['element_type'] == 'PointPropertyType');
-//					alert(isMultiPolygon + " " + isPolygon + " " + isMultiLine + " " + isLine + " " + isPoint);
-					if (isMultiPolygon || isPolygon || isMultiLine || isLine || isPoint || wfsConf[attr]['element'][elementIndex]['element_type'] == 'GeometryAssociationType') {
-						
-						wfsConfIndices.push(attr);
-					}
-				}
-			}
-		}	
-	}
-	return wfsConfIndices;
-}
-function wfsExistsForGeom(geom, wfsConf) {
-	wfsConfIndices = getAvailableWfsForGeom(geom, wfsConf);
-//	alert(wfsConfIndices.join(","));
-	if (wfsConfIndices.length > 0) {
-		return true;
-	}
-	return false;
-}
-
-
-function showWfsKml (geometryIndex) {
-	wfsKmlWindow = open("", "wfsattributes", "width="+wfsWindowWidth+", height="+wfsWindowHeight+", resizable, dependent=yes, scrollbars=yes");
-	wfsKmlWindow.document.open("text/html");
-	wfsKmlWindow.document.writeln("<html><head><meta http-equiv='Content-Type' content='text/html; charset=<?php echo CHARSET;?>'></head><body><div id='linkToKml'></div><div id='elementForm'></div></body></html>");
-	wfsKmlWindow.document.close();
-	
-	str = "<form id = 'wmsKmlForm' onsubmit='return false;'><table>";
-
-	var properties = d.get(geometryIndex).e;
-	var propertyCount = properties.count();	
-	for (var i = 0; i < propertyCount; i++) {
-		var key = properties.getName(i);
-		var value = properties.getValue(i);
-		var expr = /Mapbender:/;
-		if (!key.match(expr)) {
-			str += "\t\t<tr>\n";
-			str += "\t\t\t<td>\n\t\t\t\t<div>" + key + "</div>\n\t\t\t</td>\n";
-			str += "\t\t\t<td>\n";
-			str += "\t\t\t\t<input id = 'wmskml_" + i + "' name='" + key + "' type='text' size=20 value = '" + value + "'>\n";
-			str += "\t\t\t</td>\n\t\t</tr>\n";
-		}
-	}	
-
-	var updateOnClickText = "this.disabled=true;window.opener.updateKmlInDb("+geometryIndex+", 'update');";
-	var deleteOnClickText = "var deltrans = confirm('This geometry will be removed from the KML.');";
-	deleteOnClickText += "if (deltrans){";
-	deleteOnClickText += "this.disabled=true;window.opener.updateKmlInDb("+geometryIndex+", 'delete')}";
-	
-	str += "\t\t\t<td><input type='button' name='updateButton' value='Update' onclick=\""+updateOnClickText+"\"/></td>\n";
-// delete button not yet implemented
-//	str += "\t\t\t<td><input type='button' name='deleteButton' value='Delete' onclick=\""+deleteOnClickText+"\"/></td>\n";
-	str += "\t\t\t<td><input type='button' name='abortButton' value='Abort' onclick=\"window.close();\" /></td>\n";
-
-	str += "\t\t</tr>\n";
-	str += "\t</table>\n";
-	str += "</form>\n";
-
-	wfsKmlWindow.document.getElementById("elementForm").innerHTML = str;
-}
-
-//
-// this method opens a new window and displays the attributes in wfs_conf
-//
-function showWfs(geometryIndex) {
-	wfsConf = parent.get_complete_wfs_conf();
-
-	wfsWindow = open("", "wfsattributes", "width="+wfsWindowWidth+", height="+wfsWindowHeight+", resizable, dependent=yes, scrollbars=yes");
-	wfsWindow.document.open("text/html");
-
-	var str = "";
-	var strStyle = "";
-	var defaultIndex = -1;
-
-	str += "<form id='wfs'>\n";
-
-	//
-	// 1. add select box 
-	//
-
-	var onChangeText = "document.getElementById('elementForm').innerHTML = ";
-	onChangeText += "window.opener.buildElementForm(this.value , " + geometryIndex + ");";
-	onChangeText += "window.opener.setWfsWindowStyle(this.value);";
-	
-	str += "\t<select name='wfs' size='" + wfsConf.length + "'";
-	str += " onChange=\""+ onChangeText +"\"";
-	str += ">\n\t\t";
-
-	var wfsConfIndices = getAvailableWfsForGeom(d.get(geometryIndex), wfsConf);
-//	alert(wfsConfIndices.join(","));
-	var selected = false;
-	for (var i = 0; i < wfsConfIndices.length ; i++) {
-		str += "<option value='" + wfsConfIndices[i] + "'";
-		if (!selected) {
-			str += " selected";
-			selected = true;
-			defaultIndex = parseInt(wfsConfIndices[i]);
-		}
-		str += ">" + wfsConf[wfsConfIndices[i]]['wfs_conf_abstract'];
-		str += "</option>\n\t\t";
-	}
-
-	
-	str += "</select>\n\t\t</form>\n\t";
-	str += "<div id='elementForm'>\n</div>";
-	
-	if (defaultIndex != -1) {
-		var htmlStr = "<html><head><style type='text/css'>" + wfsConf[defaultIndex]['g_style'] + "</style>";
-		htmlStr += '<link rel="stylesheet" type="text/css" href="../extensions/theme/ui.all.css" />';
-		htmlStr += '<style type="text/css">'
-		htmlStr += 'a.tabheader { margin: 0 3px 0 0;padding: 1px 5px;text-decoration: none;color: #999;background-color: #F5F5F5;border: 1px solid #999;border-bottom: 0; }';
-		htmlStr += 'a.tabheader.active { color: #666;background-color: transparent;border-color: #666;border-bottom: 1px solid #FFF;cursor: default; }';
-		htmlStr += 'div.tabcontent { visibility: hidden;display: none;margin: -3px 0 5px 0;padding: 5px;border: 1px solid #666; }';
-		htmlStr += 'div.helptext { visibility: hidden;display: none;position: absolute;top: 5%;left: 5%;width: 85%;padding: 5px;color: #000;background-color: #CCC;border: 1px solid #000; }';
-		htmlStr += 'div.helptext p { margin: 0 ; }';
-		htmlStr += 'div.helptext p a.close { display: block;margin: 5px auto;text-align: center; }';
-		htmlStr += 'a img { vertical-align: middle;border: 0; }';
-		htmlStr += '</style>';
-		htmlStr += '</head><body></body></html>';
-
-//		wfsWindow.document.writeln("<html><head><meta http-equiv='Content-Type' content='text/html; charset=<?php echo CHARSET;?>'><style type='text/css'>"+wfsConf[defaultIndex]['g_style']+"</style></head><body></body></html>");
-		wfsWindow.document.write(htmlStr);
-
-		wfsWindow.document.write(str);
-		wfsWindow.document.close();
-		wfsWindow.document.getElementById("elementForm").innerHTML = buildElementForm(defaultIndex, geometryIndex);
-	}
-	else {
-		wfsWindow.document.writeln("<html><head><meta http-equiv='Content-Type' content='text/html; charset=<?php echo CHARSET;?>'><style type='text/css'></style></head><body></body></html>");
-		wfsWindow.document.write(str);
-		wfsWindow.document.close();
-	}
-}
-
-function setWfsWindowStyle(wfsConfIndex) {
-	wfsWindow.document.getElementsByTagName("style")[0].innerHTML = wfsConf[wfsConfIndex]['g_style'];
-}
-
-// returns a form with the elements of a selected wfs
-// (if the original wfs is the selected wfs, the values are set too)
-function buildElementForm(wfsConfIndex, memberIndex){
-	var featureTypeMismatch = false;
-	if (parseInt(d.get(memberIndex).wfs_conf) != parseInt(wfsConfIndex)) {featureTypeMismatch = true;}
-	var str = "";
-	var hasGeometryColumn = false;
-	var featureTypeArray = wfsConf[wfsConfIndex];
-	var memberElements;
-	var fid = false;
-
-	if (!featureTypeMismatch) {
-		memberElements = d.get(memberIndex).e;
-		fid = memberElements.getElementValueByName('fid');
-	}
-	
-	if (typeof(featureTypeArray["element"]) !== "undefined") {
-
-		str += "<form id='"+featureTypeElementFormId+"'>\n\t<table>\n";
-		featureTypeElementArray = featureTypeArray["element"];
-
-		// Check if there are categories given and
-		// build the form in tabs if necessary
-		var elementCategories = ['abc','def','123'];
-		/*
-		for(var i = 0; i < featureTypeElementArray.length; i++){
-			var categoryName         = featureTypeElementArray[i].f_category_name;
-			var categoryNameIsUnique = true;
-			
-			if(categoryName.length === 0) { continue; }
-			
-			for(var j = 0; j < elementCategories.length; j++) {
-				if(elementCategories[j] == categoryName) {
-					categoryNameIsUnique = false;
-				}
-			}
-			
-			if(categoryNameIsUnique) {
-				elementCategories.push(categoryName);
-			}
-		}
-		*/
-
-		if(elementCategories.length > 0) {
-			return buildTabbedElementForm(elementCategories,wfsConfIndex,memberIndex);
-		}
-		
-		//
-		// 2. add rows to form 
-		//
-		for (var i = 0 ; i < featureTypeElementArray.length ; i ++) {
-			var featureTypeElement = featureTypeElementArray[i];
-
-			var elementName = featureTypeElement['element_name'];
-			var elementType = featureTypeElement['element_type'];
-			var isEditable = (parseInt(featureTypeElement['f_edit']) == 1); 
-			var isMandatory = (parseInt(featureTypeElement['f_mandatory']) == 1); 
-			var isGeomColumn = (parseInt(featureTypeElement['f_geom']) == 1); 
-
-			var elementLabelExists = (featureTypeElement['f_label'] != "");
-			var elementLabel = ""; 
-			if (elementLabelExists) {
-				elementLabel = featureTypeElement['f_label'];
-			}
-			var elementLabelStyle = featureTypeElement['f_label_id'];
-
-			if (!isGeomColumn) {
-				if (isEditable) {
-					str += "\t\t<tr>\n";
-					str += "\t\t\t<td>\n\t\t\t\t<div class = '"+elementLabelStyle+"''>" + elementLabel + "</div>\n\t\t\t</td>\n";
-					str += "\t\t\t<td>\n";
-
-					var elementValue = "";
-					if (!featureTypeMismatch) {
-						for (var j = 0 ; j < memberElements.count() ; j ++) {
-							if (memberElements.getName(j) == featureTypeElement['element_name']) {
-								elementValue = memberElements.getValue(j);
-							}
-						}
-					}
-					var formElementHtml = featureTypeElement['f_form_element_html']; 
-					if (!formElementHtml || !formElementHtml.match(/&lt;select/)) {
-						str += "\t\t\t\t<input id = 'datatype_mb_digitize_form_" + elementName + "' name='datatype' type='hidden' value = '" + elementType + "'>\n";
-						str += "\t\t\t\t<input id = 'mandatory_mb_digitize_form_" + elementName + "' name='mandatory' type='hidden' value = '" + isMandatory + "'>\n";
-						str += "\t\t\t\t<input id = 'mb_digitize_form_" + elementName + "' name='" + elementLabel + "' type='text' class = '"+featureTypeElement['f_style_id']+"' size=20 value = '" + elementValue + "'>\n";
-					}
-					else {
-							while (formElementHtml.match(/\\/)) {
-								formElementHtml = formElementHtml.replace(/\\/, "");
-							} 
-							str += "\t\t\t\t<input id = 'datatype_" + elementName + "' name='datatype' type='hidden' value = '" + elementType + "'>\n";
-							str += "\t\t\t\t<input id = 'mandatory_" + elementName + "' name='mandatory' type='hidden' value = '" + isMandatory + "'>\n";
-							// preselect the correct entry of the box
-							var patternString = "option value( )*=( )*'"+elementValue+"'";
-							var pattern = new RegExp(patternString);
-							var patternStringForReplace = "option value = '"+elementValue+"'";
-							formElementHtml = formElementHtml.replace(pattern, patternStringForReplace+" selected");
-							formElementHtml = formElementHtml.replace(/&lt;/g,'<');
-							formElementHtml = formElementHtml.replace(/&gt;/g,'>');
-							formElementHtml = formElementHtml.replace(/&#039;/g,'\'');
-							
-							str += formElementHtml;
-					}
-
-					if(featureTypeElement.f_helptext.length > 0) {
-						str += ' <a href="#" onclick="return window.opener.showHelptext(' + i + ')"><img src="../x_geoportal/img/help.png" width="16" height="16" alt="?" /></a> ';
-						str += '<div id="helptext' +i+ '" class="helptext">';
-						str += '<p>';
-						str += featureTypeElement.f_helptext.replace(/(http:\/\/\S*)/g,'<a href="$1" target="blank">$1<\/a>');
-						str += '<a href="#" class="close" onclick="return window.opener.hideHelptext(' + i + ')">close</a>';
-						str += '</p>';
-						str += '</div>';
-					}
-
-					str += "\t\t\t</td>\n\t\t</tr>\n";
-				}
-			}
-			else {
-				hasGeometryColumn = true;
-			}
-		}
-
-		//
-		// 3. add buttons "save", "update", "delete"
-		//
-		str += "</table><table>";
-		var isTransactional = (featureTypeArray['wfs_transaction']); 
-		if (isTransactional) {
-			str += "\t\t<tr>\n";
-
-			var options = ["insert", "update", "delete", "abort"];
-			for (var i = 0 ; i < options.length ; i++) {
-				var onClickText = "this.disabled=true;var result = window.opener.formCorrect(document, '"+featureTypeElementFormId+"');";
-				onClickText += 	"if (result.isCorrect) {";
-				onClickText += 		"window.opener.dbGeom('"+options[i]+"', "+memberIndex+"); ";
-//				onClickText +=      "window.close();";
-				onClickText += 	"}";
-				onClickText += 	"else {";
-				onClickText += 		"alert(result.errorMessage);this.disabled=false;"
-				onClickText += 	"}";
-				
-				if (options[i] == "insert" && hasGeometryColumn && (!fid || showSaveButtonForExistingGeometries)) {
-					str += "\t\t\t<td><input type='button' name='saveButton' value='"+msgObj.buttonLabelSaveGeometry+"' onclick=\""+onClickText+"\" /></td>\n";
-				}
-				
-				if (!featureTypeMismatch && fid) {
-					if (options[i] == "update" && hasGeometryColumn) {
-						str += "\t\t\t<td><input type='button' name='updateButton' value='"+msgObj.buttonLabelUpdateGeometry+"' onclick=\""+onClickText+"\"/></td>\n";
-					}
-					if (options[i] == "delete"){ 
-						var deleteOnClickText = "var deltrans = confirm('"+msgObj.messageConfirmDeleteGeomFromDb+"');";
-						deleteOnClickText += "if (deltrans){";
-						deleteOnClickText += onClickText + "}";
-						str += "\t\t\t<td><input type='button' name='deleteButton' value='"+msgObj.buttonLabelDeleteGeometry+"' onclick=\""+deleteOnClickText+"\"/></td>\n";
-					}
-				}
-				if (options[i] == "abort") {
-					str += "\t\t\t<td><input type='button' name='abortButton' value='"+msgObj.buttonLabelAbort+"' onclick=\"window.close();\" /></td>\n";
-				}
-			}
-			str += "\t\t</tr>\n";
-		}
-		str += "\t</table>\n";
-		str += "<input type='hidden' id='fid' value='"+fid+"'>";
-//			str += "<input type='text' name='mb_wfs_conf'>";
-		str += "</form>\n";
-	}
-	return str;
-}
-
-function dbGeom(type,m) {
-	if (typeof(wfsWindow) != 'undefined' && !wfsWindow.closed) {
-		d.get(m).wfs_conf = parseInt(wfsWindow.document.forms[0].wfs.options[wfsWindow.document.forms[0].wfs.selectedIndex].value);
-		d.get(m).e = new parent.Wfs_element();
-	}
-	else {
-		wfsConf = parent.get_complete_wfs_conf();
-	}
-	var myconf = wfsConf[d.get(m).wfs_conf];
-	
-	var mapObjInd = parent.getMapObjIndexByName(mod_digitize_target);
-
-	var proceed = true;
-	if (myconf['featuretype_srs'] != parent.mb_mapObj[mapObjInd].epsg) {
-		proceed = confirm(msgObj.errorMessageEpsgMismatch + parent.mb_mapObj[mapObjInd].epsg + " / "+ myconf['featuretype_srs'] + ". Proceed?");
-	}
-	if (proceed) {
-		var fid = false;
-		var errorMessage = "";
-		if (typeof(wfsWindow) != 'undefined' && !wfsWindow.closed) {
-			myform = wfsWindow.document.getElementById(featureTypeElementFormId);
-		
-			for (var i=0; i<myform.length; i++){
-				if (myform.elements[i].id == "fid") {
-					fid = myform.elements[i].value;
-					if (fid == "false") {
-						fid = false;
-					}
-					else {
-						d.get(m).e.setElement('fid', fid);
-					}
-				}
-				else if (myform.elements[i].type == 'text' ){
-					if (myform.elements[i].id) {
-						var elementId = String(myform.elements[i].id).replace(/mb_digitize_form_/, "");
-						d.get(m).e.setElement(elementId, myform.elements[i].value);
-					}
-					else {
-						errorMessage = msgObj.messageErrorFormEvaluation;
-					}
-				}
-				// selectbox
-				else if (typeof(myform.elements[i].selectedIndex) == 'number') {
-					if (myform.elements[i].id) {
-						var elementId = String(myform.elements[i].id).replace(/mb_digitize_form_/, "");
-						d.get(m).e.setElement(elementId, myform.elements[i].options[myform.elements[i].selectedIndex].value);
-					}
-					else {
-						errorMessage = msgObj.messageErrorFormEvaluation;
-					}
-				}
-			}
-		}
-		else {
-			fid = d.get(m).e.getElementValueByName('fid');
-		}
-//		str = parent.get_wfs_str(myconf, d, m, type, fid);
-		
-		var geoJson = d.featureToString(m);
-		
-		parent.mb_ajax_post(
-			"../extensions/geom2wfst.php", 
-			{
-				'geoJson' : geoJson,
-				'method' : type,
-				'wfs_conf_id' : wfsConf[d.get(m).wfs_conf]['wfs_conf_id']
-			}, 
-			function(json,status){
-				var result = eval('('+json+')');
-				var success = result.success;
-				var fid = result.fid;
-				wfsSubWrite(m, type, status, success, fid);
-			}
-		);
-	}
-}
-
-function wfsSubWrite(m, type, status, success, fid) {
-	if (status == "success" && success) {
-		if (type == 'insert' && fid) {
-			d.get(m).e.setElement("fid", fid);
-		}
-		if (type == 'delete') {
-			parent.mb_disableThisButton(mod_digitizeEvent);
-			d.del(m);
-		}
-		
-		var wfsWriteMessage = msgObj.messageSuccessWfsWrite;
-	}
-	else {
-		var wfsWriteMessage = msgObj.messageErrorWfsWrite;
-	} 
-
-	parent.mb_execWfsWriteSubFunctions();
-	executeDigitizeSubFunctions();
-
-	if (typeof(wfsWindow) != 'undefined' && !wfsWindow.closed) {
-		wfsWindow.alert(wfsWriteMessage);
-		window.setTimeout("wfsWindow.close()",0);
-	}
-	else {
-		alert(wfsWriteMessage);
-	}
-}
-function getMultiGeometryIdsByPlacemarkId (placemarkId) {
-	var multiGeometryIdArray = [];
-	for (var i = 0; i < d.count(); i++) {
-		var currentPlacemarkId = d.get(i).e.getElementValueByName("Mapbender:placemarkId");
-		if (currentPlacemarkId && currentPlacemarkId == placemarkId) {
-			multiGeometryIdArray.push(i);	
-		}
-	}	
-	return multiGeometryIdArray;
-}
-
-function updateKmlInDb (geometryIndex, command) {
-	var properties = d.get(geometryIndex).e;
-	var placemarkId = properties.getElementValueByName("Mapbender:placemarkId");
-	
-	var multiGeometryIdArray = getMultiGeometryIdsByPlacemarkId(placemarkId);
-
-	if (typeof(wfsKmlWindow) != 'undefined' && !wfsKmlWindow.closed) {
-
-		// update properties from form
-		myform = wfsKmlWindow.document.getElementById("wmsKmlForm");
-	
-		for (var i=0; i < myform.length; i++){
-			if (myform.elements[i].type == 'text' ){
-				if (myform.elements[i].id) {
-					var key = myform.elements[i].name;
-					var value = myform.elements[i].value;
-					
-					// update all geometries with the same placemark id
-					for (var j = 0; j < multiGeometryIdArray.length; j++) {
-						var currentProperties = d.get(j).e; 
-						currentProperties.setElement(key, value);
-					}
-				}
-			}
-		}
-		var kmlId = properties.getElementValueByName("Mapbender:id");
-	
-		parent.mb_ajax_post("../php/mod_updateKmlInDb.php", {command:command, kmlId:kmlId, placemarkId:placemarkId, geoJSON:d.placemarkToString(placemarkId)}, function(obj, status) {
-			if (obj === "1") {
-				wfsKmlWindow.alert("KML updated.");
-				var link = wfsKmlWindow.document.createElement("a");
-				link.href = "../php/mod_displayKML.php?kmlId=" + kmlId;
-				link.target = "_blank";
-				link.innerHTML = "KML";
-				wfsKmlWindow.document.getElementById('elementForm').innerHTML = "";
-				wfsKmlWindow.document.getElementById('linkToKml').appendChild(link);
-			}
-			else {
-				wfsKmlWindow.alert("Error, KML could not be updated. Check your error log.");
-			}
-		});
-	}
-}
-
-
-// --- wfs window (begin) -----------------------------------------------------------------------------------------
-// -----------------------------------------------------------------------------------------------------------
-
-function getMessages() {
-	parent.mb_ajax_json("../php/mod_digitize_messages.php", function(obj, status) {
-		msgObj = obj;
-		applyMessages();
-	});
-}
-
-function applyMessages() {
-	updateMeasureTag();
-	updateListOfGeometries();
-	updateButtons();
-}
-
-	</script>
-	</head>
-	<body onload="registerFunctions();displayButtons();">
-		<div id='digButtons'></div>
-		<div id='listOfGeometries' class='digitizeGeometryList'></div>
-	</body>
-</html>
\ No newline at end of file

Deleted: branches/print_dev/http/javascripts/mod_loadwmc_list.php
===================================================================
--- branches/print_dev/http/javascripts/mod_loadwmc_list.php	2009-08-04 11:47:46 UTC (rev 4470)
+++ branches/print_dev/http/javascripts/mod_loadwmc_list.php	2009-08-04 11:51:01 UTC (rev 4471)
@@ -1,3 +0,0 @@
-<?php
-	echo "fisch";
-?>
\ No newline at end of file

Deleted: branches/print_dev/http/javascripts/mod_log.php
===================================================================
--- branches/print_dev/http/javascripts/mod_log.php	2009-08-04 11:47:46 UTC (rev 4470)
+++ branches/print_dev/http/javascripts/mod_log.php	2009-08-04 11:51:01 UTC (rev 4471)
@@ -1,13 +0,0 @@
-<?php
-require(dirname(__FILE__)."/../php/mb_validatePermission.php");
-?>
-mb_registerInitFunctions("mb_log_init()");
-function mb_log_init(){
-	mb_log = "mb_log_set";
-}
-try{if(logtype){}}catch(e){logtype="";}
-function mb_log_set(req, time_client){
-	var url = "../php/mod_log.php?<?php echo $urlParameters;?>&req=" + escape(req) + "&time_client=" + time_client;
-	mb_ajax_post(url, {req:req, time:time_client});
-	return true;
-}
\ No newline at end of file

Deleted: branches/print_dev/http/javascripts/mod_reload.php
===================================================================
--- branches/print_dev/http/javascripts/mod_reload.php	2009-08-04 11:47:46 UTC (rev 4470)
+++ branches/print_dev/http/javascripts/mod_reload.php	2009-08-04 11:51:01 UTC (rev 4471)
@@ -1,66 +0,0 @@
-<?php
-# $Id$
-# http://www.mapbender.org/index.php/reload
-# Copyright (C) 2002 CCGIS 
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-?>
-/**
- * Package: Reload
- * 
- * Description:
- * A button that reloads the whole window. 
- *
- * SQL:
- * > INSERT INTO gui_element (fkey_gui_id, e_id, e_pos, e_public, 
- * > e_comment, e_element, e_src, e_attributes, e_left, e_top, e_width, 
- * > e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, 
- * > e_mb_mod, e_target, e_requires, e_url) VALUES ('<gui_id>', 'reload',
- * > 2,1,'reload','img','../img/button_blink_red/reload_off.png', '',335,
- * > 60,24,24,1,'','','','mod_reload.php','','mapframe1','',
- * > 'http://www.mapbender.org/index.php/Reload');
- *
- * Maintainer: 
- * http://www.mapbender.org/User:Vera_Schulze
- */
-var Reload = function (domElement) {
-	
-	var that = this;
-	
-	domElement.src = options.src;
-	if (!options.src) {
-		new Mb_exception(options.id + " requires a src.");
-	}
-	else {
-		$(domElement).mouseover(function () {
-			domElement.src = options.src.replace(/_off/,"_over");
-		}).mouseout(function () {
-			domElement.src = options.src;
-		}).click(function () {
-		   that.reload(); 
-		});
-	};
-	
-	/**
-	 * Method: reload
-	 *
-	 * Reloads the window.
-	 */
-	this.reload = function () {
-		location.reload();
-	};
-};
-
-var reload = new Reload(this);
\ No newline at end of file

Deleted: branches/print_dev/http/javascripts/mod_resize_mapsize.php
===================================================================
--- branches/print_dev/http/javascripts/mod_resize_mapsize.php	2009-08-04 11:47:46 UTC (rev 4470)
+++ branches/print_dev/http/javascripts/mod_resize_mapsize.php	2009-08-04 11:51:01 UTC (rev 4471)
@@ -1,123 +0,0 @@
-<?php
-# $Id:mod_resize_mapsize.php 1964 2008-01-15 08:11:29Z christoph $
-# http://www.mapbender.org/index.php/ResizeMapsize
-# Created on 12.07.2006/07:32:08
-# Copyright (C) 2002 CCGIS 
-# Projekt: mapbender
-# File: mod_resize_mapsize.php
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-require_once(dirname(__FILE__)."/../php/mb_validatePermission.php");
-include(dirname(__FILE__) . "/../include/dyn_js.php");
-
-$sqltarget = "SELECT e_target FROM gui_element WHERE e_id = 'resizeMapsize' AND fkey_gui_id = $1";
-$v = array($gui_id);
-$t = array('s');
-$res = db_prep_query($sqltarget, $v, $t);
-while($row = db_fetch_array($res)){
-	$e_target = $row["e_target"];
-}
-
-$sql = "SELECT e_left, e_top FROM gui_element WHERE e_id = '".$e_target."' AND fkey_gui_id = $1";
-$v = array($gui_id);
-$t = array('s');
-$res = db_prep_query($sql, $v, $t);
-while($row = db_fetch_array($res)){
-	$e_left = $row["e_left"];
-	$e_top = $row["e_top"];
-}
-
-$sqllegend = "SELECT e_width FROM gui_element WHERE e_id = 'legend' AND fkey_gui_id = $1";
-$v = array($gui_id);
-$t = array('s');
-$res = db_prep_query($sqllegend, $v, $t);
-while($row = db_fetch_array($res)){
-	$leg_e_width = $row["e_width"];
-}
-
-?>
-try{
-	if (resize_option){}
-}
-catch(e){
-	resize_option = "auto";
-}
-
-try{
-	if (adjust_width){}
-}
-catch(e){
-	adjust_width = "-45";
-}
-
-try{
-	if (adjust_height){}
-}
-catch(e){
-	adjust_height = "-35";
-}
-var map_frame = "<?php echo $e_target ?>";
-var map_frame_left = "<?php echo $e_left ?>";
-var map_frame_top = "<?php echo $e_top ?>";
-var legend_width = "<?php echo $leg_e_width ?>";
-
-function frameWidth(){
-  	if (window.innerWidth) return window.innerWidth;
-  	else if (document.body && document.body.offsetWidth)  return document.body.offsetWidth;
-  	else return 0;
-}
-
-function frameHeight(){
-  	if (window.innerHeight)return window.innerHeight;
-	else if (document.body && document.body.offsetHeight) return document.body.offsetHeight;
-    else return 0;
-}
-
-function adjustDimension(){
-	var ind = getMapObjIndexByName("<?php  echo $e_target;  ?>");
-	var mapheight = frameHeight() - <?php echo $e_top ?> + parseInt(adjust_height);
-	var mapwidth = frameWidth() - map_frame_left - legend_width + parseInt(adjust_width) ;
-	var coords = mb_mapObj[ind].extent.split(",");
-	midcoordx=parseFloat((parseFloat(coords[2])-parseFloat(coords[0]))/2)+parseFloat(coords[0]);
-	midcoordy=parseFloat((parseFloat(coords[3])-parseFloat(coords[1]))/2)+parseFloat(coords[1]);
-	mb_mapObj[ind].setWidth(mapwidth);
-	mb_mapObj[ind].setHeight(mapheight);
-	mb_mapObj[ind].repaintScale(midcoordx,midcoordy,mb_mapObj[ind].getScale());
-}
-
-function rebuild() {
-  	if (width_temp != frameWidth() || height_temp != frameHeight()) window.setTimeout('adjustDimension()', 500);
-}
-
-function control(){
-  	adjustDimension();
-	if (!window.width_temp && window.innerWidth) {
-  	    window.onresize = rebuild;
-  	    width_temp = frameWidth();
-  	    height_temp = frameHeight();
-    }
-
-    if (!window.width_temp && document.body && document.body.offsetWidth) {
-  	    window.onresize = rebuild;
-  	    width_temp = frameWidth();
-  	    height_temp = frameHeight();
-    }
-}
-if (resize_option == 'auto'){
-	eventInit.register(function() {
-		control();
-	});
-}

Deleted: branches/print_dev/http/javascripts/mod_sandclock.php
===================================================================
--- branches/print_dev/http/javascripts/mod_sandclock.php	2009-08-04 11:47:46 UTC (rev 4470)
+++ branches/print_dev/http/javascripts/mod_sandclock.php	2009-08-04 11:51:01 UTC (rev 4471)
@@ -1,151 +0,0 @@
-<?php
-# $Id$
-# http://www.mapbender.org/index.php/mod_sandclock.php
-# Copyright (C) 2002 CCGIS 
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-?>
-/**
- * Package: Sandclock
- *
- * Description:
- * Displays an arbitrary sandclock image on a map
- *
- * SQL:
- * > INSERT INTO gui_element (fkey_gui_id, e_id, e_pos, e_public, 
- * > e_comment, e_element, e_src, e_attributes, e_left, e_top, e_width, 
- * > e_height, e_z_index, e_more_styles, e_content, e_closeTag, e_js_file, 
- * > e_mb_mod, e_target, e_requires) VALUES ('<gui_id>', 'sandclock', '0002', 
- * > '1', 'displays a sand clock while waiting for requests', 'div', '', 
- * > '', '', '', '', '', '', '', '', 'div', 'mod_sandclock.php', '', 
- * > 'mapframe1', '');
- * > 
- * > INSERT INTO gui_element_vars (fkey_gui_id, fkey_e_id, var_name, 
- * > var_value, context, var_type) VALUES ('<gui_id>', 'sandclock', 
- * > 'mod_sandclock_image', '../img/sandclock.gif', 
- * > 'define a sandclock-image', 'var');
- * 
- * Maintainer:
- * http://www.mapbender.org/User:Christoph_Baudson
- * 
- * Parameters:
- * mod_sandclock_img - *[optional]* the filename and path to the sandclock image
- */
- 
-var Sandclock = function (options) {
-	var that = this;
-
-	//
-	// check if target is set correctly
-	//
-	if (!options.target) {
-		new Mb_Exception(this.id + "requires a target.");
-		return;
-	}
-	
-	if (!Mapbender.Modules[options.target]) {
-		new Mb_exception("Target " + options.target + " not found by " + this.id)
-	}
-	var map = Mapbender.Modules[options.target];
-	
-	//
-	// element vars
-	//
-	if (!options.mod_sandclock_image) {
-		options.mod_sandclock_image = "../img/sandclock.gif";
-	}
-
-	var mod_sandclock_img = new Image();
-	mod_sandclock_img.src = options.mod_sandclock_image;
-	
-	
-	//
-	// constructor
-	//
-	eventAfterMapRequest.register(function (obj) {
-		that.show(obj.myMapId);
-	});
-
-	var isInitialised = false;
-	
-	var aktiv;
-	
-	/** 
-	 * Method: show
-	 *
-	 * Displays the sandclock
-	 */
-	this.show = function (mapId) {
-		if (!isInitialised) {
-			var temp = "<img src='"+mod_sandclock_img.src+"'>";
-	
-			var map_el = map.getDomElement();
-			if(!map_el.ownerDocument.getElementById(map.elementName+"_sandclock")){
-				//create Box Elements
-				el_top = map_el.ownerDocument.createElement("div");
-				el_top.style.position = "absolute";
-				el_top.style.top = "0px";
-				el_top.style.left = "0px";
-				el_top.style.overflow = "hidden";
-				el_top.style.zIndex = "10";
-				el_top.style.visibility = "visible";
-				el_top.style.cursor = "crosshair";
-				el_top.id = map.elementName+"_sandclock";
-				map_el.appendChild(el_top);
-			}
-			writeTag(map.frameName, map.elementName+"_sandclock", temp);
-			mb_arrangeElement("", options.target+"_sandclock", (map.width/2 - 16), (map.height/2 - 16));
-			isInitialised = true;
-		}
-	
-		//
-		// if mapId is not given, the sandclock has to be turned off manually
-		// by calling hide(). Usually this is done in a callback 
-		// function.
-		//
-		if (typeof mapId !== "undefined") {
-			aktiv = setTimeout(function () {
-				that.show(mapId);
-			},10);
-			var mapIdArray = mapId.split(",");
-			var complete = true;
-			var mapId;
-			for (var i = 0; i < mapIdArray.length && complete; i++) {
-				mapId = mapIdArray[i];
-				var myDoc = map.getDomElement().ownerDocument;
-				if(myDoc.getElementById(mapId) && 
-					!myDoc.getElementById(mapId).complete) {
-					complete = false;
-				}
-			}
-			if (complete) {
-				clearTimeout(aktiv);
-				that.hide(map);
-			} 
-		}
-		
-	};
-	
-	/**
-	 * Method: hide
-	 *
-	 * Hides the sandclock
-	 */
-	this.hide = function () {
-		writeTag(map.frameName, map.elementName+"_sandclock", "");
-	};
-}
-
-var sandclock = new Sandclock(options);

Deleted: branches/print_dev/http/javascripts/mod_sandclock2.php
===================================================================
--- branches/print_dev/http/javascripts/mod_sandclock2.php	2009-08-04 11:47:46 UTC (rev 4470)
+++ branches/print_dev/http/javascripts/mod_sandclock2.php	2009-08-04 11:51:01 UTC (rev 4471)
@@ -1,72 +0,0 @@
-<?php
-# $Id$
-# http://www.mapbender.org/index.php/mod_sandclock2.php
-# Copyright (C) 2002 CCGIS 
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
-echo "var mod_sandclock_target = '".$e_target[0]."';";
-?>
-var mod_sandclock_maxWait = 1000 * 60;
-var mod_sandclock_minWait = 1000 * 0;
-
-var mod_sandclock_count;
-var mod_sandclock_img = new Image();
-mod_sandclock_img.src = "../img/sandclock.gif";
-mb_registerSubFunctions("mod_sandclock(true,myMapId)");
-
-
-function mod_sandclock(start){
-	var ind = getMapObjIndexByName(mod_sandclock_target);
-	if(start){  
-		mod_sandclock_count = mod_sandclock_maxWait; 
-		var temp = "<img src='"+mod_sandclock_img.src+"'>";
-		writeTag(mod_sandclock_target, "sandclock", temp);
-
-		mb_arrangeElement(mod_sandclock_target, "sandclock", (mb_mapObj[ind].width/2 - 16), (mb_mapObj[ind].height/2 - 16));
-
-		var dim = mod_sandclock_getWSize();
-		document.getElementById("sandclock2").style.width = dim[0];
-		document.getElementById("sandclock2").style.height = dim[1];
-	}
-
-	// check images:
-	aktiv = setTimeout("mod_sandclock(false)",100);
-	mod_sandclock_count -= 1000;
-
-	var allMaps = window.frames[mod_sandclock_target].document.getElementsByName("mapimage");
-	var cnt = 1;
-	for(var i=0; i<allMaps.length; i++){
-		if(allMaps[i].complete == true){
-			cnt++;
-		}         
-	}   
-	if((mod_sandclock_count <= 0 || cnt >= allMaps.length) && mod_sandclock_count < (mod_sandclock_maxWait - mod_sandclock_minWait)){
-		clearTimeout(aktiv);
-		writeTag(mod_sandclock_target, "sandclock", "");
-		document.getElementById("sandclock2").style.width = 1;
-		document.getElementById("sandclock2").style.height = 1;      
-	}
-}
-function mod_sandclock_getWSize(){
-	if(ie){
-		var dim = new Array(window.document.body.offsetWidth,  window.document.body.offsetHeight);
-	}
-	else{
-		var dim = new Array(window.innerWidth, window.innerHeight);
-	}
-	return dim;
-}
\ No newline at end of file

Deleted: branches/print_dev/http/javascripts/mod_scalebar.php
===================================================================
--- branches/print_dev/http/javascripts/mod_scalebar.php	2009-08-04 11:47:46 UTC (rev 4470)
+++ branches/print_dev/http/javascripts/mod_scalebar.php	2009-08-04 11:51:01 UTC (rev 4471)
@@ -1,105 +0,0 @@
-<?php
-# $Id$
-# http://www.mapbender.org/index.php/mod_scalebar.php
-# Copyright (C) 2002 CCGIS 
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-require_once(dirname(__FILE__)."/../php/mb_validatePermission.php");
-echo "var mod_scalebar_target = '".$e_target[0]."';";
-?>
-
-var mod_scalebar_left = 5;
-var mod_scalebar_bottom = 17;
-
-var mod_scalebar_color1 = "white";
-var mod_scalebar_color2 = "black";
-var mod_scalebar_font = "Arial, Helvetica, sans-serif";
-var mod_scalebar_fontsize = "9px";
-
-eventAfterMapRequest.register(function () {
-	mod_scalebar();
-});
-function mod_scalebar(){
-	var scale = mb_getScale(mod_scalebar_target);
-	var ind = getMapObjIndexByName(mod_scalebar_target);
-	if(scale < 10){
-		var unit = '10&nbsp;cm';
-		var factor = 10/scale;
-		var img_width = Math.round(factor * mb_resolution);
-	}
-	if(scale >= 10 && scale < 100){
-		var unit = '1&nbsp;m';
-		var factor = 100/scale;
-		var img_width = Math.round(factor * mb_resolution);
-	}
-	if(scale < 1000 && scale >= 100){
-		var unit = '10&nbsp;m';
-		var factor = 1000/scale;
-		var img_width = Math.round(factor * mb_resolution);
-	}
-	if(scale < 10000 && scale >= 1000){
-		var unit = '100&nbsp;m';
-		var factor = 10000/scale;
-		var img_width = Math.round(factor * mb_resolution);
-	}
-	if(scale < 100000 && scale >= 10000){
-		var unit = '1&nbsp;km';
-		var factor = 100000/scale;
-		var img_width = Math.round(factor * mb_resolution);
-	}
-	if(scale < 1000000 && scale >= 100000){
-		var unit = '10&nbsp;km';
-		var factor = 1000000/scale;
-	var img_width = Math.round(factor * mb_resolution);
-	}
-	if(scale < 10000000 && scale >= 1000000){
-		var unit = '100&nbsp;km';
-		var factor = 10000000/scale;
-		var img_width = Math.round(factor * mb_resolution);
-	}
-	if(scale < 100000000 && scale >= 10000000){
-		var unit = '1000&nbsp;km';
-		var factor = 100000000/scale;
-		var img_width = Math.round(factor * mb_resolution);
-	}
-	if(scale >= 100000000){
-		var unit = '1000&nbsp;km';
-		var factor = 100000000/scale;
-		var img_width = Math.round(factor * mb_resolution);
-	}
-	var scalebarTag = "<img src='../img/scalebar_bw.gif' width='"+ img_width  +"' height='6'>&nbsp; ";
-	scalebarTag += "<div style='position:absolute;left:"+(img_width + 4)+"px;top:5px;color:"+mod_scalebar_color1+";font-family:"+mod_scalebar_font+";font-size:"+mod_scalebar_fontsize+";'><nobr>"+ unit+"</nobr></div>";
-	scalebarTag += "<div style='position:absolute;left:"+(img_width + 2)+"px;top:7px;color:"+mod_scalebar_color1+";font-family:"+mod_scalebar_font+";font-size:"+mod_scalebar_fontsize+";'><nobr>"+ unit+"</nobr></div>";
-	scalebarTag += "<div style='position:absolute;left:"+(img_width + 2)+"px;top:5px;color:"+mod_scalebar_color1+";font-family:"+mod_scalebar_font+";font-size:"+mod_scalebar_fontsize+";'><nobr>"+ unit+"</nobr></div>";
-	scalebarTag += "<div style='position:absolute;left:"+(img_width + 3)+"px;top:6px;color:"+mod_scalebar_color2+";font-family:"+mod_scalebar_font+";font-size:"+mod_scalebar_fontsize+";'>"+ unit+"</div>";
-
-	var map_el = mb_mapObj[ind].getDomElement();
-	if(!map_el.ownerDocument.getElementById(mb_mapObj[ind].elementName+"_scalebar")){
-		//create Box Elements
-		el_top = map_el.ownerDocument.createElement("div");
-		el_top.style.position = "absolute";
-		el_top.style.top = "0px";
-		el_top.style.left = "0px";
-		el_top.style.width = "200px";
-		el_top.style.overflow = "hidden";
-		el_top.style.zIndex = "10";
-		el_top.id = mb_mapObj[ind].elementName+"_scalebar";
-		map_el.appendChild(el_top);
-	}
-	mb_arrangeElement("", mod_scalebar_target+"_scalebar", mod_scalebar_left, (mb_mapObj[ind].height - mod_scalebar_bottom));
-	writeTag(mb_mapObj[ind].frameName, mb_mapObj[ind].elementName+"_scalebar", scalebarTag);
-
-}
\ No newline at end of file

Deleted: branches/print_dev/http/javascripts/mod_zoomFull.php
===================================================================
--- branches/print_dev/http/javascripts/mod_zoomFull.php	2009-08-04 11:47:46 UTC (rev 4470)
+++ branches/print_dev/http/javascripts/mod_zoomFull.php	2009-08-04 11:51:01 UTC (rev 4471)
@@ -1,21 +0,0 @@
-<?php
-#$Id$
-#$Header: /cvsroot/mapbender/mapbender/http/javascripts/mod_zoomFull.php,v 1.8 2005/09/13 18:16:42 bjoern_heuser Exp $
-?>
-$(this).click(function () {
-	if (!options.target) {
-		return;
-	}
-	if (!Mapbender.Modules[options.target]) {
-		return;
-	}
-	Mapbender.Modules[options.target].zoomFull();
-}).mouseover(function () {
-	if (options.src) {
-		this.src = options.src.replace(/_off/, "_over");
-	}
-}).mouseout(function () {
-	if (options.src) {
-		this.src = options.src;
-	}
-});
\ No newline at end of file

Deleted: branches/print_dev/http/php/mod_map1.php
===================================================================
--- branches/print_dev/http/php/mod_map1.php	2009-08-04 11:47:46 UTC (rev 4470)
+++ branches/print_dev/http/php/mod_map1.php	2009-08-04 11:51:01 UTC (rev 4471)
@@ -1,150 +0,0 @@
-<?php
-# $Id$
-# http://www.mapbender.org/index.php/Administration
-# Copyright (C) 2002 CCGIS 
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
-?>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-<head>
-<meta http-equiv="cache-control" content="no-cache">
-<meta http-equiv="pragma" content="no-cache">
-<meta http-equiv="expires" content="0">
-<?php
-echo '<meta http-equiv="Content-Type" content="text/html; charset='.CHARSET.'">';	
-?>
-
-<title>mod_map1</title>
-<?php
-$sql = "SELECT e_width, e_height FROM gui_element WHERE e_id = 'mapframe1' AND fkey_gui_id = $1";
-$v = array($_SESSION["mb_user_gui"]);
-$t = array("s");
-$res = db_prep_query($sql, $v, $t);
-$cnt = 0;
-while($row = db_fetch_array($res)){
-   $e_width = $row["e_width"];
-   $e_height = $row["e_height"];
-   $cnt++;
-}
-session_write_close();
-if($cnt > 1){ echo "alert('mapframe1: ID not unique!');";}
-echo '<script type="text/javascript">';
-echo "\n";
-echo "var mod_map1_width = '".$e_width."';\n";
-echo "var mod_map1_height = '".$e_height."';\n";
-echo "</script>\n";
-?>
-<!--
-<script type='text/javascript' src='../extensions/jquery-1.2.6.min.js'></script>
-<script type='text/javascript' src='../extensions/jquery.mousewheel.min.js'></script>
-<script type='text/javascript' src='../extensions/jqjson.js'></script>
--->
-<script type="text/javascript">
-<!--
-
-var mapTimeout;
-var	sum_delta = 0;
-var lastTimestamp;
-var lastScrollPositionX;
-var lastScrollPositionY;
-
-function init () {
-	
-	parent.eventInitMap.register(function init_mod_map1(){
-		parent.mb_registerMapObj('mapframe1', 'mapframe1', null,mod_map1_width, mod_map1_height);
-		
-		if (!parent.$.browser.msie) {
-			
-			parent.$(document, window.frames['mapframe1']).mousewheel(function (event, delta) {
-				if (sum_delta == 0) {
-					mapTimeout = setTimeout(function () {
-							lastScrollPositionX=event.pageX;
-							lastScrollPositionY=event.pageY;
-							mousewheelZoom();	
-						}, 
-						100);
-				}
-				sum_delta = sum_delta + (delta);
-				var currentTime = new Date();
-				lastTimestamp = currentTime.getTime();
-				
-				return false;
-			});
-		}
-	});
-}
-
-function mousewheelZoom () {
-	var currentTime = new Date();
-
-	if (currentTime.getTime() - lastTimestamp > 200) {
-				
-		var ind = parent.getMapObjIndexByName('mapframe1');			
-		var pos = parent.makeClickPos2RealWorldPos("mapframe1", lastScrollPositionX, lastScrollPositionY);
-				
-		if (sum_delta > 0) {
-			parent.zoom("mapframe1", true, Math.pow(parent.Mapbender.zoomMousewheel, sum_delta), pos[0],pos[1]);
-		}
-		else {
-			parent.zoom("mapframe1", false, Math.pow(parent.Mapbender.zoomMousewheel, -sum_delta), pos[0], pos[1]);
-		}
-		
-		var newPosX =  parent.parent.mb_mapObj[ind].width - lastScrollPositionX;
-		var newPosY =  parent.parent.mb_mapObj[ind].height - lastScrollPositionY;
-				
-		var posAfterZoom = parent.makeClickPos2RealWorldPos("mapframe1", newPosX, newPosY);
-		parent.zoom('mapframe1', false, 1.0, posAfterZoom[0], posAfterZoom[1]); 
-		
-		sum_delta = 0;
-		clearTimeout(mapTimeout);
-	}
-	else {
-		mapTimeout = setTimeout(function () {
-				mousewheelZoom(sum_delta);	
-			}, 
-			100);
-	}
-}
-// -->
-</script>
-</head>
-<body leftmargin='0' topmargin='0' onload="init()" bgcolor='#ffffff'>
-<div id='mapframe1' name='mapframe1' style ='position: absolute; left: 0px; top: 0px; width: 0px; height: 0px; z-index:2;'>
-<div id='markResult' name='maps' style ='position: absolute; left: 0px; top: 0px; width: 0px; height: 0px; z-index:26'> </div>
-<div id='mapframe1_maps' name='maps' style ='position: absolute; left: 0px; top: 0px; width: 0px; height: 0px; z-index:2;'> </div>
-<div id='highlight' style="position:absolute;top:-10px;left:-10px;width:14px;height:14px;z-index:3;visibility:visible"><img src="../img/redball.gif"/></div>
-<div id='l_right' name='l_right' style="position:absolute;top:0px;left:0px;width:0px;height:0px;overflow:hidden;z-index:10;visibility:hidden;background-color:#ff0000;cursor: crosshair;"></div>
-<div id='l_bottom'  name='l_bottom' style="position:absolute;top:0px;left:0px;width:0px;height:0px;overflow:hidden;z-index:11;visibility:hidden;background-color:#ff0000;cursor: crosshair;"></div>
-<div id='l_left' name='l_left' style="position:absolute;top:0px;left:0px;width:0px;height:0px;overflow:hidden;z-index:12;visibility:hidden;background-color:#ff0000;cursor: crosshair;"></div>
-<div id='l_top' name='l_top' style="position:absolute;top:0px;left:0px;width:0px;height:0px;overflow:hidden;z-index:13;visibility:hidden;background-color:#ff0000;cursor: crosshair;"></div>
-<div id="sandclock" style="position:absolute; top:0px; left:0px; z-index:14;"></div>
-<div id="scalebar" style="position:absolute; top:0px; left:0px; z-index:15;"></div>
-<div id="measuring" style="position:absolute; top:0px; left:0px; z-index:16; font-size:10px"></div>
-<div id="measure_display" style="position:absolute; top:0px; left:0px; z-index:17;"></div>
-<div id="copyright" style="position:absolute; top:0px; left:0px; z-index:18;"></div>
-<div id="measure_sub" style="position:absolute; top:0px; left:0px; z-index:19;"></div>
-<div id='permanent' style="position:absolute;top:-10px;left:-10px;width:14px;height:14px;z-index:13;visibility:hidden"><img src="../img/redball.gif"/></div>
-<div id="digitize_sub" style="position:absolute; top:0px; left:0px; z-index:24;"></div>
-<div id="digitize_display" style="position:absolute; top:0px; left:0px; z-index:25;"></div>
-<div id='um_title' name='um_title' style="font-family: Arial, Helvetica, sans-serif; DISPLAY:none; OVERFLOW:visible; POSITION:absolute; DISPLAY:none; BACKGROUND:#BEC1C4;border:1px solid black; z-index:98;"></div>
-<div id='um_draw' name='um_draw' style="LEFT:0px;OVERFLOW:visible;POSITION:absolute;TOP:0px;z-index:99;"></div>
-<img id='um_img' name='um_img' style ='position: absolute; left: 0px; top: 0px; width: 0px; height: 0px; border:0;z-index:100' src='../img/transparent.gif' useMap='#um'>
-<map name='um' id='um'></map>
-</div>
-</body>
-</html>

Deleted: branches/print_dev/http/php/mod_mapOV.php
===================================================================
--- branches/print_dev/http/php/mod_mapOV.php	2009-08-04 11:47:46 UTC (rev 4470)
+++ branches/print_dev/http/php/mod_mapOV.php	2009-08-04 11:51:01 UTC (rev 4471)
@@ -1,149 +0,0 @@
-<?php
-# $Id$
-# http://www.mapbender.org/index.php/Administration
-# Copyright (C) 2002 CCGIS 
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
-
-if(isset($_REQUEST["wms"])){
-	$rank = $_REQUEST["wms"];
-}
-else{
-	$rank = 0;
-}
-?>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-
-<html>
-<head>
-<meta http-equiv="cache-control" content="no-cache">
-<meta http-equiv="pragma" content="no-cache">
-<meta http-equiv="expires" content="0">
-<?php
-echo '<meta http-equiv="Content-Type" content="text/html; charset='.CHARSET.'">';	
-?>
-<title>mod_mapOV0.php</title>
-<?php
-include '../include/dyn_css.php';
-?>
-<?php
-$gui_id = $_SESSION["mb_user_gui"];
-$sql = "SELECT e_width,e_height, e_target FROM gui_element WHERE e_id = 'overview' AND fkey_gui_id = $1";
-$v = array($gui_id);
-$t = array("s");
-$res = db_prep_query($sql, $v, $t);
-$cnt = 0;
-echo "<script type='text/javascript'>";
-while($row = db_fetch_array($res)){ 
-   echo "var mod_overview_width = " . $row["e_width"].";";
-   echo "var mod_overview_height = " . $row["e_height"].";";
-   echo "var mod_overview_target = '" . $row["e_target"]."';";
-   $cnt++;
-}
-echo "var mod_overview_rank = ".$rank.";";
-if($cnt > 1){ echo "alert('overview: ID not unique!');";}
-echo "</script>";
-?>
-<script type="text/javascript">
-<!--
-
-function init () {
-	parent.eventInitMap.register(function init_mod_mapOV(){
-		parent.mb_registerMapObj('overview', 'overview', mod_overview_rank, mod_overview_width, mod_overview_height);
-		document.onmouseover = mod_ov_setHandler;
-		document.onmousedown = parent.mod_box_start;
-		document.onmouseup = mod_ov_getExtent;
-		document.onmousemove = parent.mod_box_run;
-		
-		var ind = parent.getMapObjIndexByName('overview');
-		var ov_extent = parent.mb_mapObj[ind].getExtentInfos();
-		parent.mb_mapObj[ind].isOverview = true;
-	});
-}
-function mod_ov_setHandler(e){
-   parent.mb_isBF = "overview";
-   parent.mb_zF = mod_overview_target;
-}
-function mod_ov_getExtent(e){
-	mod_ov_setValidClipping(parent.mod_box_stop(e));
-}
-parent.mb_registerSubFunctions("window.frames['overview'].mod_ov_showMapExtent()");
-function mod_ov_showMapExtent(){
-	for(var i=0; i<parent.mb_mapObj.length; i++){
-		if(parent.mb_mapObj[i].frameName == mod_overview_target){
-			var arrayBBox = parent.mb_mapObj[i].extent.split(",");
-			var minX = parseFloat(arrayBBox[0]);
-			var minY = parseFloat(arrayBBox[1]);
-			var maxX = parseFloat(arrayBBox[2]);
-			var maxY = parseFloat(arrayBBox[3]);
-			var ind = parent.getMapObjIndexByName(mod_overview_target);
-			var pointMin = parent.mb_mapObj[ind].convertRealToPixel(new parent.Point(minX, maxY)); 
-			var pointMax = parent.mb_mapObj[ind].convertRealToPixel(new parent.Point(maxX, minY)); 
-			var px1 = pointMin.x;
-			var py1 = pointMin.y;
-			var px2 = pointMax.x;
-			var py2 = pointMax.y;
-
-		parent.mb_isBF = "overview";
-		parent.mb_zF = mod_overview_target;
-		while((px2 - px1) < 8){
-			px1 -= 1;
-			px2 += 1;
-		}
-		while((py2 - py1) < 8){
-			py1 -= 1;
-			py2 += 1;
-		}
-		if(px1 < 0){px1 = 1;}
-		if(px1 > mod_overview_width){px1 = mod_overview_width-1;}
-
-		if(py1 < 0){py1 = 1;}
-		if(py1 > mod_overview_height){py1 = mod_overview_height-1;}
-
-		if(px2 > mod_overview_width){px2 = mod_overview_width-1;}
-		if(px2 < 0){px2 = 1;}
-
-		if(py2 > mod_overview_height){py2 = mod_overview_height-1;}
-		if(py2 < 0){py2 = 1;}
-
-		parent.mb_drawBox(px1,py1,px2,py2);
-		}
-	}
-}
-function mod_ov_setValidClipping(coords){
-	if(coords.length > 2){
-		parent.mb_calculateExtent(parent.mb_zF,coords[0],coords[1],coords[2],coords[3]);
-		parent.setMapRequest(parent.mb_zF);
-	}
-	else{
-		parent.zoom(parent.mb_zF,true,1.0,coords[0], coords[1]);
-	}
-}
-// -->
-</script>
-</head>
-<body leftmargin='0' topmargin='0' onload="init()"  bgcolor='#ffffff'>
-<div id='overview' name='overview' style =' position:absolute;left:0px;top:0px;width:0px;height:0px;' >
-<div id='overview_maps' name='maps' style =' position:absolute;left:0px;top:0px;width:0px;height:0px;' ></div>
-<div id='l_top' name='l_top' style="position:absolute;top:0px;left:0px;width:0px;height:0px;overflow:hidden;z-index:11;visibility:hidden;background-color:red;cursor: crosshair;"></div>
-<div id='l_right' name='l_right' style="position:absolute;top:0px;left:0px;width:0px;height:0px;overflow:hidden;z-index:12;visibility:hidden;background-color:red;cursor: crosshair;"></div>
-<div id='l_bottom'  name='l_bottom' style="position:absolute;top:0px;left:0px;width:0px;height:0px;overflow:hidden;z-index:13;visibility:hidden;background-color:red;cursor: crosshair;"></div>
-<div id='l_left' name='l_left' style="position:absolute;top:0px;left:0px;width:0px;height:0px;overflow:hidden;z-index:14;visibility:hidden;background-color:red;cursor: crosshair;"></div>
-<div id='highlight' style="position:absolute;top:-10px;left:-10px;width:14px;height:14px;z-index:3;visibility:visible"><img src="../img/redball.gif" width="14" height="14" /></div>
-</div>
-</body>
-</html>

Added: branches/print_dev/http/print/mod_printPDF_div.js
===================================================================
--- branches/print_dev/http/print/mod_printPDF_div.js	                        (rev 0)
+++ branches/print_dev/http/print/mod_printPDF_div.js	2009-08-04 11:51:01 UTC (rev 4471)
@@ -0,0 +1,271 @@
+var myTarget = options.target;
+var myId = options.id;
+
+/* the array of json print config files */
+if (!options.mbPrintConfigFilenames)
+	mbPrintConfigFilenames = new Array("testConfigTemplate.json");
+else
+	mbPrintConfigFilenames = options.mbPrintConfigFilenames;
+
+if (!options.mbPrintConfigTitles)
+	mbPrintConfigTitles = new Array("Default");
+else
+	mbPrintConfigTitles = options.mbPrintConfigTitles
+
+if (!options.mbPrintConfigPath)
+	mbPrintConfigPath = "../print/";
+else
+	mbPrintConfigPath = options.mbPrintConfigPath;
+
+
+/* ------------- printbox addition ------------- */
+var printBox;
+
+var PrintPDF = function (options) {
+
+var that = this;
+
+eventInit.register(function () {
+	mod_printPDF_init();
+});
+
+this.createPrintBox = function () {
+	size = "A4";
+	//document.form1.size.value = size;
+	format = "portrait";
+	var w, h;
+	//validate();
+	var map = Mapbender.modules[myTarget];
+	var map_el = map.getDomElement();
+	var jqForm = $("#"+myId+"_form");
+	printBox = createBox({
+		target : myTarget,
+		width : w/mb_resolution,
+		height : h/mb_resolution,
+		scale : Math.pow(10, Math.floor(Math.log(map.getScale())/Math.LN10)),
+		afterChangeAngle : function (obj) {
+			if (typeof(obj) == "object") {
+				if (typeof(obj.angle) == "number") {
+					jqForm[0].angle.value = obj.angle;
+				}
+				if (obj.coordinates) {
+					jqForm[0].coordinates.value = String(obj.coordinates);
+				}
+			}
+		},
+		afterChangeSize : function (obj) {
+			if (typeof(obj) == "object") {
+				if (obj.scale) {
+					jqForm[0].scale.value = obj.scale;
+				}
+				if (obj.coordinates) {
+					jqForm[0].coordinates.value = String(obj.coordinates);
+				}
+			}
+		}
+	});
+	
+	eventAfterMapRequest.register(function () {
+		if (typeof(printBox) !== "undefined") {
+			printBox.repaint();
+		}
+	});
+};
+
+var destroyPrintBox = function () {
+	if (printBox) {
+		printBox.destroy();
+	}
+};
+/* ------------- printbox addition -------------*/
+
+
+var mod_printPDF_init = function () {
+	/* first we'd need to build the configuration selection */
+	buildConfigSelector();	
+	/* second we'd need to read the json configuration */
+	that.loadConfig(mbPrintConfigFilenames[0]);
+};
+
+this.loadConfig = function (configFilename) {
+	$.get(mbPrintConfigPath + configFilename, function(json, status){
+	    var obj = eval('(' + json + ')');
+	    buildForm(obj); 
+	    hookForm();
+	});
+};
+
+var hookForm = function () {
+	var options = { 
+   		url:			'../print/printFactory.php', 
+   		type:			'post',
+   		dataType:		'json',
+   		beforeSubmit: 	validate,
+   		success:    	showResult
+	};
+	$("#"+myId+"_form").ajaxForm(options);	
+};
+
+/**
+ * Change status of the working elements. These should begin with "$myId_working" 
+ *
+ * @param {String} newStatus either "hide or "show"
+ */
+var showHideWorking = function (newStatus) {
+	if (newStatus=="hide")
+    	$("[id^='"+myId+"_working']").hide();
+    else
+    	$("[id^='"+myId+"_working']").show();	
+};
+
+/**
+ * update form values helper function
+ *
+ */
+var updateFormField = function (formData, key, value) {
+	for(var j=0; j < formData.length; j++){
+		if (formData[j].name == key) {
+			formData[j].value = value;
+			break;
+		}
+	}	
+};
+
+
+/**
+ * Validates and updates form data values.
+ * Adds the elements before the submit button.
+ *
+ * @see jquery.forms#beforeSubmitHandler
+ */
+var validate = function (formData, jqForm, options) {
+	showHideWorking("show");
+	var ind = getMapObjIndexByName(myTarget);
+	var f = jqForm[0];
+	f.map_url.value = '';
+	f.overview_url.value = '';
+	for(var i=0; i < mb_mapObj[ind].wms.length; i++){
+		if(mb_mapObj[ind].wms[i].gui_wms_visible > 0){
+			if(mb_mapObj[ind].wms[i].mapURL != false && mb_mapObj[ind].wms[i].mapURL != 'false' && mb_mapObj[ind].wms[i].mapURL != ''){   
+				if(f.map_url.value != ""){
+					f.map_url.value += '___';
+				}      
+				f.map_url.value += mb_mapObj[ind].wms[i].mapURL;
+			}
+		}
+	}
+	updateFormField(formData, "map_url", f.map_url.value);
+	
+	//overview_url
+	var ind_overview = getMapObjIndexByName('overview');
+	if(mb_mapObj[ind_overview].mapURL != false ){
+	    f.overview_url.value = mb_mapObj[ind_overview].mapURL;
+		updateFormField(formData, "overview_url", f.overview_url.value);
+	}
+	
+	updateFormField(formData, "map_scale", mb_getScale(myTarget));
+	// write the measured coordinates
+	if (typeof(mod_measure_RX) !== "undefined") {
+		var tmp_x = '';
+		var tmp_y = '';
+		for(i = 0; i < mod_measure_RX.length; i++) {
+			if(tmp_x != '') {
+				tmp_x += ','
+			}
+			tmp_x += mod_measure_RX[i];
+		}
+		for(i = 0; i < mod_measure_RY.length; i++) {
+			if(tmp_y != '') {
+				tmp_y += ','
+			}
+			tmp_y += mod_measure_RY[i];
+		}
+		updateFormField(formData, "measured_x_values", tmp_x);
+		updateFormField(formData, "measured_y_values", tmp_y);
+	}	
+	
+	
+	if (f.map_url.value!="") {
+		//return true;
+	} else {
+	    showHideWorking("hide");
+		return false;
+	}
+		
+};
+
+var showResult = function (res, text) {
+	if (text == 'success') {
+		window.location = stripslashes(res.outputFileName);
+		showHideWorking("hide");	
+	}
+	else {
+		/* something went wrong */
+		$("#"+myId+"_result").html(text);
+	}
+};
+
+/**
+ * Generates form elements as specified in the config controls object.
+ * Adds the elements before the submit button.
+ * 
+ * @param {Object} json the config object in json
+ */
+var buildForm = function (json) {
+	$(".print_option_dyn").remove();
+	var str = "";
+	for (var item in json.controls) {
+		var element = json.controls[item];
+		var element_id = myId + "_" + element.id;
+		if (element.type != "hidden") {
+			str += '<div class="print_option_dyn">\n';	
+			str += '<label class="print_label" for="'+element.id+'">'+element.label+'</label>\n';
+		} else {
+			str += '<div class="print_option_dyn" style="display:none;">\n';	
+		}
+		switch (element.type) {
+			case "text":
+				str += '<input type="'+element.type+'" name="'+element.id+'" id="'+element.id+'" size="'+element.size+'"><br>\n';
+				break;
+			case "hidden":
+				str += '<input type="'+element.type+'" name="'+element.id+'" id="'+element.id+'">\n';
+				break;				
+			case "textarea":
+				str += '<textarea id="'+element.id+'" name="'+element.id+'" size="'+element.size+'"></textarea><br>\n';
+				break;				
+			case "select":
+				str += '<select id="'+element.id+'" name="'+element.id+'" size="1">\n';
+				for (var option_index in element.options) {
+					option = element.options[option_index];
+					str += '<option value="'+option.value+'">'+option.label+'</option>\n';
+				}
+				str += '</select><br>\n';
+				break;
+		}
+		str += '</div>\n';
+	}
+	if (str) $("#"+myId+"_formsubmit").before(str);
+};
+
+/**
+ * Generates the configuration select element from the gui element vars
+ * mbPrintConfigFilenames and mbPrintConfigTitles
+ */
+var buildConfigSelector = function () {
+	var str = "";
+	str += '<label class="print_label" for="printPDF_template">Vorlage</label>\n';
+	str += '<select id="printPDF_template" name="printPDF_template" size="1" onchange="Mapbender.modules[\''+myId+'\'].loadConfig(mbPrintConfigFilenames[this.selectedIndex]);">\n';
+	for (var i = 0; i < mbPrintConfigFilenames.length; i++) {
+		str += '<option value="'+mbPrintConfigFilenames[i]+'">'+mbPrintConfigTitles[i]+'</option>\n';
+	}
+	str += '</select><a href="#" onclick="Mapbender.modules[\''+myId+'\'].createPrintBox();return false;">o</a><br />\n';
+	if (str) $("#printPDF_selector").append(str);
+};
+
+var stripslashes = function ( str ) {
+    return (str+'').replace(/\0/g, '0').replace(/\\([\\'"])/g, '$1');
+};
+
+}
+
+$.extend(Mapbender.modules[options.id], new PrintPDF(options));
\ No newline at end of file

Modified: branches/print_dev/http/print/mod_printPDF_div.php
===================================================================
--- branches/print_dev/http/print/mod_printPDF_div.php	2009-08-04 11:47:46 UTC (rev 4470)
+++ branches/print_dev/http/print/mod_printPDF_div.php	2009-08-04 11:51:01 UTC (rev 4471)
@@ -53,6 +53,60 @@
 	mod_printPDF_init();
 });
 
+/* ------------- printbox addition ------------- */
+var printBox;
+
+function createPrintBox () {
+	size = "A4";
+	//document.form1.size.value = size;
+	format = "portrait";
+	var w, h;
+	//validate();
+	var map = Mapbender.modules[myTarget];
+	var map_el = map.getDomElement();
+	var jqForm = $("#"+myId+"_form");
+	printBox = createBox({
+		target : myTarget,
+		width : w/mb_resolution,
+		height : h/mb_resolution,
+		scale : Math.pow(10, Math.floor(Math.log(map.getScale())/Math.LN10)),
+		afterChangeAngle : function (obj) {
+			if (typeof(obj) == "object") {
+				if (typeof(obj.angle) == "number") {
+					jqForm[0].angle.value = obj.angle;
+				}
+				if (obj.coordinates) {
+					jqForm[0].coordinates.value = String(obj.coordinates);
+				}
+			}
+		},
+		afterChangeSize : function (obj) {
+			if (typeof(obj) == "object") {
+				if (obj.scale) {
+					jqForm[0].scale.value = obj.scale;
+				}
+				if (obj.coordinates) {
+					jqForm[0].coordinates.value = String(obj.coordinates);
+				}
+			}
+		}
+	});
+	
+	eventAfterMapRequest.register(function () {
+		if (typeof(printBox) !== "undefined") {
+			printBox.repaint();
+		}
+	});
+}
+
+function destroyPrintBox () {
+	if (printBox) {
+		printBox.destroy();
+	}
+}
+/* ------------- printbox addition -------------*/
+
+
 function mod_printPDF_init() {
 	/* first we'd need to build the configuration selection */
 	buildConfigSelector();	
@@ -132,12 +186,13 @@
 	//overview_url
 	var ind_overview = getMapObjIndexByName('overview');
 	if(mb_mapObj[ind_overview].mapURL != false ){
-		updateFormField(formData, "overview_url", mb_mapObj[ind_overview].mapURL);
+	    f.overview_url.value = mb_mapObj[ind_overview].mapURL;
+		updateFormField(formData, "overview_url", f.overview_url.value);
 	}
 	
 	updateFormField(formData, "map_scale", mb_getScale(myTarget));
 	// write the measured coordinates
-	if (mod_measure_RX != undefined && mod_measure_RY != undefined) {
+	if (typeof(mod_measure_RX) !== "undefined") {
 		var tmp_x = '';
 		var tmp_y = '';
 		for(i = 0; i < mod_measure_RX.length; i++) {
@@ -158,7 +213,7 @@
 	
 	
 	if (f.map_url.value!="") {
-		return true;
+		//return true;
 	} else {
 	    showHideWorking("hide");
 		return false;
@@ -198,7 +253,7 @@
 				str += '<input type="'+element.type+'" name="'+element.id+'" id="'+element.id+'" size="'+element.size+'"><br>\n';
 				break;
 			case "hidden":
-				str += '<input type="'+element.type+'" name="'+element.id+'" id="'+element.id+'"><br>\n';
+				str += '<input type="'+element.type+'" name="'+element.id+'" id="'+element.id+'">\n';
 				break;				
 			case "textarea":
 				str += '<textarea id="'+element.id+'" name="'+element.id+'" size="'+element.size+'"></textarea><br>\n';
@@ -228,7 +283,7 @@
 	for (var i = 0; i < mbPrintConfigFilenames.length; i++) {
 		str += '<option value="'+mbPrintConfigFilenames[i]+'">'+mbPrintConfigTitles[i]+'</option>\n';
 	}
-	str += '</select><br />\n';
+	str += '</select><a href="#" onclick="createPrintBox();return false;">o</a><br />\n';
 	if (str) $("#printPDF_selector").append(str);
 }
 

Modified: branches/print_dev/http/print/print_functions.php
===================================================================
--- branches/print_dev/http/print/print_functions.php	2009-08-04 11:47:46 UTC (rev 4470)
+++ branches/print_dev/http/print/print_functions.php	2009-08-04 11:51:01 UTC (rev 4471)
@@ -1,381 +1,377 @@
-<?php
-/**
- * $Id$
- * 
- * converts the coordinates created via the JavaScript
- * functions in 'mod_measure.php' into an array which 
- * then holds both X- ans Y-values for each point in
- * the formats 'realworld coordinate' and 'pdf_coordinate' 
- * 
- * @param string commaseperated X-values of the points (realworld coordinate)
- * @param string commaseperated Y-values of the points (realworld coordinate)
- * 
- * @return array Array looking like 0 => array(
- *                                         'real_x' => 1234567,
- *                                         'real_y' => 7654321,
- *                                         'pdf_x'  => 451.12,
- *                                         'pdf_y'  => 254.7          
- *                                       )
- * 
- * @see transformForPDF
- *
- * @author M. Jansen <jansen at terrestris.de>, 2006-05-26
- */
-function makeCoordPairs($x_values, $y_values) {
-  $arr_x = explode(",", $x_values);
-	$arr_y = explode(",", $y_values);
-	$x_elems = count($arr_x);
-	$y_elems = count($arr_y);
-	
-	$the_return_arr = array();
-	
-	if ($x_elems == $y_elems) {
-	  for ($i = 0; $i < $x_elems; $i ++) {
-		  $the_return_arr[$i] = array(
-			                        "real_x" => $arr_x[$i],
-															"real_y" => $arr_y[$i],
-															"pdf_x"  => transformForPDF($arr_x[$i], "x"),
-															"pdf_y"  => transformForPDF($arr_y[$i], "y")
-															);
-		}
-	}
-	
-	return $the_return_arr;
-} // end of function makeCoordPairs
-
-
-
-/**
- * Transforms given realworld-coordinate according to its type (X or Y) 
- * into a pdf-coordinate. Needs the variables $mapOffset_left, $mapOffset_bottom,
- * $map_height, $map_width, $coord to be defined in a global scope.
- *
- * @param float the realworld coordinate
- * @param string type of coordinate either 'X' or 'Y'
- *   
- * @see makeCoordPairs [needs this function]
- *
- * @return float the pdf-coordinate
- *
- * @author M. Jansen <jansen at terrestris.de>, 2006-05-26
- */
-function transformForPDF ($theRealCoord, $theType) {
-  global $mapOffset_left, $mapOffset_bottom, $map_height, $map_width, $coord;
-  global $yAxisOrientation;
-	
-	$thePDFvalue = "";
-	
-	switch (mb_strtolower($theType)) {
-	  case 'x':
-		  // calculate pdf x-pos:
-			$real_shown_width = $coord[2] - $coord[0];
-			$ratio_to_display = $map_width / $real_shown_width;
-			$target_width     = $theRealCoord - $coord[0];
-			$thePDFvalue      = $mapOffset_left + ($target_width * $ratio_to_display);
-			break;
-		case 'y':
-		  // calculate pdf y-pos:
-			$real_shown_height = $coord[3] - $coord[1];
-			$ratio_to_display  = $map_height / $real_shown_height;
-			$target_height     = $theRealCoord - $coord[1];
-			if (isset($yAxisOrientation) && $yAxisOrientation==1)
-				$thePDFvalue   = $map_height + $mapOffset_bottom - ($target_height * $ratio_to_display);
-			else	
-				$thePDFvalue   = $mapOffset_bottom + ($target_height * $ratio_to_display);
-		  break;
-		default:
-		  // a non valid parameter was given
-		  $thePDFvalue = $theRealCoord;
-      break;
-	}
-	return $thePDFvalue;
-} // end of function transformForPDF
-
-
-
-
-/**
- * extracts PDF-relevant information from a full coordinates array 
- * and returns a transformed array
- * 
- * @param array the Array containing all infos about single coordinates
- *              created via makeCoordPairs()
- * 
- * @return array the array containing PDF-Values for a polygon
- *
- * @see makeCoordPairs
- *
- * @author M. Jansen <jansen at terrestris.de>, 2006-05-26
- */
-function makePolyFromCoord($theFullCoordinatesArray) {
-  $theRetArr = array();
-	foreach($theFullCoordinatesArray as $singlePoint) {
-	  $theRetArr[] = $singlePoint['pdf_x'];
-		$theRetArr[] = $singlePoint['pdf_y'];
-	}
-	return $theRetArr;
-} // end of function makePolyFromCoord
-
-
-
-
-/**
- * converts an array of coordinates (created e.g. by makeCoordPairs()) into
- * an array thats needed to draw lines via line(x0, y0, x1, y1)
- *
- * @param array the Array containing all infos about single coordinates
- *              created via makeCoordPairs()
- * 
- * @return array the array containing PDF-Values for single lines
- *
- * @see makeCoordPairs
- *
- * @author M. Jansen <jansen at terrestris.de>, 2006-05-26
- */
-function makeStrokePointPairs($thePointArray) {
-  $cnt = count($thePointArray);
-	$theRetArray = array();
-  for($i = 0; $i < $cnt; $i++) {
-	  if($i != $cnt - 1) {
-		  $theRetArray[] = array(
-		    $thePointArray[$i]['pdf_x'],
-				$thePointArray[$i]['pdf_y'],
-				$thePointArray[$i+1]['pdf_x'],
-				$thePointArray[$i+1]['pdf_y'],
-				);
-		} else {
-		  $theRetArray[] = array(
-		    $thePointArray[$i]['pdf_x'],
-				$thePointArray[$i]['pdf_y'],
-				$thePointArray[0]['pdf_x'],
-				$thePointArray[0]['pdf_y'],
-				);
-		}
-	}
-	return $theRetArray;
-} // end of function makeStrokePointPairs
-
-
-
-
-/**
- * test whether the coordinates in an array form a closed polygon
- * meaning that first an last point of polygon are equal
- *
- * @param array the Array containing all infos about single coordinates
- *              created via makeCoordPairs()
- * 
- * @return bool is it closed (TRUE || FALSE)
- *
- * @see makeCoordPairs
- *
- * @author M. Jansen <jansen at terrestris.de>, 2006-05-26
- */
-function isClosedPolygon($coord_arr) {
-  $nr_of = count($coord_arr);
-	if ($coord_arr[0]['pdf_x'] == $coord_arr[$nr_of-1]['pdf_x']
-	    && $coord_arr[0]['pdf_y'] == $coord_arr[$nr_of-1]['pdf_y']
-			&& $nr_of != 1) {
-	  return TRUE; 
-	} else {
-	  return FALSE;
-	}
-}  // end of function isClosedPolygon
-
-
-
-
-/**
- * Adds the measured item to the PDF output.
- * 
- * @param object reference (!) to the current ezPDF-Object
- * @param string commaseperated X-Values of polygon / line
- * @param string commaseperated Y-Values of polygon / line
- * @param array configuration settings.
- *
- * @return void nothing
- *
- * @see makeCoordPairs
- * @see isClosedPolygon
- * @see makeStrokePointPairs
- * @see makePolyFromCoord
- * @see transformForPDF
- * @see makeCoordPairs
- *
- * @author M. Jansen <jansen at terrestris.de>, 2006-05-26
- */
-function addMeasuredItem($thePDF, $x_value_str, $y_value_str, $theConfArray = array()) {
-  // get global variable:
-  global $legendFilenameUserPolygon;
-	// create legend image:
-	$legend_width = 17;
-	$leg_img = imagecreate($legend_width, $legend_width);
-	// save previous state:
-	$thePDF->saveState();
-	
-	// save colors for legend:
-	if(!defined("MAP_HAS_USER_POLYGON")) {
-	  define("MAP_HAS_USER_POLYGON", "test");
-	}
-
-	// get the arrays
-	$theFullArr = makeCoordPairs($x_value_str, $y_value_str);
-    $thePolyArr = makePolyFromCoord($theFullArr);
-	
-	if (isClosedPolygon($theFullArr)) {
-		$isClosed = TRUE;
-	} 
-	else {
-		$isClosed = FALSE;
-	}
-	$nr_of_points = count($theFullArr);
-	
-	// is fill option set?
-	// wenn der erste und letzte punkt nicht �bereinstimmen,
-	// so muss in jedem Falle dofill auf 0 gesetzt werden
-	if($theConfArray['do_fill'] != '' && $isClosed) {
-	  $doFill = 1;
-	  // which color to use for filling?
-	  if (is_array($theConfArray['fill_color']) 
-	      && $theConfArray['fill_color']['r'] != ''
-			  && $theConfArray['fill_color']['g'] != ''
-			  && $theConfArray['fill_color']['b'] != '') {
-	    $thePDF->setColor($theConfArray['fill_color']['r'], $theConfArray['fill_color']['g'], $theConfArray['fill_color']['b']);
-			$legend_image_fill = $theConfArray['fill_color']['r'] . "," . $theConfArray['fill_color']['g'] . "," . $theConfArray['fill_color']['b'];
-			// color to legend file
-			$bg_color = imagecolorallocate($leg_img, round($theConfArray['fill_color']['r'] * 255), round($theConfArray['fill_color']['g'] * 255), round($theConfArray['fill_color']['b'] * 255));
-	  } else {
-	    $thePDF->setColor(0, 0, 0);
-			// color to legend file
-			$bg_color = imagecolorallocate($leg_img, 0, 0, 0);
-	  }
-	} else {
-	  $doFill = 0;
-		// color to legend file
-	  $bg_color = imagecolorallocate($leg_img, -1, -1, -1);
-	}
-	
-	// Do we need to stroke (outline)?
-	if($theConfArray['do_stroke'] != '') {
-	  // which color to use for filling?
-	  if (is_array($theConfArray['stroke_color']) 
-	      && $theConfArray['stroke_color']['r'] != ''
-			  && $theConfArray['stroke_color']['g'] != ''
-			  && $theConfArray['stroke_color']['b'] != '') {
-	    $thePDF->setStrokeColor($theConfArray['stroke_color']['r'], $theConfArray['stroke_color']['g'], $theConfArray['stroke_color']['b']);
-			$thePDF->setLineStyle($theConfArray['line_style']['width'], $theConfArray['line_style']['cap'], $theConfArray['line_style']['join'], $theConfArray['line_style']['dash']);
-			$theStrokePointPairs = makeStrokePointPairs($theFullArr);
-			for($i = 0; $i < count($theStrokePointPairs); $i++) {
-			  $line = $theStrokePointPairs[$i];
-				if ($i != count($theStrokePointPairs) - 1
-				    || $isClosed) {
-			    $thePDF->line($line[0], $line[1], $line[2], $line[3]);
-					
-					$stroke_color_legend_image = imagecolorallocate($leg_img, round($theConfArray['stroke_color']['r'] * 255), round($theConfArray['stroke_color']['g'] * 255), round($theConfArray['stroke_color']['b'] * 255));
-					if (is_array($theConfArray['line_style']['dash'])
-					    && $theConfArray['line_style']['dash'][1] != ""
-							&& $theConfArray['line_style']['dash'][1] != 0) {
-						imagedashedline($leg_img, 0, 0, $legend_width-1, 0, $stroke_color_legend_image);
-						imagedashedline($leg_img, $legend_width-1, 1, $legend_width-1, $legend_width-1, $stroke_color_legend_image);
-						imagedashedline($leg_img, 0, 0, 0, $legend_width-1, $stroke_color_legend_image);
-						imagedashedline($leg_img, 0, $legend_width-1, $legend_width-1,$legend_width-1, $stroke_color_legend_image);
-					} else {
-					  imageline($leg_img, 0, 0, $legend_width-1, 0, $stroke_color_legend_image);
-						imageline($leg_img, $legend_width-1, 0, $legend_width-1, $legend_width-1, $stroke_color_legend_image);
-						imageline($leg_img, $legend_width-1, $legend_width-1, 0, $legend_width-1, $stroke_color_legend_image);
-						imageline($leg_img, 0, $legend_width-1, 0, 0, $stroke_color_legend_image);
-					}		
-				} 
-			}
-	  } 
-	}
-	
-  $thePDF->polygon($thePolyArr, $nr_of_points, $doFill);
-  // eventually create the file:
-	imagepng($leg_img, $legendFilenameUserPolygon);
-	
-	$thePDF->restoreState();
-} // end of function addMeasuredItem
-
-/**
- * Konvertiert einen Text in ein array aus einzelnen Zeilen. Parameter wie Zeichen pro
- * zeile etc. k�nnen in der Funktion ge�ndert werden.
- */
-function convert2lines($the_text) {
-    $words = explode(' ', $the_text);
-	$maxlines                 = 6;
-	$available_chars_per_line = 35;
-	$total_number_of_lines    = 0;
-	$chars_current_line       = 0;
-	$the_return_array         = array();
-
-    foreach($words as $word) {
-    	// trimme wort auf maximal erlaubte zeichenzahl
-        $word_fit = mb_substr($word, 0, $available_chars_per_line);
-	    $chars = preg_split('//', $word_fit, -1, PREG_SPLIT_NO_EMPTY);
-	    
-	    if(count($chars) + $chars_current_line + 1 < $available_chars_per_line && $total_number_of_lines < $maxlines) {
-		    $chars_current_line += count($chars) + 1;
-			$the_return_array[$total_number_of_lines]  .= " " . $word_fit;
-		} elseif($total_number_of_lines < $maxlines) {
-	      $chars_current_line = count($chars) + 1;
-		  $the_return_array[$total_number_of_lines + 1] = " " . $word_fit;
-		  $total_number_of_lines++;
-		}
-	}
-  return $the_return_array;
-} // end of function convert2lines
-
-/**
- * Adds two white polygons to hide any user elements outside the mapframe:
- * First all A-Areas are filled, then all B-Areas. This is a rather grumpy
- * way out of having user edited stuff flying outside the mapframe.
- * 
- * @example <pre>
- * BBBBBBBBBBBBBBBBBBBBBBBBBBBBAAA
- * BBBBBBBBBBBBBBBBBBBBBBBBBBBBAAA
- * BBB                                                  AAA
- * BBB                                                  AAA
- * BBB       Mapframe                              AAA
- * BBB                                                  AAA
- * BBB                                                  AAA
- * BBB                                                  AAA
- * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
- * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
- * </pre>
- * 
- * @param reference (!, pass over with '&') to the pdf-file
- * @author M. Jansen <jansen at terrestris.de>
- */
-function hideElementsOutsideMapframe($pdf) {
-  // get globals
-  global $mapOffset_left, $map_width, $mapOffset_bottom, $map_height;
-  $pdf->saveState();
-  $pdf->setColor(1, 1, 1);
-	// The AAA-Part
-  $allOutside = array(
-    0                              , 0,                       // 1st coord-pair
-    $pdf->ez['pageWidth']          , 0,                       // 2nd coord-pair
-    $pdf->ez['pageWidth']          , $pdf->ez['pageHeight'],  // ...
-    $mapOffset_left + $map_width   , $pdf->ez['pageHeight'],
-    $mapOffset_left + $map_width   , $mapOffset_bottom,
-    0                              , $mapOffset_bottom,
-    0                              , 0
-  );
-	// draw polygon
-  $pdf->polygon($allOutside, 7, 1);    
-  // The BBB-part
-  $allOutside = array(
-    0                              , $mapOffset_bottom,       // 1st coord-pair
-    $mapOffset_left                , $mapOffset_bottom,       // 2nd coord-pair
-    $mapOffset_left                , $mapOffset_bottom + $map_height, // ...
-    $mapOffset_left + $map_width   , $mapOffset_bottom + $map_height,
-    $mapOffset_left + $map_width   , $pdf->ez['pageHeight'],
-    0                              , $pdf->ez['pageHeight'],
-    0                              , $mapOffset_bottom,  
-  );
-	// draw polygon
-  $pdf->polygon($allOutside, 7, 1);
-  $pdf->restoreState();
-}
+<?php
+/**
+ * $Id$
+ * 
+ * converts the coordinates created via the JavaScript
+ * functions in 'mod_measure.php' into an array which 
+ * then holds both X- ans Y-values for each point in
+ * the formats 'realworld coordinate' and 'pdf_coordinate' 
+ * 
+ * @param string commaseperated X-values of the points (realworld coordinate)
+ * @param string commaseperated Y-values of the points (realworld coordinate)
+ * 
+ * @return array Array looking like 0 => array(
+ *                                         'real_x' => 1234567,
+ *                                         'real_y' => 7654321,
+ *                                         'pdf_x'  => 451.12,
+ *                                         'pdf_y'  => 254.7          
+ *                                       )
+ * 
+ * @see transformForPDF
+ *
+ * @author M. Jansen <jansen at terrestris.de>, 2006-05-26
+ */
+function makeCoordPairs($x_values, $y_values) {
+  $arr_x = explode(",", $x_values);
+	$arr_y = explode(",", $y_values);
+	$x_elems = count($arr_x);
+	$y_elems = count($arr_y);
+	
+	$the_return_arr = array();
+	
+	if ($x_elems == $y_elems) {
+	  for ($i = 0; $i < $x_elems; $i ++) {
+		  $the_return_arr[$i] = array(
+			                        "real_x" => $arr_x[$i],
+															"real_y" => $arr_y[$i],
+															"pdf_x"  => transformForPDF($arr_x[$i], "x"),
+															"pdf_y"  => transformForPDF($arr_y[$i], "y")
+															);
+		}
+	}
+	
+	return $the_return_arr;
+} // end of function makeCoordPairs
+
+
+
+/**
+ * Transforms given realworld-coordinate according to its type (X or Y) 
+ * into a pdf-coordinate. Needs the variables $mapOffset_left, $mapOffset_bottom,
+ * $map_height, $map_width, $coord to be defined in a global scope.
+ *
+ * @param float the realworld coordinate
+ * @param string type of coordinate either 'X' or 'Y'
+ *   
+ * @see makeCoordPairs [needs this function]
+ *
+ * @return float the pdf-coordinate
+ *
+ * @author M. Jansen <jansen at terrestris.de>, 2006-05-26
+ */
+function transformForPDF ($theRealCoord, $theType) {
+  global $mapOffset_left, $mapOffset_bottom, $map_height, $map_width, $coord;
+	
+	$thePDFvalue = "";
+	
+	switch (mb_strtolower($theType)) {
+	  case 'x':
+		  // calculate pdf x-pos:
+			$real_shown_width = $coord[2] - $coord[0];
+			$ratio_to_display = $map_width / $real_shown_width;
+			$target_width     = $theRealCoord - $coord[0];
+			$thePDFvalue      = $mapOffset_left + ($target_width * $ratio_to_display);
+			break;
+		case 'y':
+		  // calculate pdf y-pos:
+			$real_shown_height = $coord[3] - $coord[1];
+			$ratio_to_display  = $map_height / $real_shown_height;
+			$target_height     = $theRealCoord - $coord[1];
+			$thePDFvalue       = $mapOffset_bottom + ($target_height * $ratio_to_display);
+		  break;
+		default:
+		  // a non valid parameter was given
+		  $thePDFvalue = $theRealCoord;
+      break;
+	}
+	return $thePDFvalue;
+} // end of function transformForPDF
+
+
+
+
+/**
+ * extracts PDF-relevant information from a full coordinates array 
+ * and returns a transformed array
+ * 
+ * @param array the Array containing all infos about single coordinates
+ *              created via makeCoordPairs()
+ * 
+ * @return array the array containing PDF-Values for a polygon
+ *
+ * @see makeCoordPairs
+ *
+ * @author M. Jansen <jansen at terrestris.de>, 2006-05-26
+ */
+function makePolyFromCoord($theFullCoordinatesArray) {
+  $theRetArr = array();
+	foreach($theFullCoordinatesArray as $singlePoint) {
+	  $theRetArr[] = $singlePoint['pdf_x'];
+		$theRetArr[] = $singlePoint['pdf_y'];
+	}
+	return $theRetArr;
+} // end of function makePolyFromCoord
+
+
+
+
+/**
+ * converts an array of coordinates (created e.g. by makeCoordPairs()) into
+ * an array thats needed to draw lines via line(x0, y0, x1, y1)
+ *
+ * @param array the Array containing all infos about single coordinates
+ *              created via makeCoordPairs()
+ * 
+ * @return array the array containing PDF-Values for single lines
+ *
+ * @see makeCoordPairs
+ *
+ * @author M. Jansen <jansen at terrestris.de>, 2006-05-26
+ */
+function makeStrokePointPairs($thePointArray) {
+  $cnt = count($thePointArray);
+	$theRetArray = array();
+  for($i = 0; $i < $cnt; $i++) {
+	  if($i != $cnt - 1) {
+		  $theRetArray[] = array(
+		    $thePointArray[$i]['pdf_x'],
+				$thePointArray[$i]['pdf_y'],
+				$thePointArray[$i+1]['pdf_x'],
+				$thePointArray[$i+1]['pdf_y'],
+				);
+		} else {
+		  $theRetArray[] = array(
+		    $thePointArray[$i]['pdf_x'],
+				$thePointArray[$i]['pdf_y'],
+				$thePointArray[0]['pdf_x'],
+				$thePointArray[0]['pdf_y'],
+				);
+		}
+	}
+	return $theRetArray;
+} // end of function makeStrokePointPairs
+
+
+
+
+/**
+ * test whether the coordinates in an array form a closed polygon
+ * meaning that first an last point of polygon are equal
+ *
+ * @param array the Array containing all infos about single coordinates
+ *              created via makeCoordPairs()
+ * 
+ * @return bool is it closed (TRUE || FALSE)
+ *
+ * @see makeCoordPairs
+ *
+ * @author M. Jansen <jansen at terrestris.de>, 2006-05-26
+ */
+function isClosedPolygon($coord_arr) {
+  $nr_of = count($coord_arr);
+	if ($coord_arr[0]['pdf_x'] == $coord_arr[$nr_of-1]['pdf_x']
+	    && $coord_arr[0]['pdf_y'] == $coord_arr[$nr_of-1]['pdf_y']
+			&& $nr_of != 1) {
+	  return TRUE; 
+	} else {
+	  return FALSE;
+	}
+}  // end of function isClosedPolygon
+
+
+
+
+/**
+ * Adds the measured item to the PDF output.
+ * 
+ * @param object reference (!) to the current ezPDF-Object
+ * @param string commaseperated X-Values of polygon / line
+ * @param string commaseperated Y-Values of polygon / line
+ * @param array configuration settings.
+ *
+ * @return void nothing
+ *
+ * @see makeCoordPairs
+ * @see isClosedPolygon
+ * @see makeStrokePointPairs
+ * @see makePolyFromCoord
+ * @see transformForPDF
+ * @see makeCoordPairs
+ *
+ * @author M. Jansen <jansen at terrestris.de>, 2006-05-26
+ */
+function addMeasuredItem($thePDF, $x_value_str, $y_value_str, $theConfArray = array()) {
+  // get global variable:
+  global $legendFilenameUserPolygon;
+	// create legend image:
+	$legend_width = 17;
+	$leg_img = imagecreate($legend_width, $legend_width);
+	// save previous state:
+	$thePDF->saveState();
+	
+	// save colors for legend:
+	if(!defined("MAP_HAS_USER_POLYGON")) {
+	  define("MAP_HAS_USER_POLYGON", "test");
+	}
+
+	// get the arrays
+	$theFullArr = makeCoordPairs($x_value_str, $y_value_str);
+    $thePolyArr = makePolyFromCoord($theFullArr);
+	
+	if (isClosedPolygon($theFullArr)) {
+		$isClosed = TRUE;
+	} 
+	else {
+		$isClosed = FALSE;
+	}
+	$nr_of_points = count($theFullArr);
+	
+	// is fill option set?
+	// wenn der erste und letzte punkt nicht �bereinstimmen,
+	// so muss in jedem Falle dofill auf 0 gesetzt werden
+	if($theConfArray['do_fill'] != '' && $isClosed) {
+	  $doFill = 1;
+	  // which color to use for filling?
+	  if (is_array($theConfArray['fill_color']) 
+	      && $theConfArray['fill_color']['r'] != ''
+			  && $theConfArray['fill_color']['g'] != ''
+			  && $theConfArray['fill_color']['b'] != '') {
+	    $thePDF->setColor($theConfArray['fill_color']['r'], $theConfArray['fill_color']['g'], $theConfArray['fill_color']['b']);
+			$legend_image_fill = $theConfArray['fill_color']['r'] . "," . $theConfArray['fill_color']['g'] . "," . $theConfArray['fill_color']['b'];
+			// color to legend file
+			$bg_color = imagecolorallocate($leg_img, round($theConfArray['fill_color']['r'] * 255), round($theConfArray['fill_color']['g'] * 255), round($theConfArray['fill_color']['b'] * 255));
+	  } else {
+	    $thePDF->setColor(0, 0, 0);
+			// color to legend file
+			$bg_color = imagecolorallocate($leg_img, 0, 0, 0);
+	  }
+	} else {
+	  $doFill = 0;
+		// color to legend file
+	  $bg_color = imagecolorallocate($leg_img, -1, -1, -1);
+	}
+	
+	// Do we need to stroke (outline)?
+	if($theConfArray['do_stroke'] != '') {
+	  // which color to use for filling?
+	  if (is_array($theConfArray['stroke_color']) 
+	      && $theConfArray['stroke_color']['r'] != ''
+			  && $theConfArray['stroke_color']['g'] != ''
+			  && $theConfArray['stroke_color']['b'] != '') {
+	    $thePDF->setStrokeColor($theConfArray['stroke_color']['r'], $theConfArray['stroke_color']['g'], $theConfArray['stroke_color']['b']);
+			$thePDF->setLineStyle($theConfArray['line_style']['width'], $theConfArray['line_style']['cap'], $theConfArray['line_style']['join'], $theConfArray['line_style']['dash']);
+			$theStrokePointPairs = makeStrokePointPairs($theFullArr);
+			for($i = 0; $i < count($theStrokePointPairs); $i++) {
+			  $line = $theStrokePointPairs[$i];
+				if ($i != count($theStrokePointPairs) - 1
+				    || $isClosed) {
+			    $thePDF->line($line[0], $line[1], $line[2], $line[3]);
+					
+					$stroke_color_legend_image = imagecolorallocate($leg_img, round($theConfArray['stroke_color']['r'] * 255), round($theConfArray['stroke_color']['g'] * 255), round($theConfArray['stroke_color']['b'] * 255));
+					if (is_array($theConfArray['line_style']['dash'])
+					    && $theConfArray['line_style']['dash'][1] != ""
+							&& $theConfArray['line_style']['dash'][1] != 0) {
+						imagedashedline($leg_img, 0, 0, $legend_width-1, 0, $stroke_color_legend_image);
+						imagedashedline($leg_img, $legend_width-1, 1, $legend_width-1, $legend_width-1, $stroke_color_legend_image);
+						imagedashedline($leg_img, 0, 0, 0, $legend_width-1, $stroke_color_legend_image);
+						imagedashedline($leg_img, 0, $legend_width-1, $legend_width-1,$legend_width-1, $stroke_color_legend_image);
+					} else {
+					  imageline($leg_img, 0, 0, $legend_width-1, 0, $stroke_color_legend_image);
+						imageline($leg_img, $legend_width-1, 0, $legend_width-1, $legend_width-1, $stroke_color_legend_image);
+						imageline($leg_img, $legend_width-1, $legend_width-1, 0, $legend_width-1, $stroke_color_legend_image);
+						imageline($leg_img, 0, $legend_width-1, 0, 0, $stroke_color_legend_image);
+					}		
+				} 
+			}
+	  } 
+	}
+	
+  $thePDF->polygon($thePolyArr, $nr_of_points, $doFill);
+  // eventually create the file:
+	imagepng($leg_img, $legendFilenameUserPolygon);
+	
+	$thePDF->restoreState();
+} // end of function addMeasuredItem
+
+/**
+ * Konvertiert einen Text in ein array aus einzelnen Zeilen. Parameter wie Zeichen pro
+ * zeile etc. k�nnen in der Funktion ge�ndert werden.
+ */
+function convert2lines($the_text) {
+    $words = explode(' ', $the_text);
+	$maxlines                 = 6;
+	$available_chars_per_line = 35;
+	$total_number_of_lines    = 0;
+	$chars_current_line       = 0;
+	$the_return_array         = array();
+
+    foreach($words as $word) {
+    	// trimme wort auf maximal erlaubte zeichenzahl
+        $word_fit = mb_substr($word, 0, $available_chars_per_line);
+	    $chars = preg_split('//', $word_fit, -1, PREG_SPLIT_NO_EMPTY);
+	    
+	    if(count($chars) + $chars_current_line + 1 < $available_chars_per_line && $total_number_of_lines < $maxlines) {
+		    $chars_current_line += count($chars) + 1;
+			$the_return_array[$total_number_of_lines]  .= " " . $word_fit;
+		} elseif($total_number_of_lines < $maxlines) {
+	      $chars_current_line = count($chars) + 1;
+		  $the_return_array[$total_number_of_lines + 1] = " " . $word_fit;
+		  $total_number_of_lines++;
+		}
+	}
+  return $the_return_array;
+} // end of function convert2lines
+
+/**
+ * Adds two white polygons to hide any user elements outside the mapframe:
+ * First all A-Areas are filled, then all B-Areas. This is a rather grumpy
+ * way out of having user edited stuff flying outside the mapframe.
+ * 
+ * @example <pre>
+ * BBBBBBBBBBBBBBBBBBBBBBBBBBBBAAA
+ * BBBBBBBBBBBBBBBBBBBBBBBBBBBBAAA
+ * BBB                                                  AAA
+ * BBB                                                  AAA
+ * BBB       Mapframe                              AAA
+ * BBB                                                  AAA
+ * BBB                                                  AAA
+ * BBB                                                  AAA
+ * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ * </pre>
+ * 
+ * @param reference (!, pass over with '&') to the pdf-file
+ * @author M. Jansen <jansen at terrestris.de>
+ */
+function hideElementsOutsideMapframe($pdf) {
+  // get globals
+  global $mapOffset_left, $map_width, $mapOffset_bottom, $map_height;
+  $pdf->saveState();
+  $pdf->setColor(1, 1, 1);
+	// The AAA-Part
+  $allOutside = array(
+    0                              , 0,                       // 1st coord-pair
+    $pdf->ez['pageWidth']          , 0,                       // 2nd coord-pair
+    $pdf->ez['pageWidth']          , $pdf->ez['pageHeight'],  // ...
+    $mapOffset_left + $map_width   , $pdf->ez['pageHeight'],
+    $mapOffset_left + $map_width   , $mapOffset_bottom,
+    0                              , $mapOffset_bottom,
+    0                              , 0
+  );
+	// draw polygon
+  $pdf->polygon($allOutside, 7, 1);    
+  // The BBB-part
+  $allOutside = array(
+    0                              , $mapOffset_bottom,       // 1st coord-pair
+    $mapOffset_left                , $mapOffset_bottom,       // 2nd coord-pair
+    $mapOffset_left                , $mapOffset_bottom + $map_height, // ...
+    $mapOffset_left + $map_width   , $mapOffset_bottom + $map_height,
+    $mapOffset_left + $map_width   , $pdf->ez['pageHeight'],
+    0                              , $pdf->ez['pageHeight'],
+    0                              , $mapOffset_bottom,  
+  );
+	// draw polygon
+  $pdf->polygon($allOutside, 7, 1);
+  $pdf->restoreState();
+}
 ?>
\ No newline at end of file

Added: branches/print_dev/http/print/printbox.js
===================================================================
--- branches/print_dev/http/print/printbox.js	                        (rev 0)
+++ branches/print_dev/http/print/printbox.js	2009-08-04 11:51:01 UTC (rev 4471)
@@ -0,0 +1,707 @@
+function createBox (options) {
+	myPrintBox = new PrintBox(options);
+	myPrintBox.paintPoints();
+	myPrintBox.paintBox();	
+	return myPrintBox;
+}
+
+function PrintBox (options) {
+	if (!options) {
+		options = {};
+	}
+
+	var target = options.target || "mapframe1";
+	//var mapObj = getMapObjByName(target);
+	var map = Mapbender.modules[target];
+	var map_el = map.getDomElement();
+
+	// Default is portrait, A4, unit seems to be cm
+	var printWidth = options.printWidth || 21;
+	var printHeight = options.printHeight || 29.7;
+
+	// initialised in setScale()
+	var boxWidth, boxHeight; 
+
+	var scale = options.scale || 100000;
+
+	// behaviour
+	var afterChangeAngle = options.afterChangeAngle || function (obj) {};
+	var afterChangeSize = options.afterChangeSize || function (obj) {};
+	
+	// styles
+	var opacity = options.boxOpacity || 0.6;
+	var boxColour = options.boxColour || "#9999FF";
+	var frameColour = options.frameColour || "#000000";
+	var pointColour = options.pointColour || "#DD0000";
+	var circleColour = options.circleColour || "#DD0000";
+	var circleWidth = options.circleWidth || 4;
+
+	// attributes
+	this.id = "printbox";
+	var angle = 0;
+	var totalAngle = 0;
+
+	// the four points of the box as pixel coordinates (incl rotation),
+	// with (0,0) as center. This is important for angle calculations.
+	var pointArray = [];
+
+	// The pointArray is moved by the center vector.
+	// default: place box in the center of the map
+	var center = options.center || new Point(map.width/2,map.height/2);
+
+	// the center in real world coordinates
+	var centerMap = null;
+
+	// the four points of the box as pixel coordinates (NO ROTATION)
+	var startPointPixArray = [];
+
+	// the four points of the box as real world coordinates (NO ROTATION)
+	var startPointMapArray = [];
+	var that = this;
+
+	// if the box is smaller than this, the circle will not be drawn
+	var MIN_BOX_WIDTH_OR_HEIGHT = 10;
+
+	// if the box is larger than this, the box will not be filled
+	var MAX_BOX_WIDTH_OR_HEIGHT = 800;
+
+	this.toString = function () {
+		var str = "";
+		str += "Center: " + getCenter() + "\n";
+		str += "Radius: " + radius + "\n";
+		str += "StartRadius: " + startRadius + "\n";
+		str += "Pixelpos: " + String(pointArray) + "\n";
+		str += "StartPixelpos: " + String(startPointPixArray) + "\n";
+		str += "Mappos: " + String(startPointMapArray) + "\n";
+		return str;
+	};
+	
+	var initBehaviour = function () {
+		initMoveBehaviour();
+		initResizeBehaviour();
+		initRotateBehaviour();
+	};
+
+	var initRotateBehaviour = function () {
+		$circleCanvas.css("z-index", "110").mousedown(function (e) {
+			circleCanvas.clear();	
+	
+			var newCenter = getCenter();
+	
+			var mouseMoveStart = map.getMousePos(e);
+			var vectorA = pointArray[0].minus(newCenter);
+			
+			var currentPos = map.getMousePos(e);
+			var vectorCurrent = currentPos.minus(newCenter);
+			
+			angle = Math.ceil(getAngle(vectorA, vectorCurrent));
+			
+			$(document).mousemove(function (e) {
+				var currentPos = map.getMousePos(e);
+				var vectorCurrent = currentPos.minus(newCenter);
+				var currentAngle = Math.ceil(getAngle(vectorA, vectorCurrent));
+				var diffAngle = currentAngle - angle;
+				if (Math.abs(diffAngle) >= 1) {
+					angle = currentAngle;
+					totalAngle = ((totalAngle + diffAngle) +360 )% 360;
+					that.rotate(totalAngle);
+				}
+				return false;
+			}).mouseup(function (e) {
+				angle = 0;
+				$(document).unbind("mousemove");
+				$(document).unbind("mouseup");
+				afterChangeAngle({
+					angle: totalAngle,
+					coordinates: that.getStartCoordinates()
+				});
+				that.paintBox();
+				return false;
+			});	
+			return false;
+		}).css("cursor", "move");
+	};
+
+	var initMoveBehaviour = function () {
+		$boxCanvas.mousedown(function (e) {
+			circleCanvas.clear();	
+	
+			var mouseMoveStart = map.getMousePos(e);
+	
+			var containerStart = new Point(
+				parseInt($container.css("left"), 10),
+				parseInt($container.css("top"), 10)
+			);
+
+			var diff;
+	
+			$(document).mousemove(function (e) {
+				diff = (map.getMousePos(e)).minus(mouseMoveStart);
+	
+				$container.css({
+					"top": (containerStart.y + diff.y) + "px",
+					"left": (containerStart.x + diff.x) + "px"
+				});
+				return false;
+	
+			}).mouseup(function (e) {
+				$(document).unbind("mousemove");
+				$(document).unbind("mouseup");
+				recalculateMapPositions();
+				that.rotate(totalAngle);
+				that.paintBox();
+				return false;
+			});	
+			return false;
+		});
+	};
+
+	var initResizeBehaviour = function () {
+		$pointCanvas.css("z-index", "120").mousedown(function (e) {
+			circleCanvas.clear();	
+
+			var vectorA = getCenter();
+	
+			resizeRatio = 1;
+			mouseMoveStart = map.getMousePos(e);
+			$(document).mousemove(function (e) {
+				var newRadius = vectorA.dist(map.getMousePos(e));
+				var resizeRatio = newRadius / radius;
+				if (resizeRatio < 0.98 || resizeRatio > 1.02) {
+					for (var i = 0; i < pointArray.length; i++) {
+						pointArray[i].x *= resizeRatio;
+						pointArray[i].y *= resizeRatio;
+						startPointPixArray[i].x *= resizeRatio;
+						startPointPixArray[i].y *= resizeRatio;
+					}
+					radius *= resizeRatio;
+					that.paintPoints();
+				}
+				return false;
+			});
+			$(document).mouseup(function (e) {
+				$(document).unbind("mousemove");
+				$(document).unbind("mouseup");
+
+				recalculateMapPositions();
+				recalculatePixPositions();
+				afterChangeSize({
+					scale: that.getScale(),
+					coordinates: that.getStartCoordinates()
+				});
+				that.rotate(totalAngle);
+				that.paintBox();
+				return false;
+			});
+			return false;
+		}).css("cursor", "move");
+	};
+
+	var setCenter = function (inputCenter) {
+		center = inputCenter.minus(
+			new Point(
+				parseInt($container.css("left"), 10), 
+				parseInt($container.css("top"), 10)
+			)
+		);
+	};
+	
+	var getCenter = function () {
+		var c = center.plus(
+			new Point(
+				parseInt($container.css("left"), 10), 
+				parseInt($container.css("top"), 10)
+			)
+		);
+		return c;
+	};
+
+	/**
+	 * Calculates the angle (-180 < angle <= 180) between two vectors.
+	 * 
+	 * @param {Point} a
+	 * @param {Point} b
+	 */
+	var getAngle = function (a, b) {
+		var undirectedAngle = 180 * Math.acos(
+				(a.x * b.x + a.y * b.y) 
+				/
+				(
+					Math.sqrt(
+						a.x * a.x
+					+ 
+					 	a.y * a.y
+					) * 
+					Math.sqrt(
+						b.x * b.x
+					+ 
+						b.y * b.y
+					)
+				)
+			) / Math.PI;
+
+		if ((a.x*b.y - a.y*b.x) > 0) {
+			return -1 * undirectedAngle;
+		}
+		return undirectedAngle;
+		
+	};
+	
+	/**
+	 * To be replaced by the map objects native getMousePosition
+	 * 
+	 * @param {Event} e
+	 
+	var getMousePos = function (e) {
+		if ($.msie) {
+			return new Point(event.clientX, event.clientY);
+		}
+		return new Point(e.pageX, e.pageY);
+	};
+	 */
+
+	var recalculateMapPositions = function () {
+		for (var i = 0; i < pointArray.length; i++) {
+			startPointMapArray[i] = convertPixelToMap(startPointPixArray[i].plus(getCenter()));
+		}
+		centerMap = convertPixelToMap(getCenter());
+		
+	};
+
+	var recalculatePixPositions = function () {
+		setCenter(convertMapToPixel(centerMap));
+		for (var i = 0; i < startPointMapArray.length; i++) {
+			pointArray[i] = convertMapToPixel(startPointMapArray[i]).minus(getCenter());
+			startPointPixArray[i] = convertMapToPixel(startPointMapArray[i]).minus(getCenter());
+		}
+		radius = pointArray[0].dist(new Point(0,0));
+		startRadius = radius;
+		boxWidth = pointArray[2].x - pointArray[0].x;
+		boxHeight = pointArray[0].y - pointArray[2].y;
+	};
+
+	var initPoints = function () {
+		var w = parseInt((boxWidth/2), 10);
+		var h = parseInt((boxHeight/2), 10);
+
+		pointArray[0] = new Point(-w,  h);
+		pointArray[1] = new Point( w,  h);
+		pointArray[2] = new Point( w, -h);
+		pointArray[3] = new Point(-w, -h);
+
+		startPointPixArray[0] = (new Point(-w,  h));
+		startPointPixArray[1] = (new Point( w,  h));
+		startPointPixArray[2] = (new Point( w, -h));
+		startPointPixArray[3] = (new Point(-w, -h));
+
+		radius = pointArray[0].dist(new Point(0,0));
+		startRadius = radius;
+
+		recalculateMapPositions();
+
+		scale = that.getScale();
+	};
+
+	var switchBoxDimensions = function () {
+		setBoxDimensions(boxHeight, boxWidth);
+		afterChangeSize({
+			scale: that.getScale(),
+			coordinates: that.getStartCoordinates()
+		});
+	};
+
+	this.setPortrait = function () {
+		this.setAngle(0);
+		if (boxWidth > boxHeight) {
+			switchBoxDimensions();
+		}
+	};
+	
+	this.setLandscape = function () {
+		this.setAngle(0);
+		if (boxWidth < boxHeight) {
+			switchBoxDimensions();
+		}
+	};
+	
+	this.setPrintWidthAndHeight = function (width, height) {
+		var currentScale = this.getScale();
+		printWidth = width;
+		printHeight = height;
+		this.setScale(currentScale);
+	};
+	
+	var convertMapToPixel = function (aPoint) {
+		var pArray = makeRealWorld2mapPos(map.elementName, aPoint.x, aPoint.y);
+		return new Point(pArray[0], pArray[1]);
+	};
+	
+	var convertPixelToMap = function (aPoint) {
+		var pArray = makeClickPos2RealWorldPos(map.elementName, aPoint.x, aPoint.y);
+		return new Point(pArray[0], pArray[1]);
+	};
+	
+	/**
+	 * Sets the box width and box height (calculated in setScale)
+	 * 
+	 * @param {Integer} inputWidth
+	 * @param {Integer} inputHeight
+	 */
+	var setBoxDimensions = function (inputWidth, inputHeight) {
+		boxWidth = inputWidth;
+		boxHeight = inputHeight;
+		
+		initPoints();
+		that.rotate(totalAngle);
+
+		afterChangeSize({
+			scale: that.getScale(),
+			coordinates: that.getStartCoordinates()
+		});
+
+		that.paintBox();
+	};
+
+	/**
+	 * Returns an array of two points, the lower left and upper right of the initial box
+	 */
+	this.getStartCoordinates = function () {
+		var a = startPointMapArray[0];
+		var b = startPointMapArray[2];
+		if (!a || !b) {
+			return null;
+		}
+		var returnString =  a.x + "," + a.y + "," + b.x + "," + b.y;
+		return returnString;
+	};
+
+	/**
+	 * Returns the current scale of the print box
+	 */
+	this.getScale = function () {
+/*
+		var coords = this.getStartCoordinates();
+		var coordsArray = coords.split(",");		
+
+		var ext = mapObj.getExtentInfos();
+		var extMinX = ext.minx;
+		var extMaxX = ext.maxx;
+		
+		var x = (ext.minx + ext.maxx)/2;
+		var y = (ext.miny + ext.maxy)/2;
+		var scale1 = (x - coordsArray[0]) * (mb_resolution * 100 *2) / mapObj.width;
+		var scale2 = (coordsArray[2] - x) * (mb_resolution * 100 *2) / mapObj.width;
+		scale = Math.round(scale1/2 + scale2/2);
+		return scale;
+*/
+		var coords = this.getStartCoordinates();
+		var coordsArray = coords.split(",");		
+	
+		xtentx =  coordsArray[2] - coordsArray[0];
+		scale = parseInt(Math.ceil(xtentx / (printWidth / 100)), 10);
+		return scale;
+	};
+
+	/**
+	 * Repaints the Box with the current scale. Can be called from outside, 
+	 * for example after zoom in.
+	 */
+	this.repaint = function () {
+		recalculatePixPositions();
+		this.rotate(totalAngle);
+		this.paintBox();
+	};
+	
+	/**
+	 * Sets the current scale, and repaints the box
+	 * 
+	 * @param {Integer} inputScale
+	 */
+	this.setScale = function (inputScale) {
+		if (typeof(inputScale) == "number") {
+/*			
+			var arrayBBox = mapObj.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) - (mapObj.width / (mb_resolution * 100 *2) * inputScale);
+			var miny = parseFloat(y) -  (mapObj.height / (mb_resolution * 100 *2) * inputScale);
+			var maxx = parseFloat(x) + (mapObj.width / (mb_resolution * 100 *2) * inputScale);
+			var maxy = parseFloat(y) +  (mapObj.height / (mb_resolution * 100 *2) * inputScale);
+
+			var newMinPos = makeRealWorld2mapPos(mapObj.frameName, minx, miny);
+			var newMaxPos = makeRealWorld2mapPos(mapObj.frameName, maxx, maxy);
+			var newBoxWidth = newMaxPos[0] - newMinPos[0];
+			var newBoxHeight = newBoxWidth * (printHeight / printWidth);
+*/
+			var mapWidthInM = printWidth / 100;
+			var realWidthInM = inputScale * mapWidthInM;
+			var mapHeightInM = printHeight / 100;
+			var realHeightInM = inputScale * mapHeightInM;
+			
+			var coords = this.getStartCoordinates();
+			if (coords !== null) {
+				var coordsArray = coords.split(",");
+				var oldMin = new Point(parseFloat(coordsArray[0]), parseFloat(coordsArray[1]));
+				var oldMax = new Point(parseFloat(coordsArray[2]), parseFloat(coordsArray[3]));
+				centerMap = (oldMin.times(0.5)).plus(oldMax.times(0.5));
+				
+			}
+			else {
+				centerMap = convertPixelToMap(getCenter());
+			}
+			var newMin = new Point(centerMap.x - 0.5 * realWidthInM, centerMap.y - 0.5 * realHeightInM);
+			var newMax = new Point(centerMap.x + 0.5 * realWidthInM, centerMap.y + 0.5 * realHeightInM);
+
+			startPointMapArray[0] = new Point(newMin.x, newMin.y);
+			startPointMapArray[1] = new Point(newMax.x, newMin.y);
+			startPointMapArray[2] = new Point(newMax.x, newMax.y);
+			startPointMapArray[3] = new Point(newMin.x, newMax.y);
+
+			this.getStartCoordinates();
+			var newMinPos = convertMapToPixel(newMin);
+			var newMaxPos = convertMapToPixel(newMax);
+			boxWidth = newMaxPos.x - newMinPos.x;
+			boxHeight = newMinPos.y - newMaxPos.y;
+
+			var w = parseInt(0.5 * boxWidth, 10);
+			var h = parseInt(0.5 * boxHeight, 10);
+
+			pointArray[0] = new Point(-w,  h);
+			pointArray[1] = new Point( w,  h);
+			pointArray[2] = new Point( w, -h);
+			pointArray[3] = new Point(-w, -h);
+	
+			startPointPixArray[0] = (new Point(-w,  h));
+			startPointPixArray[1] = (new Point( w,  h));
+			startPointPixArray[2] = (new Point( w, -h));
+			startPointPixArray[3] = (new Point(-w, -h));
+	
+			radius = pointArray[0].dist(new Point(0,0));
+			startRadius = radius;
+	
+			this.rotate(totalAngle);
+	
+	
+			afterChangeSize({
+				scale: that.getScale(),
+				coordinates: that.getStartCoordinates()
+			});
+	
+			that.paintBox();
+
+			return true;
+		}
+		return false;
+	};
+
+	/**
+	 * Sets the angle of the box to a specific angle.
+	 * 
+	 * @param {Integer} angle
+	 */
+	this.setAngle = function (angle) {
+		if (typeof(angle) == "number" && angle >= -360) {
+			totalAngle = (360 + angle) % 360;
+			this.rotate(totalAngle);
+			this.paintBox();
+			afterChangeAngle({
+				angle: totalAngle,
+				coordinates: that.getStartCoordinates()
+			});
+			return true;
+		}
+		return false;
+	};
+
+
+	//
+	//
+	// VIEW
+	//
+	//
+
+	/**
+	 * Rotates the box by a given degree (0 <= degree < 360), 
+	 * and paints the corner points.
+	 * 
+	 * @param {Integer} degree
+	 */
+	this.rotate = function (degree) {
+		var rotationAngle = (Math.PI * parseFloat(degree))/180;
+		var resizeRatio = radius / startRadius;
+
+		for (var i = 0; i < pointArray.length; i++) {
+			var p = (convertMapToPixel(startPointMapArray[i])).minus(getCenter());
+			var newx = p.x * Math.cos(rotationAngle) + p.y * Math.sin(rotationAngle);
+			var newy = p.x * -Math.sin(rotationAngle) + p.y * Math.cos(rotationAngle);
+			pointArray[i] = (new Point(newx, newy)).times(resizeRatio);
+		}
+		afterChangeAngle({
+			angle: degree,
+			coordinates: this.getStartCoordinates()
+		});
+		this.paintPoints();
+	};
+
+	/**
+	 * Paints the four corner points of the print box.
+	 */
+	this.paintPoints = function () {
+
+		switchActiveCanvas();
+		var c = center;
+		for (var i = 0; i < pointArray.length; i++) {
+			activeCanvas.fillEllipse(
+				pointArray[i].x + c.x - 4,
+				pointArray[i].y + c.y - 4,
+				8,
+				8
+			);
+		}
+		activeCanvas.paint();
+		passiveCanvas.clear();
+	};
+
+	var boxTooBig = function () {
+		if (boxWidth > MAX_BOX_WIDTH_OR_HEIGHT || boxHeight > MAX_BOX_WIDTH_OR_HEIGHT) {
+			return true;
+		}
+		return false;
+	}
+
+	var boxTooSmall = function () {
+		if (boxWidth < MIN_BOX_WIDTH_OR_HEIGHT || boxHeight < MIN_BOX_WIDTH_OR_HEIGHT) {
+			return true;
+		}
+		return false;
+	}
+
+	/**
+	 * Paints the box itself. Plus the circle.
+	 */
+	this.paintBox = function () {
+		var r = Math.round(0.75 * radius);
+		var c = center;
+		circleCanvas.clear();	
+		if (!boxTooSmall() && !boxTooBig()) {
+			circleCanvas.drawEllipse(c.x-r, c.y-r, 2*r, 2*r);
+		}
+		else {
+			new Mb_warning("The print box is too small or too big. The rotate circle is not shown.");
+		}
+		circleCanvas.paint();
+
+		boxCanvas.clear();
+		if (!boxTooBig()) {
+			boxCanvas.fillPolygon([
+				pointArray[0].x + c.x,
+				pointArray[1].x + c.x,
+				pointArray[2].x + c.x,
+				pointArray[3].x + c.x
+			], 
+			[
+				pointArray[0].y + c.y,
+				pointArray[1].y + c.y,
+				pointArray[2].y + c.y,
+				pointArray[3].y + c.y
+			]);
+		}
+		else {
+			new Mb_warning("The print box is too big. The box is not filled.");
+		}
+		
+		// frame
+		boxCanvas.setColor(frameColour);	
+		for (var i = 0; i < pointArray.length; i++) {
+			var indexA = i % 4;
+			var a = pointArray[indexA].plus(center);
+			var indexB = (i + 1) % 4;
+			var b = pointArray[indexB].plus(center);
+			boxCanvas.drawLine(a.x, a.y, b.x, b.y);
+		}
+		
+		boxCanvas.setColor(boxColour);	
+		boxCanvas.paint();
+	};
+	
+	/**
+	 * Clears all canvases, to be performed onunload.
+	 */
+	this.destroy = function () {
+		circleCanvas.clear();	
+		boxCanvas.clear();
+		activeCanvas.clear();
+		passiveCanvas.clear();
+	};
+
+	var switchActiveCanvas = function () {
+		if (canvasNr == 1) {
+			canvasNr = 2;
+			activeCanvas = jg[2];
+			passiveCanvas = jg[1];
+		}
+		else {
+			canvasNr = 1;
+			activeCanvas = jg[1];
+			passiveCanvas = jg[2];
+		}
+	};
+
+
+	var $container = $("<div id='" + this.id + "' style='position:relative;top:0px;left:0px;" + 
+		"'></div>");
+		
+	var $superContainer = $("<div id='container_" + this.id + "' style='position:absolute;z-index:1000;'></div>");
+	$superContainer.append($container);
+	//$("#"+map.elementName).append($superContainer);
+	$(map_el).append($superContainer);
+	
+	var canvasName = [
+		this.id + "_canvas_box",
+		this.id + "_canvas_points1",
+		this.id + "_canvas_points2",
+		this.id + "_canvas_circle"
+	];
+
+	var jg = [];
+	
+	var canvasNr = 1;
+
+	for (var i = 0; i < canvasName.length; i++) {
+		$container.append(
+			$("<div id='" + canvasName[i] + "'></div>")
+		);
+		jg[i] = new jsGraphics(canvasName[i]);
+	}
+
+	$circleCanvas = $("#" + canvasName[3]);
+	$pointCanvas = $("#" + canvasName[1] +  ", #" + canvasName[2]);
+	$boxCanvas = $("#" + canvasName[0]);
+	$boxCanvas.css({
+		"opacity" : opacity, 
+		"filter" : "alpha(opacity=" + (opacity * 100) + ")"
+	});
+		
+	
+
+	var boxCanvas = jg[0];
+	boxCanvas.setColor(boxColour);	
+	var activeCanvas = jg[1];
+	activeCanvas.setColor(pointColour);
+	var passiveCanvas = jg[2];
+	passiveCanvas.setColor(pointColour);
+	var circleCanvas = jg[3];
+	circleCanvas.setColor(circleColour);
+	circleCanvas.setStroke(circleWidth);	
+
+	var mouseMoveStart = [];	
+
+	var radius = 0;
+	var startRadius = 0;
+
+	// "constructor" functions
+	initBehaviour();
+	this.setScale(scale);
+	mb_registerPanSubElement($superContainer.get(0).id);
+}
\ No newline at end of file

Modified: branches/print_dev/http/print/testConfigTemplate.json
===================================================================
--- branches/print_dev/http/print/testConfigTemplate.json	2009-08-04 11:47:46 UTC (rev 4470)
+++ branches/print_dev/http/print/testConfigTemplate.json	2009-08-04 11:51:01 UTC (rev 4471)
@@ -44,11 +44,19 @@
     		}
     	},
     	{
-    		"id" : "rotation",
+    		"id" : "angle",
     		"type" : "hidden",
     		"pageElementsLink" : {
     			"nordpfeil" : "rotation"
     		}
+    	},
+    	{
+    		"id" : "coordinates",
+    		"type" : "hidden"
+    	},
+    	{
+    		"id" : "scale",
+    		"type" : "hidden"
     	}    	    		
     ],
     "pages" : [



More information about the Mapbender_commits mailing list