var ICONTYPE_EF    = "ef";
var ICONTYPE_PLACE = "place";
var ICONTYPE_BOTH  = "gruenrot";
var ICONTYPE_EMPTY = "empty"; // leeres Icon fuer den Anlege-Prozess
var ICONSIZE_SMALL = "klein";
var ICONSIZE_BIG   = "gross";
var GSIZE_SMALL  = new GSize(26, 26);
var GSIZE_BIG    = new GSize(32, 36);

//var ZOOMLEVEL_CHANGE_MARKER		 = 13; // ab diesem Zoomlevel ï¿½ndert sich das grosse Placemark-Icon in das kleine
//var ZOOMLEVEL_CENTER_ON_MAP		 = 17; // Zoomlevel beim Klick auf "Center on Map"

// [1] und [2]: beide Werte GLEICH erhoehen!!
var GPOINT_ANCHOR_SMALL    = new GPoint(13, 20); // das Kreuz: (-links/+rechts ; -oben/+unten) [2]
var GPOINT_ANCHOR_BIG      = new GPoint(20, 32); // das Kreuz: (-links/+rechts ; -oben/+unten) [1]
var GPOINT_DRAGCROSS_SMALL = new GPoint(9, 7);   // das Objekt: (-links/+rechts ; -oben/+unten) [2]
var GPOINT_DRAGCROSS_BIG   = new GPoint(9, 7);   // das Objekt: (-links/+rechts ; -oben/+unten) [1]

var GPOINT_INFOWA_SMALL = new GPoint(14, 6);
var GPOINT_INFOWA_BIG   = new GPoint(25, 6);

// Info-Window fuer den Anlege-Prozess
var GPOINT_INFOWA_SMALL_EX = new GPoint(14, -20); // (-links/+rechts ; -oben/+unten)
var GPOINT_INFOWA_BIG_EX   = new GPoint(22, -20); // (-links/+rechts ; -oben/+unten)

// TODO: die 4 wichtigsten Icons werden global gespeichert
var ICON_EF_SMALL;
var ICON_EF_BIG;
var ICON_PLACE_SMALL;
var ICON_PLACE_BIG;

var image_dir  = global.IMG_URL;
var addToEF = image_dir + "img-nontext/icons/e_gruen_kl.png";
var addToMyEF = image_dir + "img-nontext/icons/add_to_e.png";
var addToSetImage = image_dir + "img-nontext/icons/add_to_set.png";
var showDetailsImage = image_dir + "img-nontext/icons/details.png";
var zoomCenterImage = image_dir + "img-nontext/icons/show_on_map.gif";
var placeZoomCenterImage = image_dir + "img-nontext/icons/place_show_on_map.gif";

var GOOGLE_STYLE = "<style type=\"text/css\">"+
"a:link { font-weight:bold; color:#0099cf; text-decoration:none; }"+
"a:visited { font-weight:bold; color:#0099cf; text-decoration:none; }"+
"a:focus { font-weight:bold; color:#0099cf; text-decoration:underline; }"+
"a:hover { font-weight:bold; color:#6dc067; text-decoration:underline; }"+
"a:active { font-weight:bold; color:#0099cf; text-decoration:underline; }"+
"</style>";

var EF_STYLE = "<style type=\"text/css\">"+
"a:link { font-weight:bold; color:#0099cf; text-decoration:none; }"+
"a:visited { font-weight:bold; color:#0099cf; text-decoration:none; }"+
"a:focus { font-weight:bold; color:#0099cf; text-decoration:underline; }"+
"a:hover { font-weight:bold; color:#ec5e20; text-decoration:underline; }"+
"a:active { font-weight:bold; color:#0099cf; text-decoration:underline; }"+
"</style>";

//var timeOverlay = false; //daniel brauch ich fuer die MapOverlays, wenn man mit der Maus ueber einen ef - Marker geht
//var showOverlay = false; //daniel brauch ich fuer die MapOverlays, wenn man mit der Maus ueber einen ef - Marker geht
//var overlayVisible = false; //daniel brauch ich fuer die MapOverlays, wenn man mit der Maus ueber einen ef - Marker geht
//var IamVisible = false;
//var overlayMouseOver  = false; //daniel brauch ich fuer die MapOverlays, wenn man mit der Maus ueber einen ef - Marker geht
// daniel 
// eine eigene Classe in der die Suchewerte gespeichert werden sollen wenn eine
// suche ABGESENDET wird
//
//ARNO 16.10.
//var test = false;
MapSearchSaver = function (){
	this.search1 = "";
	this.search2 = "";
	this.searchLat1 = 0;
	this.searchLat2 = 0;
	this.searchLng1 = 0;
	this.searchLng2 = 0;
	this.searchFilter = "";
	this.searchFrom = 1;
	this.searchMax = global.PAGINATION_STEP_EARTHFAVES;
	this.searchListId = "";
	this.searchAutoZoom = false;
	this.searchZoom = 2;
	this.searchIgnoreSearch1 = false;
	this.searchIgnoreSearch2 = false;
	this.searchQuadrantSearch = true;
}

// d aniel
// uebertragen der werte in die Map
MapSearchSaver.prototype.transferToMap = function(mapi){
	mapi.search1 = this.search1;
	mapi.search2= this.search2;
	mapi.searchLat1 = this.searchLat1;
	mapi.searchLat2 = this.searchLat2;
	mapi.searchLng1 = this.searchLng1;
	mapi.searchLng2 = this.searchLng2;
	mapi.searchFilter = this.searchFilter;
	mapi.searchFrom = this.searchFrom;
	mapi.searchMax = this.searchMax;
	mapi.searchListId = this.searchListId;
	mapi.searchAutoZoom = this.searchAutoZoom;
	mapi.searchIgnoreSearch1 = this.searchIgnoreSearch1;
	mapi.searchIgnoreSearch2 = this.searchIgnoreSearch2;
	mapi.searchQuadrantSearch = this.searchQuadrantSearch;	
	}

// daniel
// speichere die daten im saver
MapSearchSaver.prototype.transferMapSaver = function(mapi){
	this.search1 = mapi.search1;
	this.search2 = mapi.search2;
	this.searchLat1 = mapi.searchLat1;
	
	this.searchLat2 = mapi.searchLat2;
	this.searchLng1 = mapi.searchLng1;
	this.searchLng2 = mapi.searchLng2;
	this.searchFilter = mapi.searchFilter;
	this.searchFrom = mapi.searchFrom;
	this.searchMax = mapi.searchMax;
	this.searchListId = mapi.searchListId;
	this.searchAutoZoom = mapi.searchAutoZoom;
	this.searchIgnoreSearch1 = mapi.searchIgnoreSearch1;
	this.searchIgnoreSearch2 = mapi.searchIgnoreSearch2;
	this.searchQuadrantSearch = mapi.searchQuadrantSearch;
	}




