function drawSelectionMarkers()
{
	//alert(selectedProperty.length);
	//selectedListingMarkers = new Array(0);
	clearSelectionMarkers();
	//alert("drawSelectionMarkers(): " + selectedProperty.length);
	for(var i=0; i<selectedProperty.length; i++)
	{
		//alert(selectedProperty[i][1]);
		var lng = selectedProperty[i][1];
		var lat = selectedProperty[i][2];
		
		//alert(lng + ":" + lat);
		
		icon = new GIcon();
		var tmp = String(i + 42);
		var letter = num_to_str(tmp);

		//icon_url = "/maps/markers/marker" + letter + ".png";
		icon_url = "genMarker.php?text=" + letter;
		
		icon.image = icon_url;	
		icon.iconSize = new GSize(20, 34);
		icon.iconSize = new GSize(20, 34);
		icon.shadowSize = new GSize(0, 0);
		icon.iconAnchor = new GPoint(9, 34);
		icon.infoWindowAnchor = new GPoint(10, 17);		
				
		selectedListingMarkers[i] = new GMarker(new GPoint(lng, lat), icon);
		map.addOverlay(selectedListingMarkers[i]);
		
		GEvent.addListener(selectedListingMarkers[i], "click", function() {
			selectedListingMarkers[i].openInfoWindowHtml(selectedProperty[i][0]);
		});
	}

}

function clearSelectionMarkers()
{

	for(var i=0; i<selectedProperty.length; i++)
	{
		map.removeOverlay(selectedListingMarkers[i]);
	}
	
	if(arguments[0] == true)
	{
		selectedProperty = new Array(0);
	}
}

function clearLastSelection()
{
	map.removeOverlay(selectedListingMarkers[selectedProperty.length-1]);
	selectedProperty.pop();
}

	
function getSelectionHTML(info, letter)
{
	//icon_url = "/maps/markers/marker" + letter + ".png";
	icon_url = "/maps/genMarker.php?text=" + letter;
	var html ="<table border=0 width='100%'><tr><td width='20%' align='center'><img src='" + icon_url + "'></td>";
	html += "<td width='80%' align='center'>";
 		var prop_address = "<div id='the_address'><font size='1'><b>" + info[1] + "<br>" + info[2] + "</b>";
	var mls_address = info[1] + ", " + info[2];
	prop_address += "<BR>" + info[3] + "</font>";
	var mlsOpenWindow = "window.open(\"http://uticaromerealtor.localhost/search/SearchQuick.php?mlsnum=" + info[0] + "\");";
	//var view_mls = "<br><div onclick='" + mlsOpenWindow + "'  style=\"cursor: hand\"><font size='1' color='blue'>View Listing</font></div></div>";

	html = html + prop_address+ "</td></tr></table>";

 		return html;
}

function getLocationHTML()
{
	//icon_url = "/maps/markers/marker" + letter + ".png";
	icon_url = "/maps/genMarker.php?text=*&color='#4C87E0'";
	var html ="<table border=0 bgcolor='#4C87E0' width='100%'><tr><td width='20%' align='center'><img src='" + icon_url + "'></td>";
	html += "<td width='80%' align='center'> <font size='2'>You are here";

	html = html + "</font></td></tr></table>";

 	return html;
}
	
function num_to_str(num_out) {
	str_out = "";
	if(num_out == "") 
		alert(e)
	else {
		for(i = 0; i < num_out.length; i += 2) {
			num_in = parseInt(num_out.substr(i,[2])) + 23;
			num_in = unescape('%' + num_in.toString(16));
			str_out += num_in;
		}
   }   
   return str_out;
}

function isSelected(array, listing)
{
	var selected = false;
	
	for(var i=0; i<array.length; i++)
	{
		if(array[i][0]==listing)
		{
			selected = true;
			return selected;
		}
	}	
	
	return selected;
}