function $EL(el){return $(el)};function $EL2(el){return $(el)};function $CLASS(name){return $$("."+name)};function $ADD_CLASS(el,name){el.addClassName(name)};function $REMOVE_CLASS(el,name){el.removeClassName(name)};function $UPDATE(el,html){return $EL(el).update(html)};function $REPLACE(el,html){return $EL(el).replace(html)};function $HASH(obj){return $H(obj)};function $EACH(arr,fn){return arr.each(fn)};function $MAP(arr,fn){return arr.map(fn)};function $GREP(arr,fn){var result=[];arr.each(function(el){if(fn(el))result.push(el)});return result}function $AJAX(url,param){new Ajax.Request(url,param)};function $CLONE(obj){return Object.clone(obj)};function $TO_JSON(obj){return Object.toJSON(obj)};function $EVAL_JSON(str){return Object.evalJSONString(str)};function $EXTEND(dest,src){return Object.extend(dest,src)};function $BLINDDOWN(el,param){return window.Effect?Effect.BlindDown(el,param):$(el).show()};function $BLINDUP(el,param){return window.Effect?Effect.BlindUp(el,param):$(el).hide()};function $EVENT(el,name,fkt){return Event.observe($EL(el),name,fkt)};function $VISIBLE(el){return $EL(el).visible()};function $DIMENSIONS(el){return $EL(el).getDimensions()};function $PREVIOUS(el){return $EL(el).previous()};function $NEXT(el){return $EL(el).next()};function $OPACITY(el,o){return o==null?Element.getOpacity(el):Element.setOpacity(el,o)};function $OFFSETTOP(el){return Element.cumulativeOffset(el)[1]};function $OFFSETLEFT(el){return Element.cumulativeOffset(el)[0]};function $INARRAY(arr,obj){return arr.indexOf(obj)};
var JsonRPCCounter=0;var JsonRPCStore={};function setMessage(msg,id){$EL(id||'message').style.display=msg?"block":"none";$UPDATE(id||'message',msg)}function ajaxHelper(param){var url=param.url;delete param.url;var callback=param.callback;delete param.callback;if(callback&&typeof callback=="string")eval("callback = "+callback);var update=param.update;delete param.update;var replace=param.replace;delete param.replace;if(param.method==null)param.method="get";param.onComplete=function(req,json){var redirect=eval("req.getResponseHeader('X-Ajax-Redirect-Location')");if(redirect)location.href=redirect;if(callback)callback(req,json);if(update)$UPDATE(update,req.responseText);if(replace)$REPLACE(replace,req.responseText)};for(var i in param.parameters){if(typeof(param.parameters[i])!="string")param.parameters[i]=$TO_JSON(param.parameters[i])}return $AJAX(url,param)}function jsonRpc(param){var s=document.createElement("script");var id="cb"+ ++JsonRPCCounter;var timeout=param.timeout&&window.setTimeout(function(){jsonRpcCleanup(id,s);param.callback(null)},param.timeout);JsonRPCStore[id]=function(data){if(timeout)clearTimeout(timeout);jsonRpcCleanup(id,s);param.callback(data)};for(var i in param.parameters)if(typeof(param.parameters[i])!="string")param.parameters[i]=$TO_JSON(param.parameters[i]);var p="&"+$HASH(param.parameters).toQueryString();var callbackFkt=param.callbackFunctionName||'callback';s.src=param.url+"?"+callbackFkt+"=JsonRPCStore."+id+p;document.getElementsByTagName("HEAD")[0].appendChild(s)}function jsonRpcCleanup(id,s){delete JsonRPCStore[id];setTimeout(function(){s.parentNode.removeChild(s)},1)}function $P(a,b){if(a!=null&&b!=null)return new GLatLng(a,b);if(typeof a=="object"){if(a[0]!=null&&a[1]!=null)return $P(a[0],a[1]);if(a.lat!=null&&a.lng!=null)return $P(a.lat,a.lng)}throw"invalid argument to $P "+a+", "+b}
var MapToolkit={version:5,host:"http://mtk2.toursprung.com",maps:{},documentLoaded:false,location:{lat:google&&google.loader.ClientLocation&&google.loader.ClientLocation.latitude,lng:google&&google.loader.ClientLocation&&google.loader.ClientLocation.longitude,country:google&&google.loader.ClientLocation&&google.loader.ClientLocation.address.country_code.toLowerCase()},language:_mHL||"en",resizeDiv:function(div,isFullscreen,config){var m=$EL(div);var size=config.map.size;if(!m)return;if(isFullscreen){if(this.isIE6()){MapToolkit.mapParent=m.parentNode;MapToolkit.mapParent.removeChild(m);document.getElementsByTagName("BODY")[0].appendChild(m)}m.style.position="fixed";m.style.top="0px";m.style.left="0px";m.style.width=this.windowWidth()+"px";m.style.height=this.windowHeight()+"px"}else{if(MapToolkit.mapParent){document.getElementsByTagName("BODY")[0].removeChild(m);MapToolkit.mapParent.appendChild(m);delete MapToolkit.mapParent}m.style.position="relative";m.style.top="";m.style.left="";if(size.width&&size.height){m.style.width=size.width+"px";m.style.height=size.height+"px"}else if(size.offsetBottom){m.style.width=size.offsetRight!=null?(this.windowWidth()-$OFFSETLEFT(m)-size.offsetRight)+"px":"";m.style.height=(this.windowHeight()-$OFFSETTOP(m)-size.offsetBottom)+"px"}}},windowHeight:function(){var windowHeight=0;if(typeof(window.innerHeight)=="number")windowHeight=window.innerHeight;else if(document.documentElement&&document.documentElement.clientHeight)windowHeight=document.documentElement.clientHeight;else if(document.body&&document.body.clientHeight)windowHeight=document.body.clientHeight;return windowHeight},windowWidth:function(){var windowWidth=0;if(typeof(window.innerWidth)=="number")windowWidth=window.innerWidth;else if(document.documentElement&&document.documentElement.clientWidth)windowWidth=document.documentElement.clientWidth;else if(document.body&&document.body.clientWidth)windowWidth=document.body.clientWidth;return windowWidth},isIE6:function(){if(!window.navigator)return false;if(!navigator.appVersion)return false;return navigator.appVersion.match(/MSIE 6/)},isIE7:function(){if(!window.navigator)return false;if(!navigator.appVersion)return false;return navigator.appVersion.match(/MSIE 7/)},setMap:function(div,map){return MapToolkit.maps[div]=map},getMap:function(div){return MapToolkit.maps[div]},deleteMap:function(div){delete MapToolkit.maps[div]},createMap:function(div,config,callback){if(MapToolkit.maps[div])throw"MapToolkit already defined for div '"+div+"'";var map=$EL(div);map.style.overflow=map.style.overflow||'hidden';map.style.zIndex=map.style.zIndex||'50';this.resizeDiv(div,false,config);if(MapToolkit.documentLoaded){var map=new MapToolkit.Map(div,$CLONE(config));if(callback)callback(map)}else{GEvent.addDomListener(window,"load",function(_div,_config){return function(){var map=new MapToolkit.Map(_div,_config);if(callback)callback(map)}}(div,$CLONE(config)))}}};GEvent.addDomListener(window,"load",function(){MapToolkit.documentLoaded=true});
document.write('<scr'+'ipt src="http://mtk2.toursprung.com/static/js/i18n/'+MapToolkit.language+'.js" type="text/javascript"></sc'+'ript>');
MapToolkit.TreeMenu=function(element,rootNodes,param){var init=true;param=param||{};var nodesByName={};var entry=param.entry||MapToolkit.host+"/static/images/treemenu/entry.png";var entrySelected=param.entrySelected||MapToolkit.host+"/static/images/treemenu/entry_selected.png";var open=param.opened||MapToolkit.host+"/static/images/treemenu/open.png";var closed=param.closed||MapToolkit.host+"/static/images/treemenu/closed.png";var loading=param.loading||MapToolkit.host+"/static/images/loader.gif";var getIcon=function(node,i){if(!node.icon)return entry;if(typeof node.icon=="string")return node.icon;return node.icon[i]};var renderNodes=function(nodes,toplevel){var ul=document.createElement("ul");ul.className=toplevel?"mtk-treemenu-block-first":"mtk-treemenu-block";$EACH(nodes,function(node){var li=document.createElement("li");if(node.name)nodesByName[node.name]=li;li.className=(node.children&&node.children.length)?"mtk-treemenu-group":"mtk-treemenu-entry";li.checked=false;if(node.disabled)li.className+=" mtk-treemenu-disabled";if(node.visible!=null&&!node.visible)li.style.display="none";li.onmouseover=function(){li.className+=" mtk-treemenu-entry-hover mtk-treemenu-entry-selected";if(!node.children&&!node.isLoading)img.src=getIcon(node,1);if(!init&&node.onmouseover)node.onmouseover()};li.onmouseout=function(){li.className=li.className.replace(/ mtk-treemenu-entry-hover/g,"");if(!li.checked)li.className=li.className.replace(/ mtk-treemenu-entry-selected/g,"");if(!node.children&&!li.checked&&!node.isLoading)img.src=getIcon(node,0);if(!init&&node.onmouseout)node.onmouseout()};ul.appendChild(li);var img=document.createElement("img");img.className="mtk-treemenu-entry-image";img.width=16;img.height=16;li.appendChild(img);if(!node.children){img.src=getIcon(node,0);li.onclick=function(checkOnly){checkOnly=(checkOnly=="checkOnly");if(!init&&node.disabled)return;li.checked=!li.checked;if(li.checked)li.className+=" mtk-treemenu-entry-selected";if(checkbox)checkbox.checked=li.checked;if(!checkOnly&&node.onclick&&(node.showLoading==null||node.showLoading)){img.src=loading;node.isLoading=true;if(!init)node.onclick(li.checked,function(){node.isLoading=false;img.src=getIcon(node,(li.checked?1:0))})}else{img.src=getIcon(node,(li.checked?1:0));if(!checkOnly&&!init&&node.onclick)node.onclick(li.checked)}};if(node.checkbox){var checkbox=document.createElement("input");checkbox.className="mtk-treemenu-entry-checkbox";checkbox.type="checkbox";checkbox.onchange=li.onclick;li.appendChild(checkbox)}}var label=document.createElement("span");label.className=node.checkbox?"mtk-treemenu-check-label":"mtk-treemenu-entry-label";label.innerHTML=node.title;li.appendChild(label);if(node.children){img.src=closed;var children=renderNodes(node.children);children.style.display=node.checked?"block":"none";ul.appendChild(children);li.onclick=function(checkOnly){checkOnly=(checkOnly=="checkOnly");if(!init&&node.disabled)return;li.checked=!li.checked;if(!init)li.checked?$BLINDDOWN(children,{duration:0.1}):$BLINDUP(children,{duration:0.1});img.src=li.checked?open:closed;if(!checkOnly&&!init&&node.onclick)node.onclick(li.checked)}}li.check=function(){li.onclick("checkOnly")};if(node.checked)li.onclick()});return ul};$EL(element).appendChild(renderNodes(rootNodes,"toplevel"));init=false;return nodesByName}
MapToolkit.RestAPI=function(){var hexcase=0,b64pad="",chrsz=8;function core_md5(x,len){x[len>>5]|=0x80<<((len)%32);x[(((len+64)>>>9)<<4)+14]=len;var a=1732584193;var b=-271733879;var c=-1732584194;var d=271733878;for(var i=0;i<x.length;i+=16){var olda=a;var oldb=b;var oldc=c;var oldd=d;a=md5_ff(a,b,c,d,x[i+0],7,-680876936);d=md5_ff(d,a,b,c,x[i+1],12,-389564586);c=md5_ff(c,d,a,b,x[i+2],17,606105819);b=md5_ff(b,c,d,a,x[i+3],22,-1044525330);a=md5_ff(a,b,c,d,x[i+4],7,-176418897);d=md5_ff(d,a,b,c,x[i+5],12,1200080426);c=md5_ff(c,d,a,b,x[i+6],17,-1473231341);b=md5_ff(b,c,d,a,x[i+7],22,-45705983);a=md5_ff(a,b,c,d,x[i+8],7,1770035416);d=md5_ff(d,a,b,c,x[i+9],12,-1958414417);c=md5_ff(c,d,a,b,x[i+10],17,-42063);b=md5_ff(b,c,d,a,x[i+11],22,-1990404162);a=md5_ff(a,b,c,d,x[i+12],7,1804603682);d=md5_ff(d,a,b,c,x[i+13],12,-40341101);c=md5_ff(c,d,a,b,x[i+14],17,-1502002290);b=md5_ff(b,c,d,a,x[i+15],22,1236535329);a=md5_gg(a,b,c,d,x[i+1],5,-165796510);d=md5_gg(d,a,b,c,x[i+6],9,-1069501632);c=md5_gg(c,d,a,b,x[i+11],14,643717713);b=md5_gg(b,c,d,a,x[i+0],20,-373897302);a=md5_gg(a,b,c,d,x[i+5],5,-701558691);d=md5_gg(d,a,b,c,x[i+10],9,38016083);c=md5_gg(c,d,a,b,x[i+15],14,-660478335);b=md5_gg(b,c,d,a,x[i+4],20,-405537848);a=md5_gg(a,b,c,d,x[i+9],5,568446438);d=md5_gg(d,a,b,c,x[i+14],9,-1019803690);c=md5_gg(c,d,a,b,x[i+3],14,-187363961);b=md5_gg(b,c,d,a,x[i+8],20,1163531501);a=md5_gg(a,b,c,d,x[i+13],5,-1444681467);d=md5_gg(d,a,b,c,x[i+2],9,-51403784);c=md5_gg(c,d,a,b,x[i+7],14,1735328473);b=md5_gg(b,c,d,a,x[i+12],20,-1926607734);a=md5_hh(a,b,c,d,x[i+5],4,-378558);d=md5_hh(d,a,b,c,x[i+8],11,-2022574463);c=md5_hh(c,d,a,b,x[i+11],16,1839030562);b=md5_hh(b,c,d,a,x[i+14],23,-35309556);a=md5_hh(a,b,c,d,x[i+1],4,-1530992060);d=md5_hh(d,a,b,c,x[i+4],11,1272893353);c=md5_hh(c,d,a,b,x[i+7],16,-155497632);b=md5_hh(b,c,d,a,x[i+10],23,-1094730640);a=md5_hh(a,b,c,d,x[i+13],4,681279174);d=md5_hh(d,a,b,c,x[i+0],11,-358537222);c=md5_hh(c,d,a,b,x[i+3],16,-722521979);b=md5_hh(b,c,d,a,x[i+6],23,76029189);a=md5_hh(a,b,c,d,x[i+9],4,-640364487);d=md5_hh(d,a,b,c,x[i+12],11,-421815835);c=md5_hh(c,d,a,b,x[i+15],16,530742520);b=md5_hh(b,c,d,a,x[i+2],23,-995338651);a=md5_ii(a,b,c,d,x[i+0],6,-198630844);d=md5_ii(d,a,b,c,x[i+7],10,1126891415);c=md5_ii(c,d,a,b,x[i+14],15,-1416354905);b=md5_ii(b,c,d,a,x[i+5],21,-57434055);a=md5_ii(a,b,c,d,x[i+12],6,1700485571);d=md5_ii(d,a,b,c,x[i+3],10,-1894986606);c=md5_ii(c,d,a,b,x[i+10],15,-1051523);b=md5_ii(b,c,d,a,x[i+1],21,-2054922799);a=md5_ii(a,b,c,d,x[i+8],6,1873313359);d=md5_ii(d,a,b,c,x[i+15],10,-30611744);c=md5_ii(c,d,a,b,x[i+6],15,-1560198380);b=md5_ii(b,c,d,a,x[i+13],21,1309151649);a=md5_ii(a,b,c,d,x[i+4],6,-145523070);d=md5_ii(d,a,b,c,x[i+11],10,-1120210379);c=md5_ii(c,d,a,b,x[i+2],15,718787259);b=md5_ii(b,c,d,a,x[i+9],21,-343485551);a=safe_add(a,olda);b=safe_add(b,oldb);c=safe_add(c,oldc);d=safe_add(d,oldd)}return Array(a,b,c,d)}function md5_cmn(q,a,b,x,s,t){return safe_add(bit_rol(safe_add(safe_add(a,q),safe_add(x,t)),s),b)}function md5_ff(a,b,c,d,x,s,t){return md5_cmn((b&c)|((~b)&d),a,b,x,s,t)}function md5_gg(a,b,c,d,x,s,t){return md5_cmn((b&d)|(c&(~d)),a,b,x,s,t)}function md5_hh(a,b,c,d,x,s,t){return md5_cmn(b^c^d,a,b,x,s,t)}function md5_ii(a,b,c,d,x,s,t){return md5_cmn(c^(b|(~d)),a,b,x,s,t)}function core_hmac_md5(key,data){var bkey=str2binl(key);if(bkey.length>16)bkey=core_md5(bkey,key.length*chrsz);var ipad=Array(16),opad=Array(16);for(var i=0;i<16;i++){ipad[i]=bkey[i]^0x36363636;opad[i]=bkey[i]^0x5C5C5C5C}var hash=core_md5(ipad.concat(str2binl(data)),512+data.length*chrsz);return core_md5(opad.concat(hash),512+128)}function safe_add(x,y){var lsw=(x&0xFFFF)+(y&0xFFFF);var msw=(x>>16)+(y>>16)+(lsw>>16);return(msw<<16)|(lsw&0xFFFF)}function bit_rol(num,cnt){return(num<<cnt)|(num>>>(32-cnt))}function str2binl(str){var bin=Array();var mask=(1<<chrsz)-1;for(var i=0;i<str.length*chrsz;i+=chrsz)bin[i>>5]|=(str.charCodeAt(i/chrsz)&mask)<<(i%32);return bin}function binl2hex(binarray){var hex_tab=hexcase?"0123456789ABCDEF":"0123456789abcdef";var str="";for(var i=0;i<binarray.length*4;i++){str+=hex_tab.charAt((binarray[i>>2]>>((i%4)*8+4))&0xF)+hex_tab.charAt((binarray[i>>2]>>((i%4)*8))&0xF)}return str}function hex_md5(s){return binl2hex(core_md5(str2binl(s),s.length*chrsz))}function doRequest(params,type){var role=params.role?"#"+params.role:"";var password=params.password||"";var time=password&&parseInt((new Date()).getTime()/1000);params.parameters.api_key=""+params.api_key+role;params.parameters.token=hex_md5(params.api_key+password+time);params.url=params.url+"/"+type;params.parameters=params.parameters||{};jsonRpc(params)}return{"get":function(params){doRequest(params,"get")},"post":function(params){doRequest(params,"post")},"put":function(params){doRequest(params,"put")},"delete":function(params){doRequest(params,"delete")}}}();
if(!GLatLng.prototype.__lat&&!GLatLng.prototype.__lng){GLatLng.prototype.__lat=GLatLng.prototype.lat;GLatLng.prototype.lat=function(){return Math.round(this.__lat()*100000)/100000};GLatLng.prototype.__lng=GLatLng.prototype.lng;GLatLng.prototype.lng=function(){return Math.round(this.__lng()*100000)/100000};GLatLng.prototype.equals=function(other){return(this.lat()==other.lat()&&this.lng()==other.lng())}}
MapToolkit.Tooltip=function(){var tooltips={};var priority={};var getTooltip=function(map,className,style){if(tooltips[map.div])return tooltips[map.div];var div=document.createElement("div");div.style.display="none";div.className=className||"mtk-tooltip";div.style.position="absolute";if(style)for(var i in style)div.style[i]=style[i];map.gmap.getPane(G_MAP_FLOAT_SHADOW_PANE).appendChild(div);return tooltips[map.div]=div};var setOpacity=function(map,opacity){var div=getTooltip(map);if(opacity<0)opacity=0;if(opacity>=100)opacity=100;var opacity2=opacity/100;if(typeof(div.style.filter)=='string')div.style.filter='alpha(opacity:'+opacity+')';if(typeof(div.style.KHTMLOpacity)=='string')div.style.KHTMLOpacity=opacity2;if(typeof(div.style.MozOpacity)=='string')div.style.MozOpacity=opacity2;if(typeof(div.style.opacity)=='string')div.style.opacity=opacity2};return{show:function(params){if((params.priority||0)<priority[params.map.div])return;this.hide(params);priority[params.map.div]=params.priority;var div=getTooltip(params.map,params.className,params.style);if(params.text!=null)div.innerHTML=params.text;if(params.opacity!=null)setOpacity(params.map,params.opacity);this.move(params);div.style.display="block"},move:function(params){var div=getTooltip(params.map,params.className,params.style);var xy=params.map.gmap.fromLatLngToDivPixel(params.point);var xy2=params.map.gmap.fromLatLngToContainerPixel(params.point);var offset=params.icon?[params.icon.iconSize.width-params.icon.iconAnchor.x,0-params.icon.iconAnchor.y]:[0,0];var point={top:xy.y+offset[1]-5,left:xy.x+offset[0]+5};var point2={top:xy2.y+offset[1],left:xy2.x+offset[0]};var mapSize=params.map.gmap.getSize();var winSize=$DIMENSIONS(div);var iconSize=params.icon?params.icon.iconSize:{width:0,height:0};winSize.width+=iconSize.width/2;var diff={north:point2.top,east:mapSize.width-point2.left-winSize.width,south:mapSize.height-point2.top-winSize.height,west:point2.left-winSize.width-iconSize.width};if(diff.east<0&&diff.east<diff.west)point.left-=winSize.width+iconSize.width+10;if(diff.south<0&&diff.south<diff.north)point.top+=diff.south-10;if(diff.north<0&&diff.north<diff.south)point.top-=diff.north-10;div.style.left=point.left+"px";div.style.top=point.top+"px"},hide:function(params){if((params.priority||0)<priority[params.map.div])return;delete priority[params.map.div];getTooltip(params.map,params.className,params.style).style.display="none"}}}();
MapToolkit.InfoWindow=function(){this.prototype=new GOverlay();var that=this;var windows={};var getWindow=function(map,className,style){if(windows[map.div])return windows[map.div];var isIE6=MapToolkit.isIE6()?"-ie6":"";var div=document.createElement("div");div.style.position="absolute";div.className=className||"mtk-infowindow";div.innerHTML=''+'<div id="mtk-infowindow-content-'+map.div+'">&nbsp</div>'+'<div class="mtk-infowindow-close'+isIE6+'" onclick="javascript:MapToolkit.InfoWindow.hide({map:MapToolkit.getMap(\''+map.div+'\')})">&nbsp;</div>';if(style)for(var i in style)div.style[i]=style[i];map.gmap.getPane(G_MAP_FLOAT_PANE).appendChild(div);return windows[map.div]=[div,$EL("mtk-infowindow-content-"+map.div)]};var setOpacity=function(map,opacity){var obj=getWindow(map)[0];if(opacity<0)opacity=0;if(opacity>=100)opacity=100;var opacity2=opacity/100;if(typeof(obj.style.filter)=='string')obj.style.filter='alpha(opacity:'+opacity+')';if(typeof(obj.style.KHTMLOpacity)=='string')obj.style.KHTMLOpacity=opacity2;if(typeof(obj.style.MozOpacity)=='string')obj.style.MozOpacity=opacity2;if(typeof(obj.style.opacity)=='string')obj.style.opacity=opacity2};return{show:function(params){this.hide(params);var window=getWindow(params.map,params.className,params.style);if(params.details!=null)window[1].innerHTML=params.details[0][1];if(params.opacity!=null)setOpacity(params.map,params.opacity);this.move(params);window[0].style.display="block"},move:function(params){var window=getWindow(params.map,params.className,params.style);var xy=params.map.gmap.fromLatLngToDivPixel(params.point);var xy2=params.map.gmap.fromLatLngToContainerPixel(params.point);var offset=params.icon?[params.icon.iconSize.width-params.icon.iconAnchor.x,0-params.icon.iconAnchor.y]:[0,0];var point={top:xy.y+offset[1]-5,left:xy.x+offset[0]+5};var point2={top:xy2.y+offset[1],left:xy2.x+offset[0]};var mapSize=params.map.gmap.getSize();var winSize=$DIMENSIONS(window[0]);var iconSize=params.icon?params.icon.iconSize:{width:0,height:0};winSize.width+=iconSize.width/2;var diff={north:point2.top,east:mapSize.width-point2.left-winSize.width,south:mapSize.height-point2.top-winSize.height,west:point2.left-winSize.width-iconSize.width};if(diff.east<0&&diff.east<diff.west)point.left-=winSize.width+iconSize.width+15;if(diff.south<0&&diff.south<diff.north)point.top+=diff.south-15;if(diff.north<0&&diff.north<diff.south)point.top-=diff.north-10;window[0].style.left=point.left+"px";window[0].style.top=point.top+"px";var latLng=params.map.gmap.fromDivPixelToLatLng(new GPoint(point.left,point.top));var point=params.map.gmap.fromLatLngToContainerPixel(latLng);var bounds=params.map.gmap.getBounds();var span=bounds.toSpan();var panToLat=params.map.gmap.getCenter().lat();var panToLng=params.map.gmap.getCenter().lng();var outside={north:point.y,east:mapSize.width-point.x-winSize.width,south:mapSize.height-point.y-winSize.height,west:point.x};if(outside.north<0)panToLat-=outside.north/mapSize.height*span.lat();if(outside.east<0)panToLng-=outside.east/mapSize.width*span.lng();if(outside.west<0)panToLng+=outside.west/mapSize.width*span.lng();params.map.gmap.panTo($P(panToLat,panToLng))},hide:function(params){getWindow(params.map,params.className,params.style)[0].style.display="none"}}}();
MapToolkit.Marker=function(params){this._params=params;this.map=params.map;this.point=params.point;this.oldPoint=params.point;this.icon=params.icon?MapToolkit.Icon.get(params.icon):G_DEFAULT_ICON;this.label=params.label;this.className=params.markerClass||"mtk-marker";this.style=params.markerStyle||{}};MapToolkit.Marker.prototype=new GOverlay();MapToolkit.Marker.activeMarker=null;MapToolkit.Marker.prototype.initialize=function(gmap){var that=this;that.gmap=gmap;that.image=document.createElement('div');that.image.className=this.className;that.image.style.position='absolute';that.image.style.zIndex=GOverlay.getZIndex(that.point.lat());that.image.style.width=this.icon.iconSize.width+"px";that.setImage(this.icon.image);that.image.style.height=this.icon.iconSize.height+"px";that.image.style.cursor='pointer';for(var i in this.style)that.image.style[i]=this.style[i];if(this.label)that.image.innerHTML=this.label;if(this.icon.shadow){that.shadow=document.createElement('div');that.shadow.className=this.className+"-shadow";that.shadow.style.position='absolute';if(MapToolkit.isIE6())that.shadow.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale, src='"+this.icon.shadow+"')";else that.shadow.style.backgroundImage="url("+this.icon.shadow+")";that.shadow.style.width=this.icon.shadowSize.width+"px";that.shadow.style.height=this.icon.shadowSize.height+"px"}that.gmap.getPane(G_MAP_MARKER_PANE).appendChild(that.image);if(that.shadow)that.gmap.getPane(G_MAP_MARKER_SHADOW_PANE).appendChild(that.shadow);GEvent.addDomListener(that.image,'click',function(){that.onclick()});GEvent.addDomListener(that.image,'mouseover',function(){that.onmouseover()});GEvent.addDomListener(that.image,'mouseout',function(){that.onmouseout()})};MapToolkit.Marker.prototype.setImage=function(src){if(MapToolkit.isIE6())this.image.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale, src='"+src+"')";else this.image.style.backgroundImage="url("+src+")"};MapToolkit.Marker.prototype.setTooltip=function(details,opacity){this.tooltip=details;this.opacity=opacity};MapToolkit.Marker.prototype.setInfoWindow=function(details,opacity){this.infoWindow=details;this.opacity=opacity};MapToolkit.Marker.prototype.setGoogleInfoWindow=function(details){this.googleInfoWindow=details};MapToolkit.Marker.prototype.onclick=function(){if(this.dimmed)return;if(this.googleInfoWindow){this.log&&this.log();if(this.googleInfoWindow.length==1){this.gmap.openInfoWindowHtml(this.point,this.googleInfoWindow[0][1])}else{this.gmap.openInfoWindowTabsHtml($MAP(item.googleInfoWindow,function(i){return new GInfoWindowTab(i[0],i[1])}))};this.details=true}else if(this.infoWindow){this.log&&this.log();MapToolkit.InfoWindow.show({map:this.map,point:this.point,details:this.infoWindow,opacity:this.opacity,icon:this.icon,style:this._params.infoWindowStyle,className:this._params.infoWindowClass});this.details=true}GEvent.trigger(this,'click',this.point)};MapToolkit.Marker.prototype.onmouseover=function(point){if(this.dimmed)return;if(this==MapToolkit.Marker.activeMarker)return;if(this._params.highlightImage)typeof this._params.highlightImage=="function"?this.setImage(this._params.highlightImage(this.params)):this.setImage(this._params.highlightImage);if(this.tooltip){this.log&&this.log();MapToolkit.Tooltip.show({map:this.map,point:this.point,text:this.tooltip[0][1],opacity:this.opacity,icon:this.icon,style:this._params.tooltipStyle,className:this._params.tooltipClass,priority:1});this.details=true}MapToolkit.Marker.activeMarker=this;GEvent.trigger(this,'mouseover',this.point)};MapToolkit.Marker.prototype.onmouseout=function(){if(this._params.highlightImage)this.setImage(this.icon.image);if(this.tooltip&&this.details){MapToolkit.Tooltip.hide({map:this.map,priority:1});this.details=false}MapToolkit.Marker.activeMarker=null;GEvent.trigger(this,'mouseout',this.point)};MapToolkit.Marker.prototype.closeDetails=function(){if(this.tooltip&&this.details)MapToolkit.Tooltip.hide({map:this.map,priority:1});if(this.infoWindow&&this.details)MapToolkit.InfoWindow.hide(this._params);if(this.googleInfoWindow&&this.details)this.gmap.closeInfoWindow();this.details=false};MapToolkit.Marker.prototype.panTo=function(newPoint){this.image.style.zIndex=0;this.oldPoint=this.point;this.point=newPoint;this.redraw(1);this.polyline=new GPolyline([this.oldPoint,this.point],'#555555',2,0.8);this.map.gmap.addOverlay(this.polyline)};MapToolkit.Marker.prototype.dimm=function(opacity){this.dimmed=true;this.oldOpacity=$OPACITY(this.image);$OPACITY(this.image,opacity);$OPACITY(this.shadow,opacity)};MapToolkit.Marker.prototype.restore=function(){this.image.style.zIndex=GOverlay.getZIndex(this.point.lat());if(this.point=this.oldPoint)this.redraw(1);if(this.oldOpacity!=null){$OPACITY(this.image,this.oldOpacity);if(this.shadow)$OPACITY(this.shadow,this.oldOpacity);this.oldOpacity=null}if(this.polyline)this.gmap.removeOverlay(this.polyline);this.dimmed=false};MapToolkit.Marker.prototype.remove=function(){this.closeDetails;this.image.parentNode.removeChild(this.image);if(this.shadow)this.shadow.parentNode.removeChild(this.shadow)};MapToolkit.Marker.prototype.copy=function(){return new MapToolkit.Marker(this._params)};MapToolkit.Marker.prototype.redraw=function(force){if(!force)return;var p=this.gmap.fromLatLngToDivPixel(this.point);this.image.style.left=(p.x-this.icon.iconAnchor.x)+'px';this.image.style.top=(p.y-this.icon.iconAnchor.y)+'px';if(this.shadow){this.shadow.style.left=(p.x-this.icon.iconAnchor.x)+'px';this.shadow.style.top=(p.y-this.icon.iconAnchor.y)+'px'}};
MapToolkit.Map=function(div,config){if(!GBrowserIsCompatible()){alert('cannot create map, because Browser is not compatible!');return}else{config.map.mapTypes=config.map.mapTypes||["G_NORMAL_MAP","G_SATELLITE_MAP","G_PHYSICAL_MAP","OSM_MAP","OSM_CYCLE_MAP","G_HYBRID_MAP"];var gmap=new google.maps.Map2($EL(div),{mapTypes:$MAP(config.map.mapTypes,function(e){return window[e]||alert("mapType '"+e+"' does not exists!")})});gmap.enableContinuousZoom();gmap.enableDoubleClickZoom();gmap.enableScrollWheelZoom();gmap.mapDiv=div}var that=this;var tiles={};var overlays={visible:{},pending:{}};var specificMarkers={};var clusterMarkers={};var editor=null;var resizeTimeout=null;var locationHash="";var routeHighlight={};var asyncTimeout;var asyncTiles=$HASH({});var controls={};var mouseXY=[0,0];var bodyHeight=document.documentElement.clientHeight;var getMax=function(elems){var max=-999;$EACH(elems,function(e){if(e>max)max=e});return max};var getMin=function(elems){var min=999;$EACH(elems,function(e){if(e<min)min=e});return min};var getSum=function(elems){var sum=0;$EACH(elems,function(e){sum+=e});return sum};var pollAsyncTiles=function(){var tileIds=$MAP(asyncTiles.values(),function(t){return t.id});if(!tileIds.length)return;jsonRpc({url:MapToolkit.host+"/async.json",parameters:{api_key:config.api_key,version:MapToolkit.version,tileIds:$TO_JSON(tileIds),request_id:MapToolkit.Search.requestId},callback:function(data){var tiles=[];$EACH(data.tiles,function(t){var tile=MapToolkit.Search.convertTile(map,t,data.icons[t[0]]);if(asyncTiles.get(tile.id)&&!tile.async){asyncTiles.unset(tile.id);if(tile.count)tiles.push(tile)}});if(tiles.length){for(var i in overlays.visible)overlays.pending[i]=overlays.visible[i];setTiles(tiles,data.requestId)}if(asyncTiles.keys().length)asyncTimeout=setTimeout(pollAsyncTiles,3000);else asyncTimeout=null;stopSpinners()}})};var stopSpinners=function(){var asyncRes={};$EACH(asyncTiles.values(),function(tile){asyncRes[tile.resource]=true});for(var i in config.resources){if($EL('spinner-'+div+i)&&!asyncRes[i])$EL2('spinner-'+div+i).hide()}};var wheelEvent=function(e){if(!e)e=window.event;if(e.preventDefault)e.preventDefault();e.returnValue=false};var setCluster=function(params){var clusterId=params.id+","+params.count;if(overlays.visible[clusterId]){overlays.pending[clusterId]=overlays.visible[clusterId]}else{params.style=config.clusters.style||'detailed';params.color=config.clusters.color||'555555';params.naming=config.clusters.naming||'Items';params.onclick=config.clusters.onclick;params.levels=config.clusters.levels;if(config.clusters.style=='simple'){var cluster=new MapToolkit.SimpleCluster(that,params);GEvent.trigger(that,'setSimpleCluster',cluster)}else{var cluster=new MapToolkit.DetailedCluster(that,params);GEvent.trigger(that,'setDetailedCluster',cluster)}overlays.pending[clusterId]=cluster}};var setItem=function(params,i){if(overlays.visible[params.id]&&!params.id.toString().match(/^tmp_/)){overlays.pending[params.id]=overlays.visible[params.id]}else{var c=config.resources[params.resource]||(config.items&&config.items[params.resource])||{};var marker=params.icon?new MapToolkit.Marker($EXTEND({map:that,point:$P(params),icon:params.icon},c)):{};marker.params=params;marker.tileI=i;overlays.pending[params.id]=marker}};var setSpezificItems=function(){if(!config.items)return;for(var i in config.items){$EACH(config.items[i].ids,function(id){setItem({resource:i,id:id},0)})}};var showPendingOverlays=function(requestId,callback){for(var i in overlays.visible){if(overlays.pending[i]&&!i.toString().match(/^tmp_/)){delete overlays.pending[i]}else{gmap.removeOverlay(overlays.visible[i]);delete overlays.visible[i]}}var lazy=[];for(var i in overlays.pending){var marker=overlays.visible[i]=overlays.pending[i];if(marker instanceof GOverlay){gmap.addOverlay(marker)}else{lazy.push(marker)}if(marker instanceof MapToolkit.Marker)lazy.push(marker)}if(lazy.length){var items={};$EACH(lazy,function(l){items[l.params.resource]=items[l.params.resource]||[];items[l.params.resource].push(l.params.id+"_"+l.tileI)});loadItems(items,requestId,callback)}else if(callback)callback();overlays.pending={}};var loadItems=function(ids,requestId,callback){MapToolkit.Search.items(that,{ids:ids,callback:function(data){var jobs=[[]];for(var i=0;i<data.items.length;i++){if(jobs[jobs.length-1].length>50)jobs.push([]);jobs[jobs.length-1].push(data.items[i])};var doJobs=function(jobs){if(!jobs.length){GEvent.trigger(that,"setItemsDone");if(callback)callback();return}var job=jobs.shift();$EACH(job,function(item){var c=config.resources[item.resource]||(config.items&&config.items[item.resource])||{};c.detailsAs=c.detailsAs||"tooltip";var markerId=overlays.visible[item.id]?item.id:"remote_"+item.remoteid;var marker=overlays.visible[markerId];if(!marker)return;if(item.type=='cluster'){marker=new MapToolkit.Polygon($EXTEND(item,c),that);marker.params=item;GEvent.trigger(that,'setCustomCluster',marker);gmap.addOverlay(marker);overlays.visible[item.id]=marker;return}if(!(marker instanceof MapToolkit.Marker)){var params=marker.params;try{var point=$P(params)}catch(e){var point=$P(item)};if(!c.icon)delete(c.icon);marker=new MapToolkit.Marker($EXTEND({map:that,point:point,icon:item.icon||data.icons[params.resource]},c));marker.params=params;overlays.visible[markerId]=marker;gmap.addOverlay(marker)}marker.params=item;marker.log=function(){that.log([item.resource,item.id,'view'])};if(item.details.length){if(c.detailsAs=="googleInfoWindow"){marker.setGoogleInfoWindow(item.details)}else if(c.detailsAs=="infoWindow"){marker.setInfoWindow(item.details,c.opacity)}else if(c.detailsAs=="tooltip"){marker.setTooltip(item.details,c.opacity)}}GEvent.addListener(marker,"click",function(){that.log([item.resource,item.id,'click']);GEvent.trigger(that,"markerClicked",marker);var doHref=true;if(c.onclick&&c.onclick(marker)==false)doHref=false;if(doHref&&c.detailsAs=="tooltip"&&item.href)that.openHref(item.href)});GEvent.addListener(marker,"mouseover",function(){if(item.type=='route'&&item.kml){routeHighlight.timeout=setTimeout(function(){routeHighlight.polyline=new GGeoXml(item.kml);gmap.addOverlay(routeHighlight.polyline)},200)}GEvent.trigger(that,"markerMouseOver",marker)});GEvent.addListener(marker,"mouseout",function(){if(item.type=='route'&&item.kml){if(routeHighlight.timeout)clearTimeout(routeHighlight.timeout);if(routeHighlight.polyline)gmap.removeOverlay(routeHighlight.polyline);routeHighlight={}}GEvent.trigger(that,"markerMouseOut",marker)});GEvent.trigger(that,'setMarker',marker)});setTimeout(function(){doJobs(jobs)},10)};doJobs(jobs)}})};var setTiles=function(tiles,requestId,callback){var clustered={},selectiv=[];for(var i=0;i<tiles.length;i++){var tile=tiles[i];tile.isClustered=gmap.getZoom()>=gmap.getCurrentMapType().getMaximumResolution()?false:config.resources[tile.resource].clusters||false;if(tile.isClustered){clustered[tile.xy]=clustered[tile.xy]||[];clustered[tile.xy].push(tile)}else{selectiv.push([tile])}}var jobs=[[]],merged=selectiv.concat($HASH(clustered).values());for(var i=0;i<merged.length;i++){if(jobs[jobs.length-1].length>5)jobs.push([]);jobs[jobs.length-1].push(merged[i])};var doJobs=function(jobs){if(requestId<MapToolkit.Search.requestId)return;if(!jobs.length){GEvent.trigger(that,"setTilesDone");showPendingOverlays(requestId,callback);return}var job=jobs.shift();for(var t=0;t<job.length;t++){var tiles=job[t];var resource=tiles[0].resource;var z=config.resources[resource].zoom;if(z&&(z[0]<gmap.getZoom()||z[1]>gmap.getZoom()))continue;var itemCount=getSum($MAP(tiles,function(e){return e.count}));if(tiles[0].isClustered&&itemCount>=config.clusters.threshold){setCluster({id:tiles[0].xy,count:itemCount,lat:tiles[0].lat,lng:tiles[0].lng,north:getMax($MAP(tiles,function(e){return e.north})),east:getMax($MAP(tiles,function(e){return e.east})),south:getMin($MAP(tiles,function(e){return e.south})),west:getMin($MAP(tiles,function(e){return e.west}))});}else{$EACH(tiles,function(tile){var items=tile.items;var c=config.resources[tile.resource];var markerLimit=c.markerLimitPerTile;if(markerLimit&&items.length>markerLimit){items=items.splice(0,markerLimit)}for(var i=0;i<items.length;i++)setItem(items[i],i)})}}setTimeout(function(){doJobs(jobs)},10)};doJobs(jobs)};that.gmap=gmap;that.config=config;that.div=div;that.editor=editor;that.isFullscreen=false;that.reset=function(){overlays.pending={};showPendingOverlays();MapToolkit.InfoWindow.hide({map:that})};that.log=function(args,callback){jsonRpc({url:MapToolkit.host+"/log",parameters:{api_key:config.api_key,log:$TO_JSON(args)},callback:callback||function(){return}})};that.getMousePoint=function(){var point=new GPoint(mouseXY[0],mouseXY[1]);return gmap.fromContainerPixelToLatLng(point)};that.addControl=function(control,obj){var _this=control.match(/^G/)?"()":"(that)";eval("obj = obj || new "+control+_this);controls[control]=obj;gmap.addControl(obj)};that.removeControl=function(control){if(controls[control])gmap.removeControl(controls[control]);delete controls[control]};that.getItems=function(id){return $HASH(overlays.visible).values()};that.getItemById=function(id){return overlays.visible[id]};that.getMarkerById=function(id){return overlays.visible[id]};that.openHref=function(href){location.href=href};that.initEditor=function(){if(!that.editor&&MapToolkit.RouteEditor)that.editor=new MapToolkit.RouteEditor(that);return that.editor};that.getCurrentMapTypeIndex=function(){var type=0;var types=gmap.getMapTypes();for(var i=0;i<types.length;i++)if(types[i]==gmap.getCurrentMapType())type=i;return type},that.updateLayer=function(layer,onOff){config.layers[layer].optional=onOff?false:true;var layer=config.layers[layer].layer;onOff?gmap.addOverlay(layer):gmap.removeOverlay(layer)},that.updateResource=function(resource,onOff,cb){config.resources[resource].optional=onOff?false:true;this.modified(cb)},that.modified=function(callback){GEvent.trigger(that,"willBeModifyed");var resources={};for(var i in config.resources){var c=config.resources[i];var z=gmap.getZoom();if(!c.optional&&(!c.zoom||(c.zoom[0]<=z&&c.zoom[1]>=z)))resources[i]={filter:c.filter,icon:c.icon&&1}}MapToolkit.Search.tiles(that,{resources:resources,callback:function(data){if(data.status==403){alert("invalid MapToolkit api_key for host "+location.hostname);return}if(MapToolkit.Search.requestId==data.requestId){asyncTiles=$HASH({});if(!data.tiles.length&&!$HASH(data.clusters).keys().length){overlays.pending={};setSpezificItems();showPendingOverlays();GEvent.trigger(that,"modifiedDone",data);if(callback)callback($HASH(data.icons).keys())}else{$EACH(data.tiles,function(tile){if(tile.async)asyncTiles.set(tile.id,tile)});if(asyncTiles.keys().length&&!asyncTimeout)asyncTimeout=setTimeout(pollAsyncTiles,3000);setSpezificItems();for(var i in data.clusters)$EACH(data.clusters[i],function(id){setItem({resource:i,id:id},0)});setTiles(data.tiles,data.requestId,function(){GEvent.trigger(that,"modifiedDone",data);if(callback)callback($HASH(data.icons).keys())})}stopSpinners();GEvent.trigger(that,"modified",data)}}})};that.setFullscreen=function(onOff){that.isFullscreen=onOff;that.resize();GEvent.trigger(that,"setFullscreen",onOff)};that.resize=function(){MapToolkit.resizeDiv(div,that.isFullscreen,config);setTimeout(function(){var center=gmap.getCenter();gmap.checkResize();gmap.setCenter(center);GEvent.trigger(that,"resize",gmap.getSize().width,gmap.getSize().height)},1)};that.updateLocationHash=function(force){if(!config.map.useLocationHash)return;var lat=gmap.getCenter().lat();var lng=gmap.getCenter().lng();var zoom=gmap.getZoom();var type=that.getCurrentMapTypeIndex();if(!force&&config.map.location.lat==lat&&config.map.location.lng==lng&&config.map.location.zoom==zoom&&$INARRAY(config.map.mapTypes,config.map.mapType||config.map.mapTypes[0])==type)return;this.setLocationHash("lt="+lat+"&ln="+lng+"&z="+zoom+"&t="+type);GEvent.trigger(that,"updateLocationHash")};that.setLocationHash=function(hash){locationHash="#"+hash;location.hash=hash};that.checkLocationHash=function(){var hash=null;if(location.hash!=locationHash){if(location.hash.match(/lt=([\-?\d\.]+)&ln=([\-?\d\.]+)&z=(\d+)&t=(\d)(\&(.*))?$/)){var lat=parseFloat(RegExp.$1);var lng=parseFloat(RegExp.$2);var z=parseInt(RegExp.$3);var t=parseInt(RegExp.$4);var extra=RegExp.$6;GEvent.trigger(that,"checkLocationHash",extra);hash={lat:lat,lng:lng,zoom:z,type:t}}else{var loc=config.map.location;var t=$INARRAY(config.map.mapTypes,config.map.mapType||config.map.mapTypes[0]);if(t==-1)t=0;if(loc.north){var bounds=new GLatLngBounds(new GLatLng(loc.south,loc.west),new GLatLng(loc.north,loc.east));hash={lat:bounds.getCenter().lat(),lng:bounds.getCenter().lng(),zoom:gmap.getBoundsZoomLevel(bounds),type:t};}else{hash={lat:loc.lat,lng:loc.lng,zoom:loc.zoom,type:t}}}gmap.setCenter(new GLatLng(hash.lat,hash.lng),hash.zoom,gmap.getMapTypes()[hash.type]);locationHash=location.hash}setTimeout(function(){that.checkLocationHash()},500);return hash};MapToolkit.setMap(div,that);GEvent.trigger(window,"MapToolkit.Map.beforeInit",that);if(config.menu==null||config.menu){config.menu=config.menu||"MapToolkit.OptionalControl";eval("var optionalControl = new "+config.menu+"(that)");if(optionalControl.categories.length){that.addControl("MapToolkit.OptionalControl",optionalControl);config.map.optionalControl=true}}if(config.editor)that.addControl(config.editor.className||"MapToolkit.RouteEditorControl");if(config.upload)that.addControl(config.upload.className||"MapToolkit.UploadControl");for(var i in config.layers){var layer=config.layers[i];layer.layer=new GLayer(layer.id);if(!layer.optional)setTimeout(function(map,layer){return function(){gmap.addOverlay(layer)}}(map,layer.layer),1)}var hash=config.map.useLocationHash?that.checkLocationHash():null;var loc=config.map.location;if(loc.north!=null&&loc.east!=null&&loc.south!=null&&loc.west!=null){var bounds=new GLatLngBounds(new GLatLng(loc.south,loc.west),new GLatLng(loc.north,loc.east));loc.lat=bounds.getCenter().lat();loc.lng=bounds.getCenter().lng();loc.zoom=gmap.getBoundsZoomLevel(bounds);}else if(loc.geoip){if(MapToolkit.location.lat!=null)loc.lat=MapToolkit.location.lat;if(MapToolkit.location.lng!=null)loc.lng=MapToolkit.location.lng;if(MapToolkit.location.lat!=null&&loc.geoipZoom)loc.zoom=loc.geoipZoom}var lat=hash?hash.lat:loc.lat;var lng=hash?hash.lng:loc.lng;var zoom=hash?hash.zoom:loc.zoom;var type=hash?gmap.getMapTypes()[hash.type]:eval(config.map.mapType||config.map.mapTypes[0]);gmap.setCenter(new GLatLng(lat,lng),zoom,type);if(config.map.controls)$MAP(config.map.controls,function(e){try{that.addControl(e)}catch(err){alert("cannot add mapControl "+e+"', details: "+err+"'")}});that.modified();GEvent.addListener(gmap,"moveend",function(){that.updateLocationHash();that.modified()});GEvent.addListener(gmap,"zoomend",that.reset);GEvent.addDomListener(window,"resize",function(){if(bodyHeight==document.documentElement.clientHeight)return;bodyHeight=document.documentElement.clientHeight;if(resizeTimeout)clearTimeout(resizeTimeout);resizeTimeout=setTimeout(function(){that.resize();that.modified()},200)},false);GEvent.addDomListener(gmap.getContainer(),"DOMMouseScroll",wheelEvent);gmap.getContainer().onmousewheel=wheelEvent;GEvent.trigger(that,"init");GEvent.trigger(window,"MapToolkit.Map.init",div);$EVENT(div,"mousemove",function(e){mouseXY=[e.clientX,e.clientY]});if(config.circleBunchMarkers==null||config.circleBunchMarkers)new MapToolkit.BunchMarkers(that);return that};
MapToolkit.Search={requestId:0,timeout:null,convertTile:function(map,t,icon){var tile={resource:t.shift(),x:t.shift(),y:t.shift(),key:t.shift(),lat:t.shift(),lng:t.shift(),north:t.shift(),east:t.shift(),south:t.shift(),west:t.shift(),time:t.shift(),async:t.shift(),count:parseInt(t.shift()),items:[]};while(t.length){tile.items.push({lat:t.shift(),lng:t.shift(),id:t.shift(),remoteid:t.shift(),resource:tile.resource,icon:(map&&map.config.resources[tile.resource].icon)||icon})}tile.xy=[tile.x,tile.y].join(",");tile.id=[tile.resource,tile.x,tile.y,tile.key].join(",");return tile},items:function(map,param){var jobs=[],empty=false;while(!empty){empty=true;var job={},count=0;for(var r in param.ids){if(count+param.ids[r].length>300){var len=300-count;if(len>=param.ids[r].length)len=param.ids[r].length-1;job[r]=param.ids[r].splice(0,len)}else{job[r]=param.ids[r];delete param.ids[r]}}jobs.push(job);for(var r in param.ids)empty=false}var templates={};for(var i in map.config.resources){if(map.config.resources[i].template)templates[i]=map.config.resources[i].template}var result={},doJob=function(ids){jsonRpc({url:param.href||MapToolkit.host+"/items.json",parameters:{version:MapToolkit.version,api_key:map.config.api_key,request_id:MapToolkit.Search.requestId,charset:map.config.charset||'',language:map.config.language||MapToolkit.language,ids:$TO_JSON(ids),templates:$TO_JSON(templates),static_map:param.staticMap?$TO_JSON(param.staticMap):''},callback:function(data){result={icons:$EXTEND(result.icons||{},data.icons),items:(result.items||[]).concat(data.items),requestId:data.requestId};if(jobs.length)doJob(jobs.shift());else param.callback(result)}})};doJob(jobs.shift())},tiles:function(map,param){this.requestId++;this.cancel();this.timeout=setTimeout(function(){jsonRpc({url:param.href||MapToolkit.host+"/tiles.json",parameters:{version:MapToolkit.version,charset:map.config.charset||'',request_id:MapToolkit.Search.requestId,api_key:map.config.api_key,language:map.config.language||MapToolkit.language,query:param.query||MapToolkit.FulltextSearch.query[map.div]||'',resources:$TO_JSON(param.resources),zoom:map.gmap.getZoom(),north:map.gmap.getBounds().getNorthEast().lat(),east:map.gmap.getBounds().getNorthEast().lng(),south:map.gmap.getBounds().getSouthWest().lat(),west:map.gmap.getBounds().getSouthWest().lng(),num_x:parseInt(map.gmap.getSize().width/128)+2,num_y:parseInt(map.gmap.getSize().height/128)+2},callback:function(data){var convert=MapToolkit.Search.convertTile;data.tiles=$MAP(data.tiles,function(t){return convert(map,t,data.icons[t[0]])});param.callback(data)}})},200)},cancel:function(){if(this.timeout)clearTimeout(this.timeout);this.timeout=null}};
MapToolkit.highlightedPolygon=null;MapToolkit.PolygonTooltip=null;MapToolkit.PolygonMouseOver=null;MapToolkit.Polygon=function(params,map){var that=this;var polylines=$MAP(params.polygon.polylines,function(p){return{points:p.points,levels:p.levels,numLevels:p.numLevels||0,zoomFactor:p.zoomFactor||0,color:params.polygon.color||"#ff0000",weight:params.polygon.weight||0,opacity:1}});var polygon=new GPolygon.fromEncoded({polylines:polylines,fill:true,color:params.polygon.color,opacity:params.polygon.opacity,outline:true},{clickable:params.polygon.active?true:false});polygon.highlight=function(onOff){that.highlight(onOff)};that.polygon=polygon;that.map=map;that.gmap=map.gmap;that.params=params;that.detailWindow=null;that.point=polygon.getBounds().getCenter();if(params.polygon.active){GEvent.addListener(polygon,"mouseover",function(e){if(MapToolkit.PolygonMouseOver!=that){MapToolkit.PolygonMouseOver=that;that.onMouseOver(map.getMousePoint())}});GEvent.addListener(polygon,"mouseout",function(e){if(MapToolkit.PolygonMouseOver==that){MapToolkit.PolygonMouseOver=null;that.onMouseOut(map.getMousePoint())}});GEvent.addListener(polygon,"mousemove",function(e){if(MapToolkit.PolygonMouseOver==that){that.onMouseMove(map.getMousePoint())}else{MapToolkit.PolygonMouseOver.onMouseOut(map.getMousePoint());that.onMouseOver(map.getMousePoint());MapToolkit.PolygonMouseOver=that}})}return polygon};MapToolkit.Polygon.prototype.onClick=function(point){if(this.params.onclick){this.params.onclick(point)}else if(this.params.infoWindow){MapToolkit.InfoWindow.show({map:this.map,point:point,text:[["default",this.params.infoWindow]],opacity:this.params.opacity,style:this.params.infoWindowStyle,className:this.params.infoWindowClassName})}else if(this.params.googleInfoWindow){this.gmap.openInfoWindowHtml(point,this.params.infoWindow)}else{var zoom=this.gmap.getBoundsZoomLevel(this.polygon.getBounds())+1;if(zoom<=this.gmap.getZoom())zoom=this.gmap.getZoom()+1;this.gmap.setCenter(point,zoom)}};MapToolkit.Polygon.prototype.highlight=function(onOff){var that=this;setTimeout(function(){if(onOff){if(MapToolkit.highlightedPolygon)MapToolkit.highlightedPolygon.highlight(false);MapToolkit.highlightedPolygon=that;that.polygon.setFillStyle({opacity:parseFloat(that.params.polygon.opacity)+0.15})}else{MapToolkit.highlightedPolygon=null;that.polygon.setFillStyle({opacity:that.params.polygon.opacity})}},1)};MapToolkit.Polygon.prototype.onMouseOver=function(point){if(this.params.tooltip)MapToolkit.Tooltip.show({map:this.map,point:point,text:this.params.tooltip,opacity:this.params.opacity,style:this.params.tooltipStyle,className:this.params.tooltipClassName});};MapToolkit.Polygon.prototype.onMouseMove=function(point){if(this.params.tooltip)MapToolkit.Tooltip.move({map:this.map,point:point})};MapToolkit.Polygon.prototype.onMouseOut=function(point){if(this.params.tooltip)MapToolkit.Tooltip.hide({map:this.map});};
var clusterOnClickHandlers={};var clusterOnClick=null;var clusterOpacity={};var clusterHighlightTimeout={};var clusterHighlightOn=function(mapDiv,id,obj1,obj2,bounds){if(clusterHighlightTimeout[mapDiv+id])clearTimeout(clusterHighlightTimeout[mapDiv+id]);clusterHighlightTimeout[mapDiv+id]=null;if(!clusterOpacity[mapDiv+id])clusterOpacity[mapDiv+id]=$OPACITY(obj1);$OPACITY(obj1,0.7);$EL2(obj2).show();if(clusterOnClick)GEvent.removeListener(clusterOnClick);clusterOnClick=GEvent.addListener(MapToolkit.getMap(mapDiv).gmap,"click",function(){if(clusterOnClickHandlers[id])clusterOnClickHandlers[id](mapDiv,bounds);GEvent.removeListener(clusterOnClick);clusterOnClick=null})};var clusterHighlightOff=function(mapDiv,id,obj1,obj2){if(clusterHighlightTimeout[mapDiv+id])return;clusterHighlightTimeout[mapDiv+id]=setTimeout(function(){$OPACITY(obj1,clusterOpacity[mapDiv+id]);clusterOpacity[mapDiv+id]=null;$EL2(obj2).hide();if(clusterOnClick)GEvent.removeListener(clusterOnClick);clusterOnClick=null},1)};MapToolkit.DetailedCluster=function(map,params){this.params=params;this.mapDiv=map.div;return this};MapToolkit.DetailedCluster.prototype=new GOverlay();MapToolkit.DetailedCluster.prototype.initialize=function(map){this.map=map;var baseColor=this.params.color;var borderColor=$MAP(this.params.color.split(""),function(hex){hex=hex.toLowerCase();var hexChars="0123456789abcdef";var dec=hexChars.indexOf(hex);dec-=2;if(dec<0)dec=0;return hexChars.charAt(dec)}).join("");this.cluster=document.createElement("span");this.cluster.style.display="block";this.cluster.style.position="absolute";this.redraw(true);clusterOnClickHandlers[this.params.id]=this.params.onclick||function(mapDiv,bounds){var c=bounds.getCenter();var z=map.getBoundsZoomLevel(bounds);if(z==map.getZoom())z++;map.setCenter(c,z)};var bounds="new GLatLngBounds($P("+this.params.south+","+this.params.west+"),$P("+this.params.north+","+this.params.east+"))";var onclick="clusterOnClickHandlers['"+this.params.id+"'](MapToolkit.maps['"+this.mapDiv+"'].map,"+bounds+")";var t;var levels=this.params.levels||[19,39,69,99,150];if(this.params.count<levels[0])t='a';else if(this.params.count<levels[1])t='b';else if(this.params.count<levels[2])t='c';else if(this.params.count<levels[3])t='d';else if(this.params.count<levels[4])t='e';else t='f';this.cluster.innerHTML='<div class="mtk-cluster" style="width:'+width+'px;height:'+height+'px;">'+'<div class="mtk-background'+t+'" style="width:'+width+'px;height:'+height+'px;">'+'<b class="mtk-x1h" style="background: #'+baseColor+'"></b><b class="mtk-x2h" style="background: #'+baseColor+'"></b><b class="mtk-x3h" style="background: #'+baseColor+'"></b><b class="mtk-x4h" style="background: #'+baseColor+'"></b>'+'<div class="mtk-contentx" style="height:'+(height-10)+'px;background: #'+baseColor+'">&nbsp;</div>'+'<b class="mtk-x4bh" style="background: #'+baseColor+'"></b><b class="mtk-x3bh" style="background: #'+baseColor+'"></b><b class="mtk-x2bh" style="background: #'+baseColor+'"></b><b class="mtk-x1h" style="background: #'+baseColor+'"></b>'+'</div><div class="mtk-background'+t+'b" onmouseover="clusterHighlightOn(\''+this.mapDiv+'\',\''+this.params.id+'\',$PREVIOUS(this),$NEXT($NEXT(this)),'+bounds+')" onmouseout="clusterHighlightOff(\''+this.mapDiv+'\',\''+this.params.id+'\',$PREVIOUS(this),$NEXT($NEXT(this)))" style="width:'+width+'px;height:'+height+'px;">'+'<b class="mtk-x1h" style="background: #'+borderColor+';"></b><b class="mtk-x2h" style="border-right:4px solid #'+borderColor+'; border-left:4px solid #'+borderColor+'; background:#'+borderColor+';"></b><b class="mtk-x3h" style="border-right:3px solid #'+borderColor+'; border-left:3px solid #'+borderColor+';"></b><b class="mtk-x4h" style="border-right:2px solid #'+borderColor+'; border-left:2px solid #'+borderColor+';"></b>'+'<div class="mtk-contentx" style=" border-right:2px solid #'+borderColor+'; border-left:2px solid #'+borderColor+';height:'+(height-10)+'px">&nbsp;</div>'+'<b class="mtk-x4bh" style="border-right:2px solid #'+borderColor+'; border-left:2px solid #'+borderColor+';"></b><b class="mtk-x3bh" style="border-right:3px solid #'+borderColor+'; border-left:3px solid #'+borderColor+';"></b><b class="mtk-x2bh" style="border-right:4px solid #'+borderColor+'; border-left:4px solid #'+borderColor+'; background:#'+borderColor+';"></b><b class="mtk-x1h" style="background: #'+borderColor+';"></b>'+'</div><div class="mtk-text1" onmouseover="clusterHighlightOn(\''+this.mapDiv+'\',\''+this.params.id+'\',$PREVIOUS($PREVIOUS(this)),$NEXT(this),'+bounds+')" onmouseout="clusterHighlightOff(\''+this.mapDiv+'\',\''+this.params.id+'\',$PREVIOUS($PREVIOUS(this)),$NEXT(this))">'+'<a href="#" onclick="'+onclick+';return false" style="float:right;">'+'<img src="http://mtk2.toursprung.com/static/images/zoom.gif" border="0" />'+'</a>'+'</div><div class="mtk-text2" style="display:none" onmouseover="clusterHighlightOn(\''+this.mapDiv+'\',\''+this.params.id+'\',$PREVIOUS($PREVIOUS($PREVIOUS(this))),$EL(this),'+bounds+')" onmouseout="clusterHighlightOff(\''+this.mapDiv+'\',\''+this.params.id+'\',$PREVIOUS($PREVIOUS($PREVIOUS(this))),$EL(this))">'+'<a href="#" onclick="'+onclick+';return false" >'+this.params.count+" "+(this.params.naming||MapToolkit.i18n.clusters_naming)+" "+'</a>'+'</div>'+"</div>";map.getPane(G_MAP_MARKER_SHADOW_PANE).appendChild(this.cluster)};MapToolkit.DetailedCluster.prototype.redraw=function(force){if(!force)return;var center=this.map.fromLatLngToDivPixel($P(this.params.lat,this.params.lng));var ne=this.map.fromLatLngToDivPixel($P(this.params.north,this.params.east));var sw=this.map.fromLatLngToDivPixel($P(this.params.south,this.params.west));width=ne.x-sw.x;height=sw.y-ne.y;clusterTop=ne.y;clusterLeft=sw.x;if(width<80){clusterLeft-=parseInt((80-width)/2+1);width=80}if(height<50){clusterTop-=parseInt((50-height)/2+1);height=50}width+=8-width%8;height+=8-height%8;if(width>120)width=120;if(height>120)height=120;clusterTop+=8-clusterTop%8;clusterLeft+=8-clusterLeft%8;while((clusterTop+height)>=(center.y+64))clusterTop-=8;while(clusterTop<=(center.y-64))clusterTop+=8;while((clusterLeft+width)>=(center.x+64))clusterLeft-=8;while(clusterLeft<=(center.x-64))clusterLeft+=8;this.cluster.style.top=clusterTop+"px";this.cluster.style.left=clusterLeft+"px"};MapToolkit.DetailedCluster.prototype.remove=function(){this.map.getPane(G_MAP_MARKER_SHADOW_PANE).removeChild(this.cluster)};MapToolkit.DetailedCluster.prototype.getZindex=function(latitude){return 1};MapToolkit.DetailedCluster.prototype.copy=function(){};MapToolkit.DetailedCluster.prototype.type=function(){return this.params.type};MapToolkit.DetailedCluster.prototype.hide=function(){this.cluster.style.display="none"};MapToolkit.DetailedCluster.prototype.show=function(){this.cluster.style.display="block"};
MapToolkit.SimpleCluster=function(map,params){var icon;if(params.count<10){icon=MapToolkit.Icon.get({image:'http://mtk2.toursprung.com/static/images/cluster/a.png',iconSize:[53,53],iconAnchor:[27,27]})}else if(params.count<100){icon=MapToolkit.Icon.get({image:'http://mtk2.toursprung.com/static/images/cluster/b.png',iconSize:[56,56],iconAnchor:[28,28]})}else if(params.count<1000){icon=MapToolkit.Icon.get({image:'http://mtk2.toursprung.com/static/images/cluster/c.png',iconSize:[66,66],iconAnchor:[33,33]})}else if(params.count<10000){icon=MapToolkit.Icon.get({image:'http://mtk2.toursprung.com/static/images/cluster/d.png',iconSize:[78,78],iconAnchor:[36,36]})}else{icon=MapToolkit.Icon.get({image:'http://mtk2.toursprung.com/static/images/cluster/e.png',iconSize:[90,90],iconAnchor:[45,45]})}var bounds=new GLatLngBounds($P(params.south,params.west),$P(params.north,params.east));this.prototype=new MapToolkit.Marker({map:map,point:this.bounds.getCenter(),icon:icon,label:params.count});this.onclick=params.onclick&&function(){params.onclick(map,bounds)};this.onclick=this.onclick||function(){var z=map.gmap.getBoundsZoomLevel(that.bounds);if(z==map.gmap.getZoom())z++;map.gmap.setCenter(that.bounds.getCenter(),z)};return this};
MapToolkit.Icon=function(param){var icon=new GIcon();$EXTEND(icon,{image:param.image,iconSize:new GSize(param.iconSize[0],param.iconSize[1]),iconAnchor:new GPoint(param.iconAnchor[0],param.iconAnchor[1])});if(param.shadow)$EXTEND(icon,{shadow:param.shadow,shadowSize:new GSize(param.shadowSize[0],param.shadowSize[1])});if(param.infoWindowAnchor)$EXTEND(icon,{infoWindowAnchor:new GPoint(param.infoWindowAnchor[0],param.infoWindowAnchor[1])});else $EXTEND(icon,{infoWindowAnchor:new GPoint(param.iconAnchor[0],param.iconAnchor[1])});return icon};MapToolkit.Icon.icons={};MapToolkit.Icon.reset=function(){MapToolkit.Icon.icons={}};MapToolkit.Icon.get=function(param){if(!param)return G_DEFAULT_ICON;if(param instanceof GIcon)return param;if(!MapToolkit.Icon.icons[param.image])MapToolkit.Icon.icons[param.image]=new MapToolkit.Icon(param);return MapToolkit.Icon.icons[param.image]};
MapToolkit.FulltextSearch={query:{}};
MapToolkit.LocationSearch=function(){var geocoder=new GClientGeocoder();var actualSelection={};var cancel=false;return{zoomToAddress:function(query,mapDiv){if(!query)return;if(!mapDiv)return;var map=MapToolkit.getMap(mapDiv).gmap;var country=MapToolkit.location?MapToolkit.location.country:"";if(country&&!query.match(/,/))query=query+","+country;var callback=function(res){if(cancel)return;if(!res)return;if(res&&res.Status.code==200){var p=res.Placemark[0];if(p.ExtendedData&&p.ExtendedData.LatLonBox){var b=p.ExtendedData.LatLonBox;var bounds=new GLatLngBounds($P(b.south,b.west),$P(b.north,b.east));zoom=map.getBoundsZoomLevel(bounds)}var point=$P(p.Point.coordinates[1],p.Point.coordinates[0]);map.setCenter(point,zoom)}};geocoder.getLocations(query,callback)},search:function(query,mapDiv,divPrefix,cb,multiline){var map=MapToolkit.getMap(mapDiv).gmap;cancel=false;if(!query)return;var country=MapToolkit.location?MapToolkit.location.country:"";if(country&&!query.match(/,/))query=query+","+country;var callback=function(res){if(cancel)return;if(!res)return;if(res&&res.Status.code==200){actualSelection[divPrefix]=-1;var ul="<ul id='"+divPrefix+"-ul'>";for(var i=0;i<res.Placemark.length;i++){var p=res.Placemark[i];var zoom=1;if(p.AddressDetails.Accuracy>=9)zoom=17;else if(p.AddressDetails.Accuracy>=6)zoom=15;else if(p.AddressDetails.Accuracy>=4)zoom=13;else if(p.AddressDetails.Accuracy>2)zoom=7;else zoom=4;if(p.ExtendedData&&p.ExtendedData.LatLonBox){var b=p.ExtendedData.LatLonBox;var bounds=new GLatLngBounds($P(b.south,b.west),$P(b.north,b.east));zoom=map.getBoundsZoomLevel(bounds)}var address=multiline?p.address:p.address.replace(/ /g,"&nbsp;");var js="var point = $P("+p.Point.coordinates[1]+","+p.Point.coordinates[0]+"); MapToolkit.getMap('"+mapDiv+"').gmap.setCenter(point, "+zoom+");"+"$EL('"+divPrefix+"-query').value='"+p.address+"';"+"GEvent.trigger(MapToolkit.getMap('"+mapDiv+"'), 'LocationSearch.search', point);"+"$EL('"+divPrefix+"-result').style.display='none'";ul+="<li class='mtk-location-search-result-li' onclick=\""+js+"\">"+address+"</li>"}ul+="</ul>";$EL(divPrefix+'-result').style.display="block";$UPDATE(divPrefix+'-result',ul);if(cb)cb()}};geocoder.getLocations(query,callback)},selectRow:function(direction,divPrefix){if($EL(divPrefix+'-result').style.display=="none")return;var ul=$EL(divPrefix+'-ul');if(direction=="down"){actualSelection[divPrefix]++;if(actualSelection[divPrefix]>=ul.childNodes.length)actualSelection[divPrefix]=ul.childNodes.length-1}else{actualSelection[divPrefix]--;if(actualSelection[divPrefix]<0)actualSelection[divPrefix]=0}for(var i=0;i<ul.childNodes.length;i++){var c=actualSelection[divPrefix]==i?"mtk-location-search-result-li-selected":"mtk-location-search-result-li";ul.childNodes[i].className=c}},select:function(divPrefix){if($EL(divPrefix+'-result').style.display=="none")return;var ul=$EL(divPrefix+'-ul');if(actualSelection[divPrefix]<0)actualSelection[divPrefix]=0;ul.childNodes[actualSelection[divPrefix]].onclick();this.cancel(divPrefix)},cancel:function(divPrefix){cancel=true;$EL(divPrefix+'-result').style.display="none"}}}();
MapToolkit.LocationSearchControl=function(map){var that=this;var map,autocomplete,divPrefix;var query=document.createElement("input");query.setAttribute("autocomplete","off");query.className="mtk-search-query";query.type="text";query.style.color="#999999";query.value=MapToolkit.i18n.location;query.onclick=function(ev){query.value="";query.style.color="black";MapToolkit.LocationSearch.cancel(divPrefix)};query.onkeyup=function(ev){ev=ev||window.event;if(ev.keyCode==40){MapToolkit.LocationSearch.selectRow("down",divPrefix);if(ev.preventDefault)ev.preventDefault();else ev.returnValue=false;return}else if(ev.keyCode==38){MapToolkit.LocationSearch.selectRow("up",divPrefix);if(ev.preventDefault)ev.preventDefault();else ev.returnValue=false;return}else if(ev.keyCode==13){MapToolkit.LocationSearch.select(divPrefix);query.blur();return}else if(ev.keyCode==27){cancel.onclick();return}if(autocomplete)clearTimeout(autocomplete);autocomplete=setTimeout(function(){if(query.value){cancel.style.display="none";loading.style.display="inline";MapToolkit.LocationSearch.search(query.value,map.div,divPrefix,function(){loading.style.display="none";cancel.style.display="inline"})}else{MapToolkit.LocationSearch.cancel(divPrefix)}},200)};var loupe=document.createElement("img");loupe.className='mtk-search-loupe';loupe.width=17;loupe.height=12;loupe.src=MapToolkit.host+"/static/images/search/loupe_single.png";var cancel=document.createElement("img");cancel.src=MapToolkit.host+"/static/images/search/cancel.png";cancel.className='mtk-search-cancel';cancel.width=11;cancel.height=11;cancel.onclick=function(ev){if(query.value==MapToolkit.i18n.location)return;MapToolkit.LocationSearch.cancel(divPrefix);query.value=MapToolkit.i18n.location;query.style.color="#999999";loading.style.display="none";cancel.style.display="inline";query.blur()};var loading=document.createElement("img");loading.src=MapToolkit.host+"/static/images/search/loader.gif";loading.className='mtk-search-cancel';loading.width=11;loading.height=11;loading.style.display="none";var result=document.createElement("div");result.className="mtk-location-search-result";result.style.display="none";this.initialize=function(gmap){divPrefix="mtk-location-search-"+map.div;result.id=divPrefix+"-result";query.id=divPrefix+"-query";var container=document.createElement("div");container.className="mtk-search";container.appendChild(query);container.appendChild(loupe);container.appendChild(cancel);container.appendChild(loading);container.appendChild(result);gmap.getContainer().appendChild(container);return container};this.getDefaultPosition=function(){return new GControlPosition(G_ANCHOR_TOP_LEFT,new GSize(80,7))}};MapToolkit.LocationSearchControl.prototype=new GControl();
MapToolkit.MapTypesControl=function(map){var t=map.getCurrentMapTypeIndex();var activeNormal=(t==0)?"mtk-maptypes-active":"mtk-maptypes-inactive";var activeSatellite=(t==1)?"mtk-maptypes-active":"mtk-maptypes-inactive";var activeTerrain=(t==2)?"mtk-maptypes-active":"mtk-maptypes-inactive";var html=''+'<div class="mtk-maptypes-container">'+'<div class="mtk-maptypes-more" onclick="$VISIBLE(\'mtk-maptypes-more\') ? $BLINDUP(\'mtk-maptypes-more\', { duration: 0.2 }) : $BLINDDOWN(\'mtk-maptypes-more\', { duration: 0.2 });">&nbsp;</div>'+'<div class="mtk-maptypes-button '+activeTerrain+'" onclick="MapToolkit.MapTypesControl.setMapType(\''+map.div+'\', G_PHYSICAL_MAP, this)">'+MapToolkit.i18n["maptype: terrain"]+'</div>'+'<div class="mtk-maptypes-button '+activeSatellite+'" onclick="MapToolkit.MapTypesControl.setMapType(\''+map.div+'\', G_SATELLITE_MAP, this)">'+MapToolkit.i18n["maptype: satellite"]+'</div>'+'<div class="mtk-maptypes-button '+activeNormal+'" onclick="MapToolkit.MapTypesControl.setMapType(\''+map.div+'\', G_NORMAL_MAP, this)">'+MapToolkit.i18n["maptype: map"]+'</div>'+'<div id="mtk-maptypes-more" class="mtk-maptypes-more-menu" style="display:none;">'+'<ul>'+'<li onclick="$EL2(\'mtk-maptypes-more\').hide();MapToolkit.MapTypesControl.setMapType(\''+map.div+'\', OSM_MAP)">'+MapToolkit.i18n["maptype: openstreetmap"]+'</li>'+'<li onclick="$EL2(\'mtk-maptypes-more\').hide();MapToolkit.MapTypesControl.setMapType(\''+map.div+'\', OSM_CYCLE_MAP)">'+MapToolkit.i18n["maptype: opencyclemap"]+'</li>'+'<li onclick="$EL2(\'mtk-maptypes-more\').hide();MapToolkit.MapTypesControl.setMapType(\''+map.div+'\', G_HYBRID_MAP)">'+MapToolkit.i18n["maptype: satellite with labels"]+'</li>'+'</ul>'+'</div>'+'</div>';this.initialize=function(gmap){var maptypes=document.createElement("div");maptypes.innerHTML=html;gmap.getContainer().appendChild(maptypes);$EL(maptypes).pngFix&&$EL(maptypes).pngFix();return maptypes};this.getDefaultPosition=function(){var offset=10;if($INARRAY(map.config.map.controls,"MapToolkit.FullscreenIconControl")!=-1)offset+=24;return new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(offset,10))};return this};MapToolkit.MapTypesControl.prototype=new GControl();MapToolkit.MapTypesControl.setMapType=function(div,mapType,obj){var map=MapToolkit.getMap(div);map.gmap.setMapType(mapType);map.updateLocationHash("force");$EACH($CLASS("mtk-maptypes-button"),function(i){if(obj==i){$ADD_CLASS(i,"mtk-maptypes-active");$REMOVE_CLASS(i,"mtk-maptypes-inactive")}else{$REMOVE_CLASS(i,"mtk-maptypes-active");$ADD_CLASS(i,"mtk-maptypes-inactive")}})};
MapToolkit.FullscreenControl=function(map){var fullscreen;var isFullscreen=map.isFullscreen;var that=this;that.initialize=function(gmap){fullscreen=document.createElement("div");fullscreen.className=isFullscreen?"mtk-fullscreen mtk-fullscreen-active":"mtk-fullscreen mtk-fullscreen-inactive";fullscreen.innerHTML=isFullscreen?MapToolkit.i18n.fullscreen_off:MapToolkit.i18n.fullscreen_on;GEvent.addDomListener(fullscreen,"click",function(){that.fullscreenToggle()});gmap.getContainer().appendChild(fullscreen);return fullscreen};that.getDefaultPosition=function(){var offset=300;if(!map.config.map.optionalControl)offset-=70;if($INARRAY(map.config.map.controls,"MapToolkit.MapTypesControl")==-1)offset-=220;if($INARRAY(map.config.map.controls,"MapToolkit.FullscreenIconControl")!=-1)offset+=24;return new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(offset,10))};that.fullscreenToggle=function(){isFullscreen=isFullscreen?0:1;MapToolkit.InfoWindow.hide({map:map});fullscreen.innerHTML=isFullscreen?MapToolkit.i18n.fullscreen_off:MapToolkit.i18n.fullscreen_on;fullscreen.className=isFullscreen?"mtk-fullscreen mtk-fullscreen-active":"mtk-fullscreen mtk-fullscreen-inactive";var div=$EL(map.div);div.style.zIndex=isFullscreen?parseInt(div.style.zIndex)+1000:parseInt(div.style.zIndex)-1000;var center=map.gmap.getCenter();var bounds=map.gmap.getBounds();map.setFullscreen(isFullscreen);map.resize();map.gmap.setCenter(center,map.gmap.getBoundsZoomLevel(bounds));if(map.config.map.fullscreenControls){var controls=map.config.map.controls;$EACH(controls,function(c){map.removeControl(c)});if(map.config.map.optionalControl)map.removeControl("MapToolkit.OptionalControl");map.config.map.controls=map.config.map.fullscreenControls;$EACH(map.config.map.controls,function(c){map.addControl(c)});if(map.config.map.optionalControl)map.addControl("MapToolkit.OptionalControl");map.config.map.fullscreenControls=controls}}};MapToolkit.FullscreenControl.prototype=new GControl();
MapToolkit.FullscreenIconControl=function(map){var fullscreen;var isFullscreen=map.isFullscreen;var that=this;that.initialize=function(gmap){fullscreen=document.createElement("div");fullscreen.className=isFullscreen?"mtk-fullscreen-icon mtk-fullscreen-icon-active":"mtk-fullscreen-icon mtk-fullscreen-icon-inactive";fullscreen.innerHTML="&nbsp;";GEvent.addDomListener(fullscreen,"click",function(){that.fullscreenToggle()});gmap.getContainer().appendChild(fullscreen);return fullscreen};that.getDefaultPosition=function(){return new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(10,10))};that.fullscreenToggle=function(){isFullscreen=isFullscreen?0:1;MapToolkit.InfoWindow.hide({map:map});fullscreen.className=isFullscreen?"mtk-fullscreen-icon mtk-fullscreen-icon-active":"mtk-fullscreen-icon mtk-fullscreen-icon-inactive";var div=$EL(map.div);div.style.zIndex=isFullscreen?parseInt(div.style.zIndex)+1000:parseInt(div.style.zIndex)-1000;var center=map.gmap.getCenter();var bounds=map.gmap.getBounds();map.setFullscreen(isFullscreen);map.resize();map.gmap.setCenter(center,map.gmap.getBoundsZoomLevel(bounds));if(map.config.map.fullscreenControls){var controls=map.config.map.controls;$EACH(controls,function(c){map.removeControl(c)});if(map.config.map.optionalControl)map.removeControl("MapToolkit.OptionalControl");map.config.map.controls=map.config.map.fullscreenControls;$EACH(map.config.map.controls,function(c){map.addControl(c)});if(map.config.map.optionalControl)map.addControl("MapToolkit.OptionalControl");map.config.map.fullscreenControls=controls}}};MapToolkit.FullscreenIconControl.prototype=new GControl();
MapToolkit.OptionalControl=function(map){var that=this;var checked=[];var loadingResources=[];var config=map.config;var isRight=($INARRAY(map.config.map.controls,"MapToolkit.MapTypesControl")==-1);that.categories=[];for(var i in map.config.resources){if(map.config.resources[i].isOptional==null)map.config.resources[i].isOptional=map.config.resources[i].optional;var x=function(resource){if(map.config.resources[resource].isOptional){that.categories.push({name:resource,title:MapToolkit.i18n[resource],onclick:function(bool,cb){switchResource(bool,resource,cb)}});if(!map.config.resources[resource].optional)checked.push(resource)}}(i)}for(var i in map.config.layers){if(map.config.layers[i].isOptional==null)map.config.layers[i].isOptional=map.config.layers[i].optional;var x=function(layer){if(map.config.layers[i].isOptional){that.categories.push({name:layer,title:MapToolkit.i18n[layer],onclick:function(bool,cb){map.updateLayer(layer,bool);setTimeout(cb,500)}});if(!map.config.layers[layer].optional)checked.push(layer)}}(i)}var html=''+'<div class="mtk-menu-pos-container">'+'<div id="mtk-menu-container-toggle" class="mtk-menu-container-toggle mtk-menu-container-closed" onclick="MapToolkit.OptionalControl.toogleMenu()">'+"&nbsp;&nbsp;&nbsp;"+MapToolkit.i18n.more.toUpperCase()+'<img src="http://mtk2.toursprung.com/static/images/buttons/arrow.png" border="0" class="mtk-menu-container-toggle-arrow" />'+'</div>'+'<div id="mtk-menu" class="mtk-menu-menu'+(isRight?"-right":"")+'" style="display:none">'+'<div class="mtk-menu-container">'+'<div id="" class="mtk-menu-container-header"></div>'+'<div id="" class="mtk-menu-container-body">'+'<div class="mtk-menu-content mtk-menu-max300">'+'<div id="mtk-menu-content"></div>'+'</div>'+'</div>'+'<div id="" class="mtk-menu-container-footer"></div>'+'</div>	'+'<a href="http://maptoolkit.net" target="_blank"><img src="http://mtk2.toursprung.com/static/images/menu/mtk-logo.png" alt="mtk-logo" width="179" height="23"  border="0" /></a>'+'</div>'+'</div>';var switchResource=function(bool,resource,cb){loadingResources.push(cb);map.updateResource(resource,bool,function(){$EACH(loadingResources,function(cb){cb()});loadingResources=[]})};that.initialize=function(_map){var menu=document.createElement("div");menu.innerHTML=html;_map.getContainer().appendChild(menu);var nodes=new MapToolkit.TreeMenu("mtk-menu-content",that.categories);$EACH(checked,function(c){nodes[c].check()});$EL(menu).pngFix&&$EL(menu).pngFix();return menu};that.getDefaultPosition=function(){var offset=isRight?10:230;if($INARRAY(map.config.map.controls,"MapToolkit.FullscreenIconControl")!=-1)offset+=24;return new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(offset,10))}};MapToolkit.OptionalControl.prototype=new GControl();MapToolkit.OptionalControl.toogleMenu=function(){var menu=$EL("mtk-menu");if($VISIBLE(menu)){$BLINDUP(menu,{duration:0.2});setTimeout(function(){$EL("mtk-menu-container-toggle").className="mtk-menu-container-toggle mtk-menu-container-closed"},200)}else{$BLINDDOWN(menu,{duration:0.2});$EL("mtk-menu-container-toggle").className="mtk-menu-container-toggle mtk-menu-container-opened"}};
MapToolkit.BunchMarkers=function(map){var timeout,callback;var isExpanded=false;var centerPoint=null;var expansionRadius=0;var nearMarkers=[];var transparentMarkers=[];var distance=function(p1,p2){return Math.sqrt(Math.pow((p2.x-p1.x),2)+Math.pow((p2.y-p1.y),2))};var calcExpansionRadius=function(iconHeight){return Math.round(nearMarkers.length/4*iconHeight*0.6)};var arrangeMarkersCyclic=function(referencePoint,iconHeight){var n=nearMarkers.length;var radius=calcExpansionRadius(iconHeight);var shiftAngle=2*Math.PI/n;if(n==3)angle=Math.PI/2;else angle=0;for(var i=0;i<n;i++){angle+=shiftAngle;newX=referencePoint.x+radius*Math.cos(angle);newY=referencePoint.y+radius*Math.sin(angle);nearMarkers[i].panTo(map.gmap.fromDivPixelToLatLng(new GPoint(newX,newY)))}};GEvent.addListener(map.gmap,"mousemove",function(point){if(timeout)clearTimeout(timeout);if(callback)timeout=setTimeout(function(){callback&&callback();callback=null},100);if(!isExpanded)return;var actualPoint=map.gmap.fromLatLngToDivPixel(point);if(distance(actualPoint,centerPoint)<expansionRadius)return;$EACH(nearMarkers,function(p){p.restore()});$EACH(transparentMarkers,function(p){p.restore()});isExpanded=false});GEvent.addListener(map,"markerMouseOver",function(marker){if(!isExpanded)callback=function(){var iconAnchor=marker.icon.iconAnchor.y;var iconHeight=marker.icon.iconSize.height;var iconWidth=marker.icon.iconSize.width;var referencePoint=map.gmap.fromLatLngToDivPixel(marker.point);nearMarkers=$GREP(map.getItems(),function(item){if(!(item instanceof MapToolkit.Marker))return 0;if(item.params.resource!=marker.params.resource)return 0;var p=map.gmap.fromLatLngToDivPixel(item.point);return(distance(referencePoint,p)<=(iconHeight/4))});if(nearMarkers.length<2)return;isExpanded=true;marker.closeDetails();var expansionFactor=(iconHeight/iconWidth)<2?iconHeight/ (iconHeight /iconWidth):iconHeight/2;expansionRadius=calcExpansionRadius(iconHeight)+expansionFactor;centerPoint=new GPoint(referencePoint.x,referencePoint.y-iconHeight/2+(iconHeight-iconAnchor));transparentMarkers=$GREP(map.getItems(),function(item){if(!(item instanceof MapToolkit.Marker))return 0;var p=map.gmap.fromLatLngToDivPixel(item.point);var dist=distance(referencePoint,p);return(dist>(iconHeight/4)&&dist<(2*expansionRadius))});$EACH(transparentMarkers,function(m){m.dimm(0.25)});arrangeMarkersCyclic(referencePoint,iconHeight)}});GEvent.addListener(map,"markerMouseOut",function(marker){callback=null})};
var OSM_MAP=function(){var copycol=new GCopyrightCollection("");var copy=new GCopyright(1,new GLatLngBounds(new GLatLng(-90,-180),new GLatLng(90,180)),0,'(cc) <a href="http://www.openstreetmap.org/" target="_blank" style="color: rgb(119, 119, 204);">OpenStreetMap</a>');copycol.addCopyright(copy);var tileMapnik=new GTileLayer(copycol,1,17);tileMapnik.myBaseURL="http://tile.openstreetmap.org/";tileMapnik.getTileUrl=function(a,b,c){return this.myBaseURL+"/mapnik_tiles/"+b+"/"+a.x+"/"+a.y+".png"};tileMapnik.isPng=function(){return true};tileMapnik.getOpacity=function(){return 1.0};return new GMapType([tileMapnik],G_SATELLITE_MAP.getProjection(),"OSM ",G_SATELLITE_MAP)}();
var OSM_CYCLE_MAP=function(){var copycol=new GCopyrightCollection("");var copy=new GCopyright(1,new GLatLngBounds(new GLatLng(-90,-180),new GLatLng(90,180)),0,'(cc) <a href="http://www.opencyclemap.org/" target="_blank" style="color: rgb(119, 119, 204);">OpenCycleMap</a>');copycol.addCopyright(copy);var tileCycle=new GTileLayer(copycol,1,17);tileCycle.myBaseURL='http://andy.sandbox.cloudmade.com';tileCycle.getTileUrl=function(a,b,c){return this.myBaseURL+"/tiles/cycle/"+b+"/"+a.x+"/"+a.y+".png"};tileCycle.isPng=function(){return true};tileCycle.getOpacity=function(){return 1.0};return new GMapType([tileCycle],G_SATELLITE_MAP.getProjection(),"OSM Cycle",G_SATELLITE_MAP)}();
