var isBusyEmpfehlungW = false;
var httpEmpfehlungWen = createRequestObject();

function getEmpfehlungW(id, sprache) {
	
	if (isBusyEmpfehlungW) {
		// aborting previous update
		httpEmpfehlungWen.onreadystatechange = function() {}
		httpEmpfehlungWen.abort();
	}

	// setting html-element
	document.getElementById("EmpfehlungMail").innerHTML = "LOADING ...";
	
	// start request
	httpEmpfehlungWen.open("POST", "/content.weiterempfehlen.inc.asp?ArtikelID="+id+"&lang="+sprache);
	httpEmpfehlungWen.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	isBusyEmpfehlungW = true;
	httpEmpfehlungWen.onreadystatechange = handleEmpfehlungWResponse;
	httpEmpfehlungWen.send("id="+id+"&lang="+sprache);
	document.getElementById('EmpfehlungMail').style.display='inline';
}


function handleEmpfehlungWResponse() {

	if (httpEmpfehlungWen.readyState == 4) {
		// success!
		isBusyEmpfehlungW = false;
		try {
			document.getElementById("EmpfehlungMail").innerHTML = httpEmpfehlungWen.responseText;
		} catch (error) {
			document.getElementById("EmpfehlungMail").innerHTML = '<div id="EmpfehlungClose"><a href="#" onClick="document.getElementById(\'EmpfehlungMail\').style.display=\'none\'"><img src="/images/icon-close.gif" alt="schliessen" border="0"></a></div><div id="EmpfehlungMailTitel">Diese Funktion ist vor&uuml;bergehend deaktiviert.<br><br>'+error.description+'</div>';
		}
	}
}

function createRequestObject() {
	var ro;
	try {
		ro = new XMLHttpRequest();
	} catch (error)	{
		try {
			ro = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (error) {
			return false;
		}
	}
	return ro;
}