/**
 *	Die abstrakte Klasse Map und ihre Methoden.
 *  Die Funktionalitaeten muessen durch eine "reale" Map-Klasse realsiert werden.
 *
 */



/**
 * Konstruktor
 */
MapProvider = function(realMap, domElement)
{
	this.id = "";
	this.realMap = realMap;
	this.domElement = domElement;
	this.earthfaves = new Array();
	this.aktivePageEarthfavesIdArray = new Array();
	this.aktivePageEarthfavesSearch = false;
	this.aktivePageEarthfavesSearchMax = global.AKTIVE_PAGE_EARTHFAVE_SEARCH_MAX;
	this.aktivePageEarthfavesMarkerArray = new Array(); // brauchen wir wohl nicht -> ext.js paginationsEarthfavesLookupCallback
	this.aktivePageEarthfavesCounter = 0;
	
	this.places = new Array();
	this.manualyCreatedPlace = false; // benoetigt, wenn man von hand ein ein ef anlegen will. "true" bedeuted das in "ext.js" in der mapMoved() , bzw showMarkerOnMap(), beim wechsel von kleinen auf großen ef-icons, das clearOverlays() ignoriert wird.
	this.markerArray = new Array();
	this.clusterArray = new Array();
	this.clusterSearch = false; // suche nicht nach clustern
	this.showEarthfavesAllwaysOnMap = false; // sollen die efs der Rliste IMMER auf der Map angezeigt werden (auch bei cluster)
	this.clusterCounter = 0;
	this.tempEarthfave = null;
	this.tempPlace = null;
	this.tempMarker = null;		// Hier merken wir uns den temporären Marker, der beim manuellen Erzeugen eines earthfaves verzeugt wird
	this.markerCounter = 0;
	
	this.lastSearchOverall = 0; // wieviele efs wurden bei der letzten suche gefunden
	this.lastSearchMy = 0; // wieviele efs wurden von mir gefunden
	this.lastSearchFriends = 0; // wieviele efs wurden von freunden gefunden
	this.lastSearchFF = 0; // wieviele efs wurden von freundesfrunenden gefunden
	this.lastSearchOther = 0; // wieviele efs wurden von anderen gefunden
	
	this.zoomlevelCenterOnMap = 17; // Zoomlevel beim Klick auf "Center on Map"
	this.zoomlevelMerker = 17; // Zoomlevel merken siehe mapMove in ext.js
	
	this.ignoreNextMove = false;	// Wenn "true", wird das naechste Move-Event ignoriert
	this.ignoreMove = false;	// Wenn "true", wird jeder Move-Event ignoriert
	this.globalIgnoreMove = false;	// Wenn "true", wird jeder Move-Event ignoriert
	this.globalCallerOfMapMove = ""; // hier soll stehen, wer verantwortlich ist, dass mapMove aufgerufen wird
	this.resultList = null // wird mit einem String gefuellt.
	this.bottomLeftLong = null;
	this.bottomLeftLat = null;
	this.shiftPress = false; // die taste Shift wird grade gedrueckt gehalten
	this.overlaysCleared = false;
	this.googleCallback  = false; // sie wurde schon ausgefuehrt
	this.earthfavesCallback  = false; // sie wurde schon ausgefuehrt
	this.clusterCallback  = false;// sie wurde schon ausgefuehrt
	this.earthfavesFilterArray = new Array(); // wird mit den ids der Kategorien gefuellt die man mittels checkbox im Bereich earthfaves auswaehlt.
	this.historyBackArray = new Array(); // wenn ich zb auf die erste Sektion (my disc) efs geklickt hat und dann zurueck zur gesamtliste will
	this.fillHistoryBackArray = true; // erklaube das fuellen des arrays
	this.historyBackExecuted = false; // es wurde auf back geklickt 
	this.fixZoom = null; // wenn ich den zoom erzwingen will in der pointCallback der getPoint
	// einige der wichtigen suchparamteter einer Suche merke ich mir in dem MapObjekt. Andere suchparameter sind oben schon definiert
	
	this.search1 = "";
	this.search2 = "";
	this.searchLat1 = null;
	this.searchLat2 = null;
	this.searchLng1 = null;
	this.searchLng2 = null;
	this.searchFilter = "";
	this.searchFrom = 1;
	this.searchCountry = "";
	this.searchMax = global.PAGINATION_STEP_EARTHFAVES;
	this.searchListId = "result-list";
	this.searchAutoZoom = false;
	this.searchZoom = this.realMap.getZoom();
	this.searchIgnoreSearch1 = false;
	this.searchIgnoreSearch2 = false;
	this.searchQuadrantSearch = true;
	this.searchNearby = 0;
	// in der UiProvider -> lookupEarthfaves ist das Land und region kriterium mit OR eingebunden.
	// steht hier searchForcedRegion = "country" dann ist land AND eingebunden, steht searchForcedRegion = "region" ist region AND eingebunden
	this.searchForcedRegion = ""; 
	// das ist die Id von einem Land oder von einer Region je nachdem was in searchForcedRegion steht
	this.searchForcedRegionId = 0; 
	this.searchRedundanceData = 0; // sollen in den Sectionen redundanzen angezeigt werden. Also ist ein Ef in mehreren Seks gleichzeitig
	
	
}


MapProvider.prototype.setCenter = function(point, zoomLevel)
{
	if (! zoomLevel) {
		zoomLevel = this.zoomlevelCenterOnMap;
	}
	try {
		this.realMap.setCenter(point, zoomLevel);
	}
	catch (e) {
		alert("Map instance:\nerror while setting the  center: " + e.message);
	}
}

/*
MapProvider.prototype.setBounds = function(bounds)
{
	try {
		this.realMap.setBounds(bounds);
	}
	catch (e) {
		alert("Map instance:\nerror while setting bounds: " + e.message);
	}
}
*/

MapProvider.prototype.getCenter = function()
{
	try {
		return this.realMap.getCenter();
	}
	catch (e) {
	alert("Map instance:\nerror while getting center: " + e.message);
	return false; // daniel
	}
}


MapProvider.prototype.getBounds = function()
{
	try {
		return this.realMap.getBounds();
	}
	catch (e) {
		alert("Map i(nstance:\nerror while getting bounds: " + e.message);
	}
}

