// Array to hold the markers returned from the webservice
var RecentlySoldMarkers = new Array();

// Array to hold the icon types used on the map (singlepoint and recentlysold)
var RecentlySoldIcons = new Array();
var RecentlySoldIcon = new GIcon();
	RecentlySoldIcon.image = "http://bin-production.gabriels.net/realestate/recentlysold/images/map/singlepoint_off.png";
    RecentlySoldIcon.shadow = "http://bin-production.gabriels.net/realestate/recentlysold/images/map/singlepoint_shadow.png";
    RecentlySoldIcon.transparent = "http://bin-production.gabriels.net/realestate/recentlysold/images/map/singlepoint_transparent.png";
    RecentlySoldIcon.iconSize = new GSize(24, 24);
    RecentlySoldIcon.shadowSize = new GSize(37, 24);
    RecentlySoldIcon.iconAnchor = new GPoint(12, 12);
    RecentlySoldIcon.infoWindowAnchor = new GPoint(12, 12);
    RecentlySoldIcon.imageMap = [1,5,8,1,16,5,16,15,12,15,10,26,6,15,1,15];
    RecentlySoldIcons["single"] = RecentlySoldIcon;
    RecentlySoldIcon = new GIcon();
    RecentlySoldIcon.image = "http://bin-production.gabriels.net/realestate/recentlysold/images/map/recently_sold_off.png";
    RecentlySoldIcon.shadow = "http://bin-production.gabriels.net/realestate/recentlysold/images/map/recently_sold_shadow.png";
    RecentlySoldIcon.transparent = "http://bin-production.gabriels.net/realestate/recentlysold/images/map/recently_sold_transparent.png";
    RecentlySoldIcon.iconSize = new GSize(24, 24);
    RecentlySoldIcon.shadowSize = new GSize(37, 24);
    RecentlySoldIcon.iconAnchor = new GPoint(12, 12);
    RecentlySoldIcon.infoWindowAnchor = new GPoint(12, 12);
    RecentlySoldIcon.imageMap = [1,5,8,1,16,5,16,15,12,15,10,26,6,15,1,15];
    RecentlySoldIcons["recentsale"] = RecentlySoldIcon;

// Array to hold the numbers that are used for display on the icons
var RecentlySoldIconNumbers = new Array();
    for(var i = 0; i < 26; i++)
	{
		if(i < 10)
		{
			RecentlySoldIconNumbers[i] = "http://bin-production.gabriels.net/realestate/recentlysold/images/map/0" + i + ".png";
		}
		else
		{
			RecentlySoldIconNumbers[i] = "http://bin-production.gabriels.net/realestate/recentlysold/images/map/" + i + ".png";
		}
	}

// Function to add markers returned from the webservice to the map
function AddRecentlySoldMarker(point, index, desc, type) 
{
	var Label = {"url":RecentlySoldIconNumbers[index], "anchor":new GLatLng(3,5), "size":new GSize(14,14)};
	var Icon = new GIcon(RecentlySoldIcons[type], null, Label);
 	var Marker = new GMarker(point, {icon:Icon});
	if (type=="recentsale")
	{
		GEvent.addListener(Marker, "click", function() {
            Marker.openInfoWindowHtml(desc);
        });
    }
	RecentlySoldMarkers[index] = Marker;
	return Marker;
}

// Function to open an info window on a marker when clicking the map link for each record returned from the webservice
function OpenRecentlySoldMarker(index) {
	GEvent.trigger(RecentlySoldMarkers[index], "click");
}