///// LEGENDE /////


///// onload /////


function togg() {toggkul();toggspo();toggnat();toggmeh();toggweg();}



///// toggle legende /////

function clickkultur(){if (kultur == true){
exml.toggleContents(2,togglerkultur), exml.toggleFolder(2), toggkul()}}

function clicksport(){if (sport == true){
exml.toggleContents(3,togglersport), exml.toggleFolder(3), toggspo()}}

function clicknatur(){if (natur == true){
exml.toggleContents(4,togglernatur), exml.toggleFolder(4), toggnat()}}

function clickmehr(){if (mehr == true){
exml.toggleContents(5,togglermehr), exml.toggleFolder(5), toggmeh()}}

function clickwege(){if (wege == true){
exml.toggleContents(6,togglerwege), exml.toggleFolder(6), toggweg()}}


function toggkul(){if (kultur == true){
	if (togglerkultur == true ) {togglerkultur = false; document.getElementById('legendekultur').style.backgroundImage = "url(http://www.tannberg.info/fileadmin/tannberg/gfx/legende/kulturakt.png)";} else {togglerkultur = true; document.getElementById('legendekultur').style.backgroundImage = "url(http://www.tannberg.info/fileadmin/tannberg/gfx/legende/kulturinakt.png)";}
	}else{document.getElementById('legendekultur').style.backgroundImage = "url(http://www.tannberg.info/fileadmin/tannberg/gfx/legende/kulturinakt.png)";}}
	
function toggspo(){if (sport == true){
	if (togglersport == true) {togglersport = false; document.getElementById('legendesport').style.backgroundImage = "url(http://www.tannberg.info/fileadmin/tannberg/gfx/legende/sportakt.png)";} else {togglersport = true; document.getElementById('legendesport').style.backgroundImage = "url(http://www.tannberg.info/fileadmin/tannberg/gfx/legende/sportinakt.png)";}
	}else{document.getElementById('legendesport').style.backgroundImage = "url(http://www.tannberg.info/fileadmin/tannberg/gfx/legende/sportinakt.png)";}}

function toggnat(){if (natur == true){
	if (togglernatur == true) {togglernatur = false; document.getElementById('legendenatur').style.backgroundImage = "url(http://www.tannberg.info/fileadmin/tannberg/gfx/legende/naturakt.png)";} else {togglernatur = true; document.getElementById('legendenatur').style.backgroundImage = "url(http://www.tannberg.info/fileadmin/tannberg/gfx/legende/naturinakt.png)";}
	}else{document.getElementById('legendenatur').style.backgroundImage = "url(http://www.tannberg.info/fileadmin/tannberg/gfx/legende/naturinakt.png)";}}
	
function toggmeh(){if (mehr == true){
	if (togglermehr == true) {togglermehr = false; document.getElementById('legendemehr').style.backgroundImage = "url(http://www.tannberg.info/fileadmin/tannberg/gfx/legende/mehrakt.png)";} else {togglermehr = true; document.getElementById('legendemehr').style.backgroundImage = "url(http://www.tannberg.info/fileadmin/tannberg/gfx/legende/mehrinakt.png)";}
	}else{document.getElementById('legendemehr').style.backgroundImage = "url(http://www.tannberg.info/fileadmin/tannberg/gfx/legende/mehrinakt.png)";}}
	
function toggweg(){if (wege == true){
	if (togglerwege == true) {togglerwege = false; document.getElementById('legendewege').style.backgroundImage = "url(http://www.tannberg.info/fileadmin/tannberg/gfx/legende/wegeakt.png)";} else {togglerwege = true; document.getElementById('legendewege').style.backgroundImage = "url(http://www.tannberg.info/fileadmin/tannberg/gfx/legende/wegeinakt.png)";}
	}else{document.getElementById('legendewege').style.backgroundImage = "url(http://www.tannberg.info/fileadmin/tannberg/gfx/legende/wegeinakt.png)";}}


///// hover legende /////

function legmouseoverkultur(){
if (togglerkultur == true){
document.getElementById('legendekultur').style.backgroundImage = "url(http://www.tannberg.info/fileadmin/tannberg/gfx/legende/kulturhover.png)";}
}
function legmouseoutkultur(){
if (togglerkultur == true){
document.getElementById('legendekultur').style.backgroundImage = "url(http://www.tannberg.info/fileadmin/tannberg/gfx/legende/kulturinakt.png)";}
}