//daniel
//task hilft mir um zu entscheiden, was passiert, wenn man auf einen cluster klickt
MapProvider.prototype.addOverlay = function (marker,task,pos) 
{
	//info("MapProvider.prototype.addOverlay ANFANG:::");
 var das = this;
	try {
		if( task == "cluster" ) {
		 
			var cluster = marker.entity; // das ist der cluster
			this.realMap.addOverlay(marker.realMarker);
			
			GEvent.addListener(marker.realMarker, "click", function() {
					//Map.ignoreNextMove = true;//daniel			
						var center = new GLatLng(cluster.latCenter, cluster.lngCenter);
						var zoom = das.realMap.getZoom();
						var bounds = new GLatLngBounds(new GLatLng(cluster.lat1, cluster.lng1), new GLatLng(cluster.lat2, cluster.lng2));
						var zoomneu = das.realMap.getBoundsZoomLevel(bounds);
						das.realMap.setCenter(center, zoomneu);
						//info("MapProvider.prototype.addOverlay ich bin ein cluster id" + cluster.id + " zoom " + zoom + " zoomneu: " + zoomneu);
			});
			
			GEvent.addListener(marker.realMarker, "mouseover", function() {	
				if ( cluster.countEfs <= 2 ) {	
				 var efInfo = "";
				 //for ( i = 0; i < cluster.cluster_ef_id.length; i++){ efids += cluster.cluster_ef_id[i] + " "; } 
				 for ( i = 0; i < cluster.cluster_ef_array.length; i++){
					 var findeEf = findClusterEfInRList(das,cluster.cluster_ef_array[i].id);
					 if(!findeEf){// in einem 2er Cluster koennte ich einen ef rausgezogen haben. Nur der darf angezeigt werden in myTip
						 efInfo += '<b>' + cluster.cluster_ef_array[i].name + '</b><br>(' + cluster.cluster_ef_array[i].country;
						 if( cluster.cluster_ef_array[i].city != ""){ efInfo += ' > ' + cluster.cluster_ef_array[i].city; }
						 efInfo += ')<br>Discoverer:' + cluster.cluster_ef_array[i].discoverer + '<br>'; 
						 efInfo += (1 + parseInt(cluster.cluster_ef_array[i].bookmarker)) + ' love this place ';
						 efInfo += '<br><br>';
					 }
					}
				 myTip("Click to zoom to<br><br>" + efInfo); }
				 else {
					 myTip("In Cluster " + cluster.id + "  you found " + cluster.countEfs + " earthfaves. Click to zoom in.");
					 
				 }
				  var bounds = new GLatLngBounds(new GLatLng(cluster.lat1, cluster.lng1), new GLatLng(cluster.lat2, cluster.lng2));
					var zoomneu = das.realMap.getBoundsZoomLevel(bounds);
					var zoom = das.realMap.getZoom();
					info("MapProvider.prototype.addOverlay zoom " + zoom + " zoomneu: " + zoomneu); 
				});
			GEvent.addListener(marker.realMarker, "mouseout", function() {	UnTip(); }); 
			
	
			
		}
		else if( task == "paginationMarker"){ // die kleinen rotel quaudtrate
			var pMarker = marker.entity; // das ist der cluster
			this.realMap.addOverlay(marker.realMarker);
			
			GEvent.addListener(marker.realMarker, "click", function() {
					//Map.ignoreNextMove = true;//daniel			
						var center = new GLatLng(pMarker.lat, pMarker.lng);
						var zoom = das.realMap.getZoom();
						//var bounds = new GLatLngBounds(new GLatLng(cluster.lat1, cluster.lng1), new GLatLng(cluster.lat2, cluster.lng2));
						var zoomneu = zoom + 1;
						das.realMap.setCenter(center, zoomneu);
			});
//Arno Anfang===============================		
			GEvent.addListener(marker.realMarker, "mouseover", function() {
				 init_mousemove();
				 das.timerShowPaginationOverlay(pos, marker.entity.id);
				});
			GEvent.addListener(marker.realMarker, "mouseout", function() {	
						das.setEarthfaveOverlayVisible(false); 
						das.setEarthfaveOverlayInvisibleTimer(400); 	
						clearTimeout(activ);
			}); 
		
		}
		// Overlay für Places
			else if( task == "place"){// earthfaves auf der Karte
			 var obj = marker.entity; 
			this.realMap.addOverlay(marker.realMarker);
			 
				GEvent.addListener(marker.realMarker, "click", function() {
				//	Map.ignoreNextMove = true;
				//	marker.realMarker.openInfoWindowHtml(marker.entity.asMarker(marker.id));
				});
				GEvent.addListener(marker.realMarker, "mouseover", function() {
					setEarthfaveOverlayInvisible(isVisible);
					init_mousemove();
					das.timerShowPlaceOverlay(pos);//blende den overlay erst nach x sek ein
					});
				GEvent.addListener(marker.realMarker, "mouseout", function() {
						das.setPlaceOverlayVisible(false); 
						das.setPlaceOverlayInvisibleTimer(400); 
						clearTimeout(activ);   //Arno: verhindert das aufpoppen, wenn der Mauszeiger nur kurz über das ef fährt					
				}); 
		}
		
		else {// earthfaves auf der Karte
			 var obj = marker.entity; 
			this.realMap.addOverlay(marker.realMarker);
			 
				GEvent.addListener(marker.realMarker, "click", function() {
				//	Map.ignoreNextMove = true;
				//	marker.realMarker.openInfoWindowHtml(marker.entity.asMarker(marker.id));
				});
				GEvent.addListener(marker.realMarker, "mouseover", function() {
					setPlaceOverlayInvisible(isVisible);
					init_mousemove();
					das.timerShowEarthfaveOverlay(pos);//blende den overlay erst nach x sek ein
					});
				GEvent.addListener(marker.realMarker, "mouseout", function() {
						das.setEarthfaveOverlayVisible(false); 
						das.setEarthfaveOverlayInvisibleTimer(400); 
						clearTimeout(activ);   //Arno: verhindert das aufpoppen, wenn der Mauszeiger nur kurz über das ef fährt					
				}); 
		}
	}
	catch (e) {
		info("Map instance:\nerror while adding marker as overlay: " + e.message);	
	}
}
// Arno: Koordinaten der Kartenränder.
var latLeft; 
var lngLeft;
var latRight;
var lngRight;
MapProvider.prototype.timerShowPaginationOverlay = function (i, j){
var das = this;
activ = setTimeout("Map.showPaginationOverlay( " + i + "," +j+ " )",400);
setEarthfaveOverlayVisible(true);
return;
}
MapProvider.prototype.timerShowPlaceOverlay = function (i){
var das = this;
activ = setTimeout("Map.showPlaceOverlay( " + i + ")",400);
setPlaceOverlayVisible(true);
return;
}

MapProvider.prototype.timerShowEarthfaveOverlay = function (i){
		var das = this;
		activ = setTimeout('Map.showEarthfaveOverlay( "' + i + '" )',400);
		setEarthfaveOverlayVisible(true);
		latLeft = Map.getBounds().getSouthWest().lat();
		lngLeft = Map.getBounds().getSouthWest().lng();
		latRight = Map.getBounds().getNorthEast().lat();
		lngRight = Map.getBounds().getNorthEast().lng();

		return;
}

