
/* BEGIN script addLoadEvent */
//addLoadEvent(checkMap());

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}
/* END script addLoadEvent */


/* Tooltip Script Start */

document.onmousemove = updateWMTT;

function showWMTT(id,width,height) {
	wmtt = document.getElementById(id);
	wmtt.style.display = "block"
	currentimageheight = height;
	currentimagewidth = width;
}

function hideWMTT() {
	wmtt.style.display = "none";
}

function truebody(){
	return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function updateWMTT(e){
	/*out = document.getElementById('output');
		out.innerHTML=curleft+" px - "+curtop+" px";*/

	if (typeof(wmtt)!="undefined"){
		var xcoord=0;
		var ycoord=0;

		if (typeof(currentimageheight)=="undefined"){
		   currentimageheight = 200;
		}

		if (typeof(currentimagewidth)=="undefined"){
		   currentimagewidth = 300;
		}

		borderheight = 22;
		borderwidth = 40;
		image_minsize = 300;

		var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
		var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)

		if (typeof e != "undefined"){
			/* FF */
			if (docwidth - e.pageX < image_minsize){
				xcoord = e.pageX - xcoord - currentimagewidth + borderwidth; // Move to the left side of the cursor
			} else {
				xcoord += e.pageX;
			}
			if (docheight - e.pageY < ((currentimageheight + borderheight)/2)+5){
				ycoord += e.pageY - Math.max(0,(((currentimageheight + borderheight)/2) + e.pageY - docheight - truebody().scrollTop)) - ((currentimageheight + borderheight)/2);
			} else {
				ycoord += e.pageY - (currentimageheight/2);
			}

		} else if (typeof window.event != "undefined"){
		  /* IE */
			obj = document.getElementById('base');
			var curleft = curtop = 0;
			if (obj.offsetParent) {
				curleft = obj.offsetLeft
				curtop = obj.offsetTop
				while (obj = obj.offsetParent) {
					curleft += obj.offsetLeft
					curtop += obj.offsetTop
				}
			}

			if (docwidth - event.clientX < image_minsize){
				xcoord = event.clientX + truebody().scrollLeft - xcoord - currentimagewidth + borderwidth; // Move to the left side of the cursor
			} else {
				xcoord += truebody().scrollLeft+event.clientX
			}
			xcoord = xcoord-curleft;

			if (docheight - event.clientY < ((currentimageheight + borderheight)/2)+10){
				ycoord += event.clientY + truebody().scrollTop - Math.max(0,(((currentimageheight + borderheight)/2)+10 + event.clientY - docheight)) - ((currentimageheight + borderheight)/2)+10;
			} else {
				ycoord += truebody().scrollTop + event.clientY - (currentimageheight/2);
			}
			ycoord = ycoord-curtop;
		}

		if(ycoord < 0) { ycoord = ycoord*-1; }

		/*out.innerHTML = "xFF = "+xcoord+"px + "+curleft+" = "+(xcoord+curleft);*/
		wmtt.style.left=xcoord+10+"px"
		wmtt.style.top=ycoord+"px"
	}
}

/* Tooltip Script ENDE */

/* Popup Script Start */
function popUp(URL,hoehe,breite) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=570,height=520');");
}
/* Popup Script ENDE */


/* changeMap Script Start */

function changeElem(elem1,elem2,elem3) {
	if(document.getElementById(elem1) && document.getElementById(elem2) && document.getElementById(elem3)){
		document.getElementById(elem1).style.display='none';
		document.getElementById(elem2).style.display='none';
		document.getElementById(elem3).style.display='block';
	}else{
		setTimeout("changeElem("+elem1+","+elem2+","+elem3+");",500);
	}
	setCookie('blockedElem',elem3);
}

function checkMap() {
	var blockedElem = getCookie('blockedElem');
	if(blockedElem == 'map_bl') {
		changeElem('map_plz','map_europe','map_bl');
	}else if(blockedElem == 'map_europa') {
		changeElem('map_plz','map_bl','map_europe');
	}
}

/* changeMap Script ENDE */


/* Cookie Script Start */

function setCookie(name,value){
	time = new Date();
	time = new Date(time.getTime()+1000*60*60*24*365); //aktuelle Zeit + 1 Jahr
	document.cookie = name + "=" + value + ";expires=" + time.toGMTString() + ";";
}

function getCookie(name){
	value = "";
	if(document.cookie) {
		start = document.cookie.indexOf("=") + 1;
		end = document.cookie.indexOf(";");
		if(end == -1) {
			end = document.cookie.length;
		}else{
			value = document.cookie.substring(start,end);
		}
	}else{
	}
	return value
}

/* Cookie Script ENDE */


