// JavaScript Document
<!--
function confirmDelete()
{
var agree=confirm("Are you sure you want to delete?");
if (agree)
return true ;
else
return false ;
}
//-->

<!--
function open_window(url)
{
cwin = window.open(url,"attach","width=350,height=400,toolbar=no,resizable=yes");
}
function ptoutput(theText)
{
document.write(theText);
}
//-->

    //<![CDATA[
    var iconWhite = new GIcon();
    iconWhite.image = 'http://villa-websites.com/images/mm_20_white.png';
    iconWhite.shadow = 'http://villa-websites.com/images/mm_20_shadow.png';
    iconWhite.iconSize = new GSize(12, 20);
    iconWhite.shadowSize = new GSize(22, 20);
    iconWhite.iconAnchor = new GPoint(6, 20);
    iconWhite.infoWindowAnchor = new GPoint(5, 1);

    var iconYellow = new GIcon();
    iconYellow.image = 'http://villa-websites.com/images/mm_20_yellow.png';
    iconYellow.shadow = 'http://villa-websites.com/images/mm_20_shadow.png';
    iconYellow.iconSize = new GSize(12, 20);
    iconYellow.shadowSize = new GSize(22, 20);
    iconYellow.iconAnchor = new GPoint(6, 20);
    iconYellow.infoWindowAnchor = new GPoint(5, 1);

    var iconBlue = new GIcon();
    iconBlue.image = 'http://villa-websites.com/images/mm_20_blue.png';
    iconBlue.shadow = 'http://villa-websites.com/images/mm_20_shadow.png';
    iconBlue.iconSize = new GSize(12, 20);
    iconBlue.shadowSize = new GSize(22, 20);
    iconBlue.iconAnchor = new GPoint(6, 20);
    iconBlue.infoWindowAnchor = new GPoint(5, 1);

    var iconRed = new GIcon();
    iconRed.image = 'http://villa-websites.com/images/mm_20_red.png';
    iconRed.shadow = 'http://villa-websites.com/images/mm_20_shadow.png';
    iconRed.iconSize = new GSize(12, 20);
    iconRed.shadowSize = new GSize(22, 20);
    iconRed.iconAnchor = new GPoint(6, 20);
    iconRed.infoWindowAnchor = new GPoint(5, 1);

    var iconGreen = new GIcon();
    iconGreen.image = 'http://villa-websites.com/images/mm_20_green.png';
    iconGreen.shadow = 'http://villa-websites.com/images/mm_20_shadow.png';
    iconGreen.iconSize = new GSize(12, 20);
    iconGreen.shadowSize = new GSize(22, 20);
    iconGreen.iconAnchor = new GPoint(6, 20);
    iconGreen.infoWindowAnchor = new GPoint(5, 1);

    var iconPurple = new GIcon();
    iconPurple.image = 'http://villa-websites.com/images/mm_20_purple.png';
    iconPurple.shadow = 'http://villa-websites.com/images/mm_20_shadow.png';
    iconPurple.iconSize = new GSize(12, 20);
    iconPurple.shadowSize = new GSize(22, 20);
    iconPurple.iconAnchor = new GPoint(6, 20);
    iconPurple.infoWindowAnchor = new GPoint(5, 1);

    var iconOrange = new GIcon();
    iconOrange.image = 'http://villa-websites.com/images/mm_20_orange.png';
    iconOrange.shadow = 'http://villa-websites.com/images/mm_20_shadow.png';
    iconOrange.iconSize = new GSize(12, 20);
    iconOrange.shadowSize = new GSize(22, 20);
    iconOrange.iconAnchor = new GPoint(6, 20);
    iconOrange.infoWindowAnchor = new GPoint(5, 1);

    var customIcons = [];
    customIcons["1"] = iconWhite;
    customIcons["2"] = iconYellow;
    customIcons["3"] = iconBlue;
    customIcons["4"] = iconRed;
    customIcons["5"] = iconGreen;
    customIcons["6"] = iconPurple;
    customIcons["7"] = iconOrange;
	customIcons["8"] = iconWhite;

    var markerGroups = { "1": [], "2": [], "3": [], "4": [], "5": [], "6": [], "7": [], "8": []};

    function load() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map"));
        map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());
        map.setCenter(new GLatLng(28.3, -81.6), 6);

        GDownloadUrl("http://villa-websites.com/addons/mygooglemaps/domxml.xml", function(data) {
          var xml = GXml.parse(data);
          var markers = xml.documentElement.getElementsByTagName("marker");
          for (var i = 0; i < markers.length; i++) {
            var id = markers[i].getAttribute("id");
            var title = markers[i].getAttribute("title");
            var image = markers[i].getAttribute("image");
            var community = markers[i].getAttribute("community");
            var address = markers[i].getAttribute("address");
            var type = markers[i].getAttribute("type");
            var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),
                                    parseFloat(markers[i].getAttribute("lng")));
            var marker = createMarker(point, id, title, image, community, address, type);
            markerGroups[type].push(marker);
            map.addOverlay(marker);
            }
        });
      }
    }

    function createMarker(point, id, title, image, community, address, type) {
      var marker = new GMarker(point, customIcons[type]);
      var html = "<b>Listing id # " + id + "   </b><a href=http://villa-websites.com/listing-" + title + "-" + id + ".html target=blank>view listing</a><br/><br/><img src=http://villa-websites.com/images/listing_photos/" + image + " width=100 height=75><br/><b>" + community + "</b><br/>" + address;
      GEvent.addListener(marker, 'mouseover', function() {
        marker.openInfoWindowHtml(html);
      });
      return marker;
    }

    function toggleGroup(type) {
      for (var i = 0; i < markerGroups[type].length; i++) {
        var marker = markerGroups[type][i];
        if (marker.isHidden()) {
          marker.show();
        } else {
          marker.hide();
        }
      }
    }
    //]]>