MapProvider.prototype.setEarthfaveOverlayInvisibleTimer = function(time) {
setTimeout('setEarthfaveOverlayInvisible(isVisible)',time);
}

MapProvider.prototype.setEarthfaveOverlayInvisible = function (i) {
if (i == false)
document.getElementById('earthfaveInformation-pop-up').style.display = "none";
}

MapProvider.prototype.setEarthfaveOverlayVisible = function (i) {
isVisible = i;
}

MapProvider.prototype.setPlaceOverlayInvisibleTimer = function(time) {
setTimeout('setPlaceOverlayInvisible(isVisible)',time);
}

MapProvider.prototype.setPlaceOverlayInvisible = function (i) {
if (i == false)
document.getElementById('placeInformation-pop-up').style.display = "none";
}

MapProvider.prototype.setPlaceOverlayVisible = function (i) {
isVisible = i;
}

MapProvider.prototype.showPaginationOverlay = function (pos, id){
		info("ObjektPagi: pos: " + pos);
		info("ObjektPagi: id: " + id);

		if(document.getElementById('earthfaveInformation-pop-up'))
		{
			getPaginationMarkerOverviewContent(id);
			doc.onmouseover = function(){				
			}
			doc.onmouseout = function(){				
			}
			showForm2("earthfaveInformation","");
		}
		else 
		{
			info("mapProvider.js showPaginationOverlay -> earthfaveInformation-pop-up gibt es nicht");	
		}
}
MapProvider.prototype.showPlaceOverlay = function (i){
		var objekt = this.places[i];
		info("Objekt: Lat: " + objekt.lat);
		info("Objekt: Lng: " + objekt.lng);	
		info("Objekt: id: " + i);	
		if(document.getElementById('placeInformation-pop-up'))
		{
		var strNeu = "";
			var doc = document.getElementById('placeInformation-pop-up');
			var strNeu = "<table  style= 'padding:0px; margin:0px; height: 100px; width: 367px; overflow:none; padding:0px; margin:0px;' onmouseover='setPlaceOverlayVisible(true);'  onmouseout = 'setPlaceOverlayVisible(false); setPlaceOverlayInvisibleTimer(10)' >";	
			//var strNeu = "<table style= 'padding:0px; margin:0px; height: 150px; width: 345px; overflow:none; padding:0px; margin:0px;' onmouseover='setEarthfaveOverlayVisible(true);'>";	
			strNeu += objekt.asPlaceEntry(i);
			strNeu += '</table>';
			//info("mapProvider.js strNeu = " + strNeu);	
			doc.innerHTML = strNeu;
			doc.onmouseover = function(){				
			}
			doc.onmouseout = function(){				
			}
			showForm4("placeInformation","");
		}
		else 
		{
			info("mapProvider.js showPalceOverlay -> placeInformation-pop-up gibt es nicht");	
		}
}

MapProvider.prototype.showEarthfaveOverlay = function (i){
		var objekt = this.earthfaves[i];
		info("Objekt: Lat: " + objekt.lat);
		info("Objekt: Lng: " + objekt.lng);	
		info("Objekt: id: " + i);	
		
		if(document.getElementById('earthfaveInformation-pop-up'))
		{
		var strNeu = "";
			var doc = document.getElementById('earthfaveInformation-pop-up');
			var strNeu = "<table  style= 'padding:0px; margin:0px; height: 150px; width: 345px; overflow:none; padding:0px; margin:0px;' onmouseover='setEarthfaveOverlayVisible(true);'  onmouseout = 'setEarthfaveOverlayVisible(false); setEarthfaveOverlayInvisibleTimer(10);' >";	
			//var strNeu = "<table style= 'padding:0px; margin:0px; height: 150px; width: 345px; overflow:none; padding:0px; margin:0px;' onmouseover='setEarthfaveOverlayVisible(true);'>";	
			strNeu += objekt.asPopupEntry(i);
			strNeu += '</table>';
			//info("mapProvider.js strNeu = " + strNeu);	
			doc.innerHTML = strNeu;
			doc.onmouseover = function(){				
			}
			doc.onmouseout = function(){				
			}
			showForm2("earthfaveInformation","");
		}
		else 
		{
			info("mapProvider.js showEarthfaveOverlay -> earthfaveInformation-pop-up gibt es nicht");	
		}
}
//Arno ENDE===============================
MapProvider.prototype.orderOfCreation = function(id){
	/*
	var ret;
	if(what == "ef"){ 
	ret =  -281240; // + pos; 
	
	}
	if(what == "cluster"){
	//	ret =  pos;
	ret = -1;
	}
	info("MapProvider.prototype.orderOfCreation zIndexProcess zindex: " + ret);	
	return ret;
	*/
	return 1;
}



MapProvider.prototype.clearOverlays = function ()
{
	try {
		info("MapProvider.prototype.clearOverlays");
		this.realMap.clearOverlays();
		
	}
	catch (e) {
		alert("Map instance:\nerror while clearing overlays: " + e.message);
	}
}


MapProvider.prototype.show = function ()
{
	try {
		this.domElement.style.display = "block";
	}
	catch (e) {
		alert("Map instance:\nerror while showing map: " + e.message);
	}
}


MapProvider.prototype.hide = function ()
{
	try {
		this.domElement.style.display = "none";
	}
	catch (e) {
		alert("Map instance:\nerror while hiding map: " + e.message);
	}
}


MapProvider.prototype.centerMarker = function (lat, lng) 
{
/*for(var a = 0; a < this.markerArray.length; a++) {
	if(this.markerArray[a]){
	
	console.log("Ich bin ", this.markerArray[a]);
	//var entity = this.markerArray[a].entity;
	}
	//info("Meine Id a: " +a+" ist "+ entity.id );
	}*/
	this.realMap.closeInfoWindow();
//info("marker id:" + markerId + "laenge: " + this.markerArray.length);

//	var ef = this.markerArray[markerId].entity;
	//this.setCenter(new GLatLng(objekt.lat, objekt.lng));
this.setCenter(new GLatLng(lat, lng));
	if (window.pageYOffset > 106) {
		window.scrollTo(0, 106);
	}
	/*
	//logm("markerArray.length = " + markerArray.length);
	for (var i = 0; i < this.markerArray.length; i++) {
		//logm("markerArray[i]['ID']="+markerArray[i]["ID"]+" hat den Namen " + markerArray[i]["NAME"]);

		if (id >= 0) {
			if (markerArray[i]["ID"] == id) {
				// EARTHFAVES: ID gefunden

				//logm("EF-ID gefunden!!! " + markerArray[i]["GLATLNG"] + "; " + markerArray[i]["NAME"]);

				if (window.pageYOffset > 106) {
					window.scrollTo(0, 106);
				}
				map.setCenter(markerArray[i]["GLATLNG"], ZOOMLEVEL_CENTER_ON_MAP);
				var divInfofeld = "<div class=\"infofield\">"+ markerArray[i]["INFOFIELD"] + "</div>";
				markerArray[i]["MARKER_BIG"].openInfoWindowHtml(divInfofeld);
				foundElement = true;
				break;
			}
		}
		else {
			if (markerArray[i]["GLATLNG"].lat() == lat && markerArray[i]["GLATLNG"].lng() == lng) {
				// PLACE: Kooridnaten gefunden
				if (window.pageYOffset > 106)
					window.scrollTo(0, 106);
				map.setCenter(markerArray[i]["GLATLNG"], ZOOMLEVEL_CENTER_ON_MAP);
				var divInfofeld = "<div class=\"infofield\">"+ markerArray[i]["INFOFIELD"] + "</div>";
				markerArray[i]["MARKER_BIG"].openInfoWindowHtml(divInfofeld);
				foundElement = true;
				break;
			}
		}
	}
	*/

	//logm("zoome an lat="+lat+"; lng="+lng);
	//map.setCenter(new GLatLng(lat,lng), ZOOMLEVEL_CENTER_ON_MAP);
}


