
(function($){if(/1\.(0|1|2)\.(0|1|2)/.test($.fn.jquery)||/^1.1/.test($.fn.jquery)){alert('blockUI requires jQuery v1.2.3 or later!  You are using v'+$.fn.jquery);return;}
$.blockUI=function(opts){install(window,opts);};$.unblockUI=function(opts){remove(window,opts);};$.fn.block=function(opts){return this.each(function(){if($.css(this,'position')=='static')
this.style.position='relative';if($.browser.msie)
this.style.zoom=1;install(this,opts);});};$.fn.unblock=function(opts){return this.each(function(){remove(this,opts);});};$.blockUI.version=2.07;$.blockUI.defaults={message:'<h1>Please wait...</h1>',css:{padding:0,margin:0,width:'30%',top:'40%',left:'30%',textAlign:'center'},overlayCSS:{backgroundColor:'#000',opacity:'0.6'},baseZ:1000,centerX:true,centerY:true,allowBodyStretch:true,constrainTabKey:true,fadeOut:400,focusInput:true,applyPlatformOpacityRules:true,onUnblock:null};var ie6=$.browser.msie&&/MSIE 6.0/.test(navigator.userAgent);var pageBlock=null;var pageBlockEls=[];function install(el,opts){var full=(el==window);var msg=opts&&opts.message!==undefined?opts.message:undefined;opts=$.extend({},$.blockUI.defaults,opts||{});opts.overlayCSS=$.extend({},$.blockUI.defaults.overlayCSS,opts.overlayCSS||{});var css=$.extend({},$.blockUI.defaults.css,opts.css||{});msg=msg===undefined?opts.message:msg;if(full&&pageBlock)
remove(window,{fadeOut:0});if(msg&&typeof msg!='string'&&(msg.parentNode||msg.jquery)){var node=msg.jquery?msg[0]:msg;var data={};$(el).data('blockUI.history',data);data.el=node;data.parent=node.parentNode;data.display=node.style.display;data.position=node.style.position;data.parent.removeChild(node);}
var z=opts.baseZ;var lyr1=($.browser.msie)?$('<iframe class="blockUI" style="z-index:'+z+++';border:none;margin:0;padding:0;position:absolute;width:100%;height:100%;top:0;left:0" src="javascript:false;"></iframe>'):$('<div class="blockUI" style="display:none"></div>');var lyr2=$('<div class="blockUI" style="z-index:'+z+++';border:none;margin:0;padding:0;width:100%;height:100%;top:0;left:0"></div>');var lyr3=full?$('<div class="blockUI blockMsg blockPage" style="z-index:'+z+';position:fixed"></div>'):$('<div class="blockUI blockMsg blockElement" style="z-index:'+z+';display:none;position:absolute"></div>');if(msg)
lyr3.css(css);if(!opts.applyPlatformOpacityRules||!($.browser.mozilla&&/Linux/.test(navigator.platform)))
lyr2.css(opts.overlayCSS);lyr2.css('position',full?'fixed':'absolute');if($.browser.msie)
lyr1.css('opacity','0.0');$([lyr1[0],lyr2[0],lyr3[0]]).appendTo(full?'body':el);var expr=$.browser.msie&&(!$.boxModel||$('object,embed',full?null:el).length>0);if(ie6||expr){if(full&&opts.allowBodyStretch&&$.boxModel)
$('html,body').css('height','100%');if((ie6||!$.boxModel)&&!full){var t=sz(el,'borderTopWidth'),l=sz(el,'borderLeftWidth');var fixT=t?'(0 - '+t+')':0;var fixL=l?'(0 - '+l+')':0;}
$.each([lyr1,lyr2,lyr3],function(i,o){var s=o[0].style;s.position='absolute';if(i<2){full?s.setExpression('height','document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + "px"'):s.setExpression('height','this.parentNode.offsetHeight + "px"');full?s.setExpression('width','jQuery.boxModel && document.documentElement.clientWidth || document.body.clientWidth + "px"'):s.setExpression('width','this.parentNode.offsetWidth + "px"');if(fixL)s.setExpression('left',fixL);if(fixT)s.setExpression('top',fixT);}
else if(opts.centerY){if(full)s.setExpression('top','(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (blah = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"');s.marginTop=0;}});}
lyr3.append(msg).show();if(msg&&(msg.jquery||msg.nodeType))
$(msg).show();bind(1,el,opts);if(full){pageBlock=lyr3[0];pageBlockEls=$(':input:enabled:visible',pageBlock);if(opts.focusInput)
setTimeout(focus,20);}
else
center(lyr3[0],opts.centerX,opts.centerY);};function remove(el,opts){var full=el==window;var data=$(el).data('blockUI.history');opts=$.extend(true,{},$.blockUI.defaults,opts);bind(0,el,opts);var els=full?$('body').children().filter('.blockUI'):$('.blockUI',el);if(full)
pageBlock=pageBlockEls=null;if(opts.fadeOut){els.fadeOut(opts.fadeOut);setTimeout(function(){reset(els,data,opts,el);},opts.fadeOut);}
else
reset(els,data,opts,el);};function reset(els,data,opts,el){els.each(function(i,o){if(this.parentNode)
this.parentNode.removeChild(this);});if(data&&data.el){data.el.style.display=data.display;data.el.style.position=data.position;data.parent.appendChild(data.el);$(data.el).removeData('blockUI.history');}
if(typeof opts.onUnblock=='function')
opts.onUnblock(el,opts);};function bind(b,el,opts){var full=el==window,$el=$(el);if(!b&&(full&&!pageBlock||!full&&!$el.data('blockUI.isBlocked')))
return;if(!full)
$el.data('blockUI.isBlocked',b);var events='mousedown mouseup keydown keypress click';b?$(document).bind(events,opts,handler):$(document).unbind(events,handler);};function handler(e){if(e.keyCode&&e.keyCode==9){if(pageBlock&&e.data.constrainTabKey){var els=pageBlockEls;var fwd=!e.shiftKey&&e.target==els[els.length-1];var back=e.shiftKey&&e.target==els[0];if(fwd||back){setTimeout(function(){focus(back)},10);return false;}}}
if($(e.target).parents('div.blockMsg').length>0)
return true;return $(e.target).parents().children().filter('div.blockUI').length==0;};function focus(back){if(!pageBlockEls)
return;var e=pageBlockEls[back===true?pageBlockEls.length-1:0];if(e)
e.focus();};function center(el,x,y){var p=el.parentNode,s=el.style;var l=((p.offsetWidth-el.offsetWidth)/2)-sz(p,'borderLeftWidth');var t=((p.offsetHeight-el.offsetHeight)/2)-sz(p,'borderTopWidth');if(x)s.left=l>0?(l+'px'):'0';if(y)s.top=t>0?(t+'px'):'0';};function sz(el,p){return parseInt($.css(el,p))||0;};jQuery.fn.getViewportSize=function(){var aViewportSize=[0,0];if(typeof window.innerWidth!="undefined"){aViewportSize=[window.innerWidth,window.innerHeight];}else if(typeof document.documentElement!="undefined"&&typeof document.documentElement.clientWidth!="undefined"&&document.documentElement.clientWidth>0){aViewportSize=[document.documentElement.clientWidth,document.documentElement.clientHeight];}else{var oElement=document.getElementsByTagName('body')[0];aViewportSize=[oElement.clientWidth,oElement.clientHeight];}
return aViewportSize;}
jQuery.fn.displayLargeImage=function(sSrc,iWidth,height,sComment,highlight){if(iWidth==null)iWidth=340;if(height==null)height=230;if($('#largeImage')!=undefined){$('#largeImage').remove();}
var oImg=$(document.createElement('img'));oImg.attr({'src':sSrc});if(highlight==1){oImg.css({'border':'2px solid','border-color':'#000000','cursor':'pointer'});}else{oImg.css({'cursor':'pointer'});}
oImg.click(function(){$.unblockUI();});var oDiv=$(document.createElement('div'));oDiv.attr({'id':'largeImage'});oDiv.css({'display':'none'});oDiv.append(oImg);var oAttribDiv=$(document.createElement('div'));oAttribDiv.css({'background-color':'#000000','color':'#FFFFFF'});oAttribDiv.html(sComment);oDiv.append(oAttribDiv);$('body').append(oDiv);var aSize=jQuery().getViewportSize();var iTop=(aSize[1]/2)-(height/2);var iLeft=(aSize[0]/2)-(iWidth/2);$.blockUI({message:$('#largeImage'),css:{width:iWidth+'px','top':iTop+'px','left':iLeft+'px'}});return true;}
jQuery.fn.displayPopupMap=function(iLocationId,fLatitude,fLongitude,sLocation,bDraggableMarkers,oOnLoadMarkers,oSelectedMarker,sEnv){googleMapModule=new GoogleMapModule(iLocationId,fLatitude,fLongitude,sLocation,bDraggableMarkers,oOnLoadMarkers,oSelectedMarker,sEnv);$('#popupMap').css({'display':'block'});}})(jQuery);jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options.expires=-1;}
var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000));}else{date=options.expires;}
expires='; expires='+date.toUTCString();}
var path=options.path?'; path='+(options.path):'';var domain=options.domain?'; domain='+(options.domain):'';var secure=options.secure?'; secure':'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('');}else{var cookieValue=null;if(document.cookie&&document.cookie!=''){var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break;}}}
return cookieValue;}};var googleMapModule;function GoogleMapModule(locationId,latitude,longitude,theLocation,draggableMarkers,onLoadMarkers,selectedMarker,env,route){var locationId=locationId;var onLoadMarkers=onLoadMarkers;var selectedMarker=selectedMarker;var latitude=latitude;var longitude=longitude;var theLocation=theLocation;var draggableMarkers=draggableMarkers;var env=env;var toggle={};var route=route;var currentTab='overviewTab';var transportSearchIncrement=0;var attractionSearchIncrement=0;var hotelsSearchIncrement=0;var restaurantsSearchIncrement=0;var searchIncrement=0;var searchName='search_'+searchIncrement;var mapIcons={};var map;var markerManager;var markers=new Array();var polylines=new Array();var rightClickedPixel;var rightClickMenu;var fromMarker=null;var toMarker=null;var toMarkerInfo=null;var fromMarkerInfo=null;load();this.calculateRoute=function(stationFromId,stationToId){calculateRoute(stationFromId,stationToId);}
this.plotRoute=function(){var stationFrom=$.cookie('plot_route_from_station_id');var stationTo=$.cookie('plot_route_to_station_id');calculateRoute(stationFrom,stationTo);}
this.toggleRoute=function(checkbox){if(checkbox.checked){calculateRoute($('#from_station_id').val(),$('#to_station_id').val());}else{removeRouteMarkers();}}
function calculateRoute(stationFrom,stationTo){$.cookie('plot_route_from_station_id',stationFrom);$.cookie('plot_route_to_station_id',stationTo);setSelectedIndex('from_station_id',stationFrom);setSelectedIndex('to_station_id',stationTo);if(stationFrom==stationTo){alert(getString('departure_and_arrival_station_cannot_be_the_same'));return false;}
showLoading();removeRouteMarkers();$('#route_selector').attr({'checked':'checked'});var data=new AjaxData('GoogleMaps','calculateRoute');data.addParam(stationFrom);data.addParam(stationTo);callAjax(data);}
function removeRouteMarkers(){$('#route_selector').attr({'unchecked':'unchecked'});var exists=true;var i=0;while(exists){i++;var b=removeMarkerSet('route_'+i);if(b==false){exists=false;}}}
this.setStationFrom=function(stationId,stationName){$.cookie('plot_route_from_station_id',stationId);$.cookie('plot_route_from_station_name',stationName);$('#current_route').css({'display':'block'});$('#current_route_from').css({'display':'block'});$('#current_route_from_name').html(stationName);if($.cookie('plot_route_from_station_id')!=null&&$.cookie('plot_route_from_station_id')){$('#calculate_route').css({'display':'block'});}}
this.setStationTo=function(stationId,stationName){$.cookie('plot_route_to_station_id',stationId);$.cookie('plot_route_to_station_name',stationName);$('#current_route').css({'display':'block'});$('#current_route_to').css({'display':'block'});$('#current_route_to_name').html(stationName);if($.cookie('plot_route_from_station_id')!=null&&$.cookie('plot_route_from_station_id')){$('#calculate_route').css({'display':'block'});}}
this.addMarkerSet=function(dir,filename,setName,drawPolyLine,showLoading){addMarkerSet(dir,filename,setName,drawPolyLine,showLoading);}
this.openInfoWindow=function(type,id){var data=new AjaxData('GoogleMaps','getMarkerInfo');data.addParam(type);data.addParam(id);callAjax(data);}
this.displayInfoWindowTabbed=function(data){var infoTabs=new Array();for(i=0;i<data.tabHeading.length;i++){infoTabs.push(new GInfoWindowTab(data.tabHeading[i],data.tabBody[i]));}
selectedMarker.openInfoWindowTabsHtml(infoTabs);}
this.getMarkersWithin=function(type,lat,lng,distance){switch(type){case 1:type='hotels';hotelsSearchIncrement++;increment=hotelsSearchIncrement;break;case 2:type='restaurants';restaurantsSearchIncrement++;increment=restaurantsSearchIncrement;break;case 3:type='transport';transportSearchIncrement++;increment=transportSearchIncrement;break;case 4:type='attractions';attractionSearchIncrement++;increment=attractionSearchIncrement;break;}
searchName=type+"_tab_search_"+(increment-1);removeMarkerSet(searchName);searchName=type+"_tab_search_"+increment;types={};types[type]=1;var data=new AjaxData('GoogleMaps','getMarkersFromPoint');data.addParam(lat);data.addParam(lng);data.addParam(distance);data.addParam(searchName);data.addParam(types);callAjax(data);}
this.transportSelected=function(checkbox){if(checkbox.checked){addMarkerSet(theLocation,checkbox.id,checkbox.id,true,true);}else{removeMarkerSet(checkbox.id);}}
this.attractionSelected=function(checkbox){if(checkbox.checked){addMarkerSet(theLocation,checkbox.id,checkbox.id,false,true);}else{removeMarkerSet(checkbox.id);}}
this.specialSelected=function(checkbox,id){if(checkbox.checked){$('#'+id).attr({'checked':'checked'});addMarkerSet(theLocation,id,id,false,true);}else{$('#'+id).attr({'checked':''});removeMarkerSet(id);}}
this.hotelSelected=function(checkbox){if(checkbox.checked){addMarkerSet(theLocation,checkbox.id,checkbox.id,false,true);}else{removeMarkerSet(checkbox.id);}}
this.restaurantSelected=function(checkbox){if(checkbox.checked){addMarkerSet(theLocation,checkbox.id,checkbox.id,false,true);}else{removeMarkerSet(checkbox.id);}}
function selectTab(tab){$('#'+currentTab).css({'display':'none'});currentTab=tab;$('#'+tab).css({'display':'block'});}
this.addSearchMarkers=function(){var center=map.getCenter();var lat=center.lat();var lng=center.lng();var args=xajax.getFormValues('search_form');removeMarkerSet(searchName);searchIncrement++;searchName='search_'+searchIncrement;var data=new AjaxData('GoogleMaps','getSearchMarkers');data.addParam(args);data.addParam(searchName);data.addParam(lat);data.addParam(lng);callAjax(data);}
this.repositionMap=function(lat,lng){map.panTo(new GLatLng(lat,lng));}
this.showMoreDialog=function(divName){$.blockUI({message:$('#'+divName),css:{width:'550px'}});}
this.hideMoreDialog=function(divName){$.unblockUI();}
function appendRightClickMenu(){rightClickMenu=document.createElement("div");rightClickMenu.style.visibility="hidden";rightClickMenu.style.background="#ffffff";rightClickMenu.style.border="1px solid #8888FF";rightClickMenu.innerHTML='<a href="javascript:void(0)" onclick="googleMapModule.setRouteFromPoint( false )"><div class="rightClickMenu">&nbsp;&nbsp;'+getString('route_from_here')+'&nbsp;&nbsp;</div></a>'+'<a href="javascript:void(0)" onclick="googleMapModule.setRouteToPoint( false )"><div class="rightClickMenu">&nbsp;&nbsp;'+getString('route_to_here')+'&nbsp;&nbsp;</div></a>';map.getContainer().appendChild(rightClickMenu);}
this.setRouteFromPoint=function(useMarkerPosition){setRouteFromPoint(useMarkerPosition);}
this.repositionRoutePoints=function(fromLat,fromLng,toLat,toLng){var fromPoint=new GLatLng(fromLat,fromLng);var toPoint=new GLatLng(toLat,toLng);if(fromMarker==null){fromMarker=addRoutePoint(fromPoint,'from');}else{fromMarker.setLatLng(fromPoint);}
if(toMarker==null){toMarker=addRoutePoint(toPoint,'to');}else{toMarker.setLatLng(toPoint);}
map.panTo(fromPoint);}
function setRouteFromPoint(useMarkerPosition){if(useMarkerPosition){var point=fromMarker.getPoint();}else{var point=map.fromContainerPixelToLatLng(rightClickedPixel);}
rightClickMenu.style.visibility="hidden";if(fromMarker!=null){fromMarker.setPoint(point);}else{fromMarker=addRoutePoint(point,'from');}
if(toMarker!=null){showLoading();toPoint=toMarker.getPoint();removeRouteMarkers();var data=new AjaxData('GoogleMaps','calculateRouteFromPoints');data.addParam(point.lat());data.addParam(point.lng());data.addParam(toPoint.lat());data.addParam(toPoint.lng());data.addParam('from');callAjax(data);}}
this.setRouteToPoint=function(useMarkerPosition){setRouteToPoint(useMarkerPosition);}
function setRouteToPoint(useMarkerPosition){if(useMarkerPosition){var point=toMarker.getPoint();}else{var point=map.fromContainerPixelToLatLng(rightClickedPixel);}
rightClickMenu.style.visibility="hidden";if(toMarker!=null){toMarker.setPoint(point);}else{toMarker=addRoutePoint(point,'to');}
if(fromMarker!=null){showLoading();fromPoint=fromMarker.getPoint();removeRouteMarkers();var data=new AjaxData('GoogleMaps','calculateRouteFromPoints');data.addParam(fromPoint.lat());data.addParam(fromPoint.lng());data.addParam(point.lat());data.addParam(point.lng());data.addParam('to');callAjax(data);}}
this.displayRouteInfo=function(data,lastMarker,justSave){var infoTabs=new Array();for(i=0;i<data.tabHeading.length;i++){if(data.tabHeading[i]!=undefined&&data.tabHeading[i]!=undefined){infoTabs.push(new GInfoWindowTab(data.tabHeading[i],data.tabBody[i]));}}
if(lastMarker=='to'){if(justSave){fromMarkerInfo=infoTabs;}else{toMarker.openInfoWindowTabsHtml(infoTabs);toMarkerInfo=infoTabs;}}else{if(justSave){toMarkerInfo=infoTabs;}else{fromMarker.openInfoWindowTabsHtml(infoTabs);fromMarkerInfo=infoTabs;}}}
function addRoutePoint(point,type){icon=new GIcon(G_DEFAULT_ICON);if(type=='from'){icon.image='/images/icons/point_a_medium.png';}else{icon.image='/images/icons/point_b_medium.png';}
icon.shadow='/images/icons/point_medium_shadow.png';icon.maxHeight=1;icon.iconSize=new GSize(21,25);icon.iconAnchor=new GPoint(10,25);var marker=new MapMarker(point,{icon:icon,draggable:true});marker.setType(type);GEvent.addListener(marker,"dragend",function(){if(this.getType()=='from'){setRouteFromPoint(true);}else{setRouteToPoint(true);}});GEvent.addListener(marker,"click",function(){if(this.getType()=='from'){if(fromMarkerInfo!=null){marker.openInfoWindowTabsHtml(fromMarkerInfo);}}else{if(toMarkerInfo!=null){marker.openInfoWindowTabsHtml(toMarkerInfo);}}});map.addOverlay(marker);return marker;}
this.toggleText=function(id,words){toggleText(id,words);}
function toggleText(id,words){if(toggle[id]!=null){$('#'+id).html(toggle[id]);toggle[id]=null;return;}
arrWords=$('#'+id).html().split(' ');toggle[id]=$('#'+id).html();var newText='';var append=true;for(var i=0;i<words;i++){if(arrWords[i]==null){append=false;continue;}
newText+=arrWords[i]+' ';}
if(append)newText+='.. <a href="javascript:void(0)" onclick="googleMapModule.toggleText( \''+id+'\', '+words+' )">'+getString('read_more')+'</a></p>';$('#'+id).html(newText);}
function load(){if($('#hotel_description').length!=0){toggleText('hotel_description',50);}
if(GBrowserIsCompatible()){map=new GMap2(document.getElementById("map"));map.enableScrollWheelZoom();map.addControl(new GSmallMapControl());map.addControl(new GMapTypeControl());map.addMapType(G_PHYSICAL_MAP);map.setMapType(G_PHYSICAL_MAP);map.setCenter(new GLatLng(latitude,longitude),14);markerManager=new GMarkerManager(map);if(!draggableMarkers){}
for(var key in onLoadMarkers){addMarkerSet(theLocation,onLoadMarkers[key],onLoadMarkers[key],false,false);}
appendRightClickMenu();GEvent.addListener(map,"singlerightclick",function(pixel,tile){rightClickedPixel=pixel;var x=pixel.x;var y=pixel.y;if(x>map.getSize().width-120){x=map.getSize().width-120}
if(y>map.getSize().height-100){y=map.getSize().height-100}
var pos=new GControlPosition(G_ANCHOR_TOP_LEFT,new GSize(x,y));pos.apply(rightClickMenu);rightClickMenu.style.visibility="visible";});GEvent.addListener(map,"click",function(){rightClickMenu.style.visibility="hidden";});if(route!=null){fromMarker=addRoutePoint(new GLatLng(route['from_lat'],route['from_lng']),'from');toMarker=addRoutePoint(new GLatLng(route['to_lat'],route['to_lng']),'to');var data=new AjaxData('GoogleMaps','calculateRouteFromPoints');data.addParam(route['from_lat']);data.addParam(route['from_lng']);data.addParam(route['to_lat']);data.addParam(route['to_lng']);data.addParam('to');callAjax(data);}}
if($('#overviewLink')!=null){$('#overviewLink').click(function(event){selectTab('overviewTab');});}
if($('#hotelLink')!=null){$('#hotelLink').click(function(event){selectTab('hotelTab');});}
if($('#transportLink')!=null){$('#transportLink').click(function(event){selectTab('transportTab');});}
if($('#restaurantLink')!=null){$('#restaurantLink').click(function(event){selectTab('restaurantTab');});}
if($('#attractionLink')!=null){$('#attractionLink').click(function(event){selectTab('attractionTab');});}}
function showMarkers(setName){if(markers[setName]==null)return;if(polylines[setName]!=null)map.addOverlay(polylines[setName]);for(var i=0;i<markers[setName].length;i++){markers[setName][i].show();}}
function createMarker(point,icon,id,type,typeId){var marker=new MapMarker(point,icon);if(draggableMarkers==true){marker=new MapMarker(point,{icon:icon,draggable:true});GEvent.addListener(marker,"dragend",function(){setMarkerPosition(marker,type,id);});}
marker.setType(type);marker.setId(id);marker.setTransportTypeId(typeId);GEvent.addListener(marker,"click",function(){selectedMarker=marker;googleMapModule.openInfoWindow(type,id);});if(selectedMarker[type]!=null&&selectedMarker[type]==id){o=new GIcon();o.image='/images/icons/selected_star.png';o.shadow='/images/icons/shadow_attraction_medium.png';o.maxHeight=1;o.iconSize=new GSize(24,21);o.iconAnchor=new GPoint(12,10);o.infoWindowAnchor=new GPoint(12,10);sm=new MapMarker(point,{icon:o,zIndexProcess:function(){return 1000000;}});sm.setType(type);sm.setId(id);sm.setTransportTypeId(typeId);GEvent.addListener(sm,"click",function(){selectedMarker=sm;googleMapModule.openInfoWindow(type,id);});selectedMarker=sm;map.addOverlay(sm);googleMapModule.openInfoWindow(type,id);}
return marker;}
function setMarkerPosition(marker,type,id){o=marker.getPoint();var data=new AjaxData('GoogleMaps','setMarkerPosition');data.addParam(map.getZoom());data.addParam(o.lat());data.addParam(o.lng());data.addParam(marker.getTransportTypeId());data.addParam(id);callAjax(data);}
function getString(key){return cs.getString(key);}
function addStaticMarkers(){addMarkerSet(theLocation,'static_stations','static_stations',false,false);}
function addMarkerSet(dir,filename,setName,drawPolyLine,showLoadingScreen){if(markers[setName]!=null){showMarkers(setName);return;}
if(showLoadingScreen)showLoading();var extra='';if(env=='beta'){extra='?i='+Math.floor(Math.random()*1000);}
GDownloadUrl("/maps/"+dir+"/"+filename+".xml"+extra,function(data,sResponseCode){var xml=GXml.parse(data);processMarkers(xml,setName,drawPolyLine);});}
this.addMultiMarkerSet=function(dir,filename,setName,drawPolyLine,showLoadingScreen){addMultiMarkerSet(dir,filename,setName,drawPolyLine,showLoadingScreen);}
function addMultiMarkerSet(dir,filename,setName,drawPolyLine,showLoadingScreen){if(markers[setName]!=null){showMarkers(setName);return;}
if(showLoadingScreen)showLoading();var extra='';if(env=='beta'){extra='?i='+Math.floor(Math.random()*1000);}
GDownloadUrl("/maps/"+dir+"/"+filename+".xml"+extra,function(data,sResponseCode){var i=0;while(true){var start=data.indexOf('<markers');var end=data.indexOf('</markers>')+10;if(start==-1)break;i++;var xmlString='<?xml version="1.0" encoding="iso-8859-1"?>'+data.substring(start,end);var xml=GXml.parse(xmlString);processMarkers(xml,setName+'_'+i,drawPolyLine);data=data.substring(end,data.length);}});}
function processMarkers(xml,setName,drawPolyLine){var theMarkers=xml.documentElement.getElementsByTagName("marker");var icons=xml.documentElement.getElementsByTagName("icon");var types=xml.documentElement.getElementsByTagName("type");var markerTypes={};var polycolour;for(var i=0;i<types.length;i++){switch(types[i].getAttribute('name')){case'station':markerTypes[types[i].getAttribute("id")]=new MTypeStation(types[i].getAttribute("transport_type_id"));polycolour=types[i].getAttribute("line_colour");break;case'restaurant':markerTypes[types[i].getAttribute("id")]=new MTypeRestaurant(types[i].getAttribute("restaurant_type_id"));break;case'attraction_rating':markerTypes[types[i].getAttribute("id")]=new MTypeAttractionRating(types[i].getAttribute("attraction_rating_id"));break;case'attraction_price':markerTypes[types[i].getAttribute("id")]=new MTypeAttractionPrice(types[i].getAttribute("attraction_price_id"));break;case'attraction_all':markerTypes[types[i].getAttribute("id")]=new MTypeAttractionAll();break;case'hotel_class':markerTypes[types[i].getAttribute("id")]=new MTypeHotelClass(types[i].getAttribute("hotel_class_id"));break;case'hotel_price':markerTypes[types[i].getAttribute("id")]=new MTypeHotelPrice(types[i].getAttribute("hotel_price_id"));break;case'hotels_all':markerTypes[types[i].getAttribute("id")]=new MTypeHotelAll();break;case'manual_marker':markerTypes[types[i].getAttribute("id")]=new MTypeManualMarker('Test');break;case'line':markerTypes[types[i].getAttribute("id")]=new MTypeLine('Test');polycolour=types[i].getAttribute("line_colour");break;}}
for(var i=0;i<icons.length;i++){icon=new GIcon();icon.image=icons[i].getAttribute("src");if(icons[i].getAttribute("shadow_src")!=''){icon.shadow=icons[i].getAttribute("shadow_src");}
icon.maxHeight=1;icon.iconSize=new GSize(icons[i].getAttribute("width"),icons[i].getAttribute("height"));icon.iconAnchor=new GPoint(Math.round(icons[i].getAttribute("width")/2),Math.round(icons[i].getAttribute("height")/2));icon.infoWindowAnchor=new GPoint(Math.round(icons[i].getAttribute("width")/2),Math.round(icons[i].getAttribute("height")/2));mapIcons[icons[i].getAttribute("id")]=icon;}
markers[setName]=new Array();var points=new Array();for(var i=0;i<theMarkers.length;i++){var point=new GLatLng(parseFloat(theMarkers[i].getAttribute("lat")),parseFloat(theMarkers[i].getAttribute("lng")));var markerType=markerTypes[theMarkers[i].getAttribute("type")];var pointType=markerType.getType();switch(pointType){case'station':marker=createMarker(point,mapIcons[theMarkers[i].getAttribute("icon")],theMarkers[i].getAttribute("id"),pointType,markerType.getTransportTypeId());markerManager.addMarker(marker,theMarkers[i].getAttribute("zmin"),theMarkers[i].getAttribute("zmax"));markers[setName].push(marker);if(theMarkers[i].getAttribute("zmax")==17){points[i]=point;}
break;case'line':marker=createMarker(point,mapIcons[theMarkers[i].getAttribute("icon")],theMarkers[i].getAttribute("id"),pointType,'1');markerManager.addMarker(marker,theMarkers[i].getAttribute("zmin"),theMarkers[i].getAttribute("zmax"));markers[setName].push(marker);break;case'manual_marker':marker=createMarker(point,mapIcons[theMarkers[i].getAttribute("icon")],theMarkers[i].getAttribute("id"),pointType,'1');markerManager.addMarker(marker,theMarkers[i].getAttribute("zmin"),theMarkers[i].getAttribute("zmax"));markers[setName].push(marker);break;case'restaurant':marker=createMarker(point,mapIcons[theMarkers[i].getAttribute("icon")],theMarkers[i].getAttribute("id"),pointType,markerType.getRestaurantTypeId());markerManager.addMarker(marker,theMarkers[i].getAttribute("zmin"),theMarkers[i].getAttribute("zmax"));markers[setName].push(marker);break;case'attraction_rating':marker=createMarker(point,mapIcons[theMarkers[i].getAttribute("icon")],theMarkers[i].getAttribute("id"),markerType.getParentType(),markerType.getAttractionRatingId());markerManager.addMarker(marker,theMarkers[i].getAttribute("zmin"),theMarkers[i].getAttribute("zmax"));markers[setName].push(marker);break;case'attraction_price':marker=createMarker(point,mapIcons[theMarkers[i].getAttribute("icon")],theMarkers[i].getAttribute("id"),markerType.getParentType(),markerType.getAttractionPriceId());markerManager.addMarker(marker,theMarkers[i].getAttribute("zmin"),theMarkers[i].getAttribute("zmax"));markers[setName].push(marker);break;case'attraction_all':marker=createMarker(point,mapIcons[theMarkers[i].getAttribute("icon")],theMarkers[i].getAttribute("id"),markerType.getParentType(),0);markerManager.addMarker(marker,theMarkers[i].getAttribute("zmin"),theMarkers[i].getAttribute("zmax"));markers[setName].push(marker);break;case'hotel_class':marker=createMarker(point,mapIcons[theMarkers[i].getAttribute("icon")],theMarkers[i].getAttribute("id"),markerType.getParentType(),markerType.getHotelClassId());markerManager.addMarker(marker,theMarkers[i].getAttribute("zmin"),theMarkers[i].getAttribute("zmax"));markers[setName].push(marker);break;case'hotel_price':marker=createMarker(point,mapIcons[theMarkers[i].getAttribute("icon")],theMarkers[i].getAttribute("id"),markerType.getParentType(),markerType.getHotelPriceId());markerManager.addMarker(marker,theMarkers[i].getAttribute("zmin"),theMarkers[i].getAttribute("zmax"));markers[setName].push(marker);break;case'hotels_all':marker=createMarker(point,mapIcons[theMarkers[i].getAttribute("icon")],theMarkers[i].getAttribute("id"),markerType.getParentType(),0);markerManager.addMarker(marker,theMarkers[i].getAttribute("zmin"),theMarkers[i].getAttribute("zmax"));markers[setName].push(marker);break;}}
if(polycolour=='')polycolour='#FF0000';var polyLine=new GPolyline(points,polycolour,5,0.75);polylines[setName]=polyLine;if(drawPolyLine){map.addOverlay(polyLine);}
markerManager.refresh();hideLoading();}
function removeMarkerSet(setName){if(markers[setName]==null)return false;if(polylines[setName]!=null)map.removeOverlay(polylines[setName]);for(var i=0;i<markers[setName].length;i++){markers[setName][i].hide();}}
function showLoading(){$("#loadingOverlay").css('display','block');}
function hideLoading(){$("#loadingOverlay").css('display','none');}
this.showLoading=function(){showLoading();}
this.hideLoading=function(){hideLoading();}}
function MapMarker(latLng){GMarker.apply(this,arguments);}
MapMarker.prototype=new GMarker(new GLatLng(0,0));MapMarker.prototype.setType=function(type){this.type=type;}
MapMarker.prototype.setTransportTypeId=function(type){this.transportTypeId=type;}
MapMarker.prototype.getTransportTypeId=function(){return this.transportTypeId;}
MapMarker.prototype.getType=function(){return this.type;}
MapMarker.prototype.setId=function(id){this.id=id;}
MapMarker.prototype.getId=function(){return this.id;}
MapMarker.prototype.hide=function(){if(this.getPoint().lat()==90)return;this.originalPoint=this.getPoint();this.setPoint(new GLatLng(90,0));}
MapMarker.prototype.show=function(){if(this.getPoint().lat()!=90)return;if(this.originalPoint){this.setPoint(this.originalPoint);this.savePoint=null;}}
function MTypeStation(transportTypeId){var transportTypeId=transportTypeId;var type='station';this.getTransportTypeId=function(){return transportTypeId;}
this.getType=function(){return type;}}
function MTypeRestaurant(restaurantTypeId){var restaurantTypeId=restaurantTypeId;var type='restaurant';this.getRestaurantTypeId=function(){return restaurantTypeId;}
this.getType=function(){return type;}}
function MTypeHotelClass(hotelClassId){var hotelClassId=hotelClassId;var type='hotel_class';this.getHotelClassId=function(){return hotelClassId;}
this.getType=function(){return type;}
this.getParentType=function(){return'hotels';}}
function MTypeHotelPrice(hotelPriceId){var hotelPriceId=hotelPriceId;var type='hotel_price';this.getHotelPriceId=function(){return hotelPriceId;}
this.getType=function(){return type;}
this.getParentType=function(){return'hotels';}}
function MTypeHotelAll(){var type='hotels_all';this.getType=function(){return type;}
this.getParentType=function(){return'hotels';}}
function MTypeAttractionRating(attractionRatingId){var attractionRatingId=attractionRatingId;var type='attraction_rating';this.getAttractionRatingId=function(){return attractionRatingId;}
this.getType=function(){return type;}
this.getParentType=function(){return'attraction';}}
function MTypeAttractionPrice(attractionPriceId){var attractionPriceId=attractionPriceId;var type='attraction_price';this.getAttractionPriceId=function(){return attractionPriceId;}
this.getType=function(){return type;}
this.getParentType=function(){return'attraction';}}
function MTypeAttractionAll(){var type='attraction_all';this.getType=function(){return type;}
this.getParentType=function(){return'attraction';}}
function MTypeManualMarker(value){this.getType=function(){return'manual_marker';}}
function MTypeLine(value){this.getType=function(){return'line';}}
