	/***** MAKING THE DRAGGABLE MARKER *****************************************************/
	
	var mobileMarkerArray = [];
	
	function mobileMarker(toggle) {  //this function turns on or off the marker
    	if (toggle == "Show Marker") {
    		if (document.getElementById("latbox").getAttribute("value")) {
    			var ctrLat = document.getElementById("latbox").getAttribute("value");
    		} else {
	    		var ctrLat = document.getElementById("map").getAttribute("ctrlat");
	    		$('#latbox').attr('value', ctrLat);
			}
    		if (document.getElementById("lngbox").getAttribute("value")) {
    			var ctrLng = document.getElementById("lngbox").getAttribute("value");
			} else {
	    		var ctrLng = document.getElementById("map").getAttribute("ctrlng");
	    		$('#lngbox').attr('value', ctrLng);
			}
    		var center = new GLatLng(ctrLat, ctrLng);
    		var mobileMarker = createMobileMarker(center);
    		mobileMarkerArray[0] = mobileMarker;
    		mgr.addMarkers(mobileMarkerArray, 1, 6);
    		document.getElementById("markerButton").value = "Remove Marker";
    		document.getElementById("latbox").setAttribute("disabled","disabled");
    		document.getElementById("lngbox").setAttribute("disabled","disabled");
    		$("#map").attr('marker', 'true');
    		mgr.refresh();
   		 } else {
   		 	mgr.removeMarker(mobileMarkerArray[0]);
   		 	document.getElementById("markerButton").value = "Show Marker";
   		 	document.getElementById("latbox").removeAttribute("disabled");
    		document.getElementById("lngbox").removeAttribute("disabled");
    		$('#map').removeAttr('marker');
   		 	mgr.refresh();
   		 }//if toggle == Add Marker
    } //mobileMarker

	function createMobileMarker(position) {  //makes the marker
		var marker = new GMarker (position, {draggable:true});
		GEvent.addListener(marker, 'dragend', function() { updateLatLng(marker) } );
		return marker;
	} //createMobileMarker
	
	function updateLatLng(marker) { //sends new latlng to the form when the marker
									//is dropped
		var markerPos = marker.getLatLng();
		$('#latbox').attr('value',parseFloat(markerPos.lat()));
		$('#lngbox').attr('value',parseFloat(markerPos.lng()));
	} //updateLatLng
	
	/***** END MAKING THE DRAGGABLE MARKER *************************************************/

function makeIcons() {
	var icons = [];
	icons[0] = [];
	icons[1] = [];
	$.get("catxml.php", function(data){
		$(data).find('cat').each(function(){
			var newIcon = new GIcon();
			var imgurl = $(this).attr("imgurl");
			var catID = $(this).attr("catID");
			//alert ("New ICON: "+catID+" at: "+imgurl);
			newIcon.image = "/climate/icons/20x20/"+imgurl;
			newIcon.shadow = '/climate/icons/shadow.png';
			newIcon.iconSize = new GSize(20, 20);
			newIcon.shadowSize = new GSize(27, 22);
			newIcon.iconAnchor = new GPoint(10, 10);
			newIcon.infoWindowAnchor = new GPoint(14, 14);
			icons[0][catID] = newIcon;
			
			var newBigIcon = new GIcon();
			newBigIcon.image = "/climate/icons/40x40/"+imgurl;
			newBigIcon.shadow = '/climate/icons/shadow.png';
			newBigIcon.iconSize = new GSize(40,40);
			newBigIcon.shadowSize = new GSize(54,44);
			newBigIcon.iconAnchor = new GPoint(20, 20);
			newBigIcon.infoWindowAnchor = new GPoint(28, 28);
			icons[1][catID] = newBigIcon;
		});
	});
	return icons;
} //makeIcons