function legmouseoversport(){
if (togglersport == true){
document.getElementById('legendesport').style.backgroundImage = "url(http://www.tannberg.info/fileadmin/tannberg/gfx/legende/sporthover.png)";}
}
function legmouseoutsport(){
if (togglersport == true){
document.getElementById('legendesport').style.backgroundImage = "url(http://www.tannberg.info/fileadmin/tannberg/gfx/legende/sportinakt.png)";}
}

function legmouseovernatur(){
if (togglernatur == true){
document.getElementById('legendenatur').style.backgroundImage = "url(http://www.tannberg.info/fileadmin/tannberg/gfx/legende/naturhover.png)";}
}
function legmouseoutnatur(){
if (togglernatur == true){
document.getElementById('legendenatur').style.backgroundImage = "url(http://www.tannberg.info/fileadmin/tannberg/gfx/legende/naturinakt.png)";}
}

function legmouseovermehr(){
if (togglermehr == true){
document.getElementById('legendemehr').style.backgroundImage = "url(http://www.tannberg.info/fileadmin/tannberg/gfx/legende/mehrhover.png)";}
}
function legmouseoutmehr(){
if (togglermehr == true){
document.getElementById('legendemehr').style.backgroundImage = "url(http://www.tannberg.info/fileadmin/tannberg/gfx/legende/mehrinakt.png)";}
}

function legmouseoverwege(){
if (togglerwege == true){
document.getElementById('legendewege').style.backgroundImage = "url(http://www.tannberg.info/fileadmin/tannberg/gfx/legende/wegehover.png)";}
}
function legmouseoutwege(){
if (togglerwege == true){
document.getElementById('legendewege').style.backgroundImage = "url(http://www.tannberg.info/fileadmin/tannberg/gfx/legende/wegeinakt.png)";}
}




///// SLIDESHOW /////



/*
MMapTypeControl
Control to set the map type.

Copyright 2008 - Marcelo Montagna  - http://maps.forum.nu

Free to use as long as copyright notices are left unchanged.
Please save the file to your own server. Do not link directly,
or unexpected things might happen to your control :-)

Note: This script contains code to prevent hotlinking. (marked with 'REMOVE')
You need to remove it when saving the file to your server.

------------------------------------------------------------
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
------------------------------------------------------------


Usage:
	map.addControl(new MMapTypeControl());
	map.addControl(new MMapTypeControl(options?));

MMapTypeControl options:
	Position: GControlPosition()
	background: HTML color - Default: '#8080FF';
	foreground: HTML color - Default: '#EEEEEE';
	parent: DOM element;
	direction: 'V' or 'H' - Default: 'H';
*/

/////////////////////////////////////////////////////////////////////////////



//////////// BEGIN MMapTypeControl /////////////////
function MMapTypeControl(MOptions) {
	MOptions = MOptions ? MOptions : {};
	this.parent = MOptions.container ? MOptions.container : null;
	this.direction = MOptions.direction ? MOptions.direction : 'V';
	//this.background = MOptions.background ? MOptions.background : '#E0E0E0';
	//this.foreground = MOptions.foreground ? MOptions.foreground : '#000000';
	this.validValues = MOptions.validValues ? MOptions.validValues : [];
	this.maxRes = 0;
	this.position = MOptions.position ? MOptions.position : new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(5, 5));
}

MMapTypeControl.prototype = new GControl();

MMapTypeControl.prototype.initialize = function(map) {
	var that = this;
	this.map = map;

	GEvent.addListener(map, "addmaptype", function(type) {that.mapAddType(type)});
	GEvent.addListener(map, "removemaptype", function(type) {that.mapRemoveType(type)});
	GEvent.addListener(map, "maptypechanged", function(o,n) {that.mapTypeChanged();});

	var container = document.createElement('div');
	container.id = 'mapcontrdiv';
	this.container = container;
	var oTable = document.createElement('div');
	oTable.id = 'MMTT_TABLE';
	container.appendChild(oTable);

	var mapTypes = this.map.getMapTypes();
	for (var  n = 0 ; n < mapTypes.length ; n++ ) {
		var label = mapTypes[n].getName();
		if (this.direction == 'V' || n == 0) {
			var oRow = document.createElement('div');
			oTable.appendChild(oRow);
			oRow.id = 'MMTR_'+n;

		}
		var oCell = this.createButton(that,n,label);
	oCell.innerHTML+=" ";  // This line for f*****g IE, else it will not render the control

		oRow.appendChild(oCell);
	}

	if (this.parent) {
		this.parent.appendChild(container);
	}
	else {
		this.map.getContainer().appendChild(container);
	}

//	this.mapTypeChanged();

	return container;
}

