
function addMarkerToArray(myMarkersArray, i, googleMapPositionFromDb, html, sTranslationDirections, sTranslationToHere, imageurl, DealerId)
{
	latitude = googleMapPositionFromDb.substring(0, googleMapPositionFromDb.indexOf(","));
	longitude = googleMapPositionFromDb.substring(googleMapPositionFromDb.indexOf(",")+1);
	
	var myLatitudeLongitude = new GLatLng(latitude, longitude);
	var objMarker = new GMarker(myLatitudeLongitude, { icon: getDealerIcon(imageurl) });

	if (sTranslationDirections == undefined) { sTranslationDirections = 'Directions:'; }
	if (sTranslationToHere == undefined) { sTranslationToHere = 'To here'; }

	html = html + "<br />" + sTranslationDirections + " <a href='javascript:getDirections(" + i + ")'>" +  sTranslationToHere + "</a>"; 
	
	GEvent.addListener(objMarker, "click", function() {
		objMarker.openInfoWindowHtml(html);
    });
	
    GEvent.addListener(objMarker, "mouseover", function() {
    	var Item = document.getElementById("DealerId-" + DealerId);
        if (Item != null) { Item.className = Item.className + " dealer-box-hover"; }
    });
    GEvent.addListener(objMarker, "mouseout", function() {
        var Item = document.getElementById("DealerId-" + DealerId);
        if (Item != null) { Item.className  = Item.className.replace("dealer-box-hover", ""); }
    });
	
	//add to array
	myMarkersArray[i] = objMarker;

	bounds.extend(myLatitudeLongitude);
	if (i >= 1) {
	    map.setZoom(map.getBoundsZoomLevel(bounds));
	} else {
	    map.setZoom(15);
	}
	map.setCenter(bounds.getCenter());
}

function getDealerIcon(imageurl) {
    if (imageurl == null) { imageurl = "/images/dealers/giantglobe.png"; }
	var icon = new GIcon();
	icon.image = imageurl;
	icon.iconAnchor = new GPoint(0, 16);
	icon.infoWindowAnchor = new GPoint(16, 0);
	icon.iconSize = new GSize(32, 32);
	icon.shadow = "/images/dealers/shadow.png";
	icon.shadowSize = new GSize(59, 32);
	return icon;
}
 

