
$(document).ready(function(){
	plotOffices();

});


function plotOffices(){

	if (receiveReq.readyState == 4 || receiveReq.readyState == 0) 
	{	
		receiveReq.open("GET", '/map/get-office-plotting-data', true);		
		receiveReq.onreadystatechange = function(){
			if (receiveReq.readyState == 4) {
				locations = eval("(" + receiveReq.responseText + ")");
				for(i=0;i < locations.offices.length; i++) {	
					var temp = locations.offices[i];				
					plot(temp);
				}
			}
		};		
		receiveReq.send(null);	
	}	


}

function plot(location)
{

	var myicon = new GIcon(baseIcon);
	myicon.image = "/images/markers/" + "Blue" + ".png";
	var point = new GLatLng(location.lat, location.lng);
	var options = { icon:myicon };
	location.marker = new GMarker(point, options);
	
	GEvent.addListener(location.marker, "click", function() {
		location.marker.openInfoWindowHtml(location.content);
	});
	map.addOverlay(location.marker);
}