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 PLACE_SIZE_SMALL  = new GSize(19, 26);
var PLACE_SIZE_BIG    = new GSize(27, 39);


var GSIZE_NIRVANA   = new GSize(32, 38);
var OVERLAY_TIMER = 400 ;
var INVISIBLE_TIMER = 8000 ;

//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 image_dir = "img_sort/" ;
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){
	console.group("::::::::::::::::::::::::MapProvider::::::::::::::::::::::");
	//alert("map");
	//this.blub = realMap.getZoom();
	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.placesGoogle = new Array();//google places
	this.placesDB = new Array(); //eigene places
	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.manualyCreatedP = false;
	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; // wohl beim booken eines efs aus einer Liste. 
	this.tempPlace = null;  // wohl bei places zb beim nirvana anlege prozess.
	this.tempMarker = null;		// Hier merken wir uns den tempor�ren Marker, der beim manuellen Erzeugen eines earthfaves erzeugt 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.lastSearchExperts = 0; // wieviele efs wurden von experten gefunden
	this.lastSearchFollow = 0; // wieviele efs wurden von usern gefunden denen ich folge
	
	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.efId = "";
	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
	this.searchPlaces = global.DB_PLACES;
	this.trustLevelClick = "none";// if someone clicks a trustlevel which trustlevel ? Sonst leer
	
	//Fabrice begin 2010.08.20
	this.priceLevel=0; 
	this.expertiseLevel=0;
	//Fabrice ende
	
	this.buSearch = 0; // soll nur nach efs gesucht werden die nicht in einem BS sind.
	
	console.groupEnd();
}

MapProvider.prototype.setCenter = function(point, zoomLevel){

	if (! zoomLevel) { 
			var nowZ = this.realMap.getZoom();
			if(nowZ < this.zoomlevelCenterOnMap){	zoomLevel = this.zoomlevelCenterOnMap;}
			else { nowZ++; zoomLevel =  nowZ}
			if( zoomLevel > 21 ) {  zoomLevel = 21; }
			console.log("====== MapProvider.prototype.setCenter setze zoom  nach calculation ================");
		
	}
		console.log("====== MapProvider.prototype.setCenter setze zoom to " + zoomLevel + " ================");
	try {
		if(global.GOOGLE_MAP_V3){
			//console.log("====== MapProvider.prototype.setCenter V3 1");
			this.realMap.setCenter(point);
			//console.log("====== MapProvider.prototype.setCenter V3 2");
			this.realMap.setZoom(zoomLevel);
			//console.log("====== MapProvider.prototype.setCenter V3 3");
		}
		else {	this.realMap.setCenter(point, zoomLevel);}
	}
	catch (e) {
		alert("MapProvider.prototype.setCenter \n error 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){
	var cLog = false; // logs onOff schalten
	if(cLog){console.log('+ + + + MapProvider.prototype.addOverlay + + + + + task ' + task + ' + + + + pos ' + pos + ' + + + + ');}
 	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);
					});
					
					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();
						});
					GEvent.addListener(marker.realMarker, "mouseout", function() {	UnTip(); }); 
		}
		else if( task == "paginationMarker"){ // die kleinen rote Punkte
							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() {	
										//console.log("mouse out roter punkt");
										das.setEarthfaveOverlayVisible(false); 
										das.setEarthfaveOverlayInvisibleTimer(OVERLAY_TIMER); 	
										clearTimeout(activ);
							}); 
		
		}	// Overlay f�r Places
			else if( task == "place"){// earthfaves auf der Karte
						if(cLog){console.log('+ + + + MapProvider.prototype.addOverlay + + + + + baue Place Overlay');}
						//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,task);//blende den overlay erst nach x sek ein
								});
							GEvent.addListener(marker.realMarker, "mouseout", function() {
									das.setPlaceOverlayVisible(false); 
									das.setPlaceOverlayInvisibleTimer(OVERLAY_TIMER); 
									clearTimeout(activ);   //Arno: verhindert das aufpoppen, wenn der Mauszeiger nur kurz �ber das ef f�hrt					
							}); 
		}	else if( task == "place_db"){// place aus db
						if(cLog){console.log('+ + + + MapProvider.prototype.addOverlay + + + + + baue Place_DB Overlay');}
						this.realMap.addOverlay(marker.realMarker);
						GEvent.addListener(marker.realMarker, "mouseover", function() {
								setEarthfaveOverlayInvisible(isVisible);
								init_mousemove();
								das.timerShowPlaceOverlay(pos,task);//blende den overlay erst nach x sek ein
								});
							GEvent.addListener(marker.realMarker, "mouseout", function() {
									das.setPlaceOverlayVisible(false); 
									das.setPlaceOverlayInvisibleTimer(OVERLAY_TIMER); 
									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; 
						if(cLog){console.log('+ + + + MapProvider.prototype.addOverlay + + + + + baue earthfave Overlay');}
						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(OVERLAY_TIMER); 
								clearTimeout(activ);   //Arno: verhindert das aufpoppen, wenn der Mauszeiger nur kurz �ber das ef f�hrt					
						}); 
		}
	}
	catch (e) {
	}
}
// 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+ " )", OVERLAY_TIMER);
setEarthfaveOverlayVisible(true);
return;
}
MapProvider.prototype.timerShowPlaceOverlay = function (i,task){
	console.log('MapProvider.prototype.timerShowPlaceOverlay i ' + i + ' task ' + task);
	var das = this;
	activ = setTimeout("Map.showPlaceOverlay( " + i + ",'" + task + "')", OVERLAY_TIMER);
	setPlaceOverlayVisible(true);
	return;
}

