var theurl = "fileadmin/tipafriend/tipafriend.php";
var actDiv;
var theRes;
var textStateSave;
starStateSave = new Array ();

// ### Init AJAX communication
var xmlHttpObject = false;
// if XMLHttpRequest-class available: create request object for IE7, Firefox, etc.
if (typeof XMLHttpRequest != 'undefined') 
{
    xmlHttpObject = new XMLHttpRequest();
}
// if there wasn't a request object created before: try to create it for older ms browsers (ie6, ie5, etc.)
if (!xmlHttpObject) 
{
    try 
    {
        xmlHttpObject = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e) 
    {
        try 
        {
            xmlHttpObject = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch(e) 
        {
            xmlHttpObject = null;
        }
    }
}

function showWeiterForm () {
	document.getElementById("myoverlay").setAttribute("class", " ");
	document.getElementById("myformcontainer").setAttribute("class", " ");
	document.getElementById("myformdiv").setAttribute("class", "standardview");
}

function closeWeiter () {
	document.getElementById("myoverlay").setAttribute("class", "hide");
	document.getElementById("myformcontainer").setAttribute("class", "hide");
	document.getElementById("myformdiv").setAttribute("class", "hide");
}

function sendWeiter () {
	var docURL = encodeURIComponent(document.URL);
	var empf = encodeURIComponent(document.getElementById("theempf").value);
	var empfe = encodeURIComponent(document.getElementById("theempfe").value);
	var txt = encodeURIComponent(document.getElementById("thetxt").value);
	var snd = encodeURIComponent(document.getElementById("thesnd").value);
	var snde = encodeURIComponent(document.getElementById("thesnde").value);
	var searchStrg = "?docurl=" + docURL + "&empf=" + empf + "&empfe=" + empfe + "&txt=" + txt + "&snd=" + snd + "&snde=" + snde;
	xmlHttpObject.open("get", theurl + searchStrg);
	xmlHttpObject.onreadystatechange = handleResponse;
	xmlHttpObject.send(null);
}

function handleResponse() {
	if(xmlHttpObject.readyState == 4){
		var retVal = xmlHttpObject.responseText;
		if (retVal == "-") {
			closeWeiter();
		} else {
			theRes = xmlHttpObject.responseText.split("<<-X->>");
			document.getElementById("formerrorlist").innerHTML = "";
			for (var i = 0; i < theRes.length; i++) {
				if (theRes[i] != "") {				
					theField = theRes[i].split("<<-->>");
					if (theField[1] != "ok") {
						document.getElementById(theField[0]).setAttribute("class", "on");
						if (document.getElementById("mailformerror")) {
							document.getElementById("mailformerror").setAttribute("class", "");
							document.getElementById("mailformerror").setAttribute("id", "mailformerroron");
						}
						document.getElementById("formerrorlist").innerHTML = document.getElementById("formerrorlist").innerHTML + theField[1];
					} else {
						document.getElementById(theField[0]).setAttribute("class", " ");
					}
					document.getElementById(theField[0]).value = theField[2];
				}
			}
		}
	}
}

