//Location map functions
var user_marker;
var tinyIcon;
var tinyIcon2;

	function loadGMap($canvas, width, height, zoom, type, lat, lng) {
		if(!lat || !lng) return false;
		var map;
		if(GBrowserIsCompatible()) {
			tinyIcon = new GIcon(G_DEFAULT_ICON);
			tinyIcon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
			tinyIcon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
			tinyIcon.iconSize = new GSize(12, 20);
			tinyIcon.shadowSize = new GSize(22, 20);
			tinyIcon.iconAnchor = new GPoint(6, 20);
			tinyIcon.infoWindowAnchor = new GPoint(5, 1);

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

			var mapSize = new GSize(width,height);
			map = new GMap2($canvas, {size:mapSize, draggableCursor:"crosshair"});
			latlng = new GLatLng(lat, lng);
			map.setCenter(latlng, zoom);
			user_marker = new GMarker(latlng, {icon:tinyIcon});
			map.addOverlay(user_marker);
			map.setMapType(type);
			map.addControl(new GSmallZoomControl3D());
			map.disableDoubleClickZoom();
		}
		return map;
	};

	function getCountry(target, url, latlng, callback) {
		$.get(url, latlng, function(data) {
			var gc = data["countryName"];
			if(gc) {callback(target, gc);}
		}, "json");
	};

	function addMapListener(target, type, func) {
		GEvent.addListener(target, type, function(overlay, data) {
			if(data == undefined) return;
			func(data.lat(), data.lng());
		});
	};

	function toggleCountry(target, country) {
		var $target = $("#"+target);
		var $li = $("<li />").addClass("location").text(country);
		$li.append('<span class="btn-x2"/>');
		var $current = $target.find("li.location:first");
		if($current.length == 0) {
			$target.append($li);
		} else {
			$current.replaceWith($li);
		}
	};

	//End Location Map Functions
