	 var marker=[];
	 var pointili=[];
	  var map;
	 var xc=0;
	 var Thetour=false;
	 



function dothshow(xx,yy,zz,mt,opts){
	map.addOverlay(createMarker(new GLatLng(xx,yy),zz,mt,opts))
	}

function createMarker(point, texti,typ,opts) {
	var marker = new GMarker(point,opts);
    
	GEvent.addListener(marker, "click", function() {
	marker.openInfoWindowHtml(unescape(texti));
  });
	GEvent.addListener(marker, "mouseover", function() {
  	});
  	GEvent.addListener(marker, "mouseout", function() {
  	});
	return marker;
}

function tour(){
Thetour=true;
	if (startp!=0){
	polyline= new GPolyline(eval(poly),"#ff0000",4);
	map.addOverlay(polyline);
	
	document.getElementById("bit_tour_info").innerHTML+='<br />Entfernung: '+(parseInt(polyline.getLength())/1000).toFixed(1)+"km";
	}
	else{
		polyline= new GPolyline(new Array(),"#ff0000",4);
		map.addOverlay(polyline);
		
		}
	if (pal){
		polyline.enableEditing();
		GEvent.addListener(polyline,"click",function(bin){
  // Remove all polylines before drawing the shorter path
   map.removeOverlay(polyline);
   
  // Find out removed marker
  pointili = new Array();
  var mP="";
  var ylat=bin.lat();
	var ylng=bin.lng();
  for(var n = 0; n < polyline.getVertexCount(); n++) {
	mP=polyline.getVertex(n);
	var xlat=mP.lat();
	var xlng=mP.lng();
	
	//alert("mP lat= "+mP.lat()+" mP lng= "+mP.lng()+" / bin lat= "+bin.lat()+"bin lng= "+bin.lng())
	//break;
  
   if((xlat==ylat) && (xlng==ylng)) {
    map.removeOverlay(mP);
	   alert(bin+" - "+mP);


  //  break;
   }
   else{
   
   	pointili.push(mP);
	}
  }
 var npl = new GPolyline(pointili, "#ff1100", 4);
  map.addOverlay(npl);
  npl.enableEditing();
   alert("vorher: "+ polyline.getVertexCount() + " nachher "+ npl.getVertexCount())


			})
		}
	polyline.geodesic=1;
	icon();
	bounds = polyline.getBounds();
	map.setZoom(map.getBoundsZoomLevel(bounds));
	map.setCenter(bounds.getCenter());
	showPOI();
	}

	
function gm_uebertragen(){
	if (!pal) return(false);
	anz=polyline.getVertexCount();
	//hier nochmal prüfen, ob evtl andere Polyline zu verwenden ist!
	document.getElementById("points").value="";
	for (x=0;x<anz;x++){
		document.getElementById("points").value+=polyline.getVertex(x)+"##";
		}
	document.getElementById("UTForm").submit();
	}
	
function gm_reset(){
	if (!pal) return(false);
	map.clearOverlays();
	poly=new Array();
	polyline= new GPolyline(poly,"#ff0000",4);
	map.addOverlay(polyline);
	polyline.enableDrawing();
	//polyline.disableEditing();
	}
	
function showPOI(){
	//gehe die punkte durch durch
	bounds = new GLatLngBounds;
	for (xx in poi){
		pts=poi[xx].split('###');
		xy=pts[0].split(",");
		point=new GLatLng(xy[0],xy[1]);
		bounds.extend(point);
		markerOpts={icon:eval("ico_"+pts[1])};
		map.addOverlay(createMarker(point,pts[2],2,markerOpts))
		}
	if (!Thetour){
		map.setZoom(map.getBoundsZoomLevel(bounds));
		map.setCenter(bounds.getCenter());
		}
	}
	
	
	
	
