/** \file
 * Diese Klasse wird zum dynamischen nachladen von HTML in einen Container benutzt.
 *
 * @author "$Author: rr@nci.ch $"
 * @version "$Id: Konstanten.php 741 2010-06-01 07:51:55Z rr@nci.ch $"
 */


function LoadHTML(rootelemid)
{
	this.eRoot=document.getElementById(rootelemid);


	// Methoden
	this.writeText=lh_writeText;
	this.removeAllChildren=lh_removeAllChildren;
	this.showData=lh_showData;
	this.reload=lh_reload;



	// init
	this.setdisplaystyle=null;
	//this.writeText('<h1>Hallo Welt</h1>');
	//this.reload(65910225);
	//datatable.ev_mousedown_show_desc=lh_reload;
}



function lh_removeAllChildren(e)
{
	if(!e) e=this.eRoot;
	while(e.hasChildNodes()) {
		var child=e.firstChild;
		e.removeChild(child);
	}
}


function lh_writeText(sTxt)
{
	this.eRoot.innerHTML=sTxt;
}


function lh_reload(sURL, setdisplaystyle0)
{
	//console.log('Reloading: ' + sURL);
	this.setdisplaystyle=setdisplaystyle0;
	this.removeAllChildren();
	this.writeText('<img src="design/res/loading.gif" />');
	//var sURL='index.php/REST/artikel/artikelnummer/' + id + '/detail.html';
	var http=new HTTPRequest("GET", sURL);
	http.open();
	http.httpobj.setRequestHeader('Content-Type', 'text/html; charset=UTF-8')
	http.httpobj.setRequestHeader('Accept', 'text/html')
	http.cb4=this.showData;
	http.caller=this;
	http.container=this.eRoot;
	http.send();
}


function lh_showData(http)
{
//	alert(http.httpobj.responseText);
	this.removeAllChildren();
	if(this.setdisplaystyle)
		this.eRoot.style.display=this.setdisplaystyle;
	this.writeText(http.httpobj.responseText);
}