MapProvider.prototype.createIcon = function (type, number, size, category, rel){
	//daniel: category nur bei efs
	//var size = (parseInt(zoomLevel) < 13) ? ICONSIZE_SMALL : ICONSIZE_BIG;

//	var type = entity.getType();
	var gicon = new GIcon();
	//info("createMarker on Map. type: " + type +  " size: " + size + " categorie " + category);
	if (type == ICONTYPE_EMPTY) {	
		//info('MapProvider.prototype.createIcon IF ');
		gicon.image = image_dir + "img-nontext/icons/1_" + type + "_" + size + ".png";
	}
	// Empty-Icon gibt es nur fï¿½r Anzahl = 1
	else {
		//info('MapProvider.prototype.createIcon ELSE ');
		var numberInt = parseInt(number);
		if (numberInt > 10) {		gicon.image = image_dir + "img-nontext/icons/10plus_" + type + "_" + size + ".png";		}
		else {
			//info('MapProvider.prototype.createIcon ELSE category ist: ' + category + " rel ist " + rel + " user " + global.user_id);
			
			if( global.user_id == "1"){
					if(category > 0){	
						gicon.image = image_dir + "img-nontext/icons/category_" + category + "_" + size + "_" + rel + ".png";	
					}
					else {
						gicon.image = image_dir + "img-nontext/icons/" + number + "_" + type + "_" + size  + ".png";
					}
				//gicon.image = image_dir + "img-nontext/icons/" + number + "_" + type + "_" + size  + ".png";
			}
			else {
				if(size == "klein"){ // derzeit nur cat-icons fuer die kleine 
						if(category > 0){	
							gicon.image = image_dir + "img-nontext/icons/category_" + category + "_" + size + "_" + rel + ".png";	
							//else { gicon.image = image_dir + "img-nontext/icons/" + number + "_" + type + "_" + size  + ".png"; }
						
						}
						else {gicon.image = image_dir + "img-nontext/icons/" + number + "_" + type + "_" + size  + ".png";	}
				}
				else {//gross
						if(category > 0){
							gicon.image = image_dir + "img-nontext/icons/category_" + category + "_" + size +"_" + rel + ".png";	
							//else { gicon.image = image_dir + "img-nontext/icons/" + number + "_" + type + "_" + size  + ".png"; }
						
						}
						else {gicon.image = image_dir + "img-nontext/icons/" + number + "_" + type + "_" + size  + ".png";	}
				}
			}
		}
	}
	//info('&&&&&&&&&&&&&&&&& MapProvider.prototype.createIcon icon ist  ' + gicon.image);
	// Schatten des Icons
	//gicon.shadow = image_dir + "img-nontext/icons/shadow_" + size + ".png";

	// Groessen von Icon und Schatten
	gicon.iconSize         = (size == ICONSIZE_SMALL) ? GSIZE_SMALL : GSIZE_BIG;
	//gicon.shadowSize       = (size == ICONSIZE_SMALL) ? GSIZE_SMALL : GSIZE_BIG; schatten weg
	gicon.iconAnchor       = (size == ICONSIZE_SMALL) ? GPOINT_ANCHOR_SMALL : GPOINT_ANCHOR_BIG;
	gicon.dragCrossAnchor  = (size == ICONSIZE_SMALL) ? GPOINT_DRAGCROSS_SMALL : GPOINT_DRAGCROSS_BIG;

	if (type == ICONTYPE_EMPTY) {
		//ACHTUNG: da man das Icon im Anlege-Prozess nicht so gut verschieben kann, wurde die Sprechblase absichtlich um 20px nach oben verschoben
		gicon.infoWindowAnchor = (size == ICONSIZE_SMALL) ? GPOINT_INFOWA_SMALL_EX : GPOINT_INFOWA_BIG_EX;
	}
	else {	gicon.infoWindowAnchor = (size == ICONSIZE_SMALL) ? GPOINT_INFOWA_SMALL : GPOINT_INFOWA_BIG;	}

	return gicon;
}

/** Erstellt die Ladeanzeige ueber der Karte
 * 	
 */

MapProvider.prototype.showMapLoaderAnimation = function(){
	
	if(document.getElementById('mapLoader')){
		var mapLoader = document.getElementById('mapLoader');
    if (mapLoader) {
			//mapLoader.style.display = 'block';
			//mapLoader.style.zIndex = 10;
		}
	}
	if(	document.getElementById('result-animation')){
		document.getElementById('result-animation').innerHTML = '<img src="' + global.IMG_URL_NONTEXT + 'teaser/progress-kreis-rot.gif"/>'
	}
	
	if(	document.getElementById('mapAnimationsLoader')){
		document.getElementById('mapAnimationsLoader').innerHTML = '<img src="' + global.IMG_URL_NONTEXT + 'teaser/progress-kreis-rot.gif"/>'
	}
	
	
}
/** macht die Ladeanzeige ueber der Karte unsichtbar
 * 	
 */
MapProvider.prototype.hideMapLoaderAnimation = function(){
	if(document.getElementById('mapLoader')){
		var mapLoader = document.getElementById('mapLoader');
    if (mapLoader) {
		//	mapLoader.style.display = 'none';
			//mapLoader.style.zIndex = 10;
		}
	}
	if(	document.getElementById('result-animation')){
		document.getElementById('result-animation').innerHTML = "";
	}
	if(	document.getElementById('mapAnimationsLoader')){
		document.getElementById('mapAnimationsLoader').innerHTML = '';
	}
	
}
/** Erstellt einen Marker und versieht diesen mit einem Icon und einem Beschreibungstext
 * 	@param: entity Place or Earthfave Die Entity, fuer die der Marker erzeugt werden soll
 */
MapProvider.prototype.createMarker = function (entity)
{
	//info("MapProvider.prototype.createMarker anfang......");
	var showDetailsImage = image_dir + "img-nontext/icons/details.png";
	var options = new Object();
	//options.icon = this.createIcon(entity.getType(), 1, ICONSIZE_BIG);
	var sizeMarker;
	//info("Erzeuge Marker fuer Object. Map.zoom: " + this.realMap.getZoom() + " kleines Icon bis Zoom " + ZOOMLEVEL_CHANGE_MARKER);
	if( isNaN(this.realMap.getZoom()) ||  parseInt(this.realMap.getZoom()) < global.ZOOMLEVEL_CHANGE_MARKER ){ sizeMarker = ICONSIZE_SMALL; }
	else { sizeMarker = ICONSIZE_BIG  ; }
	// die Reihenfolge MUSS So bleiben ::::::::
	/*::*/ var efRelation = "other"; 
	/*::*/ if(entity.numberBookmarkingFF > 0 ) { efRelation = "ff"; }
	/*::*/ if(entity.numberBookmarkingFriends > 0 ) { efRelation = "friend"; }
	/*::*/ if (entity.relationship == 2 || entity.relationship == 3 ){ efRelation = "my"; } // ich habe den ef angelegt oder gebooket
	/*::::::::::*/

	
	options.icon = this.createIcon(entity.getType(), 1, sizeMarker, entity.catId0, efRelation); // daniel 2009 11 17
	//var newIcon = this.createIcon(entity.getType(), 1, sizeMarker);//
	//info("MapProvider.prototype.orderOfCreation zindex: ef " + options.zIndexProcess);	
	
	var point = new GLatLng(entity.lat, entity.lng);
	
	
	//var googleMarker = new GMarker(point, {icon: newIcon,zIndexProcess:1});//,zIndexProcess:zI
	var googleMarker = new GMarker(point, {icon: options.icon,zIndexProcess:function() { return 1; }});//,zIndexProcess:zI
	//var googleMarker = new GMarker(point, {icon: newIcon});//,zIndexProcess:zI
	//var googleMarker = new  GMarker(point,newIcon,{zIndexProcess:1}); 
	//var googleMarker = new GMarker(point, options);

	GEvent.addListener(googleMarker, "mouseover", function() {	});

	GEvent.addListener(googleMarker, "mouseout", function() {	}); 

	GEvent.addListener(googleMarker, "click", function() {
	//	googleMarker.openInfoWindowHtml(entity.asMarker());

	//	GEvent.addListener(googleMarker, "infowindowclose", function() {
		//});
	});

	GEvent.addListener(googleMarker, "infowindowopen", function() {
		GEvent.addListener(googleMarker, "infowindowclose", function() {
		});
	});


	var marker =  new Marker(this.markerCounter, entity, googleMarker);
	this.markerArray[this.markerCounter++] = marker;

	return marker;
}
//ARNO ANFANG=========================================================
MapProvider.prototype.createPlace = function() 
{
	position = this.getCenter();
	var map = Application.getActiveMap();
	map.places = new Array();
				
	var options = new Object();
	options.draggable = true;
	options.icon = this.createIcon(ICONTYPE_EMPTY, 1, 
			(parseInt(this.realMap.getZoom()) < global.ZOOMLEVEL_CHANGE_MARKER) ? ICONSIZE_SMALL : ICONSIZE_BIG);

	options.zIndexProcess = function() { return 1; }
	info("MapProvider.prototype.orderOfCreation zindex: ef " + options.zIndexProcess);	
	//var tempMarker = new GMarker(position, {icon: options.icon,zIndexProcess:function() { return 1; }});//,zIndexProcess:zI

	this.tempMarker = new GMarker(position, options);//,zIndexProcess:zI
	
	var place = new Place(
				0,
				this.tempMarker.getPoint().lat(),
				this.tempMarker.getPoint().lng(),
				"",
				"",
				"",
				"",
				"",
				"");
		//map.places.push(place);

	//this.tempMarker = new GMarker(position, options);
//	var googleMarker = new GMarker(point, {icon: newIcon,zIndexProcess:zI});

	var marker =  new Marker(100000,place, this.tempMarker);
	this.realMap.addOverlay(marker.realMarker, "place", position);
	var that = this;
	this.tempMarker.openInfoWindowHtml(this.generateNirvanaInfo(this.tempMarker.getPoint().lat(), this.tempMarker.getPoint().lng(), map.realMap.getZoom()));
	// Das Folgende ist etwas tricky, damit hier im Event-Listener keine konkrete Map stehen muß
	//eval("var f = function() { Application.get('" + this.id + "').realMap.closeInfoWindow(); }");
	GEvent.addListener(this.tempMarker, "dragstart", function(){
	});
	//GEvent.addListener(this.tempMarker, "dragstart", function() {
	//	Map.realMap.closeInfoWindow();
	//});

	// Das Folgende ist etwas tricky, damit hier im Event-Listener keine konkrete Map stehen muß
	//eval("var f = function() { var map = Application.get('" + this.id + "'); map.tempMarker.openInfoWindowHtml(map.generateNirvanaInfo(map.tempMarker.getPoint().lat(), map.tempMarker.getPoint().lng())); }"); 
	GEvent.addListener(marker.realMarker, "click", function(){
			marker.realMarker.openInfoWindowHtml(that.generateNirvanaInfo(marker.realMarker.getPoint().lat(), marker.realMarker.getPoint().lng(), map.realMap.getZoom()));
		//that.tempMarker.openInfoWindowHtml(that.generateNirvanaInfo(that.tempMarker.getPoint().lat(), that.tempMarker.getPoint().lng(), map.places[0].id));
	});
//	GEvent.addListener(this.tempMarker, "dragend", function() {
//		Map.tempMarker.openInfoWindowHtml(Map.generateNirvanaInfo(Map.tempMarker.getPoint().lat(), Map.tempMarker.getPoint().lng()));
//	});

	// Das Folgende ist etwas tricky, damit hier im Event-Listener keine konkrete Map stehen muß
	//eval("var f = function() { var map = Application.get('" + this.id + "'); map.tempMarker.openInfoWindowHtml(map.generateNirvanaInfo(map.tempMarker.getPoint().lat(), map.tempMarker.getPoint().lng())); }");
	/*GEvent.addListener(this.tempMarker, "click", function(){
		info("hallo click");
	});*/
	GEvent.addListener(marker.realMarker, "dragend", function() { // overlay soll bei dragend neu erzeugt werden
					marker.realMarker.openInfoWindowHtml(that.generateNirvanaInfo(marker.realMarker.getPoint().lat(), marker.realMarker.getPoint().lng(), map.realMap.getZoom()));
			});
//	GEvent.addListener(this.tempMarker, "click", function() {
//		Map.tempMarker.openInfoWindowHtml(Map.generateNirvanaInfo(Map.tempMarker.getPoint().lat(), Map.tempMarker.getPoint().lng()));
//	});
}
//ARNO ENDE=============================================