MapProvider.prototype.timerShowEarthfaveOverlay = function (i){
		var das = this;
		activ = setTimeout('Map.showEarthfaveOverlay( "' + i + '" )', OVERLAY_TIMER);
		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){
		console.log("ObjektPagi: pos: " + pos);
		console.log("ObjektPagi: id: " + id);

		if(document.getElementById('earthfaveInformation-pop-up'))
		{
			var doc = document.getElementById('earthfaveInformation-pop-up');
			getPaginationMarkerOverviewContent(id);
			doc.onmouseover = function(){				
			}
			doc.onmouseout = function(){				
			}
			showForm2("earthfaveInformation","");
		}
		else 
		{
			
		}
}

MapProvider.prototype.showPlaceOverlay = function (i,task){
	if(task == "place"){var objekt = this.placesGoogle[i];}
	else {var objekt = this.placesDB[i];}
	
	if(getDiv('placeInformation-pop-up')){
		var strNeu = "";
		var doc = getDiv('placeInformation-pop-up');
		var strNeu = "<div style='padding-top:0px;padding-bottom:0px;' class='rund_oben_370'></div>";
		strNeu += "<div style = 'padding-top:0px; padding-bottom:0px;' class='bgWhite2'>";
		strNeu += "	<div  style= 'padding:5px 0; width: 330px;'onmouseover='setPlaceOverlayVisible(true);'onmouseout = 'setPlaceOverlayVisible(false); setPlaceOverlayInvisibleTimer(" + INVISIBLE_TIMER + ");' >";	
		strNeu += objekt.asPlaceEntry(i);
		strNeu += "	</div>";			
		strNeu += "</div>";
		strNeu += "<div class='rund_unten_370'></div>";
		doc.innerHTML = strNeu;
		doc.onmouseover = function(){}
		doc.onmouseout = function(){}
		showForm4("placeInformation","");
	}
	else{console.log("mapProvider.js showPalceOverlay -> placeInformation-pop-up gibt es nicht");}
}

//2010.01.24 daniel. Neuer Overlay fuer den Nirvana Earthfave
MapProvider.prototype.showNirvanaOverlay = function (){
	var cLog = true;
	if(cLog){console.log("::::::::::::::: MapProvider.prototype.showNirvanaOverlay :::::::::");}
	if(getDiv('earthfaveInformation-pop-up')){
		var strNeu = "";
		var doc = getDiv('earthfaveInformation-pop-up');
		var strNeu = "<div style='padding-top:0px;padding-bottom:0px;' class='rund_oben_370'></div>";
		strNeu += "<div class='bgWhite2'>";
		strNeu += "</div>";
		strNeu += global.ADD_NIRVANA_EF_OVERLAYTEXT;
		strNeu += "</div>";
		strNeu += "<div class='rund_unten_370'></div>";
		doc.innerHTML = strNeu;
		showForm2("earthfaveInformation","");
	}		
}
	
MapProvider.prototype.showEarthfaveOverlay = function (i){
	console.log("MapProvider.prototype.showEarthfaveOverlay");
	var cLog = false;
	var objekt = this.earthfaves[i];
	
	if(cLog){
		console.log("Objekt: Lat: " + objekt.lat);
		console.log("Objekt: Lng: " + objekt.lng);	
		console.log("Objekt: id: " + i);
		console.log("Objekt: name: " + objekt.name);		
	}
	
	if(getDiv('earthfaveInformation-pop-up')){
		if (get.page_id == "extern_map"){
			var width = document.getElementById('divMap').style.width ;
			var width1 = width.substring(0,3) ;
			
			var height = document.getElementById('divMap').style.height ;
			var height1 = height.substring(0,3) ;
			
			//height1 = Number.height1 ;
			//width1 = Number.width1 ;
			
			console.log('sytel breite ' + width) ;
			console.log('sytel hoehe ' + height) ;	
		}
		
		var strNeu = "";
		var doc = document.getElementById('earthfaveInformation-pop-up');

		//anstatt <table> kommt <div> - createMapBubbleExt, createMapBubble bringen zuruck keinen Tabelleninhalt. Anna
		//strNeu += "<table  style= 'padding:0px; margin:0px; background-color:#999; width: 330px; overflow:hidden;' onmouseover='setEarthfaveOverlayVisible(true);'  onmouseout = 'setEarthfaveOverlayVisible(false); setEarthfaveOverlayInvisibleTimer(" + INVISIBLE_TIMER + ");' >";				
		//var strNeu = "<table style= 'padding:0px; margin:0px; height: 150px; width: 345px; overflow:none; padding:0px; margin:0px;' onmouseover='setEarthfaveOverlayVisible(true);'>";	mija
		//strNeu += objekt.asPopupEntry(i);
		
		if (get.page_id == "extern_map"){
			var size;
			if ((width1 < 710) || (height1 < 420)){	// diese parametres ist von normale karte. wenn die karte kleiner ist, dann kommt ein kleines popup
				size = "klein";
				strNeu += "<div class='rund_oben_220'></div>";
				strNeu += "<div class='bgWhite_small'>";
				strNeu += 		"<div  style= 'width: 200px; padding: 5px 0;' onmouseover='setEarthfaveOverlayVisible(true);'  onmouseout = 'setEarthfaveOverlayVisible(false); setEarthfaveOverlayInvisibleTimer(" + INVISIBLE_TIMER + ");' >";					
				strNeu += 			objekt.createMapBubbleExt(i,"",size);
				strNeu += 		"</div>";					
				strNeu += "</div>";
				strNeu += "<div class='rund_unten_220'></div>";				
			
			}else{ 
				size = "gross"; 
				console.log('Ich rufe createMapBubbleExt('+i+')  gross');
				strNeu += "<div style='padding-top:0px;padding-bottom:0px;' class='rund_oben_370'></div>";
				strNeu += "<div class='bgWhite2'>";
				strNeu += "<div  style= 'padding:5px 0; width: 330px;' onmouseover='setEarthfaveOverlayVisible(true);' onmouseout = 'setEarthfaveOverlayVisible(false); setEarthfaveOverlayInvisibleTimer(" + INVISIBLE_TIMER + ");' >";	
				strNeu += objekt.createMapBubbleExt(i,"",size);
				strNeu += "</div>";
				strNeu += "</div>";
				strNeu += "<div class='rund_unten_370'></div>";			
			}
		}else{ //Intern
			strNeu += "<div style='padding-top:0px;padding-bottom:0px;' class='rund_oben_370'></div>";
			strNeu += "<div class='bgWhite2'>";
			strNeu += "<div  style= 'padding:5px 0; width: 330px;' onmouseover='setEarthfaveOverlayVisible(true);' onmouseout = 'setEarthfaveOverlayVisible(false); setEarthfaveOverlayInvisibleTimer(" + INVISIBLE_TIMER + ");' >";					
			strNeu += objekt.createMapBubble(i);
			strNeu += "</div>";
			strNeu += "</div>";
			strNeu += "<div class='rund_unten_370'></div>";			
		}
		
		doc.innerHTML = strNeu;
		doc.onmouseover = function(){}
		doc.onmouseout = function(){}
		showForm2("earthfaveInformation","");
	}
	else{
		if(cLog){console.log("kein earthfaveInformation-pop-up");}
	}
}
//Arno ENDE===============================
MapProvider.prototype.orderOfCreation = function(id){
	return 1;
}

