var mapvisible = true;
var startHeight = 0;
var newHeight = 0;
var switchButton;
var onlyonce=1;

function SetCookie() {
if(arguments.length < 2) { return; }
var n = arguments[0];
var v = arguments[1];
var d = 0;
if(arguments.length > 2) { d = parseInt(arguments[2]); }
var exp = '';
if(d > 0) {
	var now = new Date();
	then = now.getTime() + (d * 24 * 60 * 60 * 1000);
	now.setTime(then);
	exp = '; expires=' + now.toGMTString();
	}
document.cookie = n + "=" + escape(String(v)) + '; path=/' + exp;
} // function SetCookie()


function ReadCookie(n) {
var cookiecontent = new String();
if(document.cookie.length > 0) {
	var cookiename = n+ '=';
	var cookiebegin = document.cookie.indexOf(cookiename);
	var cookieend = 0;
	if(cookiebegin > -1) {
		cookiebegin += cookiename.length;
		cookieend = document.cookie.indexOf(";",cookiebegin);
		if(cookieend < cookiebegin) { cookieend = document.cookie.length; }
		cookiecontent = document.cookie.substring(cookiebegin,cookieend);
		}
	}
return unescape(cookiecontent);
} 


function slideDivOut(divname, div2name)
{	
	var d = document.getElementById(divname);	
	var d2 = document.getElementById(div2name);
	d2.style.display = "none";

	newHeight-=5;
	if (newHeight<=0)
	{
		d.style.display = "none";
		return;		
	}			
	d.style.height = newHeight + "px";
	setTimeout('slideDivOut("'+divname+'", "'+div2name+'")', 50);	
}


function slideDivIn(divname, div2name)
{	
	var d = document.getElementById(divname);	
	var d2 = document.getElementById(div2name);
	
	d.style.display = "block";
	newHeight+=5;
	
	if (newHeight>=startHeight)
	{
		d.style.height = startHeight + "px";		
		d2.style.display = "block";
		return;		
	}
				
	d.style.height = newHeight + "px";
	setTimeout('slideDivIn("'+divname+'", "'+div2name+'")', 50);	
}

function slideOut(divname)
{	
	var d = document.getElementById(divname);	
	
	newHeight-=60;
	switchButton.style.display = "none";
	
	if (newHeight<=0)
	{
		switchButton.style.display = "block";
		d.style.display = "none";
		return;		
	}	
		
	d.style.height = newHeight + "px";
	setTimeout('slideOut("'+divname+'")', 1);	
}

function slideIn(divname)
{	
	var d = document.getElementById(divname);	
	
	d.style.display = "block";
	
	newHeight+=60;
	switchButton.style.display = "none";
	
	if (newHeight>=startHeight)
	{
		switchButton.style.display = "block";
		d.style.height = startHeight + "px";		
		return;		
	}
		
		
	d.style.height = newHeight + "px";
	setTimeout('slideIn("'+divname+'")', 1);	
}

function toggleMap(init)
{
	
	if ( (init==1) && (onlyonce==1) )
	{
		onlyonce = 0;
		mapvisible = false;
		startHeight = 366;
	}
	
	if (mapvisible)
	{
		mapvisible = false;
		/*document.getElementById("flashmap").style.display = "none";*/
		document.getElementById("flashmapbutton").innerHTML = "Dynamische Karte EIN";
		/* save height */
		startHeight = 366;
		newHeight = startHeight;				
		switchButton = document.getElementById("switcher");
		slideOut("flashmap");
		SetCookie("flashmap", "hide", 100);
	}
	else
	{
		mapvisible = true;
		/*document.getElementById("flashmap").style.display = "block";*/
		document.getElementById("flashmapbutton").innerHTML = "Dynamische Karte AUS";		
		switchButton = document.getElementById("switcher");
		slideIn("flashmap");
		SetCookie("flashmap", "show", 100);
	}
}