//<![CDATA[
	var map;
	var marker;
	var markers;
	var encodedPolyline;
	var rand = Math.floor(Math.random()*(10000-1+1))+1;
	
	function createMarker(point, text, icon) {
		
			var tinyIcon = new GIcon();
				tinyIcon.image = "/images/system/maps/" + icon;
				tinyIcon.shadow = "http://www.google.com/intl/ru_ALL/mapfiles/shadow50.png";
				tinyIcon.iconSize = new GSize(20, 34);
				tinyIcon.shadowSize = new GSize(37, 34);
				tinyIcon.iconAnchor = new GPoint(10, 30);
				tinyIcon.infoWindowAnchor = new GPoint(5, 1);
			
			// Set up our GMarkerOptions object literal
			markerOptions = { icon:tinyIcon };

			var marker = new GMarker(point, markerOptions);
			
			GEvent.addListener(marker, "click", function() {
				marker.openInfoWindowHtml(text);
			});
			
			return marker;
		}
		
	function showMarker(){
		
		$("#notation *").removeClass("active");
		var a = document.getElementById(this.id);
		$(a).addClass("active");
		
		var theLat = this.lat;
		var theLng = this.lng;
		var theDesc = this.desc;
		
		var point = new GLatLng(theLat, theLng);
		map.panTo(point);
			
			var description = theDesc.replace(/\[/g, "<");
				description = description.replace(/\]/g, ">");
			
			map.openInfoWindowHtml(point, description);
	}
	
	function showMarker2(point, desc){

		map.panTo(point);
			
			var description = desc.replace(/\[/g, "<");
				description = description.replace(/\]/g, ">");
			
			map.openInfoWindowHtml(point, description);
	}
	
	function showPath(){
		var thePolyline = this.polyline;
		var theLevels = this.levels;
		var theLat = this.lat;
		var theLng = this.lng;
		var theColor = this.color;
		var theWeight = this.weight;
		var theDesc = this.desc;
		
		if(encodedPolyline) map.removeOverlay(encodedPolyline);
			encodedPolyline = false;
		
		encodedPolyline = new GPolyline.fromEncoded({
			color: theColor,
			weight: theWeight,
			points: thePolyline,
			levels: theLevels,
			zoomFactor: 16,
			numLevels: 1
		});
		
		showMarker2(new GLatLng(theLat, theLng), theDesc);
		map.addOverlay(encodedPolyline);
	}

    $(document).ready(function(){
		if (GBrowserIsCompatible()){
			map = new GMap2(document.getElementById("map"));
			
			//map.disableDoubleClickZoom();
			//map.addControl(new GMapTypeControl());
			map.addControl(new GLargeMapControl());
			
			var center = new GLatLng(48.84551373054311, 2.3992252349853516);
				map.setCenter(center, 16);
			
			//DragMark
			/*
			var marker = new GMarker(new GLatLng(48.85333621606485, 2.3437142372131348), {draggable: true});
	
			GEvent.addListener(marker, "dragstart", function() {
			  map.closeInfoWindow();
			  });
			
			GEvent.addListener(marker, "dragend", function() {
				var strCenter=marker.getPoint();
				marker.openInfoWindowHtml("lat: " + strCenter.lat() + "<br />lng: " + strCenter.lng());
			  });
			
			map.addOverlay(marker);
			*/
			//!DragMark
			
			//---------------
			var notation = document.getElementById("notation");
			var theUl = document.createElement("ul");
			
			GDownloadUrl("/js/u_gmaps.xml?" + rand, function(data) {
	
				markers = GXml.parse(data).documentElement.getElementsByTagName("marker");
				
				var a = 0;
				  for (var i = 0; i < markers.length; i++) {
					if(markers[i].getAttribute("title")){
						var theUlLi = document.createElement("li");
							theUlLi.className = "extrahead";
						
						var theUlLiSpan = document.createElement("span");
		
						theUlLiSpan.appendChild(document.createTextNode(markers[i].getAttribute("title")));
						theUlLi.appendChild(theUlLiSpan);
						theUl.appendChild(theUlLi);
						
					} else if(markers[i].getAttribute("polyline")){
					
						var theUlLi = document.createElement("li");
						var theUlLiA = document.createElement("a");
							theUlLiA.polyline = markers[i].getAttribute("polyline");
							theUlLiA.levels = markers[i].getAttribute("levels");
							theUlLiA.lat = markers[i].getAttribute("lat");
							theUlLiA.lng = markers[i].getAttribute("lng");
							theUlLiA.color = markers[i].getAttribute("color");
							theUlLiA.weight = markers[i].getAttribute("weight");
							theUlLiA.desc = markers[i].getAttribute("desc");
							theUlLiA.onclick = showPath;
						
						theUlLiA.appendChild(document.createTextNode(markers[i].getAttribute("innertext")));
						theUlLi.appendChild(theUlLiA);
						theUl.appendChild(theUlLi);
		
					} else {
		
					var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")), parseFloat(markers[i].getAttribute("lng")));
						
						var description = markers[i].getAttribute("desc").replace(/\[/g, "<");
							description = description.replace(/\]/g, ">");
						
						map.addOverlay(createMarker(point, description, markers[i].getAttribute("icon")));
						
						
						var theUlLi = document.createElement("li");
						
						var theUlLiA = document.createElement("a");
							theUlLiA.id = "place-" + i;
							theUlLiA.lat = markers[i].getAttribute("lat");
							theUlLiA.lng = markers[i].getAttribute("lng");
							theUlLiA.desc = markers[i].getAttribute("desc");
							theUlLiA.onclick = showMarker;
						
						theUlLiA.appendChild(document.createTextNode(markers[i].getAttribute("innertext")));
						theUlLi.appendChild(theUlLiA);
						theUl.appendChild(theUlLi);
						
						a++;
					}
				 }
				
				 //notation.appendChild(theUl);		 
			});
		}
    });
//]]>