MapProvider.prototype.createPaginationMarker = function (Obj)
{
	//info("MapProvider.prototype.createPaginationMarker ANFANG);
	var point = new GLatLng(Obj.lat, Obj.lng);
	var iconOptions = {};
	iconOptions.primaryColor = "f15b26";//#f15b26
	//iconOptions.shape = "roundrect";
	iconOptions.strokeColor = "f15b26";
	var groesse = 25;
	iconOptions.width = 10;
	iconOptions.height = 10;
	iconOptions.label = "";
	iconOptions.addStar = false;

	//info("MapProvider.prototype.createPaginationMarker erzeuge createPaginationMarker");

	var newIcon = MapIconMaker.createFlatIcon(iconOptions);
	var googleMarker = new GMarker(point, {icon: newIcon,zIndexProcess:function() { return -1000; }});//,zIndexProcess:zI
	GEvent.addListener(googleMarker, "mouseover", function() {});
	GEvent.addListener(googleMarker, "mouseout", function() {}); 
/*
	GEvent.addListener(googleMarker, "click", function() {
		googleMarker.openInfoWindowHtml(entity.asMarker());

		GEvent.addListener(googleMarker, "infowindowclose", function() {
		});
	});

	GEvent.addListener(googleMarker, "infowindowopen", function() {
		GEvent.addListener(googleMarker, "infowindowclose", function() {
		});
	});
*/
	var PMarker =  new PaginationMarker(this.clusterCounter, Obj, googleMarker);
	//this.clusterArray[this.clusterCounter++] = cluster;
	//info("MapProvider.prototype.createClusterMarker ENDE ");
	return PMarker;
}



MapProvider.prototype.createClusterMarker = function (clusterObj)
{
	//info("MapProvider.prototype.createClusterMarker ANFANG " + clusterObj.latCenter + " " + clusterObj.lngCenter);
	var point = new GLatLng(clusterObj.latCenter, clusterObj.lngCenter);
	
	var iconOptions = {};
	iconOptions.primaryColor = "ffffff";//#f15b26
	iconOptions.strokeColor = "f15b26";
	iconOptions.label = String(clusterObj.countEfs);
	var groesse = 25;
	var add = 5;
	
	if(parseInt(clusterObj.countEfs) > 10){ groesse += add;}
	if(parseInt(clusterObj.countEfs) > 20){ groesse += add;}	
	if(parseInt(clusterObj.countEfs) > 30){ groesse += add;}
	if(parseInt(clusterObj.countEfs) > 50){ groesse += add;}
	if(parseInt(clusterObj.countEfs) > 100){groesse += add;}
	if(parseInt(clusterObj.countEfs) > 200){groesse += add + 5;}
	if(parseInt(clusterObj.countEfs) > 300){groesse += add + 5;}
	
	iconOptions.width = groesse;
	iconOptions.height = groesse;
	iconOptions.labelColor = "#f15b26";
	iconOptions.shape = "roundrect";
		
	if( clusterObj.countEfs == 1) {
		iconOptions.labelColor = "#ffffff";
		iconOptions.primaryColor = "#f15b26";//#f15b26
		iconOptions.width = 12;
		iconOptions.height = 12;
		iconOptions.label = "";
	}
	
	iconOptions.addStar = false;
	//info("MapProvider.prototype.createClusterMarker vor der erzeugung 3 " + clusterObj.countEfs);
	info("MapProvider.prototype.createClusterMarker erzeuge cluster marker");
	//var newIcon = MapIconMaker.createFlatIcon({addStar: true, label: "10", primaryColor: "#f15b26"});
	var newIcon = MapIconMaker.createFlatIcon(iconOptions);
	var googleMarker = new GMarker(point, {icon: newIcon,zIndexProcess:function() { return -10000000; }});//,zIndexProcess:zI

	//daniel test...

	GEvent.addListener(googleMarker, "mouseover", function() {});

	GEvent.addListener(googleMarker, "mouseout", function() {}); 
/*
	GEvent.addListener(googleMarker, "click", function() {
		googleMarker.openInfoWindowHtml(entity.asMarker());

		GEvent.addListener(googleMarker, "infowindowclose", function() {
		});
	});

	GEvent.addListener(googleMarker, "infowindowopen", function() {
		GEvent.addListener(googleMarker, "infowindowclose", function() {
		});
	});
*/
	var cluster =  new Cluster(this.clusterCounter, clusterObj, googleMarker);
	//this.clusterArray[this.clusterCounter++] = cluster;
	//info("MapProvider.prototype.createClusterMarker ENDE ");
	return cluster;
}


/**
 *	Die abstrakte Klasse Marker und ihre Methoden.
 *  Die Funktionalitaeten muessen durch eine "reale" Marker-Klasse realsiert werden.
 *  Die Implementierung dieser realen Klasse haengt von der Implementierung der Karte ab.
 *
 */


/**
 * Konstruktor
 */
// marker --
Marker = function (id, entity, realMarker)
{
	this.id = id;
	this.entity = entity;
	this.realMarker = realMarker;
}

Cluster = function (id, entity, realMarker)
{
	this.id = id;
	this.entity = entity; // ein cluster
	this.realMarker = realMarker;
}

PaginationMarker = function (id, entity, realMarker)
{
	this.id = id;
	this.entity = entity;
	this.realMarker = realMarker;
}

/**
 * Zeigt einen Placemark zum Anlegen eines neuen earthfaves in der Mitte der Karte an
 */
