(function(a){a.TraminoMap=function(b){tmap=this;tmap.o=b;tmap.o.url_data=b.url_data||"/tramino/ajax/markerdata/";tmap.o.url_info=b.url_info||"/tramino/ajax/markerinfo/";tmap.o.noCluster=b.noCluster||false;this.initialisize=function(k){tmap.markerid_edit=undefined;tmap.marker_edit=undefined;tmap.marker_gdir=undefined;tmap.detailData=tmap.o.detailData||[];tmap.markerData=[];tmap.layer=[];if(tmap.o.map_listeinfo){a("#"+tmap.o.map_listeinfo).empty();}if(GBrowserIsCompatible()){tmap.map=new GMap2(document.getElementById(tmap.o.mapid));tmap.map.disableScrollWheelZoom();CustomGetTileUrl=function(s,i){if(i<12){return"http://mt1.google.com/vt/lyrs=m@132&hl=de&src=api&x="+s.x+"&y="+s.y+"&z="+i+"&s=";}return"http://t0.outdooractive.com/mobile/map/"+i+"/"+s.x+"/"+s.y+".png";};var l=new GCopyright(1,new GLatLngBounds(new GLatLng(-90,-180),new GLatLng(90,180)),1,"&copy;2010 Tele Atlas");var c=new GCopyright(2,new GLatLngBounds(new GLatLng(-90,-180),new GLatLng(90,180)),12,'&copy; <a href="http://www.alpstein-tourismus.de">Alpstein Tourismus GmbH &amp; Co. KG</a><a href="http://www.bev.gv.at" title="BEV 2008, T2008/52569">BEV</a> <a href="http://www.bkg.bund.de" title="BKG und Vermessungsverwaltungen der Bundesländer">BKG</a> <a href="http://www.ign.es" title="Instituto Geográfico Nacional de Espanña" >IGNE</a>');var p=new GCopyrightCollection();p.addCopyright(l);p.addCopyright(c);var r=[new GTileLayer(p,1,16)];r[0].getTileUrl=CustomGetTileUrl;var h=new GMapType(r,G_SATELLITE_MAP.getProjection(),"Karte");tmap.map.addMapType(h);tmap.map.setMapType(h);tmap.map.removeMapType(G_HYBRID_MAP);tmap.map.removeMapType(G_PHYSICAL_MAP);tmap.map.removeMapType(G_SATELLITE_MAP);tmap.map.removeMapType(G_NORMAL_MAP);tmap.map.addMapType(G_HYBRID_MAP);tmap.map.addMapType(G_PHYSICAL_MAP);osmCustomGetTileUrl=function(s,i){return"http://tah.openstreetmap.org/Tiles/tile/"+i+"/"+s.x+"/"+s.y+".png";};var o=new GCopyright(1,new GLatLngBounds(new GLatLng(-90,-180),new GLatLng(90,180)),1,'Kartendaten &copy;2010 <a href="http://www.openstreetmap.org/">OpenStreetMap</a>');var d=new GCopyrightCollection();d.addCopyright(o);var e=[new GTileLayer(d,1,17)];e[0].getTileUrl=osmCustomGetTileUrl;var n=new GMapType(e,G_SATELLITE_MAP.getProjection(),"OSM");tmap.map.addMapType(n);var m=new GMapTypeControl();tmap.map.addControl(m);tmap.map.addControl(new GLargeMapControl3D());if(tmap.o.map_type=="m"){tmap.map.setMapType(h);}else{if(tmap.o.map_type=="h"){tmap.map.setMapType(G_HYBRID_MAP);}else{if(tmap.o.map_type=="p"){tmap.map.setMapType(G_PHYSICAL_MAP);}else{if(tmap.o.map_type=="o"){tmap.map.setMapType(n);}}}}if(tmap.o.autosave){if(a.cookie.get("googlemap_center_lat")!=null&&a.cookie.get("googlemap_center_lng")!=null&&a.cookie.get("googlemap_center_zoom")!=null){tmap.map.setCenter(new GLatLng(a.cookie.get("googlemap_center_lat"),a.cookie.get("googlemap_center_lng")),a.cookie.get("googlemap_center_zoom"));}else{tmap.map.setCenter(new GLatLng(tmap.o.center_lat,tmap.o.center_lng),tmap.o.center_zoom);}GEvent.addListener(tmap.map,"moveend",function(){a.cookie.set("googlemap_center_lat",tmap.map.getCenter().lat());a.cookie.set("googlemap_center_lng",tmap.map.getCenter().lng());a.cookie.set("googlemap_center_zoom",tmap.map.getZoom());});if(a.cookie.get("googlemap_type")=="m"){tmap.map.setMapType(G_NORMAL_MAP);}else{if(a.cookie.get("googlemap_type")=="k"){tmap.map.setMapType(G_SATELLITE_MAP);}else{if(a.cookie.get("googlemap_type")=="h"){tmap.map.setMapType(G_HYBRID_MAP);}else{if(a.cookie.get("googlemap_type")=="p"){tmap.map.setMapType(G_PHYSICAL_MAP);}}}}GEvent.addListener(tmap.map,"maptypechanged",function(){a.cookie.set("googlemap_type",tmap.map.getCurrentMapType().getUrlArg());});}else{tmap.map.setCenter(new GLatLng(tmap.o.center_lat,tmap.o.center_lng),tmap.o.center_zoom);}if(tmap.o.noCluster){tmap.markerCluster=new noMarkerClusterer(tmap.map);}else{tmap.markerCluster=new MarkerClusterer(tmap.map,null,{gridSize:10});}tmap.gdir=new GDirections();tmap.bound=new GLatLngBounds();GEvent.addListener(tmap.gdir,"load",function(){tmap.map.addOverlay(tmap.gdir.getPolyline());tmap.map.setCenter(tmap.gdir.getBounds().getCenter(),tmap.map.getBoundsZoomLevel(tmap.gdir.getBounds()));if(tmap.gdir.marker1==undefined){var i=new GIcon();i.image="http://www.google.com/intl/en_de/mapfiles/icon-dd-play-trans.png";i.shadow="http://www.google.com/mapfiles/shadow50.png";i.iconSize=new GSize(24,38);i.shadowSize=new GSize(37,34);i.iconAnchor=new GPoint(9,34);i.infoWindowAnchor=new GPoint(19,2);i.infoShadowAnchor=new GPoint(18,25);var t=new GMarker(tmap.gdir.getMarker(0).getLatLng(),{draggable:true,autoPan:true,icon:i});GEvent.addListener(t,"drag",function(){tmap.map.removeOverlay(tmap.gdir.getPolyline());});GEvent.addListener(t,"dragend",function(){tmap.gdir.load("from: "+this.getLatLng().toUrlValue()+" to: "+tmap.gdir.marker2.getLatLng().toUrlValue(),{locale:"DE_de",getPolyline:true,preserveViewport:true});});tmap.map.addOverlay(t);tmap.gdir.marker1=t;i.image="http://www.google.com/intl/en_de/mapfiles/icon-dd-stop-trans.png";var s=new GMarker(tmap.gdir.getMarker(1).getLatLng(),{draggable:true,autoPan:true,icon:i});GEvent.addListener(s,"drag",function(){tmap.map.removeOverlay(tmap.gdir.getPolyline());});GEvent.addListener(s,"dragend",function(){tmap.gdir.load("from: "+tmap.gdir.marker1.getLatLng().toUrlValue()+" to:  "+this.getLatLng().toUrlValue(),{locale:"DE_de",getPolyline:true,preserveViewport:true});});tmap.map.addOverlay(s);tmap.gdir.marker2=s;}tmap.gdir.marker1.openInfoWindowHtml("<font style='font-size:11px;'>Von <i>"+tmap.gdir.getGeocode(0).address+"</i> nach <i>"+tmap.gdir.getGeocode(1).address+"</i><br/><b>"+tmap.gdir.getSummaryHtml()+"</b><br/><a href='http://maps.google.de/?ie=UTF8&hl=de&q="+tmap.gdir.getMarker(0).getLatLng().toUrlValue()+"+nach+"+tmap.gdir.getMarker(1).getLatLng().toUrlValue()+"'> Route in Google Maps öffnen</a> </font>");});GEvent.addListener(tmap.gdir,"error",function(){alert("Fehler in der Routenplanung: "+tmap.gdir.getStatus().code);});if(tmap.o.gdir_start){a("#"+tmap.o.mapid).append('<div style="border: 1px solid black; position: absolute; background-color: white; text-align: center; width: 5em; cursor: pointer; right: 1em; bottom:1.5em;" title="" id="routenplanerbutton"><div style="border-style: solid; border-color: white rgb(176, 176, 176) rgb(176, 176, 176) white; border-width: 1px; font-size: 12px;" onclick="'+tmap.o.mapvar+'.togglegdir(this);">Routenplaner zeigen</div></div>');a("#routenplanerbutton").hide();}if(k){var g=k.split(",");for(var f=0;f<g.length;++f){tmap.genMarkerJSON(g[f]);}}if(tmap.o.staticdata){a.each(a("ul#map_tramino_layermenu li"),function(t,u){if(a(u).hasClass("off")){var s=a(u).attr("ref");tmap.layer[s]="1";}});var j=jQuery.map(tmap.o.staticdata,function(t,s){if(tmap.layer[t.ref]){return null;}return t;});tmap.genMarker(j);}if(tmap.o.collectdata){var q=[];a.each(a(".geo"),function(t,u){a(u).parent().find(".geoinfo").show();var s=new Array();var w=a(u).find("span.data").text();if(w){a.each(w.split("\n"),function(x,i){data_data=i.split(" ");data_data[0]="l";if(data_data[3]){s.push({typ:data_data[0],color:data_data[1],level:data_data[2],poi:data_data[3]});}});}var v={id:a(u).find("span.id").text(),name:a(u).find("span.name").text(),lat:a(u).find("span.latitude").text(),lng:a(u).find("span.longitude").text(),icon:a(u).find("span.icon").text(),data:s};if(a(u).find("span.id").text()){q.push(v);}});tmap.genMarker(q);}}tmap.map.disableScrollWheelZoom();};this.toggle=function(){a("#"+tmap.o.mapid).slideToggle("slow");};this.genMarkerJSON=function(d,c){if(d!=""){a.getJSON(tmap.o.url_data+"?typ="+d,function(e){tmap.genMarker(e,c);});}};this.genMarker=function(d,c){if(d==undefined){return 1;}a.each(d,function(g,j){if(tmap.markerData[j.id]==undefined){var h=j.icon.substring(0,1);var e=new GIcon();if(h=="_"){e.iconSize=new GSize(18,25);e.iconAnchor=new GPoint(1,26);e.infoWindowAnchor=new GPoint(0,34);}else{e.iconSize=new GSize(28,37);e.iconAnchor=new GPoint(4,35);e.infoWindowAnchor=new GPoint(3,45);}e.image="http://s1.tramino.de/gfx/geodata/icons/"+j.icon+".png";var f=new GMarker(new GLatLng(j.lat,j.lng),{title:j.name,icon:e,id:"marker"+j.id});f.lines=[];if(typeof j.data!="undefined"){a.each(j.data,function(l,i){var m;if(i.typ=="l"){m=new GPolyline.fromEncoded({color:i.color,weight:4,opacity:0.5,points:i.poi,levels:i.level,zoomFactor:2,numLevels:18});var n=m.getBounds();tmap.bound.extend(n.getNorthEast());tmap.bound.extend(n.getSouthWest());}else{m=new GPolygon.fromEncoded({polylines:[{points:i.poi,levels:i.level,color:i.color,opacity:0.5,weight:4,numLevels:18,zoomFactor:2}],fill:true,color:i.color,opacity:0.2,outline:true});var k=m.getBounds();tmap.bound.extend(k.getNorthEast());tmap.bound.extend(k.getSouthWest());}GEvent.addListener(m,"mouseover",function(){GEvent.trigger(tmap.markerData[j.id],"mouseover");});GEvent.addListener(m,"mouseout",function(){GEvent.trigger(tmap.markerData[j.id],"mouseout");});GEvent.addListener(m,"click",function(){GEvent.trigger(tmap.markerData[j.id],"click");});tmap.map.addOverlay(m);f.lines.push(m);});}GEvent.addListener(f,"mouseover",function(){if(typeof f.lines!="undefined"){a.each(f.lines,function(p,o){o.setStrokeStyle({opacity:1});});}a("#googlemapspoiLabel").remove();var m=document.createElement("div");var k=document.createElement("span");var n=this.getTitle()||"";n=n.replace(/&amp;/g,"&");k.appendChild(document.createTextNode(n));m.appendChild(k);var i=a("#mtgt_"+this.id)[0];var l=this.getPoint();a(i).attr("title","");if(typeof i=="undefined"||typeof i=="function"){}else{m.style.top=(parseInt(i.style.top,10)+parseInt(i.style.height,10))+"px";m.style.left=(parseInt(i.style.left,10)+parseInt(parseInt(i.style.width,10)/2,10)-75)+"px";m.style.position="absolute";m.style.height="16px";m.style.width="150px";m.style.textAlign="center";m.id="googlemapspoiLabel";m.style.color="#eee";k.style.background="#000";k.style.border="1px solid #000";k.style.fontSize="13px";k.style.color="#eee";k.style.padding="2px";k.style.display="inline";a(i).after(m);}});GEvent.addListener(f,"mouseout",function(){a("#googlemapspoiLabel").remove();if(typeof f.lines!="undefined"){a.each(f.lines,function(k,i){i.setStrokeStyle({opacity:0.5});});}});GEvent.addListener(f,"click",function(){a("#googlemapspoiLabel").remove();tmap.marker_gdir=this;this.openExtInfoWindow(tmap.map,"traminoMapWindow",'<div class="TraminoGeomatch"><center><img src=http://s1.tramino.de/gfx/loading2.gif width=32 height=32 style="margin:5px;"/></center></div>',{beakOffset:15,paddingX:10,paddingY:10});a("#routenplanerbutton").show();thismarker=this;if(tmap.detailData[j.id]){if(tmap.detailData[j.id]==""){thismarker.closeInfoWindow();tmap.map.closeExtInfoWindow();}else{if(tmap.detailData[j.id].substring(0,1)=="#"){thismarker.openExtInfoWindow(tmap.map,"traminoMapWindow","<div id='"+tmap.detailData[j.id].substring(1)+"_infowindow'><div class='match'>"+a(tmap.detailData[j.id]).clone(true).html()+"</div></div>",{beakOffset:15,paddingX:10,paddingY:10});a(tmap.detailData[j.id]+"_infowindow").replaceWith(a(tmap.detailData[j.id]).clone(true));}else{thismarker.openExtInfoWindow(tmap.map,"traminoMapWindow",tmap.detailData[j.id],{beakOffset:15,paddingX:10,paddingY:10});if(typeof map_openextwindow_callback=="function"){map_openextwindow_callback(tmap.detailData[j.id]);}}}}else{a.get(tmap.o.url_info+"?id="+j.id,function(i){if(i==""){thismarker.closeInfoWindow();tmap.map.closeExtInfoWindow();}else{if(typeof map_openextwindow_callback=="function"){map_openextwindow_callback(i);}thismarker.openExtInfoWindow(tmap.map,"traminoMapWindow",i,{beakOffset:15,paddingX:10,paddingY:10});}tmap.detailData[j.id]=i;});}});tmap.markerCluster.addMarker(f);tmap.bound.extend(f.getLatLng());tmap.markerData[j.id]=f;if(tmap.o.map_listeinfo&&a("#"+tmap.o.map_listeinfo)&&j.liste!=undefined){a("#"+tmap.o.map_listeinfo).prepend("<li onclick='GEvent.trigger("+tmap.o.mapvar+'.markerData["'+j.id+'"], "click");\' onmouseover=\'GEvent.trigger('+tmap.o.mapvar+'.markerData["'+j.id+'"], "mouseover");\' onmouseout=\'GEvent.trigger('+tmap.o.mapvar+'.markerData["'+j.id+'"], "mouseout");\'> <div style=\'float:left;width:24px;height:24px;background:url(http://s1.tramino.de/gfx/geodata/icons/'+j.icon+".png) -4px -4px;'></div> "+j.name+" </li>");}}});if(tmap.bound.isEmpty()||c){return 0;}else{tmap.map.setCenter(tmap.bound.getCenter(),tmap.map.getBoundsZoomLevel(tmap.bound));return 1;}};this.toggleLayer=function(d,e){if(tmap.layer[d]==undefined){tmap.layer[d]="1";a(e).addClass("off");}else{tmap.layer[d]=undefined;a(e).removeClass("off");}tmap.markerCluster.clearMarkers();tmap.markerData=[];tmap.map.clearOverlays();if(typeof map_clearoverlay_callback=="function"){map_clearoverlay_callback();}if(tmap.o.map_listeinfo&&a("#"+tmap.o.map_listeinfo)){a("#"+tmap.o.map_listeinfo).html(" ");}var c=jQuery.map(tmap.o.staticdata,function(g,f){if(tmap.layer[g.ref]){return null;}return g;});if(tmap.o.noCluster){tmap.markerCluster=new noMarkerClusterer(tmap.map);}else{tmap.markerCluster=new MarkerClusterer(tmap.map,null,{gridSize:10});}tmap.genMarker(c,1);};this.togglegdir=function(c){if(tmap.gdir.active==1){tmap.map.removeOverlay(tmap.gdir.getPolyline());tmap.map.removeOverlay(tmap.gdir.marker1);tmap.map.removeOverlay(tmap.gdir.marker2);delete tmap.gdir.marker1;delete tmap.gdir.marker2;tmap.gdir.active=0;c.innerHTML="Routenplaner zeigen";a("#routenplanerbutton").hide();}else{if(tmap.o.gdir_start&&tmap.marker_gdir){tmap.gdir.load("from: "+tmap.o.gdir_start+" to: "+tmap.marker_gdir.getLatLng().toUrlValue(16),{locale:"DE_de",getPolyline:true,preserveViewport:true});tmap.gdir.active=1;c.innerHTML="Routenplaner ausblenden";}}};this.editline=function(e,d,c){a.traminobox("<iframe border='0' frameborder='0' style='width:920px;height:600px;border:0px solid #fff' name='"+c+"_"+d+"_window' src='/tramino/content/poi//widgetedit/"+c+"_"+d+"/?mode=geodata'></iframe>","wide","Bearbeiten Sie die Geoinformationen","","","");};this.editmarker=function(d){if(tmap.markerid_edit!=undefined){tmap.markerid_edit.show();tmap.markerid_edit=undefined;tmap.map.removeOverlay(tmap.marker_edit);}tmap.markerid_edit=tmap.markerData[d];tmap.markerid_edit.geoid=d;tmap.markerid_edit.hide();tmap.map.closeInfoWindow();tmap.map.closeExtInfoWindow();var c=new GMarker(tmap.markerid_edit.getLatLng(),{draggable:true,autoPan:true});tmap.marker_edit=c;GEvent.addListener(c,"dragend",function(){tmap.markerid_edit.setLatLng(this.getLatLng());if(tmap.o.url_save){a.post(tmap.o.url_save,{geodata:this.getLatLng().toUrlValue(),action:"save",id:tmap.markerid_edit.geoid},function(e){});}else{alert("Speichern nicht möglich.");}tmap.markerid_edit.show();tmap.markerid_edit=undefined;tmap.map.removeOverlay(this);});tmap.map.addOverlay(c);GEvent.addListener(tmap.map,"moveend",function(){if(tmap.markerid_edit){tmap.markerid_edit.hide();}});};};})(jQuery);function noMarkerClusterer(b){var a=b;this.clearMarkers=function(){a.clearOverlays();};this.addMarker=function(c){a.addOverlay(c);};}
