//<![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/interface/tiso/" + 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(){
		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);
	}

    function initialize(){
		if (GBrowserIsCompatible()) {
			map = new GMap2(document.getElementById("map"));
			
			map.disableDoubleClickZoom();
			//map.addControl(new GMapTypeControl());
			
			var center = new GLatLng(50.43757520500181, 30.499870777130127);
				map.setCenter(center, 16);
			
			//var boundaries = new GLatLngBounds(new GLatLng(50.43093951378226, 30.485386848449707), new GLatLng(50.4466285869539, 30.522959232330322));
			//var mymap = new GGroundOverlay("/images/interface/tiso/maps.png", boundaries);
				//map.addOverlay(mymap);
			
			//DragMark
			/*
			var marker = new GMarker(new GLatLng(50.43568231684766, 30.492618083953857), {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 = "header";
		
						theUlLi.appendChild(document.createTextNode(markers[i].getAttribute("title")));
						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.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);		 
			});
		}
    }
//]]>