	// ZPS Javascript
	
	// Die meisten Funktionen können gemeinsam genutzt werden. Abweichende Funktionen für Kultur sind mit Funktion ..._kultur beschriftet.
	
	// Javascript Konstanten
	
	DEAKTIVIERT = 0;
	AKTIVIERT = 1;
	SELEKTIERT = 2;
	POINT = 3;

	// Icons inizialisieren
	flagge_icon = new Array();
	
	// Kultur
	flagge_icon['kultur'] = new Array();
	flagge_icon['kultur'][DEAKTIVIERT] = 'http://www.zurichparkside.ch/zps/images/punkt_kultur.png';
	flagge_icon['kultur'][AKTIVIERT] = 'http://www.zurichparkside.ch/zps/images/punkt_kultur_active.png';
	flagge_icon['kultur'][SELEKTIERT] = 'http://www.zurichparkside.ch/zps/images/punkt_kultur_active.png';
	flagge_icon['kultur'][POINT] = 'http://www.zurichparkside.ch/zps/images/punkt_inaktiv.png';
	
	// Natur
	flagge_icon['natur'] = new Array();
	flagge_icon['natur'][DEAKTIVIERT] = 'http://www.zurichparkside.ch/zps/images/punkt_natur.png';
	flagge_icon['natur'][AKTIVIERT] = 'http://www.zurichparkside.ch/zps/images/punkt_natur_active.png';
	flagge_icon['natur'][SELEKTIERT] = 'http://www.zurichparkside.ch/zps/images/punkt_natur_active.png';
	flagge_icon['natur'][POINT] = 'http://www.zurichparkside.ch/zps/images/punkt_inaktiv.png';
	
	// Wirtschaft
	flagge_icon['wirtschaft'] = new Array();
	flagge_icon['wirtschaft'][DEAKTIVIERT] = 'http://www.zurichparkside.ch/zps/images/punkt_wirtschaft.png';
	flagge_icon['wirtschaft'][AKTIVIERT] = 'http://www.zurichparkside.ch/zps/images/punkt_wirtschaft_active.png';
	flagge_icon['wirtschaft'][SELEKTIERT] = 'http://www.zurichparkside.ch/zps/images/punkt_wirtschaft_active.png';
	flagge_icon['wirtschaft'][POINT] = 'http://www.zurichparkside.ch/zps/images/punkt_inaktiv.png';
	
	// Bildung
	flagge_icon['bildung'] = new Array();
	flagge_icon['bildung'][DEAKTIVIERT] = 'http://www.zurichparkside.ch/zps/images/punkt_bildung.png';
	flagge_icon['bildung'][AKTIVIERT] = 'http://www.zurichparkside.ch/zps/images/punkt_bildung_active.png';
	flagge_icon['bildung'][SELEKTIERT] = 'http://www.zurichparkside.ch/zps/images/punkt_bildung_active.png';
	flagge_icon['bildung'][POINT] = 'http://www.zurichparkside.ch/zps/images/punkt_inaktiv.png';	


	// Keyboard Funktion
	function key_pressed(Ereignis) {
	
		if (!Ereignis) {
			Ereignis = window.event;
		}
		
		if (Ereignis.which) {
			key_code = Ereignis.which;
		} else if (Ereignis.keyCode) {
			key_code = Ereignis.keyCode;
		}
	
		// Debug
		// alert(key_code);
				
		// Taste: <-
		if (key_code == 37) {
			if (aktuelle_seite > 0) {
				show_table(aktuelle_seite-1);
			}
		}
		
		// Taste: ->
		if (key_code == 39) {
		
			letzte_seite = ((anzahl_locations+1)/anzahl_pro_seite) - 1;
			
			if (aktuelle_seite < letzte_seite) {
				show_table(aktuelle_seite+1);
			}							
		}
	}


	function create_inactive_location_point(location_id) {	
		
		mylng = json_locations_data[location_id]['longitude'];
		mylat = json_locations_data[location_id]['latitude'];
	
		// punkt einfügen
		Lat = parseFloat(mylat);
		Lng = parseFloat(mylng);
		
		LatLng = new GLatLng(Lat, Lng);
	
		// marker erstellen und punkt setzen
		flagge_icon[thema]['point'] = new GIcon(G_DEFAULT_ICON, flagge_icon[thema][POINT]);	
		/*
		flagge_icon[thema]['point'].iconSize = new GSize(7,7);
		flagge_icon[thema]['point'].iconAnchor = new GPoint(7,7);
		flagge_icon[thema]['point'].shadowSize = new GSize(1,1);
		flagge_icon[thema]['point'].imageMap=[0,0,7,0,7,7,0,7,0,0];		
		*/
		flagge_icon[thema]['point'].iconSize = new GSize(16,16);
		flagge_icon[thema]['point'].iconAnchor = new GPoint(0,0);
		flagge_icon[thema]['point'].shadowSize = new GSize(1,1);
		flagge_icon[thema]['point'].imageMap=[0,0,16,0,16,16,0,16,0,0];		
	
		json_locations_data[location_id]['location_point'] = new GMarker(LatLng, flagge_icon[thema]['point']);	
		map.addOverlay(json_locations_data[location_id]['location_point']);
		
		// Event Listener onclick
		json_locations_data[location_id]['listener_click_point'] = GEvent.addListener(json_locations_data[location_id]['location_point'], 'click', function() { show_info_from_point(location_id); }); 						
		
	
	}
	
	function show_info_from_point(location_id) {
	
		var info_html = '';
	
		mylng = json_locations_data[location_id]['longitude'];
		mylat = json_locations_data[location_id]['latitude'];
	
		// punkt einfügen
		Lat = parseFloat(mylat);
		Lng = parseFloat(mylng);
		
		LatLng = new GLatLng(Lat, Lng);
		
		switch(thema) {
			
			case('kultur'):
			
				// Bei Kultur Speziell: Richtigen Eintrag suchen
				for ( keyVar in json_events_data) {
					if (json_events_data[keyVar]['location_id'] == location_id) {
						event_id = keyVar;	
					}
				}
				
				my_event_title = json_events_data[event_id]['title'];
				my_event_startdate = json_events_data[event_id]['startdate'];
				my_event_enddate = json_events_data[event_id]['enddate'];
				
				info_html += '<div class=\"info_titel_popup info_titel_kultur\">Kultur</div>';
					
				info_html += '<div class=\"info_text_popup\"><strong>' + my_event_title + '</strong>';
							
				if (my_event_startdate != my_event_enddate) {
					info_html += '<br>' + my_event_startdate + '-' + my_event_enddate;
				}
				else {
					info_html += '<br>' + my_event_startdate;
				}
				info_html += '</div>';
				
				json_locations_data[location_id]['location_point'].openExtInfoWindow(map,'info_popup_info',info_html); 
				
			break;
			
			
			case('natur'):
	
				my_natur_title = json_locations_data[location_id]['titel'];
				my_natur_thema = json_locations_data[location_id]['thema'];
				my_natur_gemeinde = json_locations_data[location_id]['gemeinde'];
				my_natur_natur_thema = json_locations_data[location_id]['natur_thema'];
				
				info_html += '<div class=\"info_titel_popup info_titel_natur\">Natur</div>';
					
				info_html += '<div class=\"info_text_popup\"><strong>' + my_natur_title + '</strong>';
				if(my_natur_thema){
				  info_html += '<br>' + my_natur_thema;
				}
				info_html += '<br>' + my_natur_gemeinde;
				info_html += '<br>' + my_natur_natur_thema;
				info_html += '</div>';
	
				json_locations_data[location_id]['location_point'].openExtInfoWindow(map,'info_popup_info',info_html); 
				
			break;
			

			case('wirtschaft'):
	
				my_wirtschaft_title = json_locations_data[location_id]['title'];
				my_wirtschaft_street = json_locations_data[location_id]['street'];
				my_wirtschaft_zip = json_locations_data[location_id]['zip'];
				my_wirtschaft_city = json_locations_data[location_id]['city'];
				my_wirtschaft_thema = json_locations_data[location_id]['wirtschaft_thema'];
				
				info_html += '<div class=\"info_titel_popup info_titel_wirtschaft\">Wirtschaft</div>';
					
				info_html += '<div class=\"info_text_popup\"><strong>' + my_wirtschaft_title + '</strong>';
				info_html += '<br>' + my_wirtschaft_street;
				info_html += '<br>' + my_wirtschaft_zip + ' ' + my_wirtschaft_city;
				info_html += '</div>';

				json_locations_data[location_id]['location_point'].openExtInfoWindow(map,'info_popup_info',info_html); 
		
			break;
		
		
			case('bildung'):

				my_bildung_title = json_locations_data[location_id]['title'];
				my_bildung_street = json_locations_data[location_id]['street'];
				my_bildung_zip = json_locations_data[location_id]['zip'];
				my_bildung_city = json_locations_data[location_id]['city'];
				
				info_html += '<div class=\"info_titel_popup info_titel_bildung\">Bildung</div>';
				
				info_html += '<div class=\"info_text_popup\"><strong>' + my_bildung_title + '</strong>';
				info_html += '<br>' + my_bildung_street;
				info_html += '<br>' + my_bildung_zip + ' ' + my_bildung_city;
				info_html += '</div>';
	
				json_locations_data[location_id]['location_point'].openExtInfoWindow(map,'info_popup_info',info_html); 

			break;
			
			
			
		}
		
	}
	
	
	function create_flag(location_id) {
	
		mylng = json_locations_data[location_id]['longitude'];
		mylat = json_locations_data[location_id]['latitude'];

		// punkt einfügen
		Lat = parseFloat(mylat);
		Lng = parseFloat(mylng);
		
		LatLng = new GLatLng(Lat, Lng);

		// marker erstellen und punkt setzen
		flagge_icon[thema]['icon'] = new GIcon(G_DEFAULT_ICON, flagge_icon[thema][DEAKTIVIERT]);
		// flagge_icon[thema]['icon'].iconSize = new GSize(39, 42);
		// flagge_icon[thema]['icon'].iconAnchor = new GPoint(-3,38);
		// flagge_icon[thema]['icon'].imageMap=[0,37,15,0,38,11,32,26,18,24,10,19,3,40,0,37];
		flagge_icon[thema]['icon'].iconSize = new GSize(16,16);
		flagge_icon[thema]['icon'].iconAnchor = new GPoint(0,0);		
		flagge_icon[thema]['icon'].shadowSize = new GSize(1,1);
		flagge_icon[thema]['icon'].imageMap=[0,0,16,0,16,16,0,16,0,0];

		json_locations_data[location_id]['marker'] = new GMarker(LatLng, flagge_icon[thema]['icon']);
		map.addOverlay(json_locations_data[location_id]['marker']);
		
		// Event Listener mousover
		json_locations_data[location_id]['listener_over'] = GEvent.addListener(json_locations_data[location_id]['marker'], 'mouseover', function() { show_hide_from_flag(location_id,AKTIVIERT); }); 

		// Event Listener mouseout
		json_locations_data[location_id]['listener_out'] = GEvent.addListener(json_locations_data[location_id]['marker'], 'mouseout', function() { show_hide_from_flag(location_id,DEAKTIVIERT); }); 

		// Event Listener onclick
		json_locations_data[location_id]['listener_click'] = GEvent.addListener(json_locations_data[location_id]['marker'], 'click', function() { activate_from_map(location_id); }); 						
		
	}
	
	
	function show_hide_from_table(element,aktiv) {
					
		// Location ID holen
		var location_id;
		
		location_id = element.id;
		location_id = location_id.substring(9);

		activate_table(location_id,aktiv);
	} 	
	
	function show_hide_from_table_kultur(element,aktiv) {
					
		// Location ID holen
		var location_id;
		
		location_id = element.id;
		location_id = location_id.substring(6);

		activate_table_kultur(location_id,aktiv);
	} 	

	function show_from_table() {

		// Location ID holen
		var location_id;
	
		location_id = this.id;
		location_id = location_id.substring(9);

		status = json_locations_data[location_id]['status'];
	
		show_hide_from_table(this,AKTIVIERT);
	}
	
	function show_from_table_kultur() {
	
		// Event ID holen
		var event_id;
	
		event_id = this.id;
		event_id = event_id.substring(6,30);
		
		location_id = json_events_data[event_id]['location_id'];
		status = json_locations_data[location_id]['status'];
	
		show_hide_from_table_kultur(this,AKTIVIERT);

	}
	
	
	function hide_from_table() {
	
		// Event ID holen
		var location_id;
	
		location_id = this.id;
		location_id = location_id.substring(9);

		status = json_locations_data[location_id]['status'];
		
		show_hide_from_table(this,DEAKTIVIERT);
		
	}
	
	function hide_from_table_kultur() {
		
		// Event ID holen
		var event_id;
	
		event_id = this.id;
		event_id = event_id.substring(6,30);

		location_id = json_events_data[event_id]['location_id'];

		status = json_locations_data[location_id]['status'];
		
		show_hide_from_table_kultur(this,0);
			
	}


	function activate_from_table() {

		// Event ID holen
		var location_id;
	
		location_id = this.id;
		location_id = location_id.substring(9);
		
		show_hide_from_table(this,SELEKTIERT);
		
		show_info(location_id);
		
		center_markers();
	}	
	
	function activate_from_table_kultur() {

		// Event ID holen
		var event_id;
	
		event_id = this.id;
		event_id = event_id.substring(6,30);

		location_id = json_events_data[event_id]['location_id'];
		
		
		
		show_hide_from_table_kultur(this,SELEKTIERT);
		
		show_info_kultur(event_id,location_id);
		
		center_markers_kultur();
		
	}	
	
	
	function activate_table(location_id,aktiv) {
			
		css_location_id = 'location_'+[location_id];
		my_tr = document.getElementById(css_location_id);
		
		// Deaktivieren
		if (aktiv == DEAKTIVIERT) {
		
			if (json_locations_data[location_id]['status'] != SELEKTIERT) {
					
				json_locations_data[location_id]['status'] = DEAKTIVIERT;
				
				newcss = 'veranstaltungen_table_inactive';
				my_tr.className = newcss;
				
				activate_flag(location_id,DEAKTIVIERT);
				
			}
		}	
			
		
		// Aktivieren
		if (aktiv == AKTIVIERT) {
							
			if (json_locations_data[location_id]['status'] != SELEKTIERT) {
					
				json_locations_data[location_id]['status'] = AKTIVIERT;
				
				
				switch(thema) {
										
					case('natur'):						
						newcss = 'veranstaltungen_table_active_natur';		
					break;
					
					case('wirtschaft'):						
						newcss = 'veranstaltungen_table_active_wirtschaft';		
					break;	
					
					case('bildung'):						
						newcss = 'veranstaltungen_table_active_bildung';		
					break;						
					
				}
				
				



				my_tr.className = newcss;
				
				activate_flag(location_id,AKTIVIERT);

			}

		}	
			
			
		// Setzen
		if (aktiv == SELEKTIERT) {	

			// Zuerst alle deaktivieren					
			alle_table_rows_deaktivieren();

			json_locations_data[location_id]['status'] = SELEKTIERT;
				
			switch(thema) {
						
				case('natur'):						
					newcss = 'veranstaltungen_table_active_natur';		
				break;
				
				case('wirtschaft'):						
					newcss = 'veranstaltungen_table_active_wirtschaft';		
				break;		
				
				case('bildung'):						
					newcss = 'veranstaltungen_table_active_bildung';		
				break;					
				
			}
				
			my_tr.className = newcss;

			activate_flag(location_id,SELEKTIERT);

		}	
	}
	
	function activate_table_kultur(event_id,aktiv) {
		
		

		css_event_id = 'event_'+[event_id];
		my_tr = document.getElementById(css_event_id);
		
		location_id = json_events_data[event_id]['location_id'];
		
		// Deaktivieren
		if (aktiv == DEAKTIVIERT) {
		
			if (json_events_data[event_id]['status'] != SELEKTIERT) {
					
				json_events_data[event_id]['status'] = DEAKTIVIERT;
				
				newcss = 'veranstaltungen_table_inactive';
				my_tr.className = newcss;
				
				activate_flag(location_id,DEAKTIVIERT);
				
			}
		}	
			
		// Aktivieren
		if (aktiv == AKTIVIERT) {
			
			if (json_events_data[event_id]['status'] != SELEKTIERT) {
					
				json_events_data[event_id]['status'] = AKTIVIERT;
												
				newcss = 'veranstaltungen_table_active';
				my_tr.className = newcss;
				
				activate_flag(location_id,AKTIVIERT);

			}

		}	
			
			
		// Setzen
		if (aktiv == SELEKTIERT) {	

			// Zuerst alle deaktivieren					
			alle_table_rows_deaktivieren_kultur();

			json_events_data[event_id]['status'] = SELEKTIERT;
				
			newcss = 'veranstaltungen_table_active';
			my_tr.className = newcss;
			
			
			
			activate_flag(location_id,SELEKTIERT);

		}	

	}							
	
	
	function activate_flag(location_id,aktiv) {
		
			
		myicon = json_locations_data[location_id]['marker'].getIcon();
		myicon = myicon.image;			
		myflag = json_locations_data[location_id]['marker'];
		
		// Deaktivieren
		if (aktiv == DEAKTIVIERT) {
			
			if (json_locations_data[location_id]['status'] != SELEKTIERT) {
					
				json_locations_data[location_id]['status'] = DEAKTIVIERT;

				json_locations_data[location_id]['marker'].setImage(flagge_icon[thema][DEAKTIVIERT]);
				
			} 
		}	
	
	
		// Aktivieren
		if (aktiv == AKTIVIERT) {
		
			
			if (json_locations_data[location_id]['status'] != SELEKTIERT) {
					
				json_locations_data[location_id]['status'] = AKTIVIERT;

				json_locations_data[location_id]['marker'].setImage(flagge_icon[thema][AKTIVIERT]);		

			} 
	
		}		
	
		// Setzen
		if (aktiv == SELEKTIERT) {
		
			// Zuerst alle deaktivieren							
			alle_flags_deaktivieren();
			

			if (json_locations_data[location_id]['status'] != SELEKTIERT) {
					
				json_locations_data[location_id]['status'] = SELEKTIERT;

				json_locations_data[location_id]['marker'].setImage(flagge_icon[thema][SELEKTIERT]);		

			} 
	
		}

	}	
	
	
	function show_hide_from_flag(location_id,aktiv) {

		if (thema == 'kultur') {
			
			var event_id;
				
			// Durch alle events loopen
			for ( event_id in json_events_data ) {
				
				// Trifft zu wenn ein event zu einer location passt
				if (json_events_data[event_id]['location_id'] == location_id) {
				
					// Achtung: Nicht alle Ergebnisse sind im Table
					css_id = 'event_' + event_id;
	
					if (document.getElementById(css_id)) {
						show_hide_from_table_kultur(document.getElementById(css_id),aktiv);
					}
				}
			}	
		}
		else {
			// Durch alle locations loopen
			for ( keyVar in json_locations_data ) {
							
				// Trifft zu wenn ein location zu einer location passt
				if (keyVar == location_id) {
									
					// Achtung: Nicht alle Ergebnisse sind im Table
					css_id = 'location_' + location_id;
					if (document.getElementById(css_id)) {
						show_hide_from_table(document.getElementById(css_id),aktiv);
					}
				}
			}			
		}
	}

	
	function alle_table_rows_deaktivieren() {

		var temp_location_id;
		for ( temp_location_id in json_locations_data ) {
					
			// Achtung: Nicht alle Ergebnisse sind im Table
			
			css_id = 'location_' + temp_location_id;
			if (document.getElementById(css_id)) {
				my_tr3 = document.getElementById(css_id);
				newcss = 'veranstaltungen_table_inactive';
				my_tr3.className = newcss;
			}
		}	
	}
	
	
	function alle_table_rows_deaktivieren_kultur() {
	
		var temp_event_id;
		for ( temp_event_id in json_events_data ) {
					
			// Achtung: Nicht alle Ergebnisse sind im Table
			
			css_id = 'event_' + temp_event_id;
			if (document.getElementById(css_id)) {
				my_tr3 = document.getElementById(css_id);
				newcss = 'veranstaltungen_table_inactive';
				my_tr3.className = newcss;
			}
			
		// Deaktiviert den Status vom Tableeintrag (Bei Kultur wichtig, da es Events gibt)
		json_events_data[temp_event_id]['status'] = 0;	
				
		}	
	}	
	
	
	function alle_flags_deaktivieren() {
	
		var temp_location_id;
		for ( temp_location_id in json_locations_data ) {
					
			if ((json_locations_data[temp_location_id]['status'] == AKTIVIERT) || (json_locations_data[temp_location_id]['status'] == SELEKTIERT)) {
				
				json_locations_data[temp_location_id]['marker'].setImage(flagge_icon[thema][DEAKTIVIERT]);
			
			}

		json_locations_data[temp_location_id]['status'] = DEAKTIVIERT;
					
		}	
	}	
	
	
	function show_info(location_id) {

		show_content(location_id,location_id);
		show_location(location_id);
	
	}
	
	function show_info_kultur(event_id, location_id) {
		event_id = show_content(event_id, location_id);
		show_location(location_id, event_id);
		
	}	
	
	function activate_from_map(location_id) {
		
		if (thema == 'kultur') {
			select_flag_kultur(location_id);
			show_info_kultur(DEAKTIVIERT, location_id);
		}
		else {
			select_flag(location_id);
			show_info(location_id,location_id);	
		}
	}
	
	function select_flag(location_id) {
		
		// Zuerst alle deaktivieren							
		alle_flags_deaktivieren();

		json_locations_data[location_id]['status'] = SELEKTIERT;
		json_locations_data[location_id]['marker'].setImage(flagge_icon[thema][SELEKTIERT]);
		
		// Alle Table Rows deaktivieren
		alle_table_rows_deaktivieren();
		
		// Neue Table Rows selektieren
		for ( keyVar in json_locations_data ) { 
		
			if (keyVar == location_id) {

				json_locations_data[keyVar]['status'] = SELEKTIERT;
				
				// Achtung: Nicht alle Ergebnisse sind im Table
				css_location_id = 'location_' + location_id;
				if (document.getElementById(css_location_id)) {
				
					my_tr4 = document.getElementById(css_location_id);

					switch(thema) {
											
						case('natur'):						
							newcss = 'veranstaltungen_table_active_natur';		
						break;
						
						case('wirtschaft'):						
							newcss = 'veranstaltungen_table_active_wirtschaft';
						break;		
						
						case('bildung'):						
							newcss = 'veranstaltungen_table_active_bildung';		
						break;							
						
					}

					
					my_tr4.className = newcss;	
				}
			}
		}
	}
	
	function select_flag_kultur(location_id) {
			
		// Zuerst alle deaktivieren							
		alle_flags_deaktivieren();

		// Neues Flag aktivieren
		myicon = json_locations_data[location_id]['marker'].getIcon();
		myicon = myicon.image;			
		myflag = json_locations_data[location_id]['marker'];

		// map.removeOverlay(myflag);		
		// map.addOverlay(myflag);
		
		json_locations_data[location_id]['status'] = SELEKTIERT;
		json_locations_data[location_id]['marker'].setImage(flagge_icon[thema][SELEKTIERT]);
		
		// Alle Table Rows deaktivieren
		alle_table_rows_deaktivieren_kultur();
		
		// Neue Table Rows selektieren
		for ( event_id in json_events_data ) {
		
			if (json_events_data[event_id]['location_id'] == location_id) {

				json_events_data[event_id]['status'] = SELEKTIERT;
				
				// Achtung: Nicht alle Ergebnisse sind im Table
				css_event_id = 'event_' + event_id;
				if (document.getElementById(css_event_id)) {
				
					my_tr4 = document.getElementById(css_event_id);
					newcss = 'veranstaltungen_table_active';
					my_tr4.className = newcss;
					
				}
			}
		}
	}
	
	
	function show_content(location_id,location_id) {
		mytitle = json_locations_data[location_id]['title'];
		mycontent = json_locations_data[location_id]['description'];
		mypicture = json_locations_data[location_id]['image'];
		mystartdate = json_locations_data[location_id]['startdate'];
		myenddate = json_locations_data[location_id]['enddate'];
		
		
		
		// Sichtbar machen
		document.getElementById('info_box').style.display = '';
		
		// Table leeren:
		document.getElementById('info_box').innerHTML = '';

		// table erstellen					
		newtable = document.createElement('table');
			
		switch(thema) {
		
			case('wirtschaft'):
				newtable.className = 'head head_wirtschaft';
			break;
			
			case('bildung'):
				newtable.className = 'head head_bildung';
			break;			
			
		}
			
			
			
			newtable.id = 'info_table';
		

			// thead erstellen
			newthead = document.createElement('thead');
				
			switch(thema) {
		
				case('wirtschaft'):
					newthead.className = 'head head_wirtschaft';
				break;
				
				case('bildung'):
					newthead.className = 'head head_bildung';
				break;			
				
			}	
				

				// tr erstellen
				newtr = document.createElement('tr');

					newth = document.createElement('th');
						newth_text = document.createTextNode('Ort');
						newth.appendChild(newth_text);
						newth.className = 'info_head_natur_left';
					newtr.appendChild(newth);	
					
					newth = document.createElement('th');
					
						html_code = '';
						html_code = '<a href=\"#\" onclick=\"zoom_to_location(\'' + location_id + '\');\"><img src=\"/zps/images/lupe.gif\" border=\"0\" class=\"lupe\"></a>';
					
						newth.innerHTML = html_code;
						newth.className = 'info_head_natur_right';
						
					newtr.appendChild(newth);
								
			newthead.appendChild(newtr);	

		// thead in table einfügen
		newtable.appendChild(newthead);			
		// head fertig
		
		document.getElementById('info_box').appendChild(newtable);
			
		div_info_box_content = document.createElement('div');
		div_info_box_content.id = 'info_box_content';	
		
		switch(thema) {
		
			case('wirtschaft'):
				div_info_box_content.className = 'info_box_content_wirtschaft';		
			break;
			
			case('bildung'):
				div_info_box_content.className = 'info_box_content_bildung';		
			break;			
			
		}

		
		
		// document.getElementById('info_box').appendChild(div_info_box_content);		


		// Location
	
		div_info_location = document.createElement('div');
		div_info_location.id = 'info_location';
		// div_info_location.style.display = 'none';
						
		div_info_box_content.appendChild(div_info_location);	


		document.getElementById('info_box').appendChild(div_info_box_content);		
		
		clearer2 = document.createElement('div');
		clearer2.className = 'clearer';				
		document.getElementById('info_location').appendChild(clearer2);	
		
		myLightbox.initialize();
	}
	


	function show_location(location_id) {	

		location_mytitle = json_locations_data[location_id]['title'];
		location_mydescription = json_locations_data[location_id]['description'];
		location_mystreet = json_locations_data[location_id]['street'];
		location_myzip = json_locations_data[location_id]['zip'];
		location_mycity = json_locations_data[location_id]['city'];
		location_mycountry = json_locations_data[location_id]['country'];
		location_myphone = json_locations_data[location_id]['phone'];
		location_myemail = json_locations_data[location_id]['email'];
		location_myimage = json_locations_data[location_id]['image'];
		location_mylink = json_locations_data[location_id]['link'];	
		location_mypicture = json_locations_data[location_id]['image'];	

		// Thumb Pfad erstellen
		location_mythumb = location_mypicture.split('/');
		location_mythumb_length = location_mythumb.length;
		location_mythumb = '/zps/uploads/' + thema + '_locations/thumb_' + location_mythumb[location_mythumb_length-1];


		// Table leeren:
		document.getElementById('info_location').innerHTML = '';

		// Location

		// Dieses Div nicht mehr erstellen. da es schon besteht				
		// div_info_location = document.createElement('div');
		// div_info_location.id = 'info_location';
		
			// Div Start
			div_info_location_picture = document.createElement('div');
			div_info_location_picture.id = 'info_location_picture';
				
				//div_info_location_picture.innerHTML = '<a href=\"' + location_mypicture + '\" rel=\"lightbox\"><img src=\"' + location_mythumb + '\" class=\'info_box_img\'\"></a>';
				//alert(location_mythumb);
				if(location_mythumb != '/zps/uploads/' + thema + '_locations/thumb_'){
					div_info_location_picture.innerHTML = '<img src=\"' + location_mythumb + '\" class=\'info_box_img\'\">';
				}
			
			div_info_location.appendChild(div_info_location_picture);
			// Div End

			div_info_location_text = document.createElement('div');
			div_info_location_text.id = 'info_location_text';
				if(location_mylink == ""){
						location_html_code = '<strong>' + location_mytitle + '</strong><br>' + location_mystreet + '<br>' + location_myzip + ' ' + location_mycity + '<br>' + location_myphone + '<br>' + location_myemail;
				}
				else{
					if("http://" != location_mylink.toLowerCase().substring(0,7) && "https://" != location_mylink.toLowerCase().substring(0,8)){
							location_mylink = "http://" + location_mylink;
					}
					location_html_code = '<a href=\"' + location_mylink + '\" target=\"_blank\"><strong>' + location_mytitle + '</strong></a><br>' + location_mystreet + '<br>' + location_myzip + ' ' + location_mycity + '<br>' + location_myphone + '<br>' + location_myemail;
				}
				
				if ((location_mydescription != 'Keine Angabe') && (location_mydescription != '')) {
					location_html_code = location_html_code + '<br><br>' + location_mydescription;
				}
					
				location_html_code = location_html_code + '<br>' + insert_zvv_link();
				
				div_info_location_text.innerHTML = location_html_code;
							
			div_info_location.appendChild(div_info_location_text);											
							
		div_info_box_content.appendChild(div_info_location);	
	
		
		clearer2 = document.createElement('div');
		clearer2.className = 'clearer';				
		document.getElementById('info_location').appendChild(clearer2);	
		
		myLightbox.initialize();

	}
			
			
	function zoom_to_location(location_id) {

		myma = json_locations_data[location_id]['marker'].getLatLng();

		newlat = myma.lat();
		newlng = myma.lng();
		
		newlat = parseFloat(newlat);
		newlng = parseFloat(newlng);
		
		newCenter = new GLatLng(newlat,newlng);
		map.setCenter(newCenter);
		map.setZoom(15);
		map.setMapType(G_HYBRID_MAP);
	}
	
	function center_markers() {
			
		markerboundslat = Array();
		markerboundslng = Array();
	
		counter = 0;
		for ( location_id in json_locations_data ) {
			// Achtung: Nicht alle Ergebnisse sind im Table
			css_location_id = 'location_' + location_id;
			if (document.getElementById(css_location_id)) {
				myma = json_locations_data[location_id]['marker'].getLatLng();
				markerboundslat[counter] = myma.lat();
				markerboundslng[counter] = myma.lng();
				counter++;
					
			}
		}
	
		markerboundslat.sort(Numsort);
		markerboundslng.sort(Numsort);
	
		// track it, trace it, center it, do it				
		latmin = parseFloat(markerboundslat[0]); 
		latmax = parseFloat(markerboundslat[markerboundslat.length-1]);
		lngmin = parseFloat(markerboundslng[0]);
		lngmax = parseFloat(markerboundslng[markerboundslng.length-1]);
		newlat = latmin+(latmax-latmin)/2;
		newlng = lngmin+(lngmax-lngmin)/2;
		
		newCenter = new GLatLng(newlat,newlng);
		map.setCenter(newCenter);
	
		// zoom it
		newMaxHor = parseFloat(lngmax - lngmin);
		newMaxVer = parseFloat(latmax - latmin);
		longest = (newMaxHor > newMaxVer) ? newMaxHor : newMaxVer;
		newZoom = 11-longest;
		newZoom = parseInt(newZoom);
		map.setZoom(newZoom);
		map.setMapType(G_SATELLITE_MAP);
	
	}
	
	
	function center_markers_kultur() {
			
		markerboundslat = Array();
		markerboundslng = Array();


		counter = 0;
		for ( event_id in json_events_data ) {
		
			// Achtung: Nicht alle Ergebnisse sind im Table
			css_event_id = 'event_' + event_id;
			if (document.getElementById(css_event_id)) {
				
				location_id = json_events_data[event_id]['location_id'];
				
				myma = json_locations_data[location_id]['marker'].getLatLng();
				
				newlat = myma.lat();
				newlng = myma.lng();
				
				newlat = parseFloat(newlat);
				newlng = parseFloat(newlng);							
			
				markerboundslat[counter] = newlat;
				markerboundslng[counter] = newlng;
				counter++;
					
			}
		}
		
		markerboundslat.sort(Numsort);
		markerboundslng.sort(Numsort);
	
		// track it, trace it, center it, do it				
		latmin = parseFloat(markerboundslat[0]); 
		latmax = parseFloat(markerboundslat[markerboundslat.length-1]);
		lngmin = parseFloat(markerboundslng[0]);
		lngmax = parseFloat(markerboundslng[markerboundslng.length-1]);
		newlat = latmin+(latmax-latmin)/2;
		newlng = lngmin+(lngmax-lngmin)/2;
		
		newCenter = new GLatLng(newlat,newlng);
		map.setCenter(newCenter);
	
		// zoom it
		newMaxHor = parseFloat(lngmax - lngmin);
		newMaxVer = parseFloat(latmax - latmin);
		longest = (newMaxHor > newMaxVer) ? newMaxHor : newMaxVer;
		newZoom = 11-longest;
		newZoom = parseInt(newZoom);
		map.setZoom(newZoom);
		map.setMapType(G_SATELLITE_MAP);
		
	}
	
	
	function showBorders() {
		// var kmldefault = new GGeoXml('http://www.zurichparkside.ch/zps/map/ZPS.kml');
		// map.addOverlay(kmldefault);
	}
		
	
	// Weitere
	
	function Numsort (a, b) {
	  return a - b;
	}				
		
	
	// Checks that a string contains only numbers
	function isNumber(str) {
		for(var position=0; position<str.length; position++){
			var chr = str.charAt(position)
				if  ( (chr < '0') || (chr > '9') ) 
					return false;
			} 
		return true;
	}		
	
	// Debug in div
	function dalert(text,was) {
		debug_html_code = document.getElementById('content_debug').innerHTML;
		debug_html_code = debug_html_code + text + ' ' + was + '<br>';
		document.getElementById('content_debug').innerHTML = debug_html_code;
	}