// JScript File
 //<![CDATA[
var map;
 
function load()
{
    if (GBrowserIsCompatible()) 
	{	 
	    var mapDiv = document.getElementById("map");
	    if(mapDiv == null)
	        return;
        map = new GMap2(document.getElementById("map"));
      
  	    //Adding Controls
	    map.addControl(new GSmallMapControl()); 
	    //map.addControl(new GMapTypeControl());
	    map.addControl(new GOverviewMapControl);
    
    	map.setCenter(new GLatLng(latitude, longitude), 14);
        
        if(text.length>0)
        {
            //Pin Pointing a particular location with given latitude and longitude
            var point = new GLatLng(latitude,longitude);
            var orginalContactMarker = new GMarker(point);
            map.addOverlay(orginalContactMarker); 
            orginalContactMarker.openInfoWindow(text);
            GEvent.addListener
            (map, "click", function(marker, point)
                {
                    if (marker) 
                    {   
                        marker.openInfoWindow(text);
                    }
                 }
             );   
        } 
        try
        {  
        //var markers=[];
        
        //var mgr = new GMarkerManager(map);
        //alert('test1');
        showFeaturedDealers(); 
	//alert('featureddealer');
        showPartnerDealers();
        showAdditionalDealers(); 
        
        //mgr.addMarkers(markers,10);    
        //mgr.refresh();
        } catch(err)
        {
        }
	}
}

function AddFeaturedDealer(lat, lng, txt)
{
//  Create our "tiny" marker icon
//alert('test1');
    var icon = new GIcon();
    icon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
    icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
    icon.iconSize = new GSize(22, 30);
    icon.shadowSize = new GSize(22, 20);
    icon.iconAnchor = new GPoint(6, 20);
    icon.infoWindowAnchor = new GPoint(5, 1);
    var point = new GLatLng(lat, lng);
//	alert('test2');
//    markers.push(createMarker(point,icon,txt));
//mgr.addMarker(createMarker(point,icon,txt),5);
    map.addOverlay(createMarker(point,icon,txt));
//	alert(txt);
}

function AddPartnerDealer(lat, lng, txt)
{
//  Create our "tiny" marker icon
    var icon = new GIcon();
    icon.image = "http://labs.google.com/ridefinder/images/mm_20_green.png";
    icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
    icon.iconSize = new GSize(22, 30);
    icon.shadowSize = new GSize(22, 20);
    icon.iconAnchor = new GPoint(6, 20);
    icon.infoWindowAnchor = new GPoint(5, 1);
    var point = new GLatLng(lat, lng);
//    markers.push(createMarker(point,icon,txt));
    map.addOverlay(createMarker(point,icon,txt));
}

function AddAdditionalDealer(lat, lng, txt)
{
//  Create our "tiny" marker icon
    var icon = new GIcon();
    icon.image = "http://labs.google.com/ridefinder/images/mm_20_yellow.png";
    icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
    icon.iconSize = new GSize(22, 30);
    icon.shadowSize = new GSize(22, 20);
    icon.iconAnchor = new GPoint(6, 20);
    icon.infoWindowAnchor = new GPoint(5, 1);
    var point = new GLatLng(lat, lng);
//    markers.push(createMarker(point,icon,txt));
    map.addOverlay(createMarker(point,icon,txt));
}

// Creates a marker at the given point with the given number label 
function createMarker(point,icon, infoText) 
{  
    var marker = new GMarker(point,icon);  
    GEvent.addListener(marker, "click", function() 
        {    
            marker.openInfoWindowHtml(infoText);  
        }
    );  
    return marker;
}