MMapTypeControl.prototype.getDefaultPosition = function() {
	if (this.parent) {
		return null;
	}
	return this.position;
}








////////////////////////////


MMapTypeControl.prototype.createButton = function(that,n,label) {
	var oCell = document.createElement('div');
	oCell.id = 'MMTC_'+n;
	label = label.replace(/ /g,'&nbsp;');
	oCell.innerHTML = label;
	this.setStyle(oCell);
	GEvent.addDomListener(oCell, "click", function() {that.setMapType(n); document.getElementById('bubbleklein').style.display = 'none';});
	return oCell;
}

MMapTypeControl.prototype.setMapType = function(n) {
	this.map.setMapType(this.map.getMapTypes()[n]);
}

MMapTypeControl.prototype.mapTypeChanged = function() {
	var mapTypes = this.map.getMapTypes();
	var currentMapType = this.map.getCurrentMapType();

	for (var n = 0; n < mapTypes.length ; n++ ) {
		var oCell = document.getElementById('MMTC_'+n); //Cell
		if (oCell) {
			this.setStyle(oCell);
			if (currentMapType == mapTypes[n]) {
				this.setStyleSel(oCell);
			}
		}
	}
}



MMapTypeControl.prototype.mapAddType = function(type) {
	var mapTypes = this.map.getMapTypes();
	var ix = mapTypes.length-1;
	var label = mapTypes[ix].getName();

	if (this.direction == 'V') {
		var oTable = document.getElementById('MMTT_TABLE');
		var oRow = document.createElement('div');
		oTable.appendChild(oRow);
		oRow.id = 'MMTR_'+ix;
	}
	else {
		var oRow = document.getElementById('MMTR_0');
	}

	var oCell = this.createButton(this,ix,label);
	oRow.appendChild(oCell);

};

MMapTypeControl.prototype.mapRemoveType = function(type) {
}



////////// Styles /////////////////////



MMapTypeControl.prototype.setCommon = function(obj) {
  obj.style.cursor = 'pointer';
}

MMapTypeControl.prototype.setStyle = function(obj) {
	this.setCommon(obj);
	obj.style.color = this.foreground;
	obj.style.textDecoration = "none";
}
MMapTypeControl.prototype.setStyleSel = function(obj) {
	this.setCommon(obj);
	obj.style.className = this.foreground;
	obj.style.textDecoration = "underline";
}
MMapTypeControl.prototype.setStyle2 = function(obj) {
	this.setCommon(obj);
	obj.style.color = this.foreground;
	obj.style.textDecoration = "none";
}



MMapTypeControl.prototype.show = function () {
	this.container.style.display = '';
}

MMapTypeControl.prototype.hide = function () {
	this.container.style.display = 'none';
}

MMapTypeControl.prototype.toggle = function () {
	this.container.style.display = this.container.style.display == '' ? 'none' : '';
}


//////////// END MMapTypeControl /////////////////

//// SLIDESHOW ////

var bubpos = 0;

function bubforward(bubpictures)
   {
	var bubpicturesarray = new Array();
	bubpicturesarray = bubpictures.split(',');   
    bubpos++;
    if (bubpos == bubpicturesarray.length) { bubpos = 0; }
    document.getElementById('bubpicture').src = bubpicturesarray[bubpos];
   }
   function bubback(bubpictures)
   {
	var bubpicturesarray = new Array();
	bubpicturesarray = bubpictures.split(',');   
    bubpos--;
    if (bubpos < 0) {  bubpos = bubpicturesarray.length - 1;  }
    document.getElementById('bubpicture').src = bubpicturesarray[bubpos];
   }
   
   function test() {alert("hoho");}