MapProvider.prototype.clearOverlays = function (caller){
		if(global.GOOGLE_MAP_V3){// V3
			console.log("MapProvider.prototype.clearOverlays:::::::::::: LOESCHE MARKER AUF MAP V3 ::::::::caller: " + caller);
			console.log(":::::::::::::::::::::::::::::::::::::::: lang array: " + this.markerArray.length + ":::::::::::::::::::::::::::::::::::::::");
			for(var i=0; i < this.markerArray.length; i++){
				console.log("MapProvider.prototype.clearOverlays marker: " ,this.markerArray[i]);
				if(this.markerArray[i]){
					console.log("MapProvider.prototype.clearOverlays loesche marker");
					this.markerArray[i].realMarker.setMap(null);
				}
			}
			this.markerArray = new Array();
			this.markerCounter = 0;
		} else { // v2
			try {
				console.log("MapProvider.prototype.clearOverlays:::::::::::: LOESCHE MARKER AUF MAP V2 ::::::::: caller: " + caller);
				console.log(":::::::::::::::::::::::::::::::::::::::: lang array 1: " + this.markerArray.length + ":::::::::::::::::::::::::::::::::::::::");
				this.realMap.clearOverlays();
				this.markerArray = new Array();
				this.markerCounter = 0;
				//console.log(":::::::::::::::::::::::::::::::::::::::: lang array 2: " + this.markerArray.length + ":::::::::::::::::::::::::::::::::::::::");
			}	catch (e) {		alert("Map instance:\nerror while clearing overlays: " + e.message);	}
		}
		console.log("MapProvider.prototype.clearOverlays:::::::::::: LOESCHE MARKER AUF MAP FERTIG ::::::::");
}

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) {
	this.realMap.closeInfoWindow();
	this.setCenter(new GLatLng(lat, lng));
	if (window.pageYOffset > 106) {	window.scrollTo(0, 106);}

}

MapProvider.prototype.createIcon = function (type, number, size, category, rel){
	var cLog = false;
	//console.log("MapProvider.prototype.createIcon type,number,size,cat,rel : "+ type + " , " + number + " , " + size + " , " + category + " , " + rel );
	//daniel: category nur bei efs
	//var size = (parseInt(zoomLevel) < 13) ? ICONSIZE_SMALL : ICONSIZE_BIG;

	var image;
	if (type == ICONTYPE_EMPTY) {	image = image_dir + "img-nontext/icons/addPlace.png";}
	else if (type == ICONTYPE_PLACE) {
			if(size == "klein"){image = image_dir + "img-nontext/icons/addPlaceStaticKlein_19_26.png";	}
			else {image = image_dir + "img-nontext/icons/addPlaceStaticBig.png";	}
	}	else {
		var numberInt = parseInt(number);
		if (numberInt > 10) {		image = image_dir + "img-nontext/icons/10plus_" + type + "_" + size + ".png";		}
		else {
			if( global.user_id == "1"){
					if(category > 0){image = image_dir + "img-nontext/icons/category_" + category + "_" + size + "_" + rel + ".png";}
					else {image = image_dir + "img-nontext/icons/" + number + "_" + type + "_" + size  + ".png";}
			}
			else {
				if(size == "klein"){ // derzeit nur cat-icons fuer die kleine 
						if(category > 0){	image = image_dir + "img-nontext/icons/category_" + category + "_" + size + "_" + rel + ".png";	}
						else {image = image_dir + "img-nontext/icons/" + number + "_" + type + "_" + size  + ".png";	}
				}
				else {//gross
						if(category > 0){image = image_dir + "img-nontext/icons/category_" + category + "_" + size +"_" + rel + ".png";	}
						else {image = image_dir + "img-nontext/icons/" + number + "_" + type + "_" + size  + ".png";	}
				}
			}
		}
	}
		if(!global.GOOGLE_MAP_V3){	// NCIHT V3	 
				if(cLog){console.log("maProvider.js -> MapProvider.prototype.createIcon  baue Icon nach V2 :::::::::::");}
				var gicon = new GIcon(); 
				gicon.image = image;
				gicon.iconSize         = (size == ICONSIZE_SMALL) ? GSIZE_SMALL : GSIZE_BIG;		// Groessen von Icon und Schatten
				
				if(size == GSIZE_NIRVANA){ gicon.iconSize = GSIZE_NIRVANA;}
				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) {}
				else if ( type == ICONTYPE_PLACE){
					if(size == ICONSIZE_SMALL){ gicon.iconSize = gicon.infoWindowAnchor = PLACE_SIZE_SMALL;}
					else {  gicon.iconSize = gicon.infoWindowAnchor = PLACE_SIZE_BIG; }
				}
				else {	gicon.infoWindowAnchor = (size == ICONSIZE_SMALL) ? GPOINT_INFOWA_SMALL : GPOINT_INFOWA_BIG;	}
				
				if(size == ICONSIZE_SMALL){	gicon.shadow = image_dir + "img-nontext/icons/shadow_klein.png";} 
				else {	gicon.shadow = image_dir + "img-nontext/icons/shadow_gross.png";}
				if(cLog){console.log("MapProvider.prototype.createIcon setze shaddow");}
				
				return gicon;
	} else {
		  	if(cLog){console.log("maProvider.js -> MapProvider.prototype.createIcon  baue Icon nach V3 :::::::::::");}
				//if(size == ICONSIZE_SMALL){var x = new google.maps.Size(20, 20);}
				//else {var x = new google.maps.Size(40, 40);}
				//var mImage = new google.maps.MarkerImage(image,x,new google.maps.Point(0,0),new google.maps.Point(0, 32));
				var mImage = new google.maps.MarkerImage(image);
				if(cLog){console.log("maProvider.js -> MapProvider.prototype.createIcon  ENDE  ::::::::::: mImage: ", mImage);}
				return mImage;	
	}


}

