
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(12, 20);
icon.shadowSize = new GSize(22, 20);
icon.iconAnchor = new GPoint(6, 20);
icon.infoWindowAnchor = new GPoint(5, 1);

icon1 = new GIcon();
icon1.image = "http://labs.google.com/ridefinder/images/mm_20_blue.png";
icon1.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
icon1.iconSize = new GSize(12, 20);
icon1.shadowSize = new GSize(22, 20);
icon1.iconAnchor = new GPoint(6, 20);
icon1.infoWindowAnchor = new GPoint(5, 1);
	  
icon2 = new GIcon();
icon2.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
icon2.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
icon2.iconSize = new GSize(12, 20);
icon2.shadowSize = new GSize(22, 20);
icon2.iconAnchor = new GPoint(6, 20);
icon2.infoWindowAnchor = new GPoint(5, 1);	  
	  
icon3 = new GIcon();
icon3.image = "http://labs.google.com/ridefinder/images/mm_20_green.png";
icon3.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
icon3.iconSize = new GSize(12, 20);
icon3.shadowSize = new GSize(22, 20);
icon3.iconAnchor = new GPoint(6, 20);
icon3.infoWindowAnchor = new GPoint(5, 1);
	  
icon4 = new GIcon();
icon4.image = "http://labs.google.com/ridefinder/images/mm_20_purple.png";
icon4.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
icon4.iconSize = new GSize(12, 20);
icon4.shadowSize = new GSize(22, 20);
icon4.iconAnchor = new GPoint(6, 20);
icon4.infoWindowAnchor = new GPoint(5, 1);	 

function viewMap() {	
	map = new GMap2(document.getElementById("map"));
	map.addControl(new GLargeMapControl());
	map.addControl(new GMapTypeControl());
    map.setCenter(new GLatLng(38.89818, -94.82403), 4);		
	
	var t=setTimeout("loadMap()",600);
}

function loadMap() {
	var url = "http://www.fmdac.org/maptest/address.xml";
    xmlhttp=null;

    if (xmlhttp != null && xmlhttp.readyState != 0 && xmlhttp.readyState != 4) xmlhttp.abort();

    if (window.XMLHttpRequest) { 
		try { xmlhttp=new XMLHttpRequest(); }
    	catch(e) { xmlhttp=null; }
    } else if (window.ActiveXObject) {
    	try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
    	catch(e) {
    		try { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }
    	   	catch(e) { xmlhttp=null; }
    	}
    }

    if (xmlhttp) {
    	xmlhttp.open("GET",url,true);
        xmlhttp.setRequestHeader('content-type', 'text/xml'); 
        xmlhttp.onreadystatechange=function () {
		    var xml=null;
		    var html=null;
		    var myData=null;

		    if (xmlhttp.readyState==4) {
	        	if (xmlhttp.status==200) {
					xml  = xmlhttp.responseXML;

					myData = xml.documentElement.getElementsByTagName("LOC");
					for (var i = 0; i < myData.length; i++) {
						myXML[i]    = new Array();
						myXML[i][0] = myData[i].getAttribute("name");
						myXML[i][1] = myData[i].getAttribute("addr");
						myXML[i][2] = myData[i].getAttribute("phone");
						myXML[i][3] = myData[i].getAttribute("email");
						myXML[i][4] = myData[i].getAttribute("url");
						myXML[i][5] = myData[i].getAttribute("urlName");
						myXML[i][6] = i;
						myXML[i][7] = myData[i].getAttribute("color");
						
						mapit(myXML[i][0],myXML[i][1],myXML[i][2],myXML[i][3],myXML[i][4],myXML[i][5],myXML[i][6],myXML[i][7]);
					}  
		    	}     
			}      
        };
		xmlhttp.send(null);
	}
}
							
function mapit(name,addr,phone,email,url,urlName,num,color) {
	var infoHtml;
	
	infoHtml 	=   "<table><tr><td align=\'left\'>" +
					"<font color=black size=2><br>" +
					"<b>" + name + "</b><br>" +
					addr + "<br>" +
					"Phone #: " + phone + "<br><br>" +
					"Website: <a href=\'" + url + "\' target=\'_blank\'>" + urlName + "</a><br>" +
					"Email: <a href=\'mailto:" + email + "\'>" + email + "</a>" +
					"<br><br>" +
					"</td></tr></table>";	
	
	var t=setTimeout("showAddress(\""+myXML[num][1]+"\",\""+infoHtml+"\","+num+",\""+color+"\")",250 * num);
}					

function showAddress(addr,infoHtml,num,color) {
   var geocoder = new GClientGeocoder();

   if (geocoder) {
      geocoder.getLatLng(
         addr,
         function(point) {
            if (!point) {
            } else {			   


if (color=='1'){ var marker = new GMarker(point, icon1);}
else if (color=='2'){ var marker = new GMarker(point, icon2);}
else if (color=='3'){ var marker = new GMarker(point, icon3);}
else if (color=='4'){ var marker = new GMarker(point, icon4);}
else if (color=='0'){ var marker = new GMarker(point, icon);}


			   GEvent.addListener(marker, "click", function() {  	
    		      marker.openInfoWindowHtml(infoHtml);
               });		
			   map.addOverlay(marker);	 	   
            }
         }
      );
   }
}