var gmarkers=[];
var bounds = new GLatLngBounds();
var entrLength  = 0;
function initialize() {
      if (GBrowserIsCompatible()) {
		 mIcon=new Array(4);
		mIcon[0] = new Array(4);
		mIcon[0][0] = new GIcon();
		mIcon[0][0].image = "http://www.mathe-shirts.de/spreadmaps/images/mm_01.png";
		mIcon[0][0].shadow = "http://www.mathe-shirts.de/spreadmaps/images/mm_shadow.png";
		mIcon[0][0].iconSize = new GSize(12, 20);
		mIcon[0][0].shadowSize = new GSize(22, 20);
		mIcon[0][0].iconAnchor = new GPoint(6, 20);
		mIcon[0][0].infoWindowAnchor = new GPoint(5, 1);
		mIcon[0][1] = new GIcon();
		mIcon[0][1].image = "http://www.mathe-shirts.de/spreadmaps/images/mm_02.png";
		mIcon[0][1].shadow = "http://www.mathe-shirts.de/spreadmaps/images/mm_shadow.png";
		mIcon[0][1].iconSize = new GSize(12, 20);
		mIcon[0][1].shadowSize = new GSize(22, 20);
		mIcon[0][1].iconAnchor = new GPoint(6, 20);
		mIcon[0][1].infoWindowAnchor = new GPoint(5, 1);
		mIcon[0][2] = new GIcon();
		mIcon[0][2].image = "http://www.mathe-shirts.de/spreadmaps/images/mm_03.png";
		mIcon[0][2].shadow = "http://www.mathe-shirts.de/spreadmaps/images/mm_shadow.png";
		mIcon[0][2].iconSize = new GSize(12, 20);
		mIcon[0][2].shadowSize = new GSize(22, 20);
		mIcon[0][2].iconAnchor = new GPoint(6, 20);
		mIcon[0][2].infoWindowAnchor = new GPoint(5, 1);
		mIcon[0][3] = new GIcon();
		mIcon[0][3].image = "http://www.mathe-shirts.de/spreadmaps/images/mm_04.png";
		mIcon[0][3].shadow = "http://www.mathe-shirts.de/spreadmaps/images/mm_shadow.png";
		mIcon[0][3].iconSize = new GSize(12, 20);
		mIcon[0][3].shadowSize = new GSize(22, 20);
		mIcon[0][3].iconAnchor = new GPoint(6, 20);
		mIcon[0][3].infoWindowAnchor = new GPoint(5, 1);

		mIcon[1] = new Array(4);
		mIcon[1][0] = new GIcon();
		mIcon[1][0].image = "http://www.mathe-shirts.de/spreadmaps/images/mm_11.png";
		mIcon[1][0].shadow = "http://www.mathe-shirts.de/spreadmaps/images/mm_shadow.png";
		mIcon[1][0].iconSize = new GSize(12, 20);
		mIcon[1][0].shadowSize = new GSize(22, 20);
		mIcon[1][0].iconAnchor = new GPoint(6, 20);
		mIcon[1][0].infoWindowAnchor = new GPoint(5, 1);
		mIcon[1][1] = new GIcon();
		mIcon[1][1].image = "http://www.mathe-shirts.de/spreadmaps/images/mm_12.png";
		mIcon[1][1].shadow = "http://www.mathe-shirts.de/spreadmaps/images/mm_shadow.png";
		mIcon[1][1].iconSize = new GSize(12, 20);
		mIcon[1][1].shadowSize = new GSize(22, 20);
		mIcon[1][1].iconAnchor = new GPoint(6, 20);
		mIcon[1][1].infoWindowAnchor = new GPoint(5, 1);
		mIcon[1][2] = new GIcon();
		mIcon[1][2].image = "http://www.mathe-shirts.de/spreadmaps/images/mm_13.png";
		mIcon[1][2].shadow = "http://www.mathe-shirts.de/spreadmaps/images/mm_shadow.png";
		mIcon[1][2].iconSize = new GSize(12, 20);
		mIcon[1][2].shadowSize = new GSize(22, 20);
		mIcon[1][2].iconAnchor = new GPoint(6, 20);
		mIcon[1][2].infoWindowAnchor = new GPoint(5, 1);
		mIcon[1][3] = new GIcon();
		mIcon[1][3].image = "http://www.mathe-shirts.de/spreadmaps/images/mm_14.png";
		mIcon[1][3].shadow = "http://www.mathe-shirts.de/spreadmaps/images/mm_shadow.png";
		mIcon[1][3].iconSize = new GSize(12, 20);
		mIcon[1][3].shadowSize = new GSize(22, 20);
		mIcon[1][3].iconAnchor = new GPoint(6, 20);
		mIcon[1][3].infoWindowAnchor = new GPoint(5, 1);

	mIcon[2] = new Array(4);
	mIcon[2][0] = new GIcon();
	mIcon[2][0].image = "http://www.mathe-shirts.de/spreadmaps/images/mm_21.png";
	mIcon[2][0].shadow = "http://www.mathe-shirts.de/spreadmaps/images/mm_shadow.png";
	mIcon[2][0].iconSize = new GSize(12, 20);
	mIcon[2][0].shadowSize = new GSize(22, 20);
	mIcon[2][0].iconAnchor = new GPoint(6, 20);
	mIcon[2][0].infoWindowAnchor = new GPoint(5, 1);
	mIcon[2][1] = new GIcon();
	mIcon[2][1].image = "http://www.mathe-shirts.de/spreadmaps/images/mm_22.png";
	mIcon[2][1].shadow = "http://www.mathe-shirts.de/spreadmaps/images/mm_shadow.png";
	mIcon[2][1].iconSize = new GSize(12, 20);
	mIcon[2][1].shadowSize = new GSize(22, 20);
	mIcon[2][1].iconAnchor = new GPoint(6, 20);
	mIcon[2][1].infoWindowAnchor = new GPoint(5, 1);
	mIcon[2][2] = new GIcon();
	mIcon[2][2].image = "http://www.mathe-shirts.de/spreadmaps/images/mm_23.png";
	mIcon[2][2].shadow = "http://www.mathe-shirts.de/spreadmaps/images/mm_shadow.png";
	mIcon[2][2].iconSize = new GSize(12, 20);
	mIcon[2][2].shadowSize = new GSize(22, 20);
	mIcon[2][2].iconAnchor = new GPoint(6, 20);
	mIcon[2][2].infoWindowAnchor = new GPoint(5, 1);
	mIcon[2][3] = new GIcon();
	mIcon[2][3].image = "http://www.mathe-shirts.de/spreadmaps/images/mm_24.png";
	mIcon[2][3].shadow = "http://www.mathe-shirts.de/spreadmaps/images/mm_shadow.png";
	mIcon[2][3].iconSize = new GSize(12, 20);
	mIcon[2][3].shadowSize = new GSize(22, 20);
	mIcon[2][3].iconAnchor = new GPoint(6, 20);
	mIcon[2][3].infoWindowAnchor = new GPoint(5, 1);

	mIcon[3] = new Array(4);
	mIcon[3][0] = new GIcon();
	mIcon[3][0].image = "http://www.mathe-shirts.de/spreadmaps/images/mm_31.png";
	mIcon[3][0].shadow = "http://www.mathe-shirts.de/spreadmaps/images/mm_shadow.png";
	mIcon[3][0].iconSize = new GSize(12, 20);
	mIcon[3][0].shadowSize = new GSize(22, 20);
	mIcon[3][0].iconAnchor = new GPoint(6, 20);
	mIcon[3][0].infoWindowAnchor = new GPoint(5, 1);
	mIcon[3][1] = new GIcon();
	mIcon[3][1].image = "http://www.mathe-shirts.de/spreadmaps/images/mm_32.png";
	mIcon[3][1].shadow = "http://www.mathe-shirts.de/spreadmaps/images/mm_shadow.png";
	mIcon[3][1].iconSize = new GSize(12, 20);
	mIcon[3][1].shadowSize = new GSize(22, 20);
	mIcon[3][1].iconAnchor = new GPoint(6, 20);
	mIcon[3][1].infoWindowAnchor = new GPoint(5, 1);
	mIcon[3][2] = new GIcon();
	mIcon[3][2].image = "http://www.mathe-shirts.de/spreadmaps/images/mm_33.png";
	mIcon[3][2].shadow = "http://www.mathe-shirts.de/spreadmaps/images/mm_shadow.png";
	mIcon[3][2].iconSize = new GSize(12, 20);
	mIcon[3][2].shadowSize = new GSize(22, 20);
	mIcon[3][2].iconAnchor = new GPoint(6, 20);
	mIcon[3][2].infoWindowAnchor = new GPoint(5, 1);
	mIcon[3][3] = new GIcon();
	mIcon[3][3].image = "http://www.mathe-shirts.de/spreadmaps/images/mm_34.png";
	mIcon[3][3].shadow = "http://www.mathe-shirts.de/spreadmaps/images/mm_shadow.png";
	mIcon[3][3].iconSize = new GSize(12, 20);
	mIcon[3][3].shadowSize = new GSize(22, 20);
	mIcon[3][3].iconAnchor = new GPoint(6, 20);
	mIcon[3][3].infoWindowAnchor = new GPoint(5, 1);
	
				
        map = new GMap2(document.getElementById("map_canvas"));
		map.addControl(new GLargeMapControl());
        
map.setCenter(new GLatLng(51.32997143451423,12.328999042510986), 5);
        geocoder = new GClientGeocoder();
		var eurBounds = new GLatLngBounds(GLatLng(35.17380831799959, -27.421875), GLatLng(70.95969716686398, 33.75));
		geocoder.setViewport(eurBounds);

      }
    }

    function showAddress(address,myIcon,myDate,myProfit, myStatus) {
      if (geocoder) {
	
        geocoder.getLatLng(
          address,
          function(point) {
            if (!point) {
              document.getElementById('mapEc').innerHTML+=(address + " not found<br>");
			document.getElementById('maperror').style.visibility='visible';
			entrLength-=1;
            } else {
             // map.setCenter(point, 13);
				mymarkerOptions = { icon:myIcon ,title:myDate+", "+myProfit};
              var marker = new GMarker(point, mymarkerOptions);
              map.addOverlay(marker);
				gmarkers.push(marker);
				bounds.extend(point);
				marker.bindInfoWindowHtml("<div class='mnote'>"+address+"<br/>"+myProfit+"&euro;<br/>"+myDate+"<br/>"+myStatus+"</div>");
              //marker.openInfoWindowHtml(address);
				
				if ((entrLength>1)&&(gmarkers.length==entrLength)) {
				map.setZoom(map.getBoundsZoomLevel(bounds));

				map.setCenter(bounds.getCenter());}
            }
          }
        );
      }
    }

