document.write('<button type="button" onclick="toggleLegend();" style="position: absolute;z-index: 10000;top: 0;right: 0;width: 288px;border: 1px solid #000;height:19px;">LEGENDE</button>');

document.write('<button type="button" onclick="toggleLegend();" style="position: absolute;z-index: 10000;top: 0;right: 0;width: 21px;height: 19px;border: 1px solid #000;border-bottom-left-radius: 9px;">x</button>'); 

document.write('<button type="button" onclick="toggleScale();" style="position: absolute;z-index: 10000;bottom: 0px;left: 0px;width: 21px;height: 19px;border: 1px solid #000;border-top-right-radius: 9px;background-color: transparent;">x</button>');

document.write('<button type="button" onclick="toggleAttribution();" style="position: absolute;z-index: 10000;bottom: 0px;right: 0px;width: 21px;height: 19px;border: 1px solid #000;border-top-left-radius: 9px;background-color: transparent;">x</button>'); 
	 
function initLegend() {
	var x = document.getElementsByClassName('leaflet-top leaflet-right');	
	if (legendcollapsed == 'block') { 
		x[0].style.display = 'block';setCookie("legendcollapsed","block",64);
	}else{
		x[0].style.display = 'none' ;setCookie("legendcollapsed","none",64);
	}
}	
	
function toggleLegend() {
	var x = document.getElementsByClassName('leaflet-top leaflet-right');	
	if(x[0].style.display == 'block' ) {
		x[0].style.display = 'none';setCookie("legendcollapsed","none",64);
	}else{
		x[0].style.display = 'block';setCookie("legendcollapsed","block",64);
	}
}


// var showScale = true;
//var toggleScale = function(){
//	if(showScale == true){
//		var y = document.getElementsByClassName('leaflet-bottom  leaflet-left');
//		y[0].style.display = 'none';setCookie("showScale",false,64);
//		showScale = false; 
//	}else{
//		var y = document.getElementsByClassName('leaflet-bottom  leaflet-left');
//		y[0].style.display = 'block';setCookie("showScale",true,64);
//		showScale = true; 
//	}
//}

function initScale() {
	var z = document.getElementsByClassName('leaflet-bottom  leaflet-left');
	if (showScale == 'block') { 
		z[0].style.display = 'block';setCookie("showScale","block",64);
	}else{
		z[0].style.display = 'none' ;setCookie("showScale","none",64);
	}
}	

function toggleScale() {
	var z = document.getElementsByClassName('leaflet-bottom  leaflet-left');	
	if(showScale == 'block' ) {
		z[0].style.display = 'none';setCookie("showScale","none",64);
	}else{
		z[0].style.display = 'block';setCookie("showScale","block",64);
	}
}


var showAttribution = true; 
var toggleAttribution = function(){
	if(showAttribution == true){
		var y = document.getElementsByClassName('leaflet-bottom leaflet-right');
		y[0].style.display = 'none';
		showAttribution = false; 
	}else{
		var y = document.getElementsByClassName('leaflet-bottom leaflet-right');
		y[0].style.display = 'block';
		showAttribution = true; 
	}
}
	
	