MapProvider.prototype.placemark = function(position) 
{
	info("ID");info(this.id)
	// Alten placemark loeschen
	if (this.tempMarker) {
		this.realMap.removeOverlay(this.tempMarker);
		this.tempMarker = null;
	}

//	info("Erzeuge Marker fÃ¼r neuen EF");
	
	if (! position) {
		position = this.getCenter();
	}

	var options = new Object();
	options.icon = this.createIcon(ICONTYPE_EMPTY, 1, 
			(parseInt(this.realMap.getZoom()) < global.ZOOMLEVEL_CHANGE_MARKER) ? ICONSIZE_SMALL : ICONSIZE_BIG);
	options.draggable = true;

	//options.zIndexProcess = function() { return 1; }
	info("MapProvider.prototype.orderOfCreation zindex: ef " + options.zIndexProcess);	
	var tempMarker = new GMarker(position, {icon: options.icon,zIndexProcess:function() { return 1; }});//,zIndexProcess:zI

	//this.tempMarker = new GMarker(position, options);
//	var googleMarker = new GMarker(point, {icon: newIcon,zIndexProcess:zI});
	this.realMap.addOverlay(this.tempMarker);

	this.tempMarker.openInfoWindowHtml(this.generateNirvanaInfo(this.tempMarker.getPoint().lat(), this.tempMarker.getPoint().lng()));
	
	// Das Folgende ist etwas tricky, damit hier im Event-Listener keine konkrete Map stehen muß
	eval("var f = function() { Application.get('" + this.id + "').realMap.closeInfoWindow(); }");
	GEvent.addListener(this.tempMarker, "dragstart", f);
	//GEvent.addListener(this.tempMarker, "dragstart", function() {
	//	Map.realMap.closeInfoWindow();
	//});

	// Das Folgende ist etwas tricky, damit hier im Event-Listener keine konkrete Map stehen muß
	eval("var f = function() { var map = Application.get('" + this.id + "'); map.tempMarker.openInfoWindowHtml(map.generateNirvanaInfo(map.tempMarker.getPoint().lat(), map.tempMarker.getPoint().lng())); }");
	GEvent.addListener(this.tempMarker, "dragend", f);
//	GEvent.addListener(this.tempMarker, "dragend", function() {
//		Map.tempMarker.openInfoWindowHtml(Map.generateNirvanaInfo(Map.tempMarker.getPoint().lat(), Map.tempMarker.getPoint().lng()));
//	});

	// Das Folgende ist etwas tricky, damit hier im Event-Listener keine konkrete Map stehen muß
	eval("var f = function() { var map = Application.get('" + this.id + "'); map.tempMarker.openInfoWindowHtml(map.generateNirvanaInfo(map.tempMarker.getPoint().lat(), map.tempMarker.getPoint().lng())); }");
	GEvent.addListener(this.tempMarker, "click", f);
//	GEvent.addListener(this.tempMarker, "click", function() {
//		Map.tempMarker.openInfoWindowHtml(Map.generateNirvanaInfo(Map.tempMarker.getPoint().lat(), Map.tempMarker.getPoint().lng()));
//	});
}


/*
Generiert ein HTML-Feld
- Link: Hinzufuegen zu EF
*/
MapProvider.prototype.generateNirvanaInfo = function(lat, lng, zoomLevel)
{
	info("generateNirvanaInfo......bin drin: ");
	info("generateNirvanaInfo......: " + zoomLevel);
	var text = "You can drag this marker to your favorite location.<br>Click the underneath button to make this place an earthfave<br>";
	var tableBegin = "<table border=\"0\">";
	if(zoomLevel < global.zoomlevelAllowingCreatingEf){
		var linkToAdd = "<tr>"+
		//  				"<td align=\"left\" valign=\"middle\"><a href=\"#\" onclick=\"showAddWizard('" + lat + "','" + lng +"');\"><img src="+addToEF+" /></a></td>"+
		"<td align=\"left\" valign=\"middle\"><a href=\"#\" onclick=\"zoomInToCreateNewEarthfave(" + zoomLevel + ");\"><img src=\"" + addToEF + "\" /></a></td>"+
		//  				"<td align=\"left\" valign=\"middle\"><a href=\"#\" onclick=\"showAddEarthFaveOverlay('" + markerId + "','" + lat + "','" + lng +"');\">add as earthfave</a></td>"+
		"<td align=\"left\" valign=\"middle\"><a href=\"#\" onclick=\"zoomInToCreateNewEarthfave(" + zoomLevel + ");\">zoom to add new earthfave</a></td>"+
		"</tr>";
	}
	else{
		var linkToAdd = "<tr>"+
		//  				"<td align=\"left\" valign=\"middle\"><a href=\"#\" onclick=\"showAddWizard('" + lat + "','" + lng +"');\"><img src="+addToEF+" /></a></td>"+
		"<td align=\"left\" valign=\"middle\"><a href=\"#\" onclick=\"showAddEarthFaveOverlay('no', '" + lat + "','" + lng +"');\"><img src=\"" + addToEF + "\" /></a></td>"+
		//  				"<td align=\"left\" valign=\"middle\"><a href=\"#\" onclick=\"showAddEarthFaveOverlay('" + markerId + "','" + lat + "','" + lng +"');\">add as earthfave</a></td>"+
		"<td align=\"left\" valign=\"middle\"><a href=\"#\" onclick=\"showAddEarthFaveOverlay('no', '" + lat + "','" + lng +"');\">add as earthfave</a></td>"+
		"</tr>";
	}
	var tableEnd = "</table>";

	return GOOGLE_STYLE + text + tableBegin + linkToAdd + tableEnd + GOOGLE_STYLE;
}


MapProvider.prototype.fillMapBackArray = function(){
	
	//var suche1 = global.search1;
	//var suche2 = global.search2;
	var zoom = this.realMap.getZoom();
	var center = this.getCenter();
	
	if( this.historyBackArray.length > 0 ) {
		var alt = this.historyBackArray[( this.historyBackArray.length - 1 )];
		if ( alt[0] == zoom && alt[1] == center ) {
			info ("ext.js fillMapBackArray selbe stelle...schreibe NICHT in array");
	//		return ; 
		
		}
	}
		
	var x = new Array();
	x.push(zoom,center);
	this.historyBackArray.push(x);
	info ("ext.js fillMapBackArray suche1: " + global.search1 + " suche2: " + global.search2);
	//if( console ){ console.log("array bei MapProvider.prototype.fillMapBackArray laenge: " + this.historyBackArray.length + " inhalt " , x); }
}


ClusterProvider = function(obj)
{
	this.id = obj.cluster_id;
	this.zeile = obj.cluster_zeile;
	this.spalte = obj.cluster_spalte;
	this.lat1 = obj.cluster_lat1;
	this.lng1 = obj.cluster_lng1;
	this.lat2 = obj.cluster_lat2;
	this.lng2 = obj.cluster_lng2;
	this.latCenter = obj.cluster_latCenter;
	this.lngCenter = obj.cluster_lngCenter;
	this.countEfs =  parseInt(obj.cluster_number_of_earthfaves);	
	//this.cluster_ef_id = obj.cluster_ef_id;
	this.cluster_ef_array = obj.cluster_ef_array;
}

PaginationMarkerProvider = function(obj)
{
	this.id = obj.id;
	this.lat = obj.lat;
	this.lng = obj.lng;
	this.name = obj.name;
}



ClusterProvider.prototype.orderOfCreation = function(){
	var ret;
	/*if(what == "ef"){ 
	ret =  -281240; // + pos; 
	
	}
	if(what == "cluster"){
	//	ret =  pos;
	ret = -1;
	}
	info("MapProvider.prototype.orderOfCreation zIndexProcess zindex: " + ret);	
	*/
	return -1000000;
}
