function CreateIcon(colour)
{
	var i = new GIcon();
	
	if(colour)
		i.image = m[colour].src;
	else
		i.image = m['marker'].src;
	
	i.shadow = m['shadow'].src;
	
	i.iconSize = new GSize(12, 20);
	i.shadowSize = new GSize(22, 20);
	i.iconAnchor = new GPoint(5, 20);
	i.infoWindowAnchor = new GPoint(8, 1);
	
	return i;
}

function CreateMarker(icon, e, listen) 
{
	var marker = new GMarker(new GLatLng(e.Latitude, e.Longitude), icon);

	var content = '<h1>' + e.LocName + '</h1><p><a href="service.asp?id=' + e.ID + "&divisionid=" + e.DivisionID + '">View More Details</a> &raquo;</p>';
	
	if(listen)
		GEvent.addListener(marker, "click", function() { ShowInfoWindow(this.getPoint(), content); } );	
	
	return marker;
}

function ShowInfoWindow(point, content)
{
	iw.set(content, point);
	map.panTo(point);
}

function FormatPostcode(p)
{
	p = String(p);
	
	var op = p.substring(0, p.length - 3);
	var ip = p.substring(p.length - 3);
	
	return op + ' ' + ip;
}

function AddMouseOvers()
{
	var a = document.getElementById('loclist').getElementsByTagName('a');
	
	for(var x=0; x<a.length; x++)
		a[x].onmouseover = function() { ScrollToMarker(this.id.substring(4)); }
}

function ScrollToMarker(id)
{	
	for(var x=0; x<loc.length; x++)
		if(loc[x].ID == id) { GEvent.trigger(loc[x].Marker, 'click'); break; }
}
