﻿
function Map_panel_change(){if(_gMap.centred){$("#GeoCoordinateMapLoading").fadeOut("fast");$("#GeoCoordinateMapContainer").fadeIn("slow");}
return;}
var geoDestination=new VEShapeLayer();var geoRegion=new VEShapeLayer();var geoResort=new VEShapeLayer();var geoHotel=new VEShapeLayer();var geoVilla=new VEShapeLayer();var geoApartment=new VEShapeLayer();function GetMap(){if(_gMap.map==null){getMapData(_gMap.crdUrlBase+_gMap.dstCode);_gMap.map=new VEMap('GeoCoordinateMap');_gMap.map.SetDashboardSize(VEDashboardSize.Small);_gMap.map.LoadMap(new VELatLong(0,0),1,'r',false);_gMap.map.Resize(_gMap.mapWidth,_gMap.mapHeight);_gMap.map.AttachEvent("onmouseover",ShapeOverHandler);_gMap.map.AttachEvent("onclick",ShapeClickHandler);}}
function getMapData(sUrl){$.getJSON(sUrl.toLowerCase(),function(oData){setMapData(oData);});}
function setMapData(oData){var shape=null;var sUrl=null;_gMap.map.AddShapeLayer(geoDestination);_gMap.map.AddShapeLayer(geoRegion);_gMap.map.AddShapeLayer(geoResort);_gMap.map.AddShapeLayer(geoHotel);_gMap.map.AddShapeLayer(geoVilla);_gMap.map.AddShapeLayer(geoApartment);if(oData){$.each(oData,function(i,item){sUrl=null;shape=new VEShape(VEShapeType.Pushpin,new VELatLong(item.Latitude,item.Longitude));shape.SetTitle(item.FullDescription);shape.SetMaxZoomLevel(item.ZoomLevelMax);if(item.Hierarchy.Centre.Code){shape.SetMinZoomLevel(item.ZoomLevelMin);switch(item.Type){case"H":shape.SetCustomIcon("<img src='/images/map/hotel.gif'/>");geoHotel.AddShape(shape);break;case"V":shape.SetCustomIcon("<img src='/images/map/villa.gif'/>");geoVilla.AddShape(shape);break;case"A":shape.SetCustomIcon("<img src='/images/map/apartment.gif'/>");geoApartment.AddShape(shape);break;}
SetMapCenterZoom(item.Hierarchy.Centre.Code,item)
sUrl="/"+item.Hierarchy.Destination.NameUrl+"/"+item.Hierarchy.Region.NameUrl+"/"+item.Hierarchy.Resort.NameUrl+"/"+item.Hierarchy.Centre.NameUrl;}else{if(item.Hierarchy.Resort.Code){shape.SetMinZoomLevel(item.ZoomLevelMin);shape.SetCustomIcon("<img src='/images/map/resort.gif'/>");shape.SetDescription(item.SubCount+" "+_gMapMessages.centreCountLabel);geoResort.AddShape(shape);SetMapCenterZoom(item.Hierarchy.Resort.Code,item)}else{if(item.Hierarchy.Region.Code){shape.SetCustomIcon("<img src='/images/map/region.gif'/>");shape.SetDescription(item.SubCount+" "+_gMapMessages.resortCountLabel);geoRegion.AddShape(shape);SetMapCenterZoom(item.Hierarchy.Region.Code,item)}else{if(item.Hierarchy.Destination.Code){shape.SetCustomIcon("<img src='/images/map/region.gif'/>");geoDestination.AddShape(shape);SetMapCenterZoom(item.Hierarchy.Destination.Code,item);_gMap.zoom=item.ZoomLevel;_gMap.destLat=item.Latitude;_gMap.destLong=item.Longitude;}}}}
_gMap.shapeData[shape.GetID()]=new Array('zoom','url');_gMap.shapeData[shape.GetID()]['zoom']=item.ZoomLevel;_gMap.shapeData[shape.GetID()]['url']=sUrl;});}
if(!_gMap.centred){try{$("#GeoCoordinateMapLoading").fadeOut("fast");_gMap.map.SetCenterAndZoom(new VELatLong(_gMap.destLat,_gMap.destLong),_gMap.zoom);$("#GeoCoordinateMapContainer").fadeIn("slow");}
catch(err){$("#GeoCoordinateMapLoading").fadeOut("fast");$("#GeoCoordinateMapError").fadeIn("fast");}}}
function SetShapeDescription(oData,shape){var sHtml="<span id=\""+shape.GetID()+"_Content\" class=\"map_details_container\">";if(oData){if(oData.ImageFileNames["1"]!=""&&oData.ImageFileNames["1"]!=null)
sHtml+="<img src=\""+_gMap.imageUrl+oData.ImageFileNames["1"]["Src"].toLowerCase()+"\">";sHtml+="<p style=\"font-size: .9em;\">";if(oData.IntroText["1"]!=""&&oData.IntroText["1"]!=null)
sHtml+=oData.IntroText["1"];sHtml+="</p>";$.each(oData.ProductOffers,function(i,item){if(item.length>0)
sHtml+="<p style=\"font-size: .9em;\" class=\"red\">"+eval("_gMapMessages."+i.toLowerCase()+"OfferLabel")+"&pound;"+item[0].Price+"</p>";});var href=document.location.href;if(href.indexOf('popup')==-1)
sHtml+="<a href=\""+_gMap.shapeData[shape.GetID()]['url']+"\">"+_gMapMessages.centerBookNow+"</a>";sHtml+="</span>";$("#"+shape.GetID()+"_Content").html(sHtml);shape.SetDescription(sHtml);}}
function ShapeOverHandler(e){if(e.elementID){var shape=_gMap.map.GetShapeByID(e.elementID);var sUrl=_gMap.shapeData[shape.GetID()]['url'];if(sUrl&&!shape.GetDescription()){shape.SetDescription("<span id=\""+shape.GetID()+"_Content\" class=\"map_details_container\">"+_gMapMessages.centerDescLoad+"</span>");$.getJSON(sUrl+"/json/",function(data){SetShapeDescription(data,shape);});}}}
function ShapeClickHandler(e){if(e.elementID){var shape=_gMap.map.GetShapeByID(e.elementID);var shapeVELatLong=shape.GetPoints[0];_gMap.map.SetCenterAndZoom(new VELatLong(shape.GetPoints()[0].Latitude,shape.GetPoints()[0].Longitude),_gMap.shapeData[shape.GetID()]['zoom']);}}
function SetMapCenterZoom(code,item){if(code==_gMap.hrcCode){$("#GeoCoordinateMapLoading").fadeOut("fast");iZoom=item.ZoomLevel;if(item.Hierarchy.Centre.Code)
iZoom=19;_gMap.map.SetCenterAndZoom(new VELatLong(item.Latitude,item.Longitude),iZoom);_gMap.centred=true;$("#GeoCoordinateMapContainer").fadeIn("slow");}}
function ShowHideCenters(sType){switch(sType){case"H":geoHotel.IsVisible()?geoHotel.Hide():geoHotel.Show();break;case"V":geoVilla.IsVisible()?geoVilla.Hide():geoVilla.Show();break;case"A":geoApartment.IsVisible()?geoApartment.Hide():geoApartment.Show();break;}}
$(document).ready(function(){$("#Map_product_group").change(function(){GuideExchangeContainer.SelectedGroup=this.value;});});