function bild_folgt_maus(e) {

    e = e || window.event;
    if (e.pageX || e.pageY) {
        var mausX = e.pageX;
        var mausY = e.pageY;
    } 
    else {
        var de = document.documentElement;
        var b = document.body;
        var mausX = e.clientX + 
            (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
        var mausY = e.clientY + 
            (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
    }

	mausX=mausX+15;
	mausY=mausY+15;

	document.getElementById('ajax_bild').style.top=mausY+'px';
	document.getElementById('ajax_bild').style.left=mausX+'px';

}

function stateChanged_pw()
{
	if (xmlhttp.readyState==4)
	  {			
		 document.getElementById('ajax_bild').style.display='none';
		 document.getElementById(xmlhttp.ziel).innerHTML=xmlhttp.responseText;
	  } 
	else document.getElementById('ajax_bild').style.display='block';
}

function mag_ich(bp,bid,was,wo,welche) {
	xmlhttp=GetXmlHttpObject();
        if (xmlhttp==null)
          {
          return;
          }
		  
    var url="/js/mag_ich.ajax.php?bp="+bp+"&bid="+bid+"&was="+was+"&wo="+wo+"&welche="+welche;
	xmlhttp.ziel="l"+wo;
	xmlhttp.onreadystatechange=stateChanged_pw;
	xmlhttp.open("GET",url,true);
    xmlhttp.send(null);
}

function comment_send(id) {
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	  {
	  return;
	  }

	var url="/js/comment_send.ajax.php";
	var params="bp="+document.getElementById("bp"+id).value+"&bid="+document.getElementById("bi"+id).value+"&wo="+id+"&komm="+escape(document.getElementById("komm"+id).value);
	
	xmlhttp.open("POST",url,true);
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader("Content-length", params.length);
	xmlhttp.setRequestHeader("Connection", "close");
	
	xmlhttp.ziel='l'+id;
	xmlhttp.onreadystatechange=stateChanged_pw;
	
	xmlhttp.send(params);
	
	document.getElementById("komm"+id).value="";
			
}

function comment_aus(id) {
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	  {
	  return;
	  }
	  
	var url="/js/comment_send.ajax.php?bp="+document.getElementById("bp"+id).value+"&bid="+document.getElementById("bi"+id).value+"&wo="+id+"&caus="+id;
	xmlhttp.ziel="l"+id;
	xmlhttp.onreadystatechange=stateChanged_pw;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function comment_del(id, del) {
	if(confirm("Willst du den Kommentar wirklich löschen?")) {
		xmlhttp=GetXmlHttpObject();
		if (xmlhttp==null)
		  {
		  return;
		  }
		  
		var url="/js/comment_send.ajax.php?bp="+document.getElementById("bp"+id).value+"&bid="+document.getElementById("bi"+id).value+"&wo="+id+"&del="+del;
		xmlhttp.ziel="l"+id;
		xmlhttp.onreadystatechange=stateChanged_pw;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
	}
}

function zitat(text) {

	var result = "";

	for (var i = 0; i < text.length; i++) {
		if (text.charAt(i) == "+") result += " ";
		else result += text.charAt(i);
	}
	text=unescape(result);

	document.formular.postinhalt.value=document.formular.postinhalt.value + decodeURI(text);

}

function switch_display(element) {

	if(document.getElementById(element).style.display=="block") document.getElementById(element).style.display="none";
	else document.getElementById(element).style.display="block";

}


function errfader (r) {
	document.getElementById("err2").style.display="none";
	document.getElementById("err").style.height="0px";
	window.setTimeout("_errfader(10,"+r+")",1500);
}

function _errfader (h,r) {	
	h=h+10*r;
	document.getElementById("err").style.height=h+"px";
	if (h<200) {
		if (h>0) window.setTimeout("_errfader("+h+","+r+")",50);
		else {
			document.getElementById("err").style.display="none";
		}
	}
	else {
		errfader2(r);
	}
}

function errfader2(r) {
	document.getElementById("err").style.height="auto";
	document.getElementById("err2").style.opacity="0";
	document.getElementById("err2").filter="alpha(opacity=0)";
	document.getElementById("err2").style.display="block";
	_errfader2(10,r);
}

function _errfader2 (h,r) {	
	h=h+10*r;
	i=h/100;
	document.getElementById("err2").style.opacity=i;
	document.getElementById("err2").filter="alpha(opacity="+h+")";
	if (h<180) {
		if (h>0) window.setTimeout("_errfader2("+h+","+r+")",100);
		else {
			document.getElementById("err2").style.display="none";
			document.getElementById("err").style.height=180+"px";
			_errfader (180,-1);
		}
	}
	else {
		window.setTimeout("_errfader2("+h+",-1)",5000);
	}
}


var hinw_fader_height=20;
var hinw_fader_speed=2;
function hinw_fader (r,hoehe) {
	document.getElementById("hinw2").style.display="none";
	document.getElementById("hinw").style.height="0px";
	window.setTimeout("_hinw_fader(5,"+r+")",1000);
	if(hoehe>0) {
		hinw_fader_height=hoehe;
		hinw_fader_speed=parseInt(hinw_fader_height/10);
	}
}

function _hinw_fader (h,r) {	
	h=h+hinw_fader_speed*r;
	document.getElementById("hinw").style.height=h+"px";
	if (h<hinw_fader_height) {
		if (h>0) window.setTimeout("_hinw_fader("+h+","+r+")",50);
		else {
			document.getElementById("hinw").style.display="none";
		}
	}
	else {
		hinw_fader2(r);
	}
}

function hinw_fader2(r) {
	document.getElementById("hinw").style.height="auto";
	document.getElementById("hinw2").style.opacity="0";
	document.getElementById("hinw2").filter="alpha(opacity=0)";
	document.getElementById("hinw2").style.display="block";
	_hinw_fader2(5,r);
}

function _hinw_fader2 (h,r) {	
	h=h+hinw_fader_speed*r;
	i=h/hinw_fader_height;
	document.getElementById("hinw2").style.opacity=i;
	document.getElementById("hinw2").filter="alpha(opacity="+h+")";
	if (h<hinw_fader_height) {
		if (h>0) window.setTimeout("_hinw_fader2("+h+","+r+")",100);
		else {
			document.getElementById("hinw2").style.display="none";
			document.getElementById("hinw").style.height=hinw_fader_height+"px";
			_hinw_fader (hinw_fader_height,-1);
		}
	}
	else {
		window.setTimeout("_hinw_fader2("+h+",-1)",5000);
	}
}

