﻿var xml_regions;var regionGLatLng;var zoom;var website;var language;var map_width;var map_height;var server_url;function showMarkers(regionCode){$(document).ready(function(){$.ajax({type:"GET",url:server_url+"/markers.xml.php?website="+website+"&language="+language+"&regionCode="+regionCode,dataType:"xml",error:function(){alert("AJAX error, please try again.");},success:function(xml){$('#campings_map').append('<div id="message_camping" style="display: none;"><div class="name"></div><div class="image">Image</div><div class="info_text"></div></div>');$('#campings_map').append('<div id="message_highlight" style="display: none;"></div>');var campingMarker=new GIcon(G_DEFAULT_ICON);campingMarker.image=server_url+"/images/markers/camping.png";campingMarker.shadow=server_url+"/images/markers/camping_shadow.png";campingMarker.iconSize=new GSize(23,26);campingMarker.shadowSize=new GSize(37,26);campingMarker.iconAnchor=new GPoint(11,25);campingMarker.infoWindowAnchor=new GPoint(19,3);$(xml).find('camping').each(function(){var id=$(this).attr('id');var name=$(this).attr('name');var info_text=$(this).attr('info_text');var url=$(this).attr('url');var lat=$(this).attr('lat');var lng=$(this).attr('lng');var coordinates=new GLatLng(lat,lng);markerOptions={icon:campingMarker};var marker=new GMarker(coordinates,markerOptions);map.addOverlay(marker);GEvent.addListener(marker,"mouseover",function(){$("#message_camping .name").html(name);$("#message_camping .image").html('<img src="'+server_url+'/images/campings/'+id+'.jpg" alt="'+name+'"/>');$("#message_camping .info_text").html(info_text);$("#message_camping").appendTo(map.getPane(G_MAP_FLOAT_SHADOW_PANE));var markerOffset=map.fromLatLngToDivPixel(coordinates);var message_width=$("#message_camping").width()+14;var message_height=$("#message_camping").height()+14;var width_exceeds=markerOffset.x+message_width-map_width;if(width_exceeds<=0){info_window_x=markerOffset.x;}else{info_window_x=markerOffset.x-message_width;}
var height_exceeds=markerOffset.y+message_height-map_height;if(height_exceeds<=0){info_window_y=markerOffset.y;}else{info_window_y=markerOffset.y-height_exceeds-15;info_window_x+=12;}
if(width_exceeds>0&&height_exceeds>0){info_window_x-=23;}
$("#message_camping").show().css({top:info_window_y,left:info_window_x});});GEvent.addListener(marker,"mouseout",function(){$("#message_camping").hide();});GEvent.addListener(marker,"click",function(){top.location.href=url;});});}});});}
function showRegion(regionCode){$(document).ready(function(){$("#map_swf").remove();$('#campings_map').append('<div id="map_canvas" style="width:'+map_width+'px; height:'+map_height+'px;"></div>');if(GBrowserIsCompatible()){$(xml_regions).find("region[ code = '"+regionCode+"' ]").each(function(){var lat=parseFloat($(this).attr('centerLat'));var lng=parseFloat($(this).attr('centerLng'));zoom=parseInt($(this).attr('zoom'));regionGLatLng=new GLatLng(lat,lng);});map=new GMap2(document.getElementById('map_canvas'));map.setCenter(regionGLatLng,zoom,G_PHYSICAL_MAP);map.disableDragging();function Mask(img){this.img_=img;}
Mask.prototype=new GOverlay();Mask.prototype.initialize=function(map){var div=document.createElement("div");div.style.background="transparent url("+this.img_+") no-repeat left top";div.style.position="absolute";div.id="region_mask";map.getPane(G_MAP_MAP_PANE).appendChild(div);this.map_=map;this.div_=div;}
Mask.prototype.remove=function(){this.div_.parentNode.removeChild(this.div_);}
Mask.prototype.redraw=function(force){if(!force)return;this.div_.style.width="680px";this.div_.style.height="580px";this.div_.style.left="0px";this.div_.style.top="0px";}
map.addOverlay(new Mask(server_url+"/images/overlays/"+regionCode+".png"));$('#region_mask').ifixpng();showMarkers(regionCode);$('#map_canvas').append('<a id="back_to_europe" href="#"></a>');$("#back_to_europe").mouseover(function(){$(this).addClass("over");}).mouseout(function(){$(this).removeClass("over");});$("#back_to_europe").click(function(){initiate_flash_map(true);return false;});}else{alert("Your browser is not compatible for this map. Please use the lates version of Firefox or Internet Explorer.");}});}
function initiate_flash_map(reload){if(reload!==null&&reload==true){GUnload();$('#map_canvas').remove();$('#campings_map').append('<div id="map_swf"></div>');}
$(document).ready(function(){website=$("#website").val();language=$("#language").val();map_width=$("#map_width").val();map_height=$("#map_height").val();server_url=$("#server_url").val();$.ajax({type:"GET",url:server_url+"/regions.xml.php",dataType:"xml",error:function(){alert("AJAX error, please try again.");},success:function(xml){xml_regions=xml;}});var flashvars={website:website,regions_url:server_url+"/regions.xml.php",language:language,translations_url:server_url+"/translations.xml.php"};swfobject.embedSWF(server_url+"/flash/map.swf","map_swf",map_width,map_height,"8.0.0",server_url+"/flash/expressInstall.swf",flashvars);});}
initiate_flash_map();