function evaluateTranscript(myString) {
	gmarkers = [];
	 bounds = new GLatLngBounds();
	
	map.clearOverlays();
	document.getElementById('mapEc').innerHTML="";
	document.getElementById('maperror').style.visibility='hidden';
	
	myStA=myString.replace(/\n+$/,'').split("\n");
	for (var i = 0; i < myStA.length; ++i) {
	  myStA[i] = myStA[i].split(";");
	}
	if (myStA[0][1]=='Land') {myStA.splice(0,1);}
	
	//document.getElementById("address").value=myStA[myStA.length-1].length;
	maxV=0;
	minV=1000000;
	for (var i = 0; i < myStA.length; ++i) {
	  
	  myStA[i][3]=myStA[i][3].replace(/[^\d]*(\d+)[,.](\d{2}).*/g,'$1.$2');
		if ((myStA[i][4].match(/in Bearbeitung.*/))||(myStA[i][4].match(/neu.*/))||(myStA[i][4].match(/.*wartet.*/))) 
		{
			myStA[i][5]= 2;
		}
			else if (myStA[i][4].match(/.*verschickt.*/)) {
				myStA[i][5] = 0;
			}
				else if (myStA[i][4].match(/.*storniert.*/)) {
					myStA[i][5] = 3;
				}
		else {
			myStA[i][5] = 1;
		}
//	  myStA[i][4]=Number(myStA[i][4].replace(/in Bearbeitung.*/,'2'));
//	  myStA[i][4]=Number(myStA[i][4].replace(/verschickt.*/,'0'));
//	  myStA[i][4]=Number(myStA[i][4].replace(/Provision gut.*/,'1'));
		thisV=Number(myStA[i][3]);
		if (thisV>maxV) maxV=thisV;	
		if (thisV<minV) minV=thisV;
	}
	Vlen=maxV-minV;
	
	pr1 = minV;
	pr2= minV+Vlen/4;
	pr3 = minV+Vlen/2;
	pr4 = minV+Vlen*3/4;
	pr5 = maxV;
	
	document.getElementById('pr01').innerHTML=pr1.toFixed(2)+" &euro; &ndash; " + pr2.toFixed(2) + " &euro;" ;
	document.getElementById('pr02').innerHTML=pr2.toFixed(2)+" &euro; &ndash; " + pr3.toFixed(2) + " &euro;" ;
	document.getElementById('pr03').innerHTML=pr3.toFixed(2)+" &euro; &ndash; " + pr4.toFixed(2) + " &euro;" ;
	document.getElementById('pr04').innerHTML=pr4.toFixed(2)+" &euro; &ndash; " + pr5.toFixed(2) + " &euro;" ;
	 entrLength  = myStA.length;
	for (var i = 0; i < myStA.length; ++i) {
		if (myStA[i][3] < minV+Vlen/4) {ind = 0;}
		else if  (myStA[i][3] < minV+Vlen/2) {ind = 1;}
		else if  (myStA[i][3] < minV+Vlen*3/4) {ind = 2;}
		else {ind = 3;}
		//ind=Math.floor((myStA[i][3]-minV)/(Vlen==0?1:Vlen)*3);
		showAddress(myStA[i][1],mIcon[myStA[i][5]][ind],myStA[i][2],myStA[i][3],myStA[i][4]);
		//document.getElementById("vl").innerHTML +="  --:"+ind;
		
	}
	
	
	
	
	//document.getElementById("address").value=Vlen;
	
	//showAddress(myStA[4][1]);
	//document.getElementById("bestellung").value=myStA[1][1]+" "+myStA[1][3];
}