/*
**************************
*
* Java-Script Classes Copyright by Johannes Köber
* www.bewegungstalent.de
*
* © 2006-2007 by Johannes Köber
*
**************************
*/

function http_request() {
}

http_request.prototype = {
	init : function(path,url,url_units,eLoad,eOut) {
		var http_variable = this.srcXMLHttpRequestObject();
		http_file_path  = path;
		http_link 	    = url;
		http_link_units = url_units;
		element_loading = eLoad; 
		element_output  = eOut;
	},
	
	// XMLHttp - Browserimport wählen
	srcXMLHttpRequestObject : function(){
		http_variable = null;
		// Internet Explorer 6 und älter
		try {
			 http_variable = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(Error){
		 // Internet Explorer 6 und älter
		 try {
			http_variable = new ActiveXObject("MSXML2.XMLHTTP");
		 }
		 catch(Error){
		  // Mozilla, Opera, Safari sowie Internet Explorer 7
		  try {
			 http_variable = new XMLHttpRequest();
		  }
		  catch(Error){
			alert("Erzeugung des XMLHttpRequest-Objekts ist nicht möglich");
		  }
		 }
		}
	 return this.http_variable;
	},
		
	// Anfrage absetzen editierten Vertrag Speichern
	snd_request : function() {
			http_variable.open('GET',http_file_path+http_link+http_link_units,true);
			http_variable.onreadystatechange = this.loading; // Aufruf der HandleResponse-Funktion
			http_variable.send(null);
	},
	
	// Laden!
	loading : function() {
				if(http_variable.readyState != 4) { // Wenn Status != 4 ladenbild
					document.getElementById(element_loading).style.display = "block";
					document.getElementById(element_output).style.display = "none";
				} else {
					if(http_variable.readyState == 4) { // Anzeigen des geladenen Inhaltes
						// alert(http_file_path+http_link+http_link_units); // Testausgabe!
						document.getElementById(element_loading).style.display = "none"; // Loading ausblenden
						document.getElementById(element_output).innerHTML = http_variable.responseText; // Inhalt reinladen
						document.getElementById(element_output).style.display = "block"; // anzeigen
					}
				}	
	},
	
	// Funktion für Testausgabe
	test_snd_request_obj : function() {
				alert(http_file_path+http_link+http_link_units);
	}
}	
