var tmpobj;
function sendMail(form){
	this.form = form;
	this.link = "send.php";
	this.target = "infoBox";
}

sendMail.prototype.send = function(){
	this.vorname = escape($("#vorname").val());
	this.nachname = escape($("#nachname").val());
	this.strasse = escape($("#strasse").val());
	this.plz = $("#plz").val();
	this.ort = escape($("#ort").val());
	this.mail = $("#mail").val();
	this.telefon = $("#telefon").val();
	this.frage = escape($("#frage").val());
	
	
	
	this.link += "?send=1&vorname="+this.vorname+"&nachname="+this.nachname+"&strasse="+this.strasse+"&plz="+this.plz+"&ort="+this.ort+"&mail="+this.mail+"&telefon="+this.telefon+"&frage="+this.frage;
	//alert(this.link);
	this.doRequest();
}

sendMail.prototype.reset = function (){
	this.vorname = "";
	$("#vorname").val("");
	this.nachname = "";
	$("#nachname").val("");
	this.strasse = "";
	$("#strasse").val("");
	this.plz = "";
	$("#plz").val("");
	this.ort = "";
	$("#ort").val("");
	this.mail = "";
	$("#mail").val("");
	this.telefon = "";
	$("#telefon").val("");
	this.frage = "";
	$("#frage").val("");
	$("#remLen1").val("1000");
	
	this.link = "send.php";
}

sendMail.prototype.doRequest = function (){
		var url = this.link;
		http_request = false;
        if (window.XMLHttpRequest) { // Mozilla, Safari,...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml; charset=ISO-8859-1');
                // zu dieser Zeile siehe weiter unten
            }
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            alert('Ende :( Kann keine XMLHTTP-Instanz erzeugen');
            return false;
        }
        tmpobj = this;
        http_request.onreadystatechange = alertInhalt;
        http_request.open('GET', url, true);
        http_request.send(null);

}
function alertInhalt() {
 
  if (http_request.readyState == 4) {
    if (http_request.status == 200) {
      var content = http_request.responseText;
      	$("#infoBox").show();
        document.getElementById('infoBox').innerHTML = content;
        
        if(content.substring(0,9) == "<!--OK-->"){
        	tmpobj.reset();
        }
    } else {
        alert('Bei dem Request ist ein Problem aufgetreten.');
      }
  }
}
