var map=null,markers=[],markerIndex=0,bounds=null,unMappedItems=[];
function createMarker(b,a,e,f){var d=new GIcon;switch(a.list){case "favorites":d.image=favMarkerImage.url;d.iconSize=new GSize(favMarkerImage.width,favMarkerImage.height);d.iconAnchor=new GPoint(favMarkerImage.anchorX,favMarkerImage.anchorY);d.infoWindowAnchor=new GPoint(favMarkerImage.anchorX,favMarkerImage.anchorY);d.shadow=favMarkerImage.shadow;break;case "viewed":d.image=viewedMarkerImage.url;d.iconSize=new GSize(viewedMarkerImage.width,viewedMarkerImage.height);d.iconAnchor=new GPoint(viewedMarkerImage.anchorX,
viewedMarkerImage.anchorY);d.infoWindowAnchor=new GPoint(viewedMarkerImage.anchorX,viewedMarkerImage.anchorY);d.shadow=viewedMarkerImage.shadow;break;case "page":d.image=markerImage.url,d.iconSize=new GSize(markerImage.width,markerImage.height),d.iconAnchor=new GPoint(markerImage.anchorX,markerImage.anchorY),d.infoWindowAnchor=new GPoint(markerImage.anchorX,markerImage.anchorY),d.shadow=markerImage.shadow}var c=new GMarker(b,{icon:d});c.list=a.list;GEvent.addListener(c,"click",function(){f&&f({item:a,
marker:c})});switch(c.list){case "favorites":GEvent.addListener(c,"mouseout",function(){c.setImage(favMarkerImage.url);markerMouseOut({item:a,marker:c},"#favoriteslist_"+a.id+", #myviewlist_"+a.id+", #cpe_"+a.id+">a")});GEvent.addListener(c,"mouseover",function(){c.setImage(favMarkerImageHover.url);displayMarker(c,b,a,e,"#favoriteslist_"+a.id+", #myviewlist_"+a.id+", #cpe_"+a.id+">a")});$("#favoriteslist_"+a.id).live("mouseover",function(){GEvent.trigger(c,"mouseover")});$("#favoriteslist_"+a.id).live("mouseout",
function(){GEvent.trigger(c,"mouseout")});break;case "viewed":GEvent.addListener(c,"mouseout",function(){c.setImage(viewedMarkerImage.url);markerMouseOut({item:a,marker:c},"#favoriteslist_"+a.id+", #myviewlist_"+a.id+", #cpe_"+a.id+">a")});GEvent.addListener(c,"mouseover",function(){c.setImage(viewedMarkerImageHover.url);displayMarker(c,b,a,e,"#favoriteslist_"+a.id+", #myviewlist_"+a.id+", #cpe_"+a.id+">a")});$("#myviewlist_"+a.id).live("mouseover",function(){GEvent.trigger(c,"mouseover")});$("#myviewlist_"+
a.id).live("mouseout",function(){GEvent.trigger(c,"mouseout")});break;case "page":GEvent.addListener(c,"mouseout",function(){c.setImage(markerImage.url);markerMouseOut({item:a,marker:c},"#favoriteslist_"+a.id+", #myviewlist_"+a.id+", #cpe_"+a.id+">a")}),GEvent.addListener(c,"mouseover",function(){c.setImage(markerImageHover.url);displayMarker(c,b,a,e,"#favoriteslist_"+a.id+", #myviewlist_"+a.id+", #cpe_"+a.id+">a")}),$("#cpe_"+a.id).live("mouseover",function(){GEvent.trigger(c,"mouseover")}),$("#cpe_"+
a.id).live("mouseout",function(){GEvent.trigger(c,"mouseout")})}return c}function markerMouseOut(b,a){$("#message").hide().empty();$(a).removeClass("hotel_map_hover")}
function displayMarker(b,a,e,f,d){$("#message").hide().empty();$(d).addClass("hotel_map_hover");$(f).clone().show().attr("class","ui-widget-content").appendTo("#message");map.fromLatLngToDivPixel(b.getPoint());b=map.fromLatLngToDivPixel(b.getPoint());e=map.getBounds();a=map.fromLatLngToDivPixel(e.getNorthEast());e=map.fromLatLngToDivPixel(e.getSouthWest());f=$("#message").width();d=$("#message").outerHeight();if(b.x+f>a.x)b.x=a.x-f-12;if(b.y+d>e.y)b.y=b.y-d-12;b.y+=6;$("#message").css({top:b.y+"px",
left:b.x+"px"}).show()}var centerset=!1;
function mapAddress(b,a){bounds.extend(new GLatLng(b.lat,b.lng));bounds.toSpan().lat();map.getBounds().toSpan().lat();var e=new GLatLng(b.lat,b.lng);(!centerset||!bounds.containsLatLng(e))&&map.setCenter(e,11);centerset=!0;var f=null;switch(b.list){case "page":f="#info_cpe_"+b.id;break;case "viewed":f="#info_viewed_"+b.id;break;case "favorites":f="#info_fav_"+b.id}e=createMarker(e,b,f,a);map.addOverlay(e);e.list=b.list;e.id=b.id;e.lat=b.lat;e.lng=b.lng;markers.push(e)}
function getAddressArray(b,a){$.each(b,function(b,f){mapAddress(f,a)})};