/*
var iconBlue = new GIcon(); 
iconBlue.image = 'http://labs.google.com/ridefinder/images/mm_20_blue.png';
iconBlue.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png';
iconBlue.iconSize = new GSize(12, 20);
iconBlue.shadowSize = new GSize(22, 20);
iconBlue.iconAnchor = new GPoint(6, 20);
iconBlue.infoWindowAnchor = new GPoint(5, 1);

var iconRed = new GIcon(); 
iconRed.image = 'http://labs.google.com/ridefinder/images/mm_20_red.png';
iconRed.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png';
iconRed.iconSize = new GSize(12, 20);
iconRed.shadowSize = new GSize(22, 20);
iconRed.iconAnchor = new GPoint(6, 20);
iconRed.infoWindowAnchor = new GPoint(5, 1);
*/
var icons = [];
icons = makeIcons();
/*icons["restaurant"] = iconBlue;
icons["bar"] = iconRed;*/
//alert (icons);

function parseMapData(data) {
	var markerData = new Array();
	$(data).find('point').each(function() {
		var thisMarker = new Array();
		thisMarker['pointID'] = $(this).attr("pointID");
		thisMarker['title'] = $(this).attr("title");
		thisMarker['description'] = $(this).attr("description");
		thisMarker['place'] = $(this).attr("place");
		thisMarker['lat'] = $(this).attr("lat");
		thisMarker['lng'] = $(this).attr("lng");
		thisMarker['refurl'] = $(this).attr("refurl");
		thisMarker['catID'] = parseFloat($(this).attr("catID"));
		thisMarker['category'] = $(this).attr("category");
		thisMarker['user'] = $(this).attr("user");
		thisMarker['date_created'] = $(this).attr("date_created");
		thisMarker['date_modified'] = $(this).attr("date_modified");
		thisMarker['last_editor'] = $(this).attr("last_editor");
		markerData.push(thisMarker);
	}); //pointArray 
	return markerData;
} //parseMapData
	
function createMap() {
	if (GBrowserIsCompatible()) {
		//make a map object in the map div
		var map = new GMap2(document.getElementById("map"));
        	
		//add map controls
        map.addControl(new GSmallMapControl());
        //map.addControl(new GMapTypeControl());
        //map.enableScrollWheelZoom();
        map.enableContinuousZoom();
			
		//set the center
        map.setCenter(new GLatLng(39, -100), 3); //the US and environs
        
        //invoke the marker manager
        mgr = new MarkerManager(map, {trackMarkers:true});
        	
        //restrict zoom
        var mapTypes = map.getMapTypes();
        for (var i=0; i<mapTypes.length; i++) {
        	mapTypes[i].getMinimumResolution = function() {return 1;}
        	mapTypes[i].getMaximumResolution = function() {return 6;}
        } //for mapTypes
        return map;	
	} //if GBrowser...
	
} //createMap
	
function populateMap(pointArray, bigmap) {
	$("#loading").show();
	var markerArray = new Array();
	var bigMarkerArray = new Array();
	for(var i=0; i<pointArray.length; i++) {
		var newMarker = createMarker(pointArray[i], 0, bigmap);
		markerArray.push(newMarker);
		var newBigMarker = createMarker(pointArray[i], 1, bigmap);
		bigMarkerArray.push(newBigMarker);
	} //for pointArray
	mgr.addMarkers(markerArray, 1, 5);
	mgr.addMarkers(bigMarkerArray, 6, 7);
	mgr.refresh();
	$("#loading").hide();
} //populateMap

function createMarker(thisMarker, iconSize, bigmap){
	var point = new GLatLng(parseFloat(thisMarker['lat']),
							parseFloat(thisMarker['lng']));
	var catID = thisMarker['catID'];
	var marker = new GMarker(point, icons[iconSize][catID]);
	var html = "<b>" + thisMarker['title'] + "</b>";
	if(bigmap) {html = html + "<br/>" + thisMarker['description']};
	html = html + "<br/>" + thisMarker['refurl'] /*+"<br/>"+thisMarker['category'] */;
	if (!bigmap) {var maxWide = 250} else {var maxWide = 400 };
	GEvent.addListener(marker, 'click', function() {
		marker.openInfoWindowHtml(html, {maxWidth: maxWide});
	});
	return marker; 
}
