// JavaScript Document

	// Create a base icon for all of our markers that specifies the
	// shadow, icon dimensions, etc.
/*	var baseIcon = new GIcon();
	baseIcon.image = "http://"+host+"/images/map/pin_green.png";
	baseIcon.shadow = "http://"+host+"/images/map/pin_shadow.png";
	baseIcon.iconSize = new GSize(14, 34);
	baseIcon.shadowSize = new GSize(42, 34);
	baseIcon.iconAnchor = new GPoint(7, 34);
	baseIcon.infoWindowAnchor = new GPoint(7, 3);
//	baseIcon.infoShadowAnchor = new GPoint(18, 25);
*/
	// Create our marker icons
	var fs_icon = new GIcon();
	fs_icon.image = "http://"+host+"/images/map/pin_green.png";
	fs_icon.shadow = "http://"+host+"/images/map/pin_shadow.png";
	fs_icon.iconSize = new GSize(12, 20);
	fs_icon.shadowSize = new GSize(22, 20);
	fs_icon.iconAnchor = new GPoint(6, 20);
	fs_icon.infoWindowAnchor = new GPoint(5, 1);
	//fs_icon.infoShadowAnchor = new GPoint(10, 5); 
	
	var ao_icon = new GIcon();
	ao_icon.image = "http://"+host+"/images/map/pin_yellow.png";
	ao_icon.shadow = "http://"+host+"/images/map/pin_shadow.png";
	ao_icon.iconSize = new GSize(12, 20);
	ao_icon.shadowSize = new GSize(22, 20);
	ao_icon.iconAnchor = new GPoint(6, 20);
	ao_icon.infoWindowAnchor = new GPoint(5, 1);
	//ao_icon.infoShadowAnchor = new GPoint(10, 5); 
	
	var sold_icon = new GIcon();
	sold_icon.image = "http://"+host+"/images/map/pin_red.png";
	sold_icon.shadow = "http://"+host+"/images/map/pin_shadow.png";
	sold_icon.iconSize = new GSize(12, 20);
	sold_icon.shadowSize = new GSize(22, 20);
	sold_icon.iconAnchor = new GPoint(6, 20);
	sold_icon.infoWindowAnchor = new GPoint(5, 1);
	//sold_icon.infoShadowAnchor = new GPoint(10, 5);
	
	function close_info_window(){
		map.closeInfoWindow();
	}
	
	function add_props(){
		var mrkrs = new Array();
		var prop_added = false;
		var num_props = props.length;
		//alert(num_props);
		var cnt = 0;
		for (i = 0; i < num_props; i++){
		//	Lat: 1, Lon: 2	
		//the 7th prop (prop 0) in the array tells whether to use the red, green or yellow pin
			if (props[i][6]==0) { //0 is green
				baseIcon = fs_icon;
			} else if (props[i][6]==1) { //1 is yellow
				baseIcon = ao_icon;
			} else if (props[i][6]==2) { //2 is red
				baseIcon = sold_icon;
			}
	
			var mPt = new GLatLng(props[i][1], props[i][2]);  //props 1 dn 2 are the latitude and longitude
			mrkrs[cnt] = new GMarker(mPt, baseIcon);
		//	mrkrs[cnt].text = props[i][11]+"<br />"+props[i][0];  //the text that is showing is in props 11 and 0
			mrkrs[cnt].text = "<img src=\"/images/signs/"+props[i][10]+"\" width=\"200\" height=\"150\" /><br />"+props[i][11]+"<br />"+props[i][0];  //the text that is showing is in props 11 and 0
			GEvent.addListener(mrkrs[cnt], 'click', function() {
				this.openInfoWindow(this.text);
			});
			
			GEvent.addListener(mrkrs[cnt], 'mouseover', function() {
			//	this.openInfoWindow(this.text);
			//	this.openInfoWindowHtml("<img src=\"/images/signs/"+this.text+"/"+this.text+"_1_tiny.jpg\" />");
				this.openInfoWindowHtml(this.text);
			});
			
/*			GEvent.addListener(mrkrs[cnt], 'mouseout', function() {
				this.closeInfoWindow();
			});
*/			
			cnt++;
			
		}
		mm.addMarkers(mrkrs, 0, 17);
		mm.refresh();
	}
	

	var map = null;
	var mm = null;
	var iLat = 44.46065953;
	var iLon = -87.55038603;
	var iZoom = 8;
	var initialCenterPoint = new GLatLng(iLat, iLon);
	var initialZoomLevel = iZoom;
	var initialMapType = G_NORMAL_MAP;

	function setup_MarkerManager(){
		var mgrOptions = { borderPadding: 20, trackMarkers: false };
		mm = new GMarkerManager(map, mgrOptions);
		add_props();
	}

    function initialize() {
	

      if (GBrowserIsCompatible()) {
    //    window.var map = new GMap2(document.getElementById("map_canvas"));
        map = new GMap2(document.getElementById("map_canvas")); 
    //    map.setCenter(initialCenterPoint, 13);
        map.setCenter(initialCenterPoint, initialZoomLevel);

		map.addControl(new GSmallMapControl());
		map.addControl(new GScaleControl());
		map.addControl(new GMapTypeControl());
		map.addControl(new GOverviewMapControl());
		
		map.enableScrollWheelZoom();
	//	map.enableGoogleBar();
		
//		var mgrOptions = { borderPadding: 20, trackMarkers: false };
//		mm = new GMarkerManager(map, mgrOptions);
		
		window.setTimeout(setup_MarkerManager, 1000);
		
//		GEvent.addListener(map, "moveend", function(){ add_props();} );

      }
    }
