var MtcoTools={singleFile:true};(function(){var singleFile=(typeof MtcoTools=="object"&&MtcoTools.singleFile);var scriptLocation;window.MtcoTools={_scriptName:(!singleFile)?"lib/MtcoTools.js":"MtcoTools.js",_getScriptLocation:function(){if(scriptLocation!=undefined){return scriptLocation;}
scriptLocation="";var isMtcoTools=new RegExp("(^|(.*?\\/))("+MtcoTools._scriptName+")(\\?|$)");var scripts=document.getElementsByTagName('script');for(var i=0,len=scripts.length;i<len;i++){var src=scripts[i].getAttribute('src');if(src){var match=src.match(isMtcoTools);if(match){scriptLocation=match[1];break;}}}
return scriptLocation;},_getCSSLocation:function(){var cssLocation=MtcoTools._getScriptLocation()+"styles/style.css";return cssLocation;},_getImgLocation:function(){var imgLocation=MtcoTools._getScriptLocation()+"img/";return imgLocation;}};if(!singleFile){loadJS();}
loadCSS();})();function loadJS(text){if(text)var split=text.split("\n");var jsfiles=new Array("MtcoBase/MtcoBase.js","MtcoBase/MtcoMap.js","MtcoLang/MtcoLang.js","MtcoStyle/MtcoStyle.js","MtcoLayerGroup/MtcoLayerGroup.js","MtcoPanel/MtcoPanel.js","MtcoAnimations/MtcoAnimation.js","MtcoAnimations/MtcoRun/MtcoRun.js","MtcoAnimations/MtcoWait/MtcoWait.js","MtcoControl/MtcoControl.js","MtcoControl/MtcoAttribution/MtcoAttribution.js","MtcoControl/MtcoFull/MtcoFull.js","MtcoControl/MtcoHighlightFeature/MtcoHighlightFeature.js","MtcoControl/MtcoLayerSwitcher/MtcoLayerSwitcher.js","MtcoControl/MtcoProfile/MtcoProfile.js","MtcoControl/MtcoSearch/MtcoSearch.js","MtcoControl/MtcoSelectFeature/MtcoSelectFeature.js","MtcoControl/MtcoTimeline/MtcoTimeline.js","MtcoControl/MtcoZoomBack/MtcoZoomBack.js","MtcoControl/MtcoZoomToRegions/MtcoZoomToRegions.js","MtcoControl/MtcoSelectFeature/MtcoSelectFeature.js","MtcoGeoJSON/MtcoGeoJSON.js","MtcoDecoration/MtcoDecoration.js","MtcoDecoration/MtcoKompass/MtcoKompass.js","MtcoTracker/MtcoTracker.js","MtcoHelp/MtcoHelp.js","MtcoStyle/MtcoSLD.js");if(split){for(var i=0,l=split.length;i<l;i++){var file=split[i];if(file.match(".js")){jsfiles.push(file);}}}
var agent=navigator.userAgent;var docWrite=(agent.match("MSIE")||agent.match("Safari"));if(docWrite){var allScriptTags=new Array(jsfiles.length);}
var host=MtcoTools._getScriptLocation()+"lib/";for(var j=0,len=jsfiles.length;j<len;j++){if(docWrite){allScriptTags[j]="<script src='"+host+jsfiles[j]+"'></script>";}else{var s=document.createElement("script");s.type="text/javascript";s.src=host+jsfiles[j];var h=document.getElementsByTagName("head").length?document.getElementsByTagName("head")[0]:document.body;h.appendChild(s);}}
if(docWrite){document.write(allScriptTags.join(""));}}
function loadCSS(){var agent=navigator.userAgent;var docWrite=(agent.match("MSIE")||agent.match("Safari"));var link=document.createElement("link");link.rel="stylesheet";link.type="text/css";link.href=MtcoTools._getCSSLocation();if(docWrite){var cssLink="<link rel='stylesheet' type='text/css' href="+link.href+">";}
else{var h=document.getElementsByTagName("head").length?document.getElementsByTagName("head")[0]:document.body;h.appendChild(link);}
if(docWrite){document.write(cssLink);}}
﻿OpenLayers.Lang["de"]=OpenLayers.Util.applyDefaults(OpenLayers.Lang["de"],{'minHeight':"minimale Höhe",'maxHeight':"maximale Höhe",'altitudeDifference':"Höhenmeter",'velocity':"Geschwindigkeit",'mapNotComplete':"Karte kann nicht vollständig geladen werden.",'ajaxError':"Ein Fehler ist aufgetreten.",'noResult':"Die Suche führte zu keinem passenden Ergebnis."});OpenLayers.Lang["fr"]=OpenLayers.Util.applyDefaults(OpenLayers.Lang["fr"],{'minHeight':"altitude maximale",'maxHeight':"altitude minimale",'altitudeDifference':"total ascension",'velocity':"vélocité",'mapNotComplete':"La carte ne peut pas chargé complète.",'ajaxError':"Erreur.",'noResult':"Sans résultat."});OpenLayers.Lang["en"]=OpenLayers.Util.applyDefaults(OpenLayers.Lang["en"],{'minHeight':"minimum altitude",'maxHeight':"maximum altitude",'altitudeDifference':"altitude difference",'velocity':"velocity",'mapNotComplete':"Map can not be loaded properly.",'ajaxError':"An error occured.",'noResult':"No matching results for this search."});OpenLayers.Layer.prototype.initialize=function(name,options){this.addOptions(options);this.name=name;if(this.id==null){this.id=OpenLayers.Util.createUniqueID(this.CLASS_NAME+"_");this.div=OpenLayers.Util.createDiv(this.id);this.div.style.width="100%";this.div.style.height="100%";this.div.dir="ltr";this.events=new OpenLayers.Events(this,this.div,this.EVENT_TYPES);if(this.eventListeners instanceof Object){this.events.on(this.eventListeners);}}
if(this.wrapDateLine){this.displayOutsideMaxExtent=true;}
var lang=OpenLayers.Lang.getCode();if(this[lang]){this.name=this[lang].name;}}
OpenLayers.StyleMap.prototype.initialize=function(style,options){this.styles={"default":new OpenLayers.Style(OpenLayers.Feature.Vector.style["default"]),"select":new OpenLayers.Style(OpenLayers.Feature.Vector.style["select"]),"temporary":new OpenLayers.Style(OpenLayers.Feature.Vector.style["temporary"]),"delete":new OpenLayers.Style(OpenLayers.Feature.Vector.style["delete"]),"highlight":new OpenLayers.Style(OpenLayers.Feature.Vector.style["highlight"])};if(style instanceof OpenLayers.Style){this.styles["default"]=style;this.styles["select"]=style;this.styles["temporary"]=style;this.styles["delete"]=style;this.styles["highlight"]=style;}else if(typeof style=="object"){for(var key in style){if(style[key]instanceof OpenLayers.Style){this.styles[key]=style[key];}else if(typeof style[key]=="object"){this.styles[key]=new OpenLayers.Style(style[key]);}else{this.styles["default"]=new OpenLayers.Style(style);this.styles["select"]=new OpenLayers.Style(style);this.styles["temporary"]=new OpenLayers.Style(style);this.styles["delete"]=new OpenLayers.Style(style);this.styles["highlight"]=new OpenLayers.Style(style);break;}}}
OpenLayers.Util.extend(this,options);}
OpenLayers.Feature.Vector.style=OpenLayers.Util.applyDefaults(OpenLayers.Feature.Vector.style,{'highlight':{fillColor:'#4e6c9b',fillOpacity:0.6,hoverFillColor:"4e6c9b",hoverFillOpacity:0.8,strokeColor:'#224477',strokeOpacity:1,strokeWidth:1,strokeLinecap:"round",strokeDashstyle:"solid",hoverStrokeColor:"224477",hoverStrokeOpacity:1,hoverStrokeWidth:0.2,pointRadius:6,hoverPointRadius:1,hoverPointUnit:"%",pointerEvents:"visiblePainted",cursor:"pointer"}});OpenLayers.MtcoLayerGroup=OpenLayers.Class(OpenLayers.Layer,{name:null,layers:null,layerGroups:null,map:null,visibility:true,closedInLayerSwitcher:true,styleMap:null,events:null,eventListeners:null,EVENT_TYPES:["changelayer"],initialize:function(name,layers,options){OpenLayers.Util.extend(this,options);this.name=name;if(layers)this.layers=layers;else this.layers=[];this.layerGroups=[];this.addOptions(options);this.setGroup();if(this.id==null){this.id=OpenLayers.Util.createUniqueID(this.CLASS_NAME+"_");}
var lang=OpenLayers.Lang.getCode();if(this[lang]){this.name=this[lang].name;}
this.events=new OpenLayers.Events(this,undefined,this.EVENT_TYPES);if(this.eventListeners instanceof Object){this.events.on(this.eventListeners);}
this.passVisibility();this.setStyle(this.styleMap);},setMap:function(map){this.map=map;},setGroup:function(){for(var key in this.layers){this.layers[key].layerGroup=this;}},addLayer:function(layer){this.layers.push(layer);layer.layerGroup=this;if(this.map){this.map.addLayer(layer);}
this.passVisibility();this.setStyle(this.styleMap);},addLayers:function(layers){if(layers instanceof Array){for(var i=0,len=layers.length;i<len;i++){this.addLayer(layers[i]);}}
else this.addLayer(layers);},removeLayer:function(layer){for(var i=0,l=this.layers.length;i<l;i++){if(layer==this.layers[i]){this.layers.splice(i,1);}}},addGroup:function(layergroup){this.layerGroups.push(layergroup);layergroup.parentGroup=this;if(this.map){this.map.addGroup(layergroup);this.passVisibility();}
else{OpenLayers.Console.error("no Map");}},addGroups:function(layergroups){if(layergroups instanceof Array){for(var i=0,len=layergroups.length;i<len;i++){this.addGroup(layergroups[i]);}}
else this.addGroup(layergroups);},getVisibility:function(){var i=0;if(!this.visibility)return false;else if(this.layers||this.layerGroups){for(var key in this.layers){if(this.layers[key].getVisibility()){i++;}}
for(var kex in this.layerGroups){if(this.layerGroups[kex].getVisibility()){i++;}}
if(i>0)return true;else return false;}
else return this.visibility;},passVisibility:function(){if(this.layers){for(var i=0;i<this.layers.length;i++){this.layers[i].visibility=this.visibility;}}
if(this.layerGroups){for(var j=0;j<this.layerGroups.length;j++){this.layerGroups[j].visibility=this.visibility;this.layerGroups[j].passVisibility();}}},setVisibility:function(visibility){if(visibility!=this.visibility){this.visibility=visibility;}
for(var key in this.layers){this.layers[key].setVisibility(visibility);}
if(this.layerGroups){for(var kex in this.layerGroups){this.layerGroups[kex].setVisibility(visibility);}}
this.events.triggerEvent("changelayer",{layer:this,property:"visibility"});},setStyle:function(styleMap){if(this.styleMap&&this.layers){for(var i=0,l=this.layers.length;i<l;i++){this.layers[i].styleMap=styleMap;this.layers[i].redraw();}}},getDataExtent:function(){var left=this.map.maxExtent.right;var bottom=this.map.maxExtent.top;var right=this.map.maxExtent.left;var top=this.map.maxExtent.bottom;for(var i=0,l=this.layers.length;i<l;i++){var bounds=this.layers[i].getDataExtent();left=(left<=bounds.left)?left:bounds.left;bottom=(bottom<=bounds.bottom)?bottom:bounds.bottom;right=(right>=bounds.right)?right:bounds.right;top=(top>=bounds.top)?top:bounds.top;}
var newBounds=new OpenLayers.Bounds(left,bottom,right,top);console.log(newBounds);return newBounds;},CLASS_NAME:"OpenLayers.MtcoLayerGroup"});OpenLayers.Map.prototype.addGroup=function(layergroup){layergroup.setMap(this);if(!this.layerGroups){this.layerGroups=[];}
if(!layergroup.parentGroup){this.layerGroups.push(layergroup);}
for(var key in layergroup.layers){this.addLayer(layergroup.layers[key]);}},OpenLayers.Map.prototype.addGroups=function(layergroups){if(layergroups instanceof Array){for(var i=0,len=layergroups.length;i<len;i++){this.addGroup(layergroups[i]);}}
else this.addGroup(layergroups);},OpenLayers.Map.prototype.removeGroup=function(layergroup){layergroup.map=this;for(var key in layergroup.layers){this.removeLayer(layergroup.layers[key]);}
for(var i=0,l=this.layerGroups.length;i<l;i++){if(layergroup==this.layerGroups[i]){this.layerGroups.splice(i,1);}}}
OpenLayers.MtcoAnimation=OpenLayers.Class({active:false,autoActivate:true,debug:false,initialize:function(options){OpenLayers.Util.extend(this,options);if(this.autoActivate)this.activate();},destroy:function(){if(this.map){this.map.removeAnimation(this);this.map=null;}},setMap:function(map){this.map=map;},activate:function(){this.active=true;},deactivate:function(){this.active=false;},disableOthers:function(){var mapControls=this.map.controls;for(var i=0;i<mapControls.length;i++){mapControls[i].deactivate();}},enableOthers:function(){var mapControls=this.map.controls;for(var i=0;i<mapControls.length;i++){mapControls[i].activate();}},breakAnimation:function(instance){var mapAnimations=this.map.animations;for(var i=0,l=mapAnimations.length;i<l;i++){if(mapAnimations[i]instanceof instance){mapAnimations[i].stop();}}},proceedAnimation:function(instance){var mapAnimations=this.map.animations;for(var i=0,l=mapAnimations.length;i<l;i++){if(mapAnimations[i]instanceof instance){mapAnimations[i].start();}}},CLASS_NAME:"OpenLayers.MtcoAnimation"});OpenLayers.Map.prototype.addAnimations=function(animations){if(!this.animations)this.animations=new Array();if(animations instanceof Array){for(var j=0;j<animations.length;j++){this.animations.push(animations[j]);}}
else this.animations.push(animations);for(var i=0;i<this.animations.length;i++){var animation=this.animations[i];animation.setMap(this);}}
OpenLayers.Map.prototype.removeAnimation=function(animation){}
MtcoBase={getZValue:function(feature,store){if(feature.geometry.components){for(var i=0,l=feature.geometry.components.length;i<l;i++){feature.geometry.components[i].z=feature.geometry.components[i].store;}}
else{feature.geometry.z=store;}},getMinimum:function(feature){var zmin=feature.geometry.components[0].z;var vertices=feature.geometry.components;for(var i=0;i<feature.geometry.components.length;i++){var z=feature.geometry.components[i].z;if(z<zmin){zmin=z;}}
return zmin;},getMaximum:function(feature){var zmax=feature.geometry.components[0].z;for(var i=0;i<feature.geometry.components.length;i++){var z=feature.geometry.components[i].z;if(z>zmax){zmax=z;}}
return zmax;},getLayerMinimum:function(layer){var features=layer.features;var zmin_feat=[];for(var i=0;i<features.length;i++){zmin_feat[i]=this.getMinimum(features[i]);zmin_feat.sort();zmin=zmin_feat[0];}
return zmin;},getLayerMaximum:function(layer){var features=layer.features;var zmax_feat=[];for(var i=0;i<features.length;i++){zmax_feat[i]=this.getMaximum(features[i]);zmax_feat.sort();zmax_feat.reverse();zmax=zmax_feat[0];}
return zmax;},getLength:function(vertices){var dist=0;var rad_const=Math.PI/180;for(i=0;i<vertices.length-1;i++){var x1=vertices[i].x;var x2=vertices[i+1].x;var y1=vertices[i].y;var y2=vertices[i+1].y;if(this.xUnit=="deegrees"||this.xUnit=="dd"){dist+=Math.acos(Math.cos((y2-y1)*rad_const)*Math.cos((y2-y1)*rad_const))*6370000;}
else{dist+=Math.sqrt(Math.pow((x2-x1),2)+Math.pow((y2-y1),2));}}
return dist;},getFeatureByValue:function(layer,nr){var feat_array=[];var length=feat_array.length;for(var i=0;i<layer.features.length;i++){var feat=layer.features[i];if(feat.attributes["TNODE"]==nr){feat_array[0]=feat;length++;}
if(feat.attributes["FNODE"]==nr){feat_array[1]=feat;length++;}}
return feat_array;},Douglas_Peucker:{outer:function(layer,tol){var container=new OpenLayers.Layer.Vector("container",{displayInLayerSwitcher:false});var features=[];this.tol=tol;layer.events.register("featuresadded",this,function(){for(var i=0,l=layer.features.length;i<l;i++){var feature=layer.features[i].clone();this.vertices=feature.geometry.components;var n=this.vertices.length-1;this.inner(0,n)
features.push(feature);}
container.addFeatures(features);});return container;},inner:function(s,n){if(n>s){var m=Math.floor(n/2);var x0=this.vertices[s].x;var y0=this.vertices[s].y;var xn=this.vertices[n].x;var yn=this.vertices[n].y;var xm=this.vertices[m].x;var ym=this.vertices[m].x;var a=Math.sqrt(Math.pow((xn-x0),2)+Math.pow((yn-y0),2));var b=Math.sqrt(Math.pow((xm-x0),2)+Math.pow((ym-y0),2));var c=Math.sqrt(Math.pow((xn-xm),2)+Math.pow((yn-ym),2));if(a>b&&a>c){var d=0;for(var i=1,l=n-1;i<l;i++){var xi=this.vertices[i].x;var yi=this.vertices[i].y;var temp=((xi-x0)*(-yn+y0)+(xn-x0)*(yi-y0))/Math.sqrt(Math.pow((-yn+y0),2)+Math.pow((xn-x0),2))
if(temp>d)d=temp;}
if(d<=d){}}
else{this.inner(s,m);}}}}}
OpenLayers.Map.prototype.EVENT_TYPES.push("sizeupdated");OpenLayers.Control.prototype.disableOthers=function(){var controls=this.map.controls;for(var i=0;i<controls.length;i++){if(controls[i]!=this)controls[i].deactivate();}};OpenLayers.Control.prototype.enableOthers=function(){var controls=this.map.controls;for(var i=0;i<controls.length;i++){if(controls[i]!=this)controls[i].activate();}};OpenLayers.MtcoSelectControl=OpenLayers.Class(OpenLayers.Control,{selectContainer:null,initialize:function(options){OpenLayers.Control.prototype.initialize.apply(this,[options]);OpenLayers.Util.extend(this,options);},activate:function(){var layers=this.map.layers;var length=layers.length;for(var i=0;i<length;i++){if(layers[i].name=="MtcoRootContainer")this.selectContainer=layers[i];else if(layers[i].CLASS_NAME=="OpenLayers.Layer.Vector.RootContainer"){this.selectContainer=layers[i];}
else this.selectContainer=this.layer;}
var isElement=false;for(var j=0,len=this.layers.length;j<len;j++){var controlLayer=this.layers[j];for(var k=0,l=this.selectContainer.layers.length;k<l;k++){var containerLayer=this.selectContainer.layers[k];if(controlLayer==containerLayer){isElement=true;}}
if(!isElement){this.selectContainer.layers.push(controlLayer);}
isElement=false;}
if(this.selectContainer.map==this.map)this.map.removeLayer(this.selectContainer);this.map.addLayer(this.selectContainer);return OpenLayers.Control.prototype.activate.apply(this,arguments);},deactivate:function(){return OpenLayers.Control.prototype.deactivate.apply(this,arguments);},CLASS_NAME:"OpenLayers.MtcoSelectControl"});OpenLayers.MtcoSelectControl.SelectFeature=OpenLayers.Class(OpenLayers.MtcoSelectControl,OpenLayers.Control.SelectFeature,{});OpenLayers.MtcoSelectControl.SelectFeature.prototype.CLASS_NAME="OpenLayers.MtcoSelectControl.SelectFeature";OpenLayers.MtcoSelectControl.SelectFeature.prototype.initialize=function(layers,options){this.EVENT_TYPES=OpenLayers.Control.SelectFeature.prototype.EVENT_TYPES.concat(OpenLayers.Control.prototype.EVENT_TYPES);OpenLayers.Control.prototype.initialize.apply(this,[options]);if(this.scope===null){this.scope=this;}
this.initLayer(layers);var callbacks={click:this.clickFeature,clickout:this.clickoutFeature};if(this.hover){callbacks.over=this.overFeature;callbacks.out=this.outFeature;}
this.callbacks=OpenLayers.Util.extend(callbacks,this.callbacks);this.handlers={feature:new OpenLayers.Handler.Feature(this,this.layer,this.callbacks,{geometryTypes:this.geometryTypes})};if(this.box){this.handlers.box=new OpenLayers.Handler.Box(this,{done:this.selectBox},{boxDivClassName:"olHandlerBoxSelectFeature"});}
OpenLayers.MtcoSelectControl.prototype.initialize.apply(this,[options]);}
OpenLayers.MtcoSelectControl.SelectFeature.prototype.activate=function(){if(!this.active){this.handlers.feature.activate();if(this.box&&this.handlers.box){this.handlers.box.activate();}}
return OpenLayers.MtcoSelectControl.prototype.activate.apply(this,arguments);}
OpenLayers.MtcoSelectControl.SelectFeature.prototype.deactivate=function(){if(this.active){this.handlers.feature.deactivate();if(this.handlers.box){this.handlers.box.deactivate();}}
return OpenLayers.MtcoSelectControl.prototype.deactivate.apply(this,arguments);}
OpenLayers.MtcoDecoration=OpenLayers.Class({initialize:function(options){OpenLayers.Util.extend(this,options);},destroy:function(){if(this.map){this.map.removeDecoration(this);this.map=null;}},setMap:function(map){this.map=map;this.activate();},activate:function(){},CLASS_NAME:"OpenLayers.MtcoDecoration"});OpenLayers.Map.prototype.addDecoration=function(decorations){if(!this.decorations)this.decorations=new Array();if(decorations instanceof Array){for(var j=0;j<decorations.length;j++){this.decorations.push(decorations[j]);}}
else this.decorations.push(decorations);for(var i=0;i<this.decorations.length;i++){var decoration=this.decorations[i];decoration.setMap(this);}}
OpenLayers.Map.prototype.removeDecoration=function(decoration){}
OpenLayers.Geometry.Point.prototype.z=null;OpenLayers.Geometry.Point.prototype.initialize=function(x,y,z){OpenLayers.Geometry.prototype.initialize.apply(this,arguments);this.x=parseFloat(x);this.y=parseFloat(y);if(z)this.z=parseFloat(z);};OpenLayers.Format.MtcoGeoJSON=OpenLayers.Class(OpenLayers.Format.GeoJSON,{initialize:function(options){OpenLayers.Format.GeoJSON.prototype.initialize.apply(this,[options]);OpenLayers.Util.extend(this.parseCoords,{"point":function(array){if(array.length!=3&&array.length!=2){throw"Only 2D or 3D points are supported: "+array;}
else if(array.length==2){return new OpenLayers.Geometry.Point(array[0],array[1]);}
else if(array.length==3){return new OpenLayers.Geometry.Point(array[0],array[1],array[2]);}}});},CLASS_NAME:"OpenLayers.Format.MtcoGeoJSON"});﻿OpenLayers.MtcoHelp=OpenLayers.Class({divId:null,div:null,helpDiv:null,contentDiv:null,content:null,contentRef:null,initialize:function(content,options){OpenLayers.Util.extend(this,options);this.content=content;this.draw();},draw:function(){this.div=OpenLayers.Util.getElement(this.divId);this.helpDiv=document.createElement("div");OpenLayers.Element.addClass(this.helpDiv,"mtcoHelpDiv");this.borderDiv=document.createElement("div");OpenLayers.Element.addClass(this.borderDiv,"mtcoHelpBorderDiv");this.contentDiv=document.createElement("div");OpenLayers.Element.addClass(this.contentDiv,"mtcoHelpContentDiv");this.contentP=document.createElement("p");OpenLayers.Element.addClass(this.contentP,"mtcoHelpContent");this.div.appendChild(this.helpDiv);this.contentRef.appendChild(this.borderDiv);this.borderDiv.appendChild(this.contentDiv);this.contentDiv.appendChild(this.contentP);this.contentP.innerHTML=this.content;$(this.helpDiv).bind("mouseover",this,this.handleOver);$(this.helpDiv).bind("mouseout",this,this.handleOver);},handleOver:function(event){var target=event.data.borderDiv;var left=Math.round(event.pageX/10)*10+5;var top=Math.round(event.pageY/10)*10+5;$(target).css("left",left+"px");$(target).css("top",top+"px");if($(target).css("display")=="none"){$(target).css("display","block");}
else{$(target).css("display","none");}},CLASS_NAME:"OpenLayers.MtcoHelp"});﻿OpenLayers.Style.MtcoSLD=OpenLayers.Class(OpenLayers.Style,{url:null,format:null,sld:null,styles:{},EVENT_TYPES:["loadstart","loadend"],initialize:function(url,options){OpenLayers.Util.extend(this,options);this.events=new OpenLayers.Events(this,this.div,this.EVENT_TYPES);this.url=url;this.format=new OpenLayers.Format.SLD();var format=this.format;var scope=this;OpenLayers.loadURL(this.url,null,null,function(request){scope.events.triggerEvent("loadstart");scope.sld=format.read(request.responseXML||request.responseText);scope.extractStyles();scope.events.triggerEvent("loadend");});OpenLayers.Style.prototype.initialize.apply(this,[options]);},extractStyles:function(){var namedLayers=this.sld.namedLayers;for(var key in namedLayers){this.styles[key]=namedLayers[key].userStyles;}},getStyle:function(name){var userStyles=this.styles[name];var style;for(var i=0;i<userStyles.length;++i){style=userStyles[i];if(style.isDefault){break;}}
return style;},CLASS_NAME:"OpenLayers.Style.MtcoSLD"});OpenLayers.MtcoLayerGroup.MtcoTracker=OpenLayers.Class(OpenLayers.MtcoLayerGroup,{name:null,url:null,ev:null,projection:null,last:null,interval:30000,labels:null,initialize:function(name,url,ev,options){OpenLayers.Util.extend(this,options);OpenLayers.MtcoLayerGroup.prototype.initialize.apply(this,[options]);this.name=name;this.url=url;this.ev=ev;},setMap:function(map){OpenLayers.MtcoLayerGroup.prototype.setMap.apply(this,arguments);this.getGeoJSON();},getGeoJSON:function(){var scope=this;this.projection=this.getProjection();var completeUrl=this.url+"/event/"+this.ev+"/srid/"+this.projection;if(this.last){completeUrl+="/last/"+this.last;}
$.get(completeUrl,function(text){var format=new OpenLayers.Format.GeoJSON();var result=format.read(text);scope.handleResponse(result);});},handleResponse:function(result){if(this.layers.length==0){this.createLayers(result);}
this.createFeatures(result);this.refresh(this.interval);},createLayers:function(result){var ids=this.countIds(result);var trackers=[];for(var i=0,l=ids.length;i<l;i++){var id=ids[i];var name="Layer_"+id;var layer=new OpenLayers.Layer.Vector(name);layer.id=id;trackers.push(layer);}
this.addLayers(trackers);if(this.labels)this.renameLayers(this.labels);},createFeatures:function(result){var features=[];for(var i=0,l=this.layers.length;i<l;i++){var layer=this.layers[i];layer.removeAllFeatures();for(var j=0,len=result.length;j<len;j++){var imei=result[j].attributes.imei;if(imei==layer.id){features.push(result[j]);}}
layer.addFeatures(features);}},countIds:function(result){var idArr=[];var count=1;var id1,id2;var ids=[];for(var i=0,l=result.length;i<l;i++){idArr.push(result[i].attributes.imei);}
idArr.sort();id1=idArr[0];ids.push(idArr[0]);for(var j=1,l2=idArr.length;j<l2;j++){id2=idArr[j];if(id2!=id1){ids.push(idArr[j]);count++;}
id1=id2;}
return ids;},getProjection:function(){var code=this.map.projection.getCode();codeSplit=code.split(":");srid=codeSplit[1];return srid;},refresh:function(interval){var scope=this;setTimeout(function(){scope.getGeoJSON();},interval);},renameLayers:function(labels){this.labels=labels;for(var key in labels){var imei=key;var name=labels[key];for(var i=0,l=this.layers.length;i<l;i++){var layer=this.layers[i];var id=layer.id;if(id==imei){layer.name=name;this.map.removeLayer(layer);this.map.addLayer(layer);}}}},zoomToGroup:function(){var bounds=this.getDataExtent();this.map.zoomToExtent(bounds);},zoomToTracker:function(trackerId){for(var i=0,l=this.layers.length;i<l;i++){if(trackerId==this.layers[i].id){var tracker=this.layers[i];}}
var bounds=tracker.getDataExtent();this.map.zoomToExtent(bounds);},CLASS_NAME:"OpenLayers.MtcoLayerGroup.MtcoTracker"});OpenLayers.MtcoAnimation.MtcoRun=OpenLayers.Class(OpenLayers.MtcoAnimation,{divId:null,div:null,autoActivate:false,runDiv:null,coverDiv:null,events:null,map:null,layer:null,layers:null,layergroup:null,vertices:null,stoppoints:null,startpoint:null,stopDistance:null,defaultUpdateSpeed:50,stopPointsIndex:0,animationStatus:0,defaultStartTime:new Date(0,0,0),startTime:null,currentTime:null,runningVelo:null,manVelo:null,accelArray:null,accelFactor:null,clockSpan:null,markerLayer:null,wormOpt:true,wormLayer:null,wormVertices:null,zIndex:900,defaultZIndex:0,imgPath:null,icons:null,initialize:function(layers,options){OpenLayers.MtcoAnimation.prototype.initialize.apply(this,[options]);this.imgPath=MtcoTools._getImgLocation();this.startTime=this.defaultStartTime;if(this.runningVelo)this.runningVelo.sort(this.numsort);else{this.manVelo=true;this.runningVelo=[25/18];}
if(this.accelArray){this.accelArray.sort(this.numsort);this.accelFactor=this.accelArray[0];}
if(!this.accelFactor)this.accelFactor=1;if(!this.icons){this.icons=this.imgPath+"mtcoRun_runner.png";}
this.markerLayer=new OpenLayers.Layer.Markers("mtcoRunLayer",{displayInLayerSwitcher:false,visibility:false});if(this.runningVelo&&this.runningVelo.length<=1)this.wormOpt=false;if(this.wormOpt){this.wormLayer=new OpenLayers.Layer.Vector("mtcoWormLayer",{displayInLayerSwitcher:false,visibility:false,style:new OpenLayers.Style({strokeColor:'#4e6c9b',strokeWidth:5,strokeOpacity:0.5})});this.wormVertices=[];}
if(layers instanceof OpenLayers.MtcoLayerGroup){this.layergroup=layers;this.layers=this.layergroup.layers;this.layer=this.layers[0];}
else this.layer=layers;this.layer.events.on({"loadend":this.activate,scope:this});this.draw();},destroy:function(){if(this.active){this.deactivate();}
this.markerLayer=null;if(this.wormLayer){this.wormLayer=null;this.wormVertices=null;}
OpenLayers.MtcoAnimation.prototype.destroy.apply(this,arguments);},numsort:function(a,b){return a-b;},activate:function(){if(!this.active){OpenLayers.MtcoAnimation.prototype.activate.apply(this,arguments);this.getVertices();this.startpoint=this.vertices[0];var length=this.getDistance();if(this.runningVelo){if(this.animationStatus==0){this.stopDistance=this.defaultUpdateSpeed*this.accelFactor*this.runningVelo[0]/1000;var stoppointLength=length/this.stopDistance;if(stoppointLength>10000)this.stopDistance=length/10000;this.slowestSpeed=1000*this.stopDistance/this.runningVelo[0];this.updateSpeed=this.slowestSpeed/this.accelFactor;}
this.getStoppoints();for(var i=0;i<this.runningVelo.length;i++){var iconpath;if(this.icons instanceof Array)iconpath=this.icons[i];else iconpath=this.icons
var icon=new OpenLayers.Icon(iconpath,new OpenLayers.Size(22,22));var marker=new OpenLayers.Marker(new OpenLayers.LonLat(this.startpoint.x,this.startpoint.y),icon);this.markerLayer.addMarker(marker);}
this.map.addLayer(this.markerLayer);if(this.wormLayer)this.map.addLayer(this.wormLayer);this.coverDiv=OpenLayers.Util.createDiv("mtcoRunCoverDiv"+OpenLayers.Util.createUniqueID(),new OpenLayers.Pixel(0,0));OpenLayers.Element.addClass(this.coverDiv,"mtcoRunCoverDiv");}}},deactivate:function(){if(this.active){OpenLayers.MtcoAnimation.prototype.deactivate.apply(this,arguments);this.vertices=null;this.stoppoints=null;this.markerLayer.clearMarkers();if(this.wormLayer){this.wormLayer.removeAllFeatures();this.map.removeLayer(this.wormLayer);}
this.map.removeLayer(this.markerLayer);this.coverDiv=null;}},draw:function(){this.runDiv=OpenLayers.Util.createDiv("mtcoRunDiv");OpenLayers.Element.addClass(this.runDiv,"mtcoTool");if(this.divId){this.div=OpenLayers.Util.getElement(this.divId);this.div.appendChild(this.runDiv);OpenLayers.Element.addClass(this.div,"mtcoRunToolDiv");}
else document.body.appendChild(this.runDiv);var buttonDiv=document.createElement("div");OpenLayers.Element.addClass(buttonDiv,"mtcoRunPanel");var accDiv=document.createElement("div");OpenLayers.Element.addClass(accDiv,"mtcoRunPanel");var layDiv=document.createElement("div");OpenLayers.Element.addClass(layDiv,"mtcoRunPanel");var veloDiv=document.createElement("div");OpenLayers.Element.addClass(veloDiv,"mtcoRunPanel");var imgSize=new OpenLayers.Size(16,16);var clockImg=OpenLayers.Util.createImage("mtcoClockImg",null,imgSize,this.imgPath+"mtcoRun_clock.png");this.clockSpan=document.createElement("span");$(this.clockSpan).html('00<span class="blink">:</span>00<span class="blink">:</span>00');var br=document.createElement("br");var backImg=OpenLayers.Util.createImage("mtcoBackImg",null,imgSize,this.imgPath+"mtcoRun_skip-backward.png");OpenLayers.Element.addClass(backImg,"mtcoRunButton");var startImg=OpenLayers.Util.createImage("mtcoStartImg",null,imgSize,this.imgPath+"mtcoRun_start.png");OpenLayers.Element.addClass(startImg,"mtcoRunButton");var pauseImg=OpenLayers.Util.createImage("mtcoPauseImg",null,imgSize,this.imgPath+"mtcoRun_pause.png");OpenLayers.Element.addClass(pauseImg,"mtcoRunButton");var stopImg=OpenLayers.Util.createImage("mtcoStopImg",null,imgSize,this.imgPath+"mtcoRun_stop.png");OpenLayers.Element.addClass(stopImg,"mtcoRunButton");this.runDiv.appendChild(buttonDiv);this.runDiv.appendChild(accDiv);this.runDiv.appendChild(layDiv);this.runDiv.appendChild(veloDiv);buttonDiv.appendChild(backImg);buttonDiv.appendChild(startImg);buttonDiv.appendChild(pauseImg);buttonDiv.appendChild(stopImg);buttonDiv.appendChild(br);buttonDiv.appendChild(clockImg);buttonDiv.appendChild(this.clockSpan);if(this.accelArray.length>1){for(var i=0;i<this.accelArray.length;i++){var accSpan=document.createElement("span");for(var j=0;j<=i;j++){var accImg=OpenLayers.Util.createImage(null,null,imgSize,this.imgPath+"mtcoRun_accel.png");accSpan.appendChild(accImg);}
var accRadio=document.createElement("input");accRadio.id="mtcoAccInput"+i;accRadio.name="mtcoAcc"
accRadio.type="radio";accRadio.value=this.accelArray[i];OpenLayers.Element.addClass(accRadio,"mtcoRunButton");var br=document.createElement("br");accDiv.appendChild(accRadio);accDiv.appendChild(accSpan);accDiv.appendChild(br);}
$(accDiv).find("#mtcoAccInput0").each(function(){this.checked=true;})}
if(this.layers){for(var j=0;j<this.layers.length;j++){var layLabel=document.createElement("label");layLabel.innerHTML=this.layers[j].name;var layRadio=document.createElement("input");layRadio.id=j;layRadio.name="mtcoLay";layRadio.type="radio";layRadio.value=this.layers[j].name;OpenLayers.Element.addClass(layRadio,"mtcoRunButton");var br=document.createElement("br");layDiv.appendChild(layRadio);layDiv.appendChild(layLabel);layDiv.appendChild(br);}
$(layDiv).find("#0").each(function(){this.checked=true;})}
if(this.manVelo){var veloLabel=document.createElement("label");veloLabel.innerHTML=OpenLayers.i18n("Geschwindigkeit")+"<br>";var veloInput=document.createElement("input");OpenLayers.Element.addClass(veloInput,"mtcoInput");veloInput.id="mtcoVeloInput";veloInput.name="mtcoVelo";veloInput.type="text";veloInput.size="3";veloInput.maxlength="3";veloInput.value=this.runningVelo[0]*18/5;var veloLabel2=document.createElement("label");veloLabel2.innerHTML="km/h";veloDiv.appendChild(veloLabel);veloDiv.appendChild(veloInput);veloDiv.appendChild(veloLabel2);}
this.events=new OpenLayers.Events(this,this.runDiv);this.events.on({"click":this.handleClick,scope:this});},getVertices:function(){var vertices=[];for(var i=0;i<this.layer.features.length;i++){var feature=this.layer.features[i];var vert=feature.geometry.components;for(var j=0;j<vert.length;j++){vertices.push(vert[j]);}}
this.vertices=vertices;},getStoppoints:function(){this.stoppoints=[];var rest=0;var arraylength=this.vertices.length;if(arraylength>0){for(var i=0;i<arraylength-1;i++){var x1=this.vertices[i].x;var x2=this.vertices[i+1].x;var y1=this.vertices[i].y;var y2=this.vertices[i+1].y;var length=Math.sqrt(Math.pow((x2-x1),2)+Math.pow((y2-y1),2));if(rest<length){var lengthNeu=length-rest;var divisor=lengthNeu/this.stopDistance;var restDivisor=rest/length;x1=x1+restDivisor*(x2-x1);y1=y1+restDivisor*(y2-y1);distX=(x2-x1)/divisor;distY=(y2-y1)/divisor;for(j=0;j<divisor;j++){x=x1+j*distX;y=y1+j*distY;this.stoppoints.push(new OpenLayers.Geometry.Point(x,y));}
rest=j*this.stopDistance-lengthNeu;}
else{rest=rest-length;}}
this.stoppoints.push(new OpenLayers.Geometry.Point(this.vertices[arraylength-1].x,this.vertices[arraylength-1].y));}},start:function(){if(this.animationStatus==4){this.animationStatus=3;this.startAnimation();}},stop:function(){if(this.animationStatus==1||this.animationStatus==-1){this.stopAnimation();this.animationStatus=4;}},startAnimation:function(){if(this.animationStatus==0||this.animationStatus==3||this.animationStatus==-1){if(this.animationStatus==3){this.resetLayer();this.resetAnimation();}
if(this.manVelo){this.inputVelo();}
this.defaultZIndex=this.markerLayer.getZIndex();this.markerLayer.setZIndex(this.zIndex);this.markerLayer.setVisibility(true);if(this.wormLayer){this.wormLayer.setZIndex(this.zIndex-1);this.wormLayer.setVisibility(true);}
this.animationStatus=1;this.zoomTo();this.disableOthers();this.doAnimation();}},zoomTo:function(){var bounds=this.layer.getDataExtent();this.map.zoomToExtent(bounds);},startBack:function(){if(this.animationStatus==1){this.animationStatus=-1;this.doAnimation();}},doAnimation:function(){if(this.animationStatus==1||this.animationStatus==-1){if(this.stopPointsIndex<this.stoppoints.length&&this.stopPointsIndex>=0){for(var i=0,l=this.runningVelo.length;i<l;i++){var pos=Math.floor(this.stopPointsIndex*this.runningVelo[i]/this.runningVelo[0]);if(pos>=this.stoppoints.length){pos=this.stoppoints.length-1;}
if(i==0)var pos0=pos;var loc=this.stoppoints[pos];var marker=this.markerLayer.markers[i];marker.lonlat=new OpenLayers.LonLat(loc.x,loc.y);this.markerLayer.drawMarker(marker);}
if(this.wormOpt)this.updateWorm(pos0,pos);if(this.animationStatus==1)this.stopPointsIndex++;else this.stopPointsIndex--;if(this.stopPointsIndex>=0){this.setClock(this.animationStatus*this.slowestSpeed);}
var scope=this;setTimeout(function(){scope.doAnimation();},scope.updateSpeed);}else{this.endAnimation();}}
else return;},updateWorm:function(pos0,pos){if(this.animationStatus==1||this.animationStatus==-1){if(this.worm){this.wormLayer.removeFeatures(this.worm);this.wormVertices=[];}
this.wormVertices=this.stoppoints.slice(pos0,pos);var linestring=new OpenLayers.Geometry.LineString(this.wormVertices);this.worm=new OpenLayers.Feature.Vector(linestring);this.wormLayer.addFeatures(this.worm);this.wormLayer.drawFeature(this.worm,this.wormLayer.style.defaultStyle);}
else return;},stopAnimation:function(){if(this.animationStatus==1||this.animationStatus==-1||this.animationStatus==2){this.animationStatus=3;this.enableOthers();this.resetLayer();this.resetAnimation();}
else return;},endAnimation:function(){if(this.animationStatus==1||this.animationStatus==-1||this.animationStatus==2){this.animationStatus=3;this.enableOthers();}
else return;},pauseAnimation:function(){if(this.animationStatus==1||this.animationStatus==-1){this.remindStatus=this.animationStatus;this.animationStatus=2;}else if(this.animationStatus==2){this.animationStatus=this.remindStatus;this.doAnimation();}
else return;},resetAnimation:function(){this.stopPointsIndex=0;this.resetClock();},resetLayer:function(){this.markerLayer.setVisibility(false);this.markerLayer.setZIndex(this.defaultZIndex);if(this.wormLayer){this.wormLayer.setVisibility(false);this.wormLayer.setZIndex(this.defaultZIndex-1);this.wormLayer.removeFeatures(this.worm);}
var numMarkers=this.markerLayer.markers.length;for(var i=0;i<numMarkers;i++){this.markerLayer.markers[i].lonlat=new OpenLayers.LonLat(this.startpoint.x,this.startpoint.y);this.markerLayer.markers[i].draw;this.markerLayer.redraw();}},setAcceleration:function(eventId){this.accelFactor=$('#'+eventId).attr('value');this.updateSpeed=this.slowestSpeed/this.accelFactor;},setLayer:function(key){this.stopAnimation();this.layer=this.layers[key];this.deactivate();this.activate();},getDistance:function(){var length=0;for(var i=0;i<this.vertices.length-1;i++){var x1=this.vertices[i].x;var x2=this.vertices[i+1].x;var y1=this.vertices[i].y;var y2=this.vertices[i+1].y;length+=Math.sqrt(Math.pow((x2-x1),2)+Math.pow((y2-y1),2));}
return length;},setClock:function(interval){if(typeof interval=="undefined"){interval=1000;}
function setDigits(digit){if(digit<10){return"0"+digit;}
return digit;};var time=new Date();time.setTime(this.startTime.getTime()+interval);var hours=setDigits(time.getHours());var minutes=setDigits(time.getMinutes());var seconds=setDigits(time.getSeconds());var clockstring=hours+'<span class="blink">:</span>';clockstring+=minutes+'<span class="blink">:</span>';clockstring+=seconds;$(this.clockSpan).html(clockstring);this.startTime=time;},resetClock:function(){$(this.clockSpan).html('00<span class="blink">:</span>00<span class="blink">:</span>00');this.startTime=this.defaultStartTime;},handleClick:function(event){var target=(event.target)?event.target.id:event.srcElement.id;var triggerelements={'mtcoBackImg':"startBack",'mtcoStartImg':"startAnimation",'mtcoPauseImg':"pauseAnimation",'mtcoStopImg':"stopAnimation",'mtcoVeloInput':"passEvent"};for(var i=0;i<this.accelArray.length;i++){triggerelements['mtcoAccInput'+i]="setAcceleration";}
for(var j=0;j<this.layers.length;j++){triggerelements[j]="setLayer";}
try{this[triggerelements[target]](target);}catch(err){if(typeof console!='undefined'){console.log("error MtcoRun",target,err);}}},passEvent:function(){return;},inputVelo:function(){this.stopAnimation();var value=parseFloat(document.getElementById("mtcoVeloInput").value)*5/18;this.runningVelo=[value];this.slowestSpeed=1000*this.stopDistance/this.runningVelo[0];this.updateSpeed=this.slowestSpeed/this.accelFactor;if(this.animationStatus==3||this.animationStatus==0)this.deactivate();this.activate();},CLASS_NAME:"OpenLayers.MtcoAnimation.MtcoRun"});﻿
OpenLayers.MtcoAnimation.MtcoWait=OpenLayers.Class(OpenLayers.MtcoAnimation,{startCount:0,stopCount:0,map:null,imgDiv:null,img:null,imgPath:null,stopped:true,initialize:function(options){OpenLayers.MtcoAnimation.prototype.initialize.apply(this,[options]);this.imgPath=MtcoTools._getImgLocation();this.imgDiv=OpenLayers.Util.createDiv("mtcoWaitDiv");this.img=OpenLayers.Util.createImage("mtcoWaitImg",null,null,this.imgPath+"ajax-loader.gif");this.imgDiv.appendChild(this.img);},setMap:function(map){this.map=map;this.map.events.register('preaddlayer',this,this.addLayer);for(var i=0;i<this.map.layers.length;i++){var layer=this.map.layers[i];layer.events.on({"loadstart":this.countStart,"loadend":this.countStop,"loadcancel":this.loadCancel,scope:this});}},addLayer:function(event){if(event.layer){event.layer.events.on({"loadstart":this.countStart,"loadend":this.countStop,"loadcancel":this.loadCancel,scope:this});}},countStart:function(event){if(this.startCount==0)this.start();this.startCount++;},countStop:function(event){this.stopCount++;if(this.stopCount==this.startCount)this.stop();},start:function(){this.map.viewPortDiv.appendChild(this.imgDiv);this.stopped=false;this.breakAnimation(OpenLayers.MtcoAnimation.MtcoRun);var that=this;},stop:function(){this.startCount=0;this.stopCount=0;this.map.viewPortDiv.removeChild(this.imgDiv);this.stopped=true;this.proceedAnimation(OpenLayers.MtcoAnimation.MtcoRun);},loadCancel:function(){console.log("loadCancel",this);},destroy:function(){this.stop();if(this.map){this.map.events.unregister('preaddlayer',this,this.addLayer);if(this.map.layers){for(var i=0;i<this.map.layers.length;i++){var layer=this.map.layers[i];layer.events.un({"loadstart":this.countStart,"loadend":this.countStop,scope:this});}}}},CLASS_NAME:"OpenLayers.MtcoAnimation.MtcoWait"});OpenLayers.Control.MtcoAttribution=OpenLayers.Class(OpenLayers.Control,{divId:null,imgPath:null,autoActivate:true,active:null,atDiv:null,contains:null,metrico:{},fisalis:{},osm:{},cadastre:{},initialize:function(contains,options){OpenLayers.Util.extend(this,options);this.imgPath=MtcoTools._getImgLocation();OpenLayers.Util.extend(this.metrico,{img:this.imgPath+"metrico_logo_small.png",label:"<a href='http://www.metrico.lu'>Metrico - Geographic Information Technologies</a>."});OpenLayers.Util.extend(this.fisalis,{img:this.imgPath+"fisalis.png",label:"<a href='http://www.fisalis.lu'>Fisalis</a>."});OpenLayers.Util.extend(this.osm,{label:"Map data &copy <a href='http://www.openstreetmap.org'>OpenStreetMap</a> contributors, <a href='http://creativecommons.org/licenses/by-sa/2.0/'>CC-BY-SA</a>."});OpenLayers.Util.extend(this.cadastre,{label:"<a href='http://www.act.public.lu/fr/index.html'>Administration du cadastre et de la topographie</a>."});this.contains=contains;this.atDiv=document.createElement("div");this.atDiv.id="mtcoAtDiv";this.div=OpenLayers.Util.getElement(this.divId);this.div.appendChild(this.atDiv);},activate:function(){this.draw();},deactivate:function(){},draw:function(){if($(this.atDiv).children()){var atDiv=this.atDiv;$(this.atDiv).children().each(function(){atDiv.removeChild(this);});}
var contentDiv=document.createElement("div");contentDiv.id="mtcoContentDiv_"+OpenLayers.Util.createUniqueID();OpenLayers.Element.addClass(contentDiv,"mtcoAtContentDiv");this.atDiv.appendChild(contentDiv);for(var i=0,l=this.contains.length;i<l;i++){var name=this.contains[i];if(this[name].add){var add=document.createElement("p");OpenLayers.Element.addClass(add,"mtcoAtAdd");OpenLayers.Element.addClass(add,"mtcoTool");add.innerHTML=this[name].add;contentDiv.appendChild(add);}
if(this[name].img){var img=document.createElement("img");OpenLayers.Element.addClass(img,"mtcoAtImg");img.src=this[name].img;contentDiv.appendChild(img);}
var p=document.createElement("p");OpenLayers.Element.addClass(p,"mtcoAtP");OpenLayers.Element.addClass(p,"mtcoTool");p.innerHTML=this[name].label;contentDiv.appendChild(p);}},CLASS_NAME:"OpenLayers.Control.MtcoAttribution"});OpenLayers.Control.MtcoFull=OpenLayers.Class(OpenLayers.Control,{divId:null,div:null,fullDiv:null,autoActivate:true,active:null,status:null,initialize:function(options){OpenLayers.Control.prototype.initialize.apply(this,[options]);},setMap:function(map){OpenLayers.Control.prototype.setMap.apply(this,arguments);this.origWidth=$(this.map.div).parent().css("width");this.origHeight=$(this.map.div).parent().css("height");},activate:function(){OpenLayers.Control.prototype.activate.apply(this,arguments);this.active=true;},deactivate:function(){OpenLayers.Control.prototype.deactivate.apply(this,arguments);this.active=false;},draw:function(){this.fullDiv=document.createElement("div");OpenLayers.Element.addClass(this.fullDiv,"mtcoFullButton");OpenLayers.Element.addClass(this.fullDiv,"nofull");if(!this.divId){this.div=document.createElement("div");OpenLayers.Element.addClass(this.div,"mtcoFullDiv");this.map.viewPortDiv.appendChild(this.div);}
else this.div=OpenLayers.Util.getElement(this.divId);this.div.appendChild(this.fullDiv);this.event=new OpenLayers.Events(this,this.fullDiv);this.event.register("click",undefined,this.onClick);this.status="nofull";},onClick:function(event){$(this.fullDiv).toggleClass("nofull full");if(this.status=="nofull"){$(this.map.div).parent().css("width","100%");$(this.map.div).parent().css("height","100%");this.status="full";}
else if(this.status=="full"){$(this.map.div).parent().css("width",this.origWidth);$(this.map.div).parent().css("height",this.origHeight);this.status="nofull";}
this.map.updateSize();this.map.events.triggerEvent("sizeupdated");},CLASS_NAME:"OpenLayers.Control.MtcoFull"});OpenLayers.Control.MtcoHighlightFeature=OpenLayers.Class(OpenLayers.Control,{elemID:null,attribute:null,autoActivate:true,active:null,container:null,highlightStyle:null,renderIntent:"highlight",map:null,zoomTo:true,initialize:function(elemID,attribute,options){OpenLayers.Control.prototype.initialize.apply(this,[options]);this.elemID=elemID;this.attribute=attribute;},activate:function(){if(!this.active){$(document.getElementById(this.elemID)).find(".mtcoHighlightFeature").bind("click",this,this.toggle);}
this.active=true;},deactivate:function(){if(this.active){$(document.getElementById(this.elemID)).find(".mtcoHighlightFeature").unbind("click");this.outClick();}
this.active=false;},setMap:function(map){OpenLayers.Control.prototype.setMap.apply(this,arguments);},onClick:function(event){event.data.outClick(event);var att=event.target.getAttribute("mtcoFeatAtt");var map=event.data.map;var left=map.maxExtent.right;var right=map.maxExtent.left;var bottom=map.maxExtent.top;var top=map.maxExtent.bottom;for(var key in map.layers){var layer=map.layers[key];if(layer.name!="mtcoHlLayer"){for(var kex in layer.features){var feature=layer.features[kex];var bounds=feature.geometry.bounds;var style=this.highlightStyle||this.renderIntent;if(att==feature.attributes[event.data.attribute]){$(event.target).addClass("highlighted");layer.drawFeature(feature,style);feature.highlighted=true;if(this.zoomTo){left=(left<=bounds.left)?left:bounds.left;bottom=(bottom<=bounds.bottom)?bottom:bounds.bottom;right=(right>=bounds.right)?right:bounds.right;top=(top>=bounds.top)?top:bounds.top;var extent=new OpenLayers.Bounds(left,bottom,right,top);}}}}}
if(this.zoomTo&&extent){this.map.zoomToExtent(extent,true);}
event.data.disableOthers();event.data.enableOthers();},outClick:function(event){var map=this.map;for(var key in map.layers){var layer=map.layers[key];for(var kex in layer.features){var feature=layer.features[kex];if(feature.highlighted){layer.drawFeature(feature,"default");feature.highlighted=false;}}}
$(document.getElementById(this.elemID)).find(".mtcoHighlightFeature").removeClass("highlighted");},createLayer:function(){this.container=new OpenLayers.Layer.Vector("mtcoHlLayer",{displayInLayerSwitcher:false});this.container.setZIndex(2000);},toggle:function(event){if($(this).hasClass("highlighted")){event.data.outClick(event);}
else{event.data.onClick(event);}},containerStyle:function(feature){this.container.styleMap=feature.layer.styleMap;this.container.style=this.highlightStyle||this.container.styleMap.styles[this.renderIntent];this.container.redraw();},CLASS_NAME:"OpenLayers.Control.MtcoHighlightFeature"});OpenLayers.Control.MtcoLayerSwitcher=OpenLayers.Class(OpenLayers.Control.LayerSwitcher,{divId:null,div:null,lsDiv:null,coverDiv:null,autoActivate:true,active:null,content:null,baseGroup:null,events:null,eventListeners:null,EVENT_TYPES:["redrawn"],initialize:function(options){var lsDiv=document.createElement("div");lsDiv.id="mtcoLsDiv"+OpenLayers.Util.createUniqueID();OpenLayers.Element.addClass(lsDiv,"mtcoLsDiv");OpenLayers.Element.addClass(lsDiv,"mtcoTool");lsDiv.style.position="relative";this.lsDiv=lsDiv;OpenLayers.Control.LayerSwitcher.prototype.initialize.apply(this,arguments);this.content={layers:[],layergroups:[]}
this.baseGroup=new OpenLayers.MtcoLayerGroup("Base Layer",null,{isBaseLayer:true});if(this.divId){this.div=OpenLayers.Util.getElement(this.divId)
this.div.appendChild(this.lsDiv);}
else document.body.appendChild(this.lsDiv);this.events=new OpenLayers.Events(this,this.div,null,false);this.events.on({"mousedown":this.stopProp,"mouseup":this.stopProp,"mousemove":this.stopProp,"dblclick":this.stopProp,"rightclick":this.stopProp,scope:this});this.coverDiv=OpenLayers.Util.createDiv("mtcoLsCoverDiv"+OpenLayers.Util.createUniqueID(),new OpenLayers.Pixel(0,0));OpenLayers.Element.addClass(this.coverDiv,"mtcoLsCoverDiv");this.lsDiv.appendChild(this.coverDiv);this.events=new OpenLayers.Events(this,undefined,this.EVENT_TYPES);if(this.eventListeners instanceof Object){this.events.on(this.eventListeners);}},activate:function(){if(!this.active){this.lsDiv.removeChild(this.coverDiv);}
this.active=true;},deactivate:function(){if(this.active){this.lsDiv.appendChild(this.coverDiv);}
this.active=false;},setMap:function(map){OpenLayers.Control.prototype.setMap.apply(this,arguments);this.map.events.on({"addlayer":this.redraw,"removelayer":this.redraw,scope:this});this.map.addGroup(this.baseGroup);},draw:function(){OpenLayers.Control.prototype.draw.apply(this);this.loadContents();this.redraw();return this.div;},loadLayers:function(){for(var i=0,l=this.baseGroup.layers.length;i<l;i++){this.baseGroup.removeLayer(this.baseGroup.layers[0]);}
this.content.layers=[];this.content.layergroups=[];for(var j=0,l=this.map.layers.length;j<l;j++){var layer=this.map.layers[j];if(layer.displayInLayerSwitcher){if(!layer.isBaseLayer&&!layer.layerGroup){this.content.layers.push(layer);}else if(layer.isBaseLayer){this.baseGroup.addLayer(layer);}}}
for(var k=0,l=this.map.layerGroups.length;k<l;k++){var layergroup=this.map.layerGroups[k];if(layergroup.displayInLayerSwitcher){if(layergroup.isBaseLayer){this.content.layergroups.unshift(layergroup);}else{this.content.layergroups.push(layergroup);}}}},loadContents:function(){OpenLayers.Event.observe(this.div,"click",this.ignoreEvent);OpenLayers.Event.observe(this.div,"dblclick",this.ignoreEvent);var lsUl=document.createElement("ul");OpenLayers.Element.addClass(lsUl,"mtcoLsUl");this.lsBase=document.createElement("li");OpenLayers.Element.addClass(this.lsBase,"mtcoLsBase");this.baseLayersDiv=document.createElement("ul");OpenLayers.Element.addClass(this.baseLayersDiv,"mtcoLsBaseLayers");OpenLayers.Element.addClass(this.baseLayersDiv,"mtcoLsGroupUl");this.lsData=document.createElement("li");OpenLayers.Element.addClass(this.lsData,"mtcoLsData");this.dataLayersDiv=document.createElement("ul");OpenLayers.Element.addClass(this.dataLayersDiv,"mtcoLsDataLayers");OpenLayers.Element.addClass(this.dataLayersDiv,"mtcoLsGroupUl");lsUl.appendChild(this.lsBase);lsUl.appendChild(this.lsData);this.lsBase.appendChild(this.baseLayersDiv);this.lsData.appendChild(this.dataLayersDiv);this.lsDiv.appendChild(lsUl);},redraw:function(){if(!this.checkRedraw()){return this.div;}
this.clear();this.loadLayers();for(var i=0,l=this.content.layers.length;i<l;i++){var layer=this.content.layers[i];var lsLayer=this.drawLayer(layer);this.dataLayersDiv.appendChild(lsLayer);}
var parent=this.map;var appendUl=this.dataLayersDiv;this.iterGroup(parent,appendUl);this.events.triggerEvent("redrawn");return this.div;},iterGroup:function(parent,appendUl){if(parent){for(var i in parent.layerGroups){var layergroup=parent.layerGroups[i];var baseLayer=layergroup.isBaseLayer;var name=layergroup.name;var id=layergroup.id;var closedInLayerSwitcher=layergroup.closedInLayerSwitcher;var klasse,display;if(closedInLayerSwitcher){klasse="closed";display="none";}else{klasse="open";display="block"}
var lsGroup=document.createElement("li");lsGroup.id="ls_"+layergroup.id;if(layergroup.timeline){OpenLayers.Element.addClass(lsGroup,"mtcoLsLayer");}
else{OpenLayers.Element.addClass(lsGroup,"mtcoLsGroup");}
var lsGroupUl=document.createElement("ul");OpenLayers.Element.addClass(lsGroupUl,"mtcoLsGroupUl");lsGroupUl.id=id;$(lsGroupUl).css("display",display);var mtcoLsImgSpan=document.createElement("div");OpenLayers.Element.addClass(mtcoLsImgSpan,"mtcoLsImgSpan");OpenLayers.Element.addClass(mtcoLsImgSpan,klasse);var nameSpan=document.createElement("span");OpenLayers.Element.addClass(nameSpan,"mtcoLabelSpan");var spanDiv=document.createElement("span");var inputElem=document.createElement("input");inputElem.id=this.id+"_input_"+id;inputElem.type="checkbox";inputElem.checked=layergroup.getVisibility();OpenLayers.Element.addClass(inputElem,"mtcoLsInput");nameSpan.innerHTML=name;lsGroup.appendChild(spanDiv);lsGroup.appendChild(lsGroupUl);spanDiv.appendChild(mtcoLsImgSpan);if(!baseLayer)spanDiv.appendChild(inputElem);spanDiv.appendChild(nameSpan);var layers=parent.layerGroups[i].layers;if(layers){for(var j=0,l=layers.length;j<l;j++){var layer=layers[j];var lsLayer=this.drawLayer(layer);lsGroupUl.appendChild(lsLayer);}}
if(layergroup.parentGroup){appendUl=document.getElementById(layergroup.parentGroup.id);}
else{appendUl=(baseLayer)?this.baseLayersDiv:this.dataLayersDiv;}
appendUl.appendChild(lsGroup);$(mtcoLsImgSpan).bind("click",{groupUl:lsGroupUl,layergroup:layergroup},this.expandGroup);$(inputElem).bind("mouseup",{groupUl:lsGroupUl,layergroup:layergroup,layerswitcher:this},this.onClick);this.iterGroup(parent.layerGroups[i],appendUl);}}},drawLayer:function(layer){var lsLayer=document.createElement("li");lsLayer.id="ls_"+layer.id;OpenLayers.Element.addClass(lsLayer,"mtcoLsLayer");var baseLayer=layer.isBaseLayer;if(layer.displayInLayerSwitcher){var checked=(baseLayer)?(layer==this.map.baseLayer):layer.getVisibility();var inputElem=document.createElement("input");inputElem.id=this.id+"_input_"+layer.name;inputElem.type=(baseLayer)?"radio":"checkbox";inputElem.checked=checked;inputElem.defaultChecked=checked;OpenLayers.Element.addClass(inputElem,"mtcoLsInput");var labelSpan=document.createElement("span");OpenLayers.Element.addClass(labelSpan,"mtcoLabelSpan")
if(!baseLayer&&!layer.inRange){inputElem.disabled=true;labelSpan.style.color="gray";}
labelSpan.innerHTML=layer.name;labelSpan.style.verticalAlign=(baseLayer)?"bottom":"baseline";var groupArray=(baseLayer)?this.baseLayers:this.dataLayers;groupArray.push({'layer':layer,'inputElem':inputElem,'labelSpan':labelSpan});lsLayer.appendChild(inputElem);lsLayer.appendChild(labelSpan);$(inputElem).bind("mouseup",{layer:layer,layerswitcher:this},this.onClick);}
return lsLayer;},clear:function(){this.baseLayersDiv.innerHTML="";this.baseLayers=[];this.dataLayersDiv.innerHTML="";this.dataLayers=[];},expandGroup:function(event){var groupUl=event.data.groupUl;var display=$(groupUl).css("display");var group=event.data.layergroup;if(display=="block"){display="none";group.closedInLayerSwitcher=true;}else{display="block";group.closedInLayerSwitcher=false;}
$(this).toggleClass("closed open");$(groupUl).css("display",display);},onClick:function(event){var data=event.data;var target=this;var layergroup;var layergroups=data.layerswitcher.map.layerGroups;if(data.layergroup){layergroup=data.layergroup;data.layerswitcher.onGroupInputClick(target,data);}else if(data.layer){layergroup=data.layer.layerGroup;data.layerswitcher.onInputClick(target,data);}
if($(target).parents("ul")[0]){var groupUl=$(target).parents("ul")[0];var checked=target.checked;var count=0;if(!checked){$(groupUl).find("input").each(function(){if(this.checked!=checked){count++;}});}
if(count==0&&$(groupUl).parent().children().children("input")[0]){$(groupUl).parent().children().children("input")[0].checked=checked;var id=$(groupUl).parent()[0].id;for(var i=0,l=layergroups.length;i<l;i++){var id2="ls_"+layergroups[i].id;if(id==id2){layergroups[i].visibility=checked;}}}}},onInputClick:function(target,data){var layer=data.layer;var layerswitcher=data.layerswitcher;if(!target.disabled){if(target.type=="radio"){layer.map.setBaseLayer(layer);for(var i=0,l=layerswitcher.baseLayers.length;i<l;i++){var baseLayer=layerswitcher.baseLayers[i];if(baseLayer.layer==layer){baseLayer.inputElem.checked=true;}else{baseLayer.inputElem.checked=false;}}}else{target.checked=!target.checked;layerswitcher.updateMap();}}},onGroupInputClick:function(target,data){if(!target.disabled){target.checked=!target.checked;var checked=target.checked;var groupUl=data.groupUl;$(groupUl).find("input").each(function(){this.checked=checked;});data.layergroup.setVisibility(checked);data.layerswitcher.updateMap();}},checkRedraw:function(){var redraw=false;if(!this.layerStates.length||(this.map.layers.length!=this.layerStates.length)){redraw=true;}else{for(var i=0,len=this.layerStates.length;i<len;i++){var layerState=this.layerStates[i];var layer=this.map.layers[i];if((layerState.name!=layer.name)||(layerState.inRange!=layer.inRange)||(layerState.id!=layer.id)||(layerState.visibility!=layer.visibility)){redraw=true;break;}}}
return redraw;},ignoreEvent:function(event){OpenLayers.Event.stop(event);},stopProp:function(event){event.cancelBubble=true;if(event.stopPropagation)event.stopPropagation();},CLASS_NAME:"OpenLayers.Control.MtcoLayerSwitcher"});OpenLayers.Control.MtcoSearch=OpenLayers.Class(OpenLayers.Control,{divId:null,seDiv:null,container:null,autoActivate:true,active:null,searchEvents:null,emptyEvents:null,url:"http://www.gis-hosting.lu/location/osm/",response:null,style:null,initialize:function(options){OpenLayers.Util.extend(this,options);var scope=this;$.ajaxSetup({error:function(a,b,c){if(b){scope.handleResponse(undefined,b);}
else if(c){scope.handleResponse(undefined,c);}}});this.seDiv=document.createElement("div");this.seDiv.id="mtcoSeDiv";OpenLayers.Element.addClass(this.seDiv,"mtcoTool");this.div=OpenLayers.Util.getElement(this.divId);this.div.appendChild(this.seDiv);this.style=new OpenLayers.StyleMap({'default':new OpenLayers.Style({'pointRadius':8,'fillColor':'#48a9c6','strokeColor':'#3b879d','fillOpacity':0.8,'strokeOpacity':1,'strokeWidth':1.5}),'select':new OpenLayers.Style({'fillColor':'#147896','strokeColor':'#1d5d70'})});this.container=new OpenLayers.Layer.Vector("mtcoSearchLayer",{displayInLayerSwitcher:false,styleMap:this.style});},activate:function(){this.map.addLayer(this.container);this.draw();},deactivate:function(){},draw:function(){if($(this.seDiv).children()){var seDiv=this.seDiv;$(this.seDiv).children().each(function(){seDiv.removeChild(this);});}
var inputDiv=document.createElement("div");OpenLayers.Element.addClass(inputDiv,"mtcoSearchInputDiv");this.input=document.createElement("input");this.input.id="mtcoSearchInput";this.input.name="mtcoSearch";this.input.type="text";this.input.size="20";OpenLayers.Element.addClass(this.input,"mtcoInput");OpenLayers.Element.addClass(this.input,"mtcoSearchInput");var searchImg=document.createElement("div");OpenLayers.Element.addClass(searchImg,"mtcoSearchImg");var emptyImg=document.createElement("div");OpenLayers.Element.addClass(emptyImg,"mtcoSearchEmpty");inputDiv.appendChild(this.input);inputDiv.appendChild(searchImg);inputDiv.appendChild(emptyImg);this.outputDiv=document.createElement("div");OpenLayers.Element.addClass(this.outputDiv,"mtcoSearchOutputDiv");this.seDiv.appendChild(inputDiv);this.seDiv.appendChild(this.outputDiv);this.searchEvents=new OpenLayers.Events(this,searchImg);this.searchEvents.on({"click":this.search,scope:this});this.emptyEvents=new OpenLayers.Events(this,emptyImg);this.emptyEvents.on({"click":this.clearSearch,scope:this});},drawOutput:function(response){this.response=response;var outputUl=document.createElement("ul");outputUl.id="mtcoSearchList";this.outputDiv.appendChild(outputUl);var format=new OpenLayers.Format.GeoJSON();var features=[];for(var i=0,l=response.features.length;i<l;i++){var feature=format.read(this.response.features[i])[0];feature.fid=i;features.push(feature);var output=document.createElement("li");output.id=i;OpenLayers.Element.addClass(output,"mtcoSearchOutput");output.innerHTML=feature.attributes.name;outputUl.appendChild(output);var listEvents=new OpenLayers.Events(this,output);listEvents.on({"click":this.select,scope:this});}
this.container.addFeatures(features);var extent=this.container.getDataExtent();this.map.zoomToExtent(extent,true);},search:function(event){this.clearSearch();if(this.input.value){var value="search/"+this.input.value;var srid="srid/"+this.map.projection.projCode.slice(5);var query=this.url+value+"/"+srid;var scope=this;$.get(query,function(response,status,request){scope.handleResponse(response,request.status);});}},handleResponse:function(response,error){if(response){this.drawOutput(response);}
else if(error||error==0){var output=document.createElement("p");this.outputDiv.appendChild(output);output.innerHTML=OpenLayers.i18n("ajaxError");}
else{var output=document.createElement("p");this.outputDiv.appendChild(output);output.innerHTML=OpenLayers.i18n("noResult");}},select:function(event){this.unselect(event);var i=event.target.id;var feature=this.container.features[i];var extent=feature.geometry.getBounds();this.map.zoomToExtent(extent,true);this.container.drawFeature(feature,"select");},unselect:function(event){for(var i=0,l=this.container.features.length;i<l;i++){var feature=this.container.features[i];this.container.drawFeature(feature,"default");}},clearSearch:function(event){if($(this.outputDiv).children()){var outputDiv=this.outputDiv;$(this.outputDiv).children().each(function(){outputDiv.removeChild(this);});}
this.container.removeFeatures(this.container.features);if(event){this.input.value="";}},CLASS_NAME:"OpenLayers.Control.MtcoSearch"});OpenLayers.Control.MtcoSelectFeature=OpenLayers.Class(OpenLayers.Control,{layers:null,selectStyle:null,renderIntent:"select",EVENT_TYPES:["featureselected","nofeatureselected"],events:null,autoActivate:false,active:null,onSelect:function(){},onUnselect:function(){},onOver:function(){},onOut:function(){},multiple:false,initialize:function(layers,options){this.EVENT_TYPES=OpenLayers.Control.MtcoSelectFeature.prototype.EVENT_TYPES.concat(OpenLayers.Control.prototype.EVENT_TYPES);OpenLayers.Control.prototype.initialize.apply(this,[options]);if(layers.CLASS_NAME=="OpenLayers.Layer.MtcoLayerGroup")layers=layers.layers;else layers=(layers instanceof Array)?layers:[layers];this.layers=layers;this.events=new OpenLayers.Events(this,null,this.EVENT_TYPES);},destroy:function(){},activate:function(){this.cache={};this.map.events.on({click:this.onClick,mousemove:this.onMousemove,scope:this});for(var i=0,l=this.layers.length;i<l;i++){this.layers[i].events.on({featureclick:this.select,featureover:this.over,featureout:this.out,scope:this});}
this.events.on({nofeatureselected:this.unselectAll,scope:this});return OpenLayers.Control.prototype.activate.apply(this,arguments);},deactivate:function(){},getFeatures:function(x,y){var features=[],targets=[],layers=[];var layer,target,feature,i,len;for(i=this.map.layers.length-1;i>=0;--i){layer=this.map.layers[i];if(layer.div.style.display!=="none"){var controlLayer=this.isControlLayer(layer);if(layer instanceof OpenLayers.Layer.Vector&&controlLayer){target=document.elementFromPoint(x,y);if(navigator.userAgent.match("Opera")&&target&&target.nodeName=="svg"){var svgxy=this.getPosition(target);var rect=target.createSVGRect();rect.x=x-svgxy[0];rect.y=y-svgxy[1];rect.width=rect.height=1;var hits=target.getIntersectionList(rect,null);for(var k=0,l=hits.length;k<l;k++){if(hits[k]._featureId)target=hits[k];}}
while(target&&target._featureId){feature=layer.getFeatureById(target._featureId);if(feature){features.push(feature);target.style.display="none";targets.push(target);target=document.elementFromPoint(x,y);i=0;}else{target=false;}}}
layers.push(layer);layer.div.style.display="none";}}
for(i=0,len=targets.length;i<len;++i){targets[i].style.display="";}
for(i=layers.length-1;i>=0;--i){layers[i].div.style.display="block";}
return features;},isControlLayer:function(layer){for(var i=0,l=this.layers.length;i<l;i++){if(layer==this.layers[i])return true;}
return false;},getPosition:function(element){var left=0;var top=0;if(element.offsetParent){do{left+=element.offsetLeft;top+=element.offsetTop;}while(element=element.offsetParent);return[left,top];}},onClick:function(event){var agent=navigator.userAgent;var docType=(agent.match("Opera")||agent.match("Safari"));var x=docType?event.pageX:event.clientX;var y=docType?event.pageY:event.clientY;var features=this.getFeatures(x,y);var feature,layer,more,clicked={};for(i=0,len=features.length;i<len;++i){feature=features[i];layer=feature.layer;clicked[layer.id]=true;more=layer.events.triggerEvent("featureclick",{feature:feature,shiftKey:event.shiftKey});if(more===false){break;}}
for(i=0,len=this.map.layers.length;i<len;++i){layer=this.map.layers[i];if(!clicked[layer.id]){layer.events.triggerEvent("nofeatureclick");}}
if(features.length==0){this.events.triggerEvent("nofeatureselected");}},onMousemove:function(evt){var agent=navigator.userAgent;var docType=(agent.match("Opera")||agent.match("Safari"));var x=docType?evt.pageX:evt.clientX;var y=docType?evt.pageY:evt.clientY;var features=this.getFeatures(x,y);var over={},newly=[],feature;for(var i=0,len=features.length;i<len;++i){feature=features[i];over[feature.id]=feature;if(!this.cache[feature.id]){newly.push(feature);}}
var out=[];for(var id in this.cache){feature=this.cache[id];if(feature.layer&&feature.layer.map){if(!over[feature.id]){out.push(feature);}}else{delete this.cache[id];}}
var more;for(i=0,len=newly.length;i<len;++i){feature=newly[i];this.cache[feature.id]=feature;more=feature.layer.events.triggerEvent("featureover",{feature:feature});if(more===false){break;}}
for(i=0,len=out.length;i<len;++i){feature=out[i];delete this.cache[feature.id];more=feature.layer.events.triggerEvent("featureout",{feature:feature});if(more===false){break;}}},select:function(event){var feature=event.feature;var layer=feature.layer;if(!feature.selected){if(!this.multiple||!event.shiftKey){this.unselectAll();}
if(!feature.selected){layer.selectedFeatures.push(feature);}
this.highlight(feature);this.onSelect.call(this.scope,event);feature.selected=true;layer.events.triggerEvent("featureselected",{feature:feature});}},unselect:function(feature){var layer=feature.layer;this.unhighlight(feature);OpenLayers.Util.removeItem(layer.selectedFeatures,feature);feature.selected=false;this.onUnselect.call(this.scope,feature);layer.events.triggerEvent("featureunselected",{feature:feature});},unselectAll:function(){for(var i=0,l=this.layers.length;i<l;i++){var layer=this.layers[i];for(var j=layer.selectedFeatures.length-1;j>=0;--j){var feature=layer.selectedFeatures[j];this.unselect(feature);}}},over:function(event){$(this.map.viewPortDiv).css("cursor","pointer");var feature=event.feature;feature.layer.drawFeature(feature,"highlight"||"default");this.onOver.call(this.scope,feature);},out:function(event){$(this.map.viewPortDiv).css("cursor","auto");var feature=event.feature;feature.layer.drawFeature(feature,feature.style||feature.layer.style||"default");this.onOut.call(this.scope,feature);},highlight:function(feature){var style=this.selectStyle||this.renderIntent;feature.layer.drawFeature(feature,style);this.events.triggerEvent("featurehighlighted",{feature:feature});},unhighlight:function(feature){feature.layer.drawFeature(feature,feature.style||feature.layer.style||"default");this.events.triggerEvent("featureunhighlighted",{feature:feature});},CLASS_NAME:"OpenLayers.Control.MtcoSelectFeature"});OpenLayers.Layer.Vector.prototype.EVENT_TYPES.push("featureover","featureout","featureclick","nofeatureclick");OpenLayers.Control.MtcoTimeline=OpenLayers.Class(OpenLayers.Control,{divId:null,div:null,interval:null,slideupdate:false,chronology:false,autoActivate:true,active:null,events:null,timeStopWidth:null,timeStopHeight:6,positionX:0,positionY:0,position:null,layergroup:null,layers:null,initLayer:null,slider:null,tlDiv:null,backgroundDiv:null,divEvents:null,timelineDivX:null,imgPath:null,initialize:function(layergroup,options){var tlDiv=document.createElement("div");tlDiv.id="mtcoTlDiv"+OpenLayers.Util.createUniqueID();OpenLayers.Element.addClass(tlDiv,"mtcoTlDiv");OpenLayers.Control.prototype.initialize.apply(this,[options]);this.imgPath=MtcoTools._getImgLocation();this.tlDiv=tlDiv;if(layergroup===null){this.layers=[];}
else{this.layergroup=layergroup;this.layergroup.timeline=true;this.layers=[];for(var key in this.layergroup.layers){this.layergroup.layers[key].displayInLayerSwitcher=false;this.layers.push(this.layergroup.layers[key]);}}
if(this.initLayer===null){this.initLayer=this.layers[0];}
if(this.divId){this.div=OpenLayers.Util.getElement(this.divId);this.div.appendChild(this.tlDiv);}
else document.body.appendChild(this.tlDiv);if(!this.interval)this.interval=1;this.position=new OpenLayers.Pixel(this.positionX,this.positionY);this.timelineDivX=parseInt($(this.tlDiv).css("width"));this.layergroup.events.register("changelayer",this,this.checkDisable);},activate:function(){if(!this.active){this.sliderEvents=new OpenLayers.Events(this,this.slider,null,true,{includeXY:true});this.sliderEvents.on({"mousedown":this.TimelineDown,"mousemove":this.TimelineDrag,"mouseup":this.TimelineUp,"dblclick":this.doubleClick,"click":this.doubleClick});this.divEvents=new OpenLayers.Events(this,this.tlDiv,null,true,{includeXY:true});this.divEvents.on({"mousedown":this.divClick,"mousemove":this.passEventToSlider,"mouseup":this.passEventToSlider,"dblclick":this.doubleClick,"click":this.doubleClick});$(".mtcoTlScaleText").css("color","#216778");this.active=true;this.draw();this.checkDisable();}},deactivate:function(){if(this.active){this.sliderEvents.un({"mousedown":this.TimelineDown,"mousemove":this.TimelineDrag,"mouseup":this.TimelineUp,"dblclick":this.doubleClick,"click":this.doubleClick});this.sliderEvents.destroy();this.divEvents.un({"mousedown":this.divClick,"mousemove":this.passEventToSlider,"mouseup":this.passEventToSlider,"dblclick":this.doubleClick,"click":this.doubleClick});this.divEvents.destroy();$(this.slider).css("background","#d5d5d3");$(".mtcoTlScaleText").css("color","#d5d5d3");this.active=false;}},destroy:function(){this._removeTimeline();OpenLayers.Control.PanZoom.prototype.destroy.apply(this,arguments);delete this.mouseDragStart;delete this.timeStart;},checkDisable:function(){if(!this.layergroup.visibility||!this.layergroup.map){this.deactivate();}
else if(this.sliderEvents&&this.divEvents){this.activate();}},setMap:function(map){OpenLayers.Control.prototype.setMap.apply(this,arguments);},addLayers:function(layers){this.layers=layers;this.draw();},getActiveLayer:function(){for(var key in this.layers){if(this.layers[key]==this.initLayer){return key;}}},draw:function(){this._removeTimeline();OpenLayers.Control.prototype.draw.apply(this,arguments);var px=new OpenLayers.Pixel(10,10);this.startLeft=px.x-2;var sz=new OpenLayers.Size(0,0);this.timeStopWidth=(this.timelineDivX-2*px.x)/this.layers.length;this._addTimeline(px,sz);this.addScaleDiv();this.toggle(this.getActiveLayer());return this.tlDiv;},_addTimeline:function(px,sz){var layerToEnd=this.layers.length-1-this.getActiveLayer();sz.w=this.timeStopWidth*this.layers.length;sz.h=this.timeStopHeight;var slider=OpenLayers.Util.createDiv("mtcoTlSlider"+OpenLayers.Util.createUniqueID(),new OpenLayers.Pixel(px.x,px.y-1),new OpenLayers.Size(sz.h+2,sz.h+4),null,"absolute");OpenLayers.Element.addClass(slider,"mtcoTlSlider");this.slider=slider;this.sliderEvents=new OpenLayers.Events(this,slider,null,true,{includeXY:true});this.sliderEvents.on({"mousedown":this.TimelineDown,"mousemove":this.TimelineDrag,"mouseup":this.TimelineUp,"dblclick":this.doubleClick,"click":this.doubleClick});var div=OpenLayers.Util.createDiv("mtcoTlBar"+OpenLayers.Util.createUniqueID(),px,sz);OpenLayers.Element.addClass(div,"mtcoTlBar");this.backgroundDiv=div;this.divEvents=new OpenLayers.Events(this,this.tlDiv,null,true,{includeXY:true});this.divEvents.on({"mousedown":this.divClick,"mousemove":this.passEventToSlider,"mouseup":this.passEventToSlider,"dblclick":this.doubleClick,"click":this.doubleClick});this.tlDiv.appendChild(this.backgroundDiv);this.tlDiv.appendChild(slider);this.moveTimeline();this.map.events.register("changelayer",this,this.moveTimeline);return px;},addScaleDiv:function(){for(var i=0,l=this.layers.length;i<l;i++){var div=document.createElement("div");var innerDiv=document.createElement("div");var innerP=document.createElement("p");div.id="mtcoTlScale"+i;OpenLayers.Element.addClass(div,"mtcoTlScale");div.style.left=i*this.timeStopWidth+"px";div.style.width=this.timeStopWidth-1+"px";div.style.height=this.timeStopHeight-1+"px";OpenLayers.Element.addClass(innerDiv,"mtcoTlInnerScale");innerDiv.style.width=Math.round((this.timeStopWidth-1)/2)+"px";innerDiv.style.height=this.timeStopHeight+"px";if((i)%this.interval==0){innerP.innerHTML=this.layers[i].name
OpenLayers.Element.addClass(innerP,"mtcoTlScaleText");}
this.backgroundDiv.appendChild(div);div.appendChild(innerDiv);div.appendChild(innerP);}},_removeTimeline:function(){if(this.slider){this.sliderEvents.un({"mousedown":this.TimelineDown,"mousemove":this.TimelineDrag,"mouseup":this.TimelineUp,"dblclick":this.doubleClick,"click":this.doubleClick});this.sliderEvents.destroy();this.divEvents.un({"mousedown":this.divClick,"mousemove":this.passEventToSlider,"mouseup":this.passEventToSlider,"dblclick":this.doubleClick,"click":this.doubleClick});this.divEvents.destroy();this.tlDiv.removeChild(this.slider);this.tlDiv.removeChild(this.backgroundDiv);this.backgroundDiv=null;this.slider=null;this.map.events.unregister("changelayer",this,this.moveTimeline);}},passEventToSlider:function(evt){this.sliderEvents.handleBrowserEvent(evt);},DivMouseout:function(evt){evt.xy=new OpenLayers.Pixel(evt.clientX-evt.currentTarget.offsets[0],evt.clientY-evt.currentTarget.offsets[1]);evt.data.tl_this.TimelineUp(evt);OpenLayers.Event.stop(evt);},divClick:function(evt){if(!OpenLayers.Event.isLeftClick(evt)){return;}
var x=evt.xy.x;var left=OpenLayers.Util.pagePosition(evt.object)[0];var level=(x-left)/this.timeStopWidth;level=Math.floor(level);if(level>=0&&level<this.layers.length){this.toggle(level);}
OpenLayers.Event.stop(evt);},TimelineDown:function(evt){if(!OpenLayers.Event.isLeftClick(evt)){return;}
this.map.events.on({"mousemove":this.passEventToSlider,"mouseup":this.passEventToSlider,scope:this});this.mouseDragStart=evt.xy.clone();this.timeStart=evt.xy.clone();this.tlDiv.style.cursor="move";$(this.tlDiv).bind("mouseleave",{tl_this:this},this.DivMouseout);OpenLayers.Event.stop(evt);},TimelineDrag:function(evt){if(this.mouseDragStart!=null){var deltaX=evt.xy.x-this.mouseDragStart.x;var offsets=OpenLayers.Util.pagePosition(this.backgroundDiv);if((evt.clientX-offsets[0])>0&&(evt.clientX-offsets[0])<parseInt(this.backgroundDiv.style.width)-2){var newLeft=parseInt(this.slider.style.left)+deltaX;this.slider.style.left=newLeft+"px";this.mouseDragStart=evt.xy.clone();if(this.slideupdate){var level=Math.round((evt.xy.x)/this.timeStopWidth*10)/10;if(this.layers[level]!=this.initLayer&&level%Math.floor(level)==0||level==0){this.toggle(level);}}}
OpenLayers.Event.stop(evt);}},TimelineUp:function(evt){if(!OpenLayers.Event.isLeftClick(evt)){return;}
if(this.mouseDragStart){this.tlDiv.style.cursor="";this.map.events.un({"mouseup":this.passEventToSlider,"mousemove":this.passEventToSlider,scope:this});var x=evt.xy.x;var left=OpenLayers.Util.pagePosition(evt.object)[0];var level=(x-left)/this.timeStopWidth;level=Math.floor(level);if(level>=0&&level<this.layers.length){this.toggle(level);}
else{this.moveTimeline();}
this.mouseDragStart=null;this.timeStart=evt.xy.clone();$(this.tlDiv).unbind("mouseleave");OpenLayers.Event.stop(evt);}},toggle:function(layerKey){if(this.layergroup.visibility){var layer=this.layers[layerKey];for(var key in this.layers){this.layers[key].setVisibility(false);}
if(layer.isBaseLayer){this.map.setBaseLayer(layer);}
this.initLayer=layer;layer.setVisibility(true);}
else return;},blend:function(newLeft){var level=Math.floor(newLeft/this.timeStopWidth);if(level>=0&&level<this.layers.length-1){this.layers[level].opacity=1-1/this.timeStopWidth*newLeft;this.layers[level+1].opacity=1/this.timeStopWidth*newLeft;this.layers[level+1].setVisibility(true);this.layers[level].redraw();this.layers[level+1].redraw();}},moveTimeline:function(){var newLeft=(parseInt(this.getActiveLayer())+0.5)*this.timeStopWidth+this.startLeft-this.positionX/2;this.slider.style.left=newLeft+"px";},CLASS_NAME:"OpenLayers.Control.MtcoTimeline"});OpenLayers.Control.MtcoZoomBack=OpenLayers.Class(OpenLayers.Control.NavigationHistory,{imgPath:null,divId:null,div:null,autoActivate:true,active:null,initialize:function(options){OpenLayers.Control.NavigationHistory.prototype.initialize.apply(this,[options]);this.imgPath=MtcoTools._getImgLocation();this.div=document.getElementById(this.divId);},draw:function(){this.zbDiv=document.createElement("div");this.zbDiv.id="mtcoZbDiv"+OpenLayers.Util.createUniqueID();OpenLayers.Element.addClass(this.zbDiv,"mtcoZbDiv");var backDiv=document.createElement("div");backDiv.id="mtcoZbBackImg";OpenLayers.Element.addClass(backDiv,"mtcoZbButton");var nextDiv=document.createElement("div");nextDiv.id="mtcoZbNextImg";OpenLayers.Element.addClass(nextDiv,"mtcoZbButton");this.div.appendChild(this.zbDiv);this.zbDiv.appendChild(backDiv);this.zbDiv.appendChild(nextDiv);this.events=new OpenLayers.Events(this,this.zbDiv);this.events.on({"click":this.handleClick,scope:this});},handleClick:function(event){var target=(event.target)?event.target.id:event.srcElement.id;var triggerelements={'mtcoZbBackImg':"previousTrigger",'mtcoZbNextImg':"nextTrigger"};try{this[triggerelements[target]](target);}catch(err){if(typeof console!='undefined'){console.log("error MtcoZoomBack",target,err);}}},CLASS_NAME:"OpenLayers.Control.MtcoZoomBack"});OpenLayers.Control.MtcoZoomToRegions=OpenLayers.Class(OpenLayers.Control,{divId:null,div:null,autoActivate:true,active:null,regions:null,initialize:function(regions,options){OpenLayers.Control.prototype.initialize.apply(this,[options]);this.regions=regions;if(this.divId)this.div=OpenLayers.Util.getElement(this.divId)},activate:function(){if(!this.active){$(this.select).bind("change",this,this.zoomTo);$(this.div).find("#null").each(function(){this.selected=true;})}
this.active=true;},deactivate:function(){if(this.active){$(this.select).unbind("change");$(this.div).find("#null").each(function(){this.selected=true;})}
this.active=false;},setMap:function(map){OpenLayers.Control.prototype.setMap.apply(this,arguments);},draw:function(){this.select=document.createElement("select");this.select.id="mtcoZoomSelect"+OpenLayers.Util.createUniqueID();this.select.name="mtcoZoomSelect";this.select.size="1";OpenLayers.Element.addClass(this.select,"mtcoZoomSelect");if(this.div)this.div.appendChild(this.select);else document.body.appendChild(this.select);var option=document.createElement("option");option.id="null";this.select.appendChild(option);for(var key in this.regions){var region=this.regions[key];option=document.createElement("option");option.id=region.id;option.innerHTML=region.name;option.value=region.id;this.select.appendChild(option);}},zoomTo:function(event){var control=event.data;var length=event.data.map.controls.length
var index=this.selectedIndex;var id=this.options[index].value;for(var key in control.regions){if(id==control.regions[key].id){var bounds=control.regions[key].bounds;control.map.zoomToExtent(bounds,false);}}
control.disableOthers();control.enableOthers();},CLASS_NAME:"OpenLayers.Control.MtcoZoomToRegions"});OpenLayers.MtcoRegion=OpenLayers.Class(OpenLayers,{initialize:function(name,bounds,options){this.name=name;this.bounds=new OpenLayers.Bounds(bounds[0],bounds[1],bounds[2],bounds[3]);this.id=OpenLayers.Util.createUniqueID();},CLASS_NAME:"OpenLayers.MtcoRegion"});OpenLayers.MtcoDecoration.MtcoKompass=OpenLayers.Class(OpenLayers.MtcoDecoration,{imgPath:null,img:null,opacity:null,size:null,position:null,viewPortDiv:null,baseDiv:null,zIndex:null,initialize:function(options){OpenLayers.MtcoDecoration.prototype.initialize.apply(this,[options]);this.div=document.createElement("div");OpenLayers.Element.addClass(this.div,"mtcoKompassDiv");this.imgPath=MtcoTools._getImgLocation();this.img=OpenLayers.Util.createImage("mtcoKompassImg",null,null,this.imgPath+"mtcoKompass.png");this.div.appendChild(this.img);},activate:function(){this.baseDiv=this.map.baseLayer.div;this.mapDiv=this.map.div;this.layerContainerDiv=this.map.layerContainerDiv;this.zIndex=parseInt($(this.baseDiv).css("z-index"))+1;this.map.events.on({'changebaselayer':this.updateKompass,'changelayer':this.updateKompass,'addlayer':this.updateKompass,'removelayer':this.updateKompass,'moveend':this.updateKompass,scope:this});this.updateKompass();},setStyle:function(){if(!this.size){this.size=this.map.size.clone();}
if(!this.opacity){this.opacity=0.1;}
$(this.img).css("height",this.size.h);this.img.style.opacity=this.opacity;$(this.img).css("z-index",this.zIndex);if(this.position){var left=this.position[0];var top=this.position[1];}
else{var left=0;var top=0;}
var layerContainerLeft=isNaN(parseInt($(this.layerContainerDiv).css("left")))?0:parseInt($(this.layerContainerDiv).css("left"));var layerContainerTop=isNaN(parseInt($(this.layerContainerDiv).css("top")))?0:parseInt($(this.layerContainerDiv).css("top"));var mapSize=this.map.size.clone();var newLeft=mapSize.w-layerContainerLeft-left;var newTop=mapSize.h-layerContainerTop-top;$(this.div).css("left",newLeft);$(this.div).css("top",newTop);},updateKompass:function(event){var scope=this;$(this.layerContainerDiv).children().each(function(){if(this==scope.div){scope.layerContainerDiv.removeChild(this);}});$(this.baseDiv).after(this.div);this.setStyle();},CLASS_NAME:"OpenLayers.MtcoDecoration.MtcoKompass"});OpenLayers.MtcoPanel=OpenLayers.Class(OpenLayers.Control,{imgPath:null,size:null,resize:true,div:null,eventDiv:null,status:null,tabs:null,events:null,initialize:function(size,options){OpenLayers.Control.prototype.initialize.apply(this,[options]);OpenLayers.Util.extend(this,options);this.imgPath=MtcoTools._getImgLocation();if(size){this.size=size;}
else{this.size=new OpenLayers.Size(500,120);}
this.tabs=[];this.status="closed";this.div=document.createElement("div");OpenLayers.Element.addClass(this.div,"mtcoPanelDiv");this.eventDiv=document.createElement("div");OpenLayers.Element.addClass(this.eventDiv,"mtcoPanelEventDiv");OpenLayers.Element.addClass(this.eventDiv,"closed");this.div.appendChild(this.eventDiv);this.eventDivEvents=new OpenLayers.Events(this,this.eventDiv,null,false);this.eventDivEvents.register("click",this,this.togglePanel);this.events=new OpenLayers.Events(this,this.div,null,false);this.events.on({"mousedown":this.stopProp,"mouseup":this.stopProp,"mousemove":this.stopProp,"dblclick":this.stopProp,"rightclick":this.stopProp,scope:this});this.closePanel();},setMap:function(map){this.map=map;this.map.events.on({"sizeupdated":this.drawTabs,scope:this});this.draw();},draw:function(){var viewPortDiv=this.map.viewPortDiv;viewPortDiv.appendChild(this.div);},togglePanel:function(event){if(this.status=="closed"){this.openPanel();this.status="open";}
else{this.closePanel();this.status="closed";}
event.cancelBubble=true;if(event.stopPropagation)event.stopPropagation();},openPanel:function(){$(this.div).css("height",this.size.h);$(this.eventDiv).toggleClass("open closed");},closePanel:function(){$(this.div).css("height","10px");$(this.eventDiv).toggleClass("open closed");if(this.tabs.length>0){for(var i=0,l=this.tabs.length;i<l;i++){this.tabs[i].status="closed";this.closeTab(this.tabs[i]);}
this.tabs[0].status="open";this.openTab(this.tabs[0]);}},addTab:function(tab){tab.setPanel(this);this.tabs.push(tab);var countTabs=this.tabs.length;tab.zIndex=parseInt($(this.div).css("z-index"))+countTabs;$(tab.div).css("z-index",tab.zIndex);this.div.appendChild(tab.div);this.drawTabs();},drawTabs:function(){var divWidth=this.div.clientWidth
var labelWidth=divWidth/this.tabs.length;for(var i=0,l=this.tabs.length;i<l;i++){var tab=this.tabs[i];$(tab.div).css("height",this.size.h-30+"px");$(tab.labelDiv).css("width",labelWidth+"px");$(tab.labelDiv).css("margin-left",i*labelWidth-1+"px");$(tab.borderDiv).css("width",divWidth-6+"px");$(tab.borderDiv).css("height",this.size.h-37+"px");if(i==l-1){$(tab.labelDiv).css("width",divWidth-i*labelWidth+1+"px");}}
var topTab=this.getTopTab();this.openTab(topTab);},redrawTabs:function(){for(var i=0,l=this.tabs.length;i<l;i++){var tab=this.tabs[i];if(tab.status=="closed"){$(tab.inactiveSpan).css("display","block");}
else{$(tab.inactiveSpan).css("display","none");}}},handleClick:function(event){var tab=event.object;this.openTab(tab);},stopProp:function(event){event.cancelBubble=true;if(event.stopPropagation)event.stopPropagation();},openTab:function(tab){var zIndex=tab.zIndex;var topTab=this.setTopTab();var topIndex=topTab.zIndex;$(tab.div).css("z-index",topIndex);tab.zIndex=topIndex;$(topTab.div).css("z-index",zIndex);topTab.zIndex=zIndex;if(tab.status=="closed"){tab.status="open";topTab.status="closed";}
this.redrawTabs();},closeTab:function(tab){$(tab.tabBack).css("height","100%");$(tab.tabBack).css("width","100%");$(tab.tabBack).css("margin","0px");$(tab.tabBack).css("border-left","0px");$(tab.labelDiv).css("margin-top","-20px");$(tab.borderDiv).css("height",tab.origContentHeight);$(tab.borderDiv).css("width",tab.origContentWidth);},setTopTab:function(){var tab=this.tabs[0];for(var i=0,l=this.tabs.length;i<l;i++){if(tab.zIndex<this.tabs[i].zIndex){tab=this.tabs[i];}}
return tab;},getTopTab:function(){var tab;for(var i=0,l=this.tabs.length;i<l;i++){if(this.tabs[i].status=="open"){tab=this.tabs[i];}}
if(!tab){tab=this.tabs[0];}
return tab;},CLASS_NAME:"OpenLayers.MtcoPanel"});OpenLayers.Map.prototype.addPanel=function(panel){this.panel=panel;panel.setMap(this);}
OpenLayers.MtcoPanel.MtcoTab=OpenLayers.Class(OpenLayers.MtcoPanel,{divId:null,div:null,borderDiv:null,contentDiv:null,labelDiv:null,status:null,name:null,events:null,zIndex:null,initialize:function(divId,options){OpenLayers.Util.extend(this,options);this.divId=divId;if(!this.name)this.name=divId;this.status="closed";this.div=OpenLayers.Util.createDiv(divId+"_container");OpenLayers.Element.addClass(this.div,"mtcoTabDiv");this.borderDiv=OpenLayers.Util.createDiv(divId+"Border");OpenLayers.Element.addClass(this.borderDiv,"mtcoTabBorderDiv")
this.contentDiv=OpenLayers.Util.createDiv(divId);OpenLayers.Element.addClass(this.contentDiv,"mtcoTabContentDiv");this.labelDiv=OpenLayers.Util.createDiv("mtcoLabelDiv_"+OpenLayers.Util.createUniqueID());OpenLayers.Element.addClass(this.labelDiv,"mtcoTabLabelDiv");var labelLeft=document.createElement("span");OpenLayers.Element.addClass(labelLeft,"mtcoTabLabelLeft");var labelCenter=document.createElement("span");OpenLayers.Element.addClass(labelCenter,"mtcoTabLabelCenter");var labelRight=document.createElement("span");OpenLayers.Element.addClass(labelRight,"mtcoTabLabelRight");var nameSpan=document.createElement("span");OpenLayers.Element.addClass(nameSpan,"mtcoTabNameSpan");nameSpan.innerHTML=this.name;this.tabBack=OpenLayers.Util.createDiv("mtcoTabBack_"+OpenLayers.Util.createUniqueID());OpenLayers.Element.addClass(this.tabBack,"mtcoTabBackDiv");this.inactiveSpan=document.createElement("span");OpenLayers.Element.addClass(this.inactiveSpan,"mtcoTabInactive");$(this.inactiveSpan).css("display","none");this.labelDiv.appendChild(labelLeft);this.labelDiv.appendChild(labelCenter);this.labelDiv.appendChild(labelRight);this.labelDiv.appendChild(this.inactiveSpan);this.labelDiv.appendChild(nameSpan);this.div.appendChild(this.tabBack);this.div.appendChild(this.labelDiv);this.tabBack.appendChild(this.borderDiv);this.borderDiv.appendChild(this.contentDiv);},setPanel:function(panel){this.panel=panel;this.events=new OpenLayers.Events(this,this.labelDiv,null,false);this.events.register("click",this.panel,this.panel.handleClick);},CLASS_NAME:"OpenLayers.MtcoPanel.MtcoTab"});﻿
OpenLayers.Control.MtcoProfile=OpenLayers.Class(OpenLayers.Control,{divId:null,div:null,type:"line",popup:null,heightInfo:false,multiple:false,sliding:false,selectControl:null,autoActivate:false,active:null,width:250,height:200,xScaleDivision:50,zScaleDivision:50,xLabelOffset:10,zLabelOffset:10,xUnit:null,zUnit:"m",xLabelUnit:null,map:null,layers:null,layer:null,vertices:[],profile:null,marker:null,callbacks:null,handlers:null,initialize:function(layers,options){OpenLayers.Geometry.Point.prototype.z=null;OpenLayers.Geometry.Point.prototype.initialize=function(x,y,z){OpenLayers.Geometry.prototype.initialize.apply(this,arguments);this.x=parseFloat(x);this.y=parseFloat(y);this.z=parseFloat(z);};this.EVENT_TYPES=OpenLayers.Control.SelectFeature.prototype.EVENT_TYPES.concat(OpenLayers.Control.prototype.EVENT_TYPES);OpenLayers.Control.prototype.initialize.apply(this,[options]);if(this.heightInfo){this.contentHeight=this.height-75;}
else this.contentHeight=this.height-10;this.contentWidth=this.width-25;if(layers.CLASS_NAME=="OpenLayers.Layer.MtcoLayerGroup")layers=layers.layers;else layers=(layers instanceof Array)?layers:[layers];this.layers=layers;this.selectControl=new OpenLayers.Control.MtcoSelectFeature(this.layers,{multiple:this.multiple,onSelect:this.select,scope:this});this.selectControl.events.on({nofeatureselected:this.unselectAll,scope:this});},setMap:function(map){OpenLayers.Control.prototype.setMap.apply(this,arguments);if(this.xUnit===null){this.xUnit=this.map.units;}
this.map.addControl(this.selectControl);},activate:function(){if(!this.active){this.selectControl.activate();}
return OpenLayers.Control.prototype.activate.apply(this,arguments);},deactivate:function(){if(this.active){this.selectControl.deactivate();}
return OpenLayers.Control.prototype.deactivate.apply(this,arguments);},draw:function(){this.prDiv=document.createElement("div");OpenLayers.Element.addClass(this.prDiv,"mtcoPrDiv");this.chartDiv=document.createElement("div");OpenLayers.Element.addClass(this.chartDiv,"mtcoPrChartDiv");this.heightInfoDiv=document.createElement("div");OpenLayers.Element.addClass(this.heightInfoDiv,"mtcoPrHeightInfoDiv");if(this.sliding){this.slider=document.createElement("div");OpenLayers.Element.addClass(this.slider,"mtcoPrSlider");this.slideLayer=new OpenLayers.Layer.Vector("mtcoPrSlideLayer",{displayInLayerSwitcher:false,styleMap:new OpenLayers.StyleMap({"default":new OpenLayers.Style({fillColor:'#FF0000',strokeColor:'#AA0000',strokeWidth:1,pointRadius:8})})});}
if(!this.divId){this.getPopup();this.div=this.popup.contentDiv;}
else{this.div=document.getElementById(this.divId);}},eventsOn:function(){this.sliderEvents=new OpenLayers.Events(this,this.slider,null,true,{includeXY:true});this.sliderEvents.on({"mousedown":this.sliderDown,"mousemove":this.sliderMove,"mouseup":this.sliderUp,scope:this});this.divEvents=new OpenLayers.Events(this,this.chartDiv,null,true,{includeXY:true});this.divEvents.on({"click":this.divClick,scope:this});},eventsUn:function(){if(this.sliderEvents){this.sliderEvents.un({"mousedown":this.sliderDown,"mousemove":this.sliderMove,"mouseup":this.sliderUp});this.sliderEvents.destroy();this.sliderEvents=null;}
if(this.divEvents){this.divEvents.un({"click":this.divClick});this.divEvents.destroy();this.divEvents=null;}},select:function(event){var feature=event.feature;if(!event.shiftKey){this.vertices=this.getVertices(feature);}
else{if(this.vertices.length>0)this.getMultipleVertices(feature);else this.vertices=this.getVertices(feature);}
if(this.popup){this.popup.lonlat=feature.geometry.getBounds().getCenterLonLat();this.map.addPopup(this.popup);}
this.drawAll(feature);},unselect:function(feature){var vertices=this.getVertices(feature);var length=vertices.length;var vertLength=this.vertices.length;if(vertices[0]==this.vertices[0]){this.vertices=this.vertices.slice(length);}
else if(vertices[length-1]==this.vertices[vertLength-1]){this.vertices=this.vertices.slice(0,vertLength-length);}
if(this.vertices.length>0)this.getProfile(feature);else this.unselectAll();},unselectAll:function(){this.vertices=[];if(this.divId=="mtcoPrPopup"){this.map.removePopup(this.popup);}
else if(this.divId){$(document.getElementById(this.divId)).children().remove();}
if(this.sliding){this.eventsUn();this.unhighlightVertex();if(this.slideLayer.map==this.map){this.map.removeLayer(this.slideLayer);}}},getPopup:function(){this.popup=new OpenLayers.Popup.Anchored("mtcoPrPopup",null,new OpenLayers.Size(this.width+25,this.height+25));this.popup.setBackgroundColor("transparent");this.popup.setBorder("thin solid #808080");this.popup.panMapIfOutOfView=true;this.divId="mtcoPrPopup";},setStyle:function(){$(".mtcoPrDiv").css("width",(this.width.toString()+"px"));$(".mtcoPrDiv").css("height",(this.height.toString()+"px"));$(".mtcoPrChartDiv").css("width",(this.contentWidth.toString()+"px"));$(".mtcoPrChartDiv").css("height",(this.contentHeight.toString()+"px"));$(".mtcoPrHeightInfoDiv").css("width",(this.contentWidth.toString()+"px"));},drawAll:function(feature){if($(this.prDiv).children()){var prDiv=this.prDiv;$(this.prDiv).children().each(function(){prDiv.removeChild(this);});}
this.getProfile(feature);var grid=this.drawBackground();this.div.appendChild(this.prDiv);this.prDiv.appendChild(this.chartDiv);this.chartDiv.innerHTML=grid+this.profile;if(this.heightInfo){this.heightInfoDiv.innerHTML="<p mtcoPrP>"+OpenLayers.i18n('minHeight')+": "+this.zmin+this.zUnit+"<br>"+
OpenLayers.i18n('maxHeight')+": "+this.zmax+this.zUnit+"<br>"+
OpenLayers.i18n('altitudeDifference')+": "+this.z_cum+"</p>";this.chartDiv.appendChild(this.heightInfoDiv);}
if(this.sliding){this.eventsOn();this.chartDiv.appendChild(this.slider);$(this.slider).css("left","0px");this.map.addLayer(this.slideLayer);this.unhighlightVertex();}
this.setStyle();},getVertices:function(feature){var feat_array=[];var vertices=[];if(this.type==null||this.type=="line"){feat_array=[feature];}
else if(this.type=="complete"){feat_array=feature.layer.features;}
this.layerZmin=MtcoBase.getLayerMinimum(feature.layer);this.layerZmax=MtcoBase.getLayerMaximum(feature.layer);for(var i=0;i<feat_array.length;i++){var vert=feat_array[i].geometry.components;for(var j=0;j<vert.length;j++){vertices.push(vert[j]);}}
return vertices;},getMultipleVertices:function(feature){if(this.multiple&&this.type=="line"){var first=[Math.round(feature.geometry.components[0].x),Math.round(feature.geometry.components[0].y)];var last=[Math.round(feature.geometry.components[feature.geometry.components.length-1].x),Math.round(feature.geometry.components[feature.geometry.components.length-1].y)];var vertFirst=[Math.round(this.vertices[0].x),Math.round(this.vertices[0].y)];var vertLast=[Math.round(this.vertices[this.vertices.length-1].x),Math.round(this.vertices[this.vertices.length-1].y)];if(first[0]==vertLast[0]&&first[1]==vertLast[1]){var vertices=this.getVertices(feature);var length=vertices.length;for(var i=0;i<length;i++){this.vertices.push(vertices[i]);}}
else if(last[0]==vertFirst[0]&&last[1]==vertFirst[1]){var vertices=this.getVertices(feature);var length=vertices.length;for(var i=length-1;i>=0;i--){this.vertices.unshift(vertices[i]);}}
else{OpenLayers.Console.warn("warn");this.selectControl.unselect(feature);}}},getProfile:function(feature){var rad_const=Math.PI/180;this.dist=MtcoBase.getLength(this.vertices);this.zmin=Math.round(MtcoBase.getMinimum(feature));this.zmax=Math.round(MtcoBase.getMaximum(feature));this.layerZmin=Math.floor(this.layerZmin/this.zScaleDivision)*this.zScaleDivision;this.layerZmax=Math.ceil(this.layerZmax/this.zScaleDivision)*this.zScaleDivision;this.z_cum=0;var z_delta=this.layerZmax-this.layerZmin;this.z_factor=this.contentHeight/z_delta;this.dist_factor=this.contentWidth/this.dist;var dist_scale=0;var dist1=0;var dist2=0;var dist_cum=0;var dz=0;var dz_scale=0;var gradient=0;var dz_px=0;var dia_string="";this.profile="";for(var n=0;n<this.vertices.length-1;n++){var x1=this.vertices[n].x;var x2=this.vertices[n+1].x;var y1=this.vertices[n].y;var y2=this.vertices[n+1].y;var z1=this.vertices[n].z;var z2=this.vertices[n+1].z;var id=this.vertices[n].id;dist2=dist1;if(this.xUnit=="deegrees"||this.xUnit=="dd"){dist_scale=Math.acos(Math.cos((y2-y1)*rad_const)*Math.cos((y2-y1)*rad_const))*6370000*this.dist_factor;}
else{dist_scale=Math.sqrt(Math.pow((x2-x1),2)+Math.pow((y2-y1),2))*this.dist_factor;}
dist1=dist_scale;dist_cum+=dist2;dz=z2-z1;if(dz>0)this.z_cum+=dz;dz_scale=dz*this.z_factor;gradient=dz_scale/(dist1+0.00001);if(gradient>=-1&&gradient<=1){for(m=0;m<=dist1;m++){dist_px=dist_cum+m;dz_px=(gradient*m)+(z1-this.layerZmin)*this.z_factor;dia_string+="<div class='mtcoPrPixel' vertexId="+id+" style='left: "+dist_px+"px; bottom: "+dz_px+"px;'></div>";}}
else{for(var m=0;m<=Math.abs(dz_scale);m++){dist_px=dist_cum+m/Math.abs(gradient);dz_px=(gradient/Math.abs(gradient)*m)+(z1-this.layerZmin)*this.z_factor;dia_string+="<div class='mtcoPrPixel' vertexId="+id+" style='left: "+dist_px+"px; bottom: "+dz_px+"px;'></div>";}}}
this.z_cum=Math.round(this.z_cum);this.profile+=dia_string;},drawBackground:function(){var re;var dia_str_x="";var dia_str_z="";var mtcoPrGrid="";var calcScalecount_z=this.scalecount(this.contentHeight,this.zScaleDivision,this.z_factor)
var scalecount_z=calcScalecount_z[0];var zScaleDivision=calcScalecount_z[1];var calcScalecount_x=this.scalecount(this.contentWidth,this.xScaleDivision,this.dist_factor);var scalecount_x=calcScalecount_x[0];var xScaleDivision=calcScalecount_x[1];if(this.dist/1000>=1){this.xLabelUnit="km";}
else{this.xLabelUnit="m";}
for(var i=0;i<scalecount_z;i++){re=this.getGrid(i,this.contentHeight,zScaleDivision,this.z_factor,scalecount_z);var value_z=re[0];var value1_z=re[1];var rest_z=re[2];var scaledist_z=re[3];if(value_z>=0){if(i>0){dia_str_z+="<p class='mtcoPrP mtcoPrZlabel' style='bottom:"+(value_z-this.zLabelOffset)+"px;'>"+(value1_z+this.layerZmin)+this.zUnit+"</p>";}
for(var j=0;j<scalecount_x;j++){re=this.getGrid(j,this.contentWidth,xScaleDivision,this.dist_factor,scalecount_x);var value_x=re[0];if(this.dist/1000>=1){var value1_x=re[1]/1000;}
else{var value1_x=re[1];}
var rest_x=re[2];var scaledist_x=re[3];if(value_x>=0){if(j>0){dia_str_x+="<p class='mtcoPrP mtcoPrXlabel' style='left:"+(value_x-this.xLabelOffset)+"px;'>"+value1_x+this.xLabelUnit+"</p>";}
mtcoPrGrid+="<div class='mtcoPrGrid' style='left:"+value_x+"px; bottom:"+value_z+"px; width:"+(scaledist_x-rest_x)+"px; height:"+(scaledist_z-rest_z)+"px'></div>";}}}}
var background=mtcoPrGrid+dia_str_x+dia_str_z;return background;},scalecount:function(contentSize,scaleDivision,factor){var scaledist=parseFloat(scaleDivision);var scalecount=contentSize/(scaledist*factor);while(scalecount<=1){scalecount+=1;scaledist=Math.ceil(contentSize/(scalecount*factor));}
return[scalecount,scaledist];},getGrid:function(i,contentSize,scaleDivision,factor,scalecount){var diascale=i*scaleDivision;var scaledist_fac=scaleDivision*factor;var rest=0;var re=[];var value;var value1;if((scaledist_fac)>=50){value=diascale*factor;value1=diascale;}
else if((Math.floor(50/(scaledist_fac))*diascale*factor)<contentSize){value=Math.floor(50/(scaledist_fac))*diascale*factor;value1=Math.floor(50/(scaledist_fac))*diascale;scaledist_fac=Math.floor(50/(scaledist_fac))*scaledist_fac;scalecount=contentSize/scaledist_fac;}
if((Math.floor(scalecount)-i)>0){rest=0;}
else{rest=scaledist_fac-(contentSize-scaledist_fac*Math.floor(scalecount));}
re.push(value,value1,rest,scaledist_fac);return re;},passEventToSlider:function(event){this.sliderEvents.handleBrowserEvent(event);},divClick:function(event){var element=(event.element)?event.element:event.data.element;this.unhighlightVertex();var left=event.clientX-OpenLayers.Util.pagePosition(element)[0];if(left>224)left=224;else if(left<0)left=0;var vertId=this.getVertexId(left);this.moveSlider(left);if(vertId){this.highlightVertex(vertId);}},sliderDown:function(event){if(!OpenLayers.Event.isLeftClick(event)){return;}
var element=(event.element)?event.element:event.data.element;this.divEvents.on({"mousemove":this.passEventToSlider,"mouseup":this.passEventToSlider,scope:this});$(this.chartDiv).bind("mouseleave",{scope:this,element:element},this.mouseleave);this.mouseDragStart=event.clientX-OpenLayers.Util.pagePosition(element)[0];this.chartDiv.style.cursor="move";OpenLayers.Event.stop(event);},sliderMove:function(event){var element=(event.element)?event.element:event.data.element;if(this.mouseDragStart!=null){var deltaX=event.clientX-OpenLayers.Util.pagePosition(element)[0]-this.mouseDragStart;var left=parseInt(this.slider.style.left)+deltaX;if(left>224)left=224;else if(left<0)left=0;this.slider.style.left=left+"px";this.mouseDragStart=event.clientX-OpenLayers.Util.pagePosition(element)[0];var vertId=this.getVertexId(left);this.moveSlider(left);if(vertId){this.unhighlightVertex();this.highlightVertex(vertId);}}
OpenLayers.Event.stop(event);},sliderUp:function(event){this.chartDiv.style.cursor="auto";this.divEvents.un({"mousemove":this.passEventToSlider,"mouseup":this.passEventToSlider});$(this.chartDiv).unbind("mouseleave");this.mouseDragStart=null;OpenLayers.Event.stop(event);},moveSlider:function(left){$(this.slider).css("left",left);},getVertexId:function(left){var vertIds=[];$(this.chartDiv).children(".mtcoPrPixel").each(function(){if(Math.round(parseFloat($(this).css("left")))==left){vertIds.push(this.getAttribute("vertexId"));}});return vertIds[0];},highlightVertex:function(vertId){for(var i=0,l=this.vertices.length;i<l;i++){if(this.vertices[i].id==vertId){var vertex=this.vertices[i];var feature=new OpenLayers.Feature.Vector(vertex.clone())
this.slideLayer.addFeatures([feature]);}}},unhighlightVertex:function(){this.slideLayer.removeFeatures(this.slideLayer.features);},mouseleave:function(event){event.data.scope.sliderUp(event);OpenLayers.Event.stop(event);},CLASS_NAME:"OpenLayers.Control.MtcoProfile"});
