// JavaScript Document

// google map-start code

var map;
var gmarkers = [];
var htmls = [];
var markerTypes = [];
var marker;
var i = 0;

// Create some custom icons

// This icon uses the same shape as the default Google marker
// So we can use its details for everything except the image

var houseMapIcon = new GIcon();
houseMapIcon.image = "images/houseMapIcon.png";
houseMapIcon.iconSize = new GSize(40, 32);
houseMapIcon.shadow = "images/houseShadowMapIcon.png";
houseMapIcon.shadowSize = new GSize(40, 32);
houseMapIcon.iconAnchor = new GPoint(12, 31);
houseMapIcon.infoWindowAnchor = new GPoint(9, 2);
houseMapIcon.infoShadowAnchor = new GPoint(18, 25);
houseMapIcon.transparent = "http://www.google.com/intl/en_ALL/mapfiles/markerTransparent.png";

function load(iLat, iLong, iZoom) {
	if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("propertyListingsMap"));
		map.setCenter(new GLatLng(iLat, iLong), iZoom);
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
	}
}

function addProperty(iLat, iLong, iMarkerID, sPostCode, sPrice, iBedrooms, sPropType, sPropCode, iPropRef) {
	if (GBrowserIsCompatible()) {
		var marker = new GMarker(new GLatLng(iLat, iLong), houseMapIcon);
		map.addOverlay(marker);
		var html = "<div style='display:inline; float:left; width:230px; height:80px; margin-top:3px; font-size:75%; line-height:1.3; font-family:Verdana, Arial, Helvetica, sans-serif;'>"
		html = html + "<img width='88' height='65' src='tools/getImage.asp?id=" + iMarkerID + "&mode=small' style='float:right;' /><strong>" + iBedrooms + " Bedroom " + sPropType + "</strong><br />" + sPostCode + " - &pound;" + sPrice
		html = html + "<br />Property Ref: " + iPropRef + "<br /><br />"
		html = html + "<a class='blueLink' href='property-info.asp?c=" + sPropCode + "'>Full details</a></div>"
		GEvent.addListener(marker, "click", function() {
			marker.openInfoWindowHtml(html);
		});
	
		gmarkers[iMarkerID] = marker;
		htmls[iMarkerID] = html;
	
		return marker;
	}
}

// This function opens the HTML info window for a marker
function myclick(i) {
	gmarkers[i].openInfoWindowHtml(htmls[i]);
}
