function klappe(id)
{
	var klappText = document.getElementById('k' + id);
	//var klappBild = document.getElementById('pic' + id);

	if (klappText.style.display == 'none') {
	  klappText.style.display = 'block';
	  // klappBild.src = 'pic/blank.gif';
	}
	else {
	  klappText.style.display = 'none';
	  // klappBild.src = 'pic/blank.gif';
	}
}

function klappe_news(id)
{
	var klappText = document.getElementById('k' + id);
	var klappBild = document.getElementById('pic' + id);

	if (klappText.style.display == 'none') {
	  klappText.style.display = 'block';
	  klappBild.src = 'pic/minus.gif';
	}
	else {
	  klappText.style.display = 'none';
	  klappBild.src = 'pic/plus.gif';
	}
}

function Post()
{
	document.compose.action = "?action=post"
	document.compose.target = "";
	document.compose.submit();
	return true;
}

function Preview()
{
	document.compose.action = "?action=preview"
	document.compose.target = "";
	document.compose.submit();
	return true;
}

function togglediv(id)
{
  if (document.getElementById)
  {
    aref = document.getElementById("a"+id);
    if (aref.innerHTML == "Click here to expand")
      aref.innerHTML = "Click here to contract";
    else if (aref.innerHTML == "Click here to contract")
      aref.innerHTML = "Click here to expand";
    img = document.getElementById("i"+id);
    img.src = (img.src.match("pic/plus.gif") == null ? "pic/plus.gif" : "pic/minus.gif"); 
    vis = document.getElementById("d"+id).style;
    vis.display = (vis.display == "block" ? "none" : "block");
  }
}

//AJAX-style scripts
function togglediv(id) {
	if (document.getElementById) {
		aref = document.getElementById("a"+id);
		if (aref.innerHTML == "Click here to expand")
			aref.innerHTML = "Click here to contract";
		else if (aref.innerHTML == "Click here to contract")
			aref.innerHTML = "Click here to expand";
		img = document.getElementById("i"+id);
		img.src = (img.src.match("pic/plus.gif") == null ? "pic/plus.gif" : "pic/minus.gif"); 
		vis = document.getElementById("d"+id).style;
		vis.display = (vis.display == "block" ? "none" : "block");
	}
}

function setContent(ph, content)
{
	switch(ph.tagName)
	{
		case 'TEXTAREA': case 'INPUT':
			ph.value = content;
			break;
		case 'DIV': case 'SPAN': default:
			ph.innerHTML = content;
			break;
	}
}

function getAJAX(placeholder, url) {
	//Make sure the browser is DOM compliant
	if (!document.getElementById) {
		//Allow the hyperlink to process normally
		return true;
	}
	//Get the placeholder
	ph = document.getElementById(placeholder);
	if (ph.innerHTML != "")	{
		//The placaeholder has content; just toggle its display
		ph.style.display = (ph.style.display == "none" ? "block" : "none");
	}
	else {
		//The div is empty; use AJAX to populate it with the contents from url
		//Initialize AJAX
		var xmlHttp;
		// Firefox, Opera 8.0+, Safari
		if (window.XMLHttpRequest) {
			xmlHttp = new XMLHttpRequest();
		}
		// Internet Explorer
		else if (window.ActiveXObject) {
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		
		if (xmlHttp == null) {
			setContent(ph, "Your browser does not support AJAX.");
			//Allow the hyperlink to process normally
			return true;
		}
	
		//Remove any pre-existing data
		setContent(ph, 'Loading...<br /><img alt="Loading" src="/ajax/loading.gif" />');
			
		xmlHttp.onreadystatechange = function() {
			if(xmlHttp.readyState==4) {
				setContent(ph, xmlHttp.responseText);
			}
		}
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
	//Prevent the anchor href from being called
	return false;
}

function refreshAJAX(placeholder, url) {
	//Make sure the browser is DOM compliant
	if (!document.getElementById) {
		//Allow the hyperlink to process normally
		return true;
	}
	//Get the placeholder div
	ph = document.getElementById(placeholder);

	var xmlHttp;
	// Firefox, Opera 8.0+, Safari
	if (window.XMLHttpRequest) {
		xmlHttp = new XMLHttpRequest();
	}
	// Internet Explorer
	else if (window.ActiveXObject) {
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	if (xmlHttp == null) {
		setContent(ph, "Your browser does not support AJAX.");
		//Allow the hyperlink to process normally
		return true;
	}
		
	xmlHttp.onreadystatechange = function() {
		if(xmlHttp.readyState==4) {
			setContent(ph, xmlHttp.responseText);
		}
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);

	//Prevent the anchor href from being called
	return false;
}

function postAJAX(placeholder, url, form)
{
		//Make sure the browser is DOM compliant
	if (!document.getElementById) {
		//Allow the hyperlink to process normally
		return true;
	}
	//Get the placeholder div
	ph = document.getElementById(placeholder);

	//Initialize AJAX
	var xmlHttp;
	// Firefox, Opera 8.0+, Safari
	if (window.XMLHttpRequest) {
		xmlHttp = new XMLHttpRequest();
	}
	// Internet Explorer
	else if (window.ActiveXObject) {
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	if (xmlHttp == null) {
		setContent(ph, "Your browser does not support AJAX.");
		//Allow the hyperlink to process normally
		return true;
	}
				
	xmlHttp.onreadystatechange = function() {
		if(xmlHttp.readyState==4) {
			setContent(ph, xmlHttp.responseText);
		}
	}
	
	//Generate the parameters from the form
    var params = ''; 
    for (i = 0; i < form.elements.length;i++) {
		var ctl = form.elements[i];
		if (ctl.name != '')
			switch (ctl.type) {
				case 'radio':
					if (ctl.checked)
						params += (params == '' ? '' : '&') + ctl.name + '=' + escape(ctl.value);
				break;
				default:
					params += (params == '' ? '' : '&') + ctl.name + '=' + escape(ctl.value);
				break;	
			}              
    } 
    params += "\n"; 
    
	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.send(params);
	//Prevent the form from being submitted
	return false;
}

function fistbump(placeholder, url) {
	//Make sure the browser is DOM compliant
	if (!document.getElementById) {
		//Allow the hyperlink to process normally
		return true;
	}
	
	//Get the placeholder div
	var ph = document.getElementById(placeholder);
	
	//Initialize AJAX
	var xmlHttp;
	// Firefox, Opera 8.0+, Safari
	if (window.XMLHttpRequest) {
		xmlHttp = new XMLHttpRequest();
	}
	// Internet Explorer
	else if (window.ActiveXObject) {
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	if (xmlHttp == null) {
		ph.innerHTML = "Your browser does not support AJAX.";
		//Allow the hyperlink to process normally
		return true;
	}

	//Remove any pre-existing data
	ph.innerHTML = "One moment...";
		
	xmlHttp.onreadystatechange = function() {
		if(xmlHttp.readyState==4) {
			ph.innerHTML = xmlHttp.responseText;
		}
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);

	//Prevent the anchor href from being called
	return false;
}