/** Erstellt die Ladeanzeige ueber der Karte
 * 	
 */

MapProvider.prototype.showMapLoaderAnimation = function(){
	if(x = getDiv('mapLoader')){
		x.innerHTML = "Load Data...";
		$('#mapLoader').show();	
	}
}

MapProvider.prototype.hideMapLoaderAnimation = function(text,fade){
	var x = ""; if(fade){x = "fade";}
	console.log('====== MapProvider.prototype.hideMapLoaderAnimation ======= ' + fade);
	if(x = getDiv('mapLoader')){
		if(fade){
			x.innerHTML = text;
			setTimeout("$('#mapLoader').fadeOut(300)",2000);	
		} else { $('#mapLoader').hide(); }
	}
}
/** 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){
	var cLog = false; // loging
	var showDetailsImage = image_dir + "img-nontext/icons/details.png";
	var options = new Object();
	var sizeMarker;

	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
	
	if(cLog){console.log('MapProvider.prototype.createMarker type: ' + entity.getType());}
	//var newIcon = this.createIcon(entity.getType(), 1, sizeMarker);//

	
	
	
	
	//var googleMarker = new GMarker(point, {icon: newIcon,zIndexProcess:1});//,zIndexProcess:zI
	if(!global.GOOGLE_MAP_V3){ // v2
		var point = new GLatLng(entity.lat, entity.lng);
		if(entity.getType() == 'place'){	var googleMarker = new GMarker(point, {icon: options.icon,zIndexProcess:function() { return +9000000; }});}
		else{ var googleMarker = new GMarker(point, {icon: options.icon,zIndexProcess:function() { return -9000001; }});}
	} else { // v3
		var point = new google.maps.LatLng(entity.lat,entity.lng);
		var googleMarker = new google.maps.Marker({position: point,map: this.realMap,icon: options.icon}); //
	}
	//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(this, "infowindowclose", function() {
			alert(" i like maria ...in MapProvider.prototype.createMarker ");

		});
	});
  */
	
	/*GEvent.addListener(googleMarker, "infowindowopen", function() {
		GEvent.addListener(googleMarker, "infowindowclose", function() {
		});
	});
	*/

  //                           id               type   echter marker
	var marker =  new Marker(this.markerCounter, entity, googleMarker);
	this.markerArray[this.markerCounter++] = marker;
	if(cLog){console.log('MapProvider.prototype.createMarker markerCounter: ' + this.markerCounter);}
	return marker;	
}

//ARNO ANFANG=========================================================
MapProvider.prototype.createPlace = function(positionSet){
	cLog = true;
	console.log(";;;;;;;;;;;;;;;; mapProvider.prototype.createPlace ;;;;;;;;;;;;;;;;;");
	var position;	var mapCenter = this.getCenter();
	if(positionSet){ position = positionSet;}
	else {	position = mapCenter; }
	
	var map = Application.getActiveMap();
	// 2011.01.02 Wenn ich Nirvana anlege aber NOCH Marker auf der Karte waehren, l�schte ich hier die PLaces zu den Markern
	// ich denke, dass ist falsch !!
	//map.placesGoogle = new Array();
	
	var options = new Object();
	options.draggable = true;
	options.icon = this.createIcon(ICONTYPE_EMPTY, 1,GSIZE_NIRVANA);
	options.zIndexProcess = function() { return 900000; }
	console.log("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(); }");
	//console.log("tempMarker::" , this.tempMarker);
	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(marker.realMarker, "infowindowclose", function() {
			//closeNirvanaEarthfave()
		});
		
//	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(){

	});*/
	GEvent.addListener(marker.realMarker, "dragend", function() { // overlay soll bei dragend neu erzeugt werden
		  //2011.01.24 Daniel. Mir gefaellt nicht, dass man den Marker aus der Karte "rausschmeiden kann.
			// Ich teste wo er liegt und liegt er ausserhalb der Karte, setze ich ihn in die mitte wieder zurueck.
			var x = that.checkMarkerInMap(); //check ob marker in map
		  //marker aus der karte gefallen setze neu auf center
			var mLat = that.tempMarker.getPoint().lat();
			var mLng = that.tempMarker.getPoint().lng();
			if(!x){
				that.tempMarker.setLatLng(mapCenter);
				movNirvanaOverlay("mapCreateNirvanaInfobox","default"); // setze den NiOv auf seine defaultPos.
			} else { 
				movNirvanaOverlay("mapCreateNirvanaInfobox","none"); 
				createAdWizardLinkForNirvanaOverlayButton(mLat,mLng);
			}
			
			// DAniel anzeigen der lat und lng
			//if(n = getDiv('nirvanaTextDivAdd')){
			//	n.innerHTML = ' lat / lng ' + mLat + ' '  + mLng;
			//}
			
			//			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=============================================

//daniel: ist ein Marker in der Map
MapProvider.prototype.checkMarkerInMap  = function(){
	var cLog = false;
	if(cLog){console.log("::::::::::: MapProvider.prototype.checkMarkerInMap ::::::::::");}
	var pLng = this.tempMarker.getPoint().lng(); // place marker lng
	var pLat = this.tempMarker.getPoint().lat() // place marker lat
	var mLatLeft = this.getBounds().getSouthWest().lat(); // karte lat unten links
	var mLngLeft = this.getBounds().getSouthWest().lng(); // karte lng unten links
	var mLatRight= this.getBounds().getNorthEast().lat(); // karte lat oben rechts
	var mLngRight= this.getBounds().getNorthEast().lng(); // karte lng oben rechts
	var ret = false;
	
	if(pLat <= mLatLeft){
			if(cLog){console.log("place suedlich der Karte");}
	} else {
		if(cLog){console.log("place nicht suedlich der Karte");}
		if(pLat >= mLatRight){
				if(cLog){console.log("place noerdlich der Karte");}
		} else {
			if(cLog){console.log("place nicht noerdlich der Karte");}
			if(pLng <= mLngLeft){
				if(cLog){ console.log("place westlich der Karte");}
			} else {
				if(cLog){console.log("place nicht westlich der Karte");}
				if(	pLng >= mLngRight ){
					if(cLog){console.log("place oestlich der Karte");}
				} else {
					if(cLog){console.log("place IN DER Karte");}
					ret = true;
				}				
			}
		 }
	}
	return ret;
}

MapProvider.prototype.createPaginationMarker = function (Obj){

	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;

	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;

	return PMarker;
}

MapProvider.prototype.createClusterMarker = function (clusterObj){
	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;
	//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;
	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){
	// Alten placemark loeschen
	if (this.tempMarker) {
		this.realMap.removeOverlay(this.tempMarker);
		this.tempMarker = null;
	}
	
	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;

	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){

	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 +"',false,'egal');\"><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 +"',false,'egal');\">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;	return -1000000;
}
