
function computeSmokeView() {
	var loadObj =  document.createElement('img');
	loadObj.src = 'pics/loadingbar.gif';
	loadObj.style.margin = '2px';
	var abortObj = document.createElement('div');
	abortObj.style.width = '100%';
	abortObj.style.textAlign = 'right';
	var abortLinkObj =  document.createElement('a');
	abortLinkObj.href = 'javascript:req.abortXMLHttpRequest()';
	var abTxtObj = document.createTextNode('Abbrechen');
	abortLinkObj.appendChild( abTxtObj );
	abortObj.appendChild( abortLinkObj );
	var txtObj = document.createTextNode('Bitte warten, lade Daten.');
	var splashObj = document.createElement('div');
	with( splashObj ) {
		style.background = '#FFFFFF';
		style.border = '1px solid black';
		style.width = '200px';
		style.height = '50px';
		style.padding = '2px';
		style.top =( winHeight()/2 )+'px';
		style.fontSize='9px';
		style.position = 'absolute';
		style.left =( winWidth()/2 )-100+'px';
		style.top =( winHeight()/2 )-25+'px';
		appendChild( txtObj );
		appendChild( loadObj );
		appendChild( abortObj );
	}
	var smokeObj = document.createElement('div');
	with( smokeObj ) {
		id ='SMOKE';
		style.textAlign = 'center';
		style.position = 'absolute';
		style.width = docWidth()+'px';
		style.height = ( docHeight()+10)+'px';
		style.top ='0px';
		style.left ='0px';
		if( typeof style.filter != 'undefined' ) {
			style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="pics/smokeViewIE.gif", sizingMethod="scale")';
			style.background = 'url( pics/smokeViewIE.gif )';
		}else{
			style.background = 'url( pics/smokeView.png )';
		}
		appendChild( splashObj );
	}
	return smokeObj;
}

var requestObj = function( ) {
	this.request 			= null;
	this.method 			= 'GET';
	this.url 				= null;
	this.sync 				= false;
	this.user				= null;
	this.password			= null;
	this.readystatefunction 	= null;
	this.overrideMime		= null;
	this.string 			= null;
	this.header 			= new Object;
	
	this.useSmoke			= false;
	this.smokeVisible		= false;
	this.smokeObject		= null;
	this.bodyObject			= null;

	this.showSmoke	= function ( docBodyObj ) {
		this.bodyObject = docBodyObj;
		if( typeof this.smokeObject == 'object' && this.useSmoke ) {
			this.bodyObject.appendChild( this.smokeObject );
			this.smokeVisible = true;
		}
	}
	
	this.hideSmoke		= function () {
		if( typeof this.smokeObject == 'object' && this.useSmoke && this.smokeVisible ) {
			this.bodyObject.removeChild( this.smokeObject );
			this.smokeVisible = false;
		}
	}

	this.createXMLHttpRequest = function () {
		var req = null;
		try {
			req = new ActiveXObject("MSXML2.XMLHTTP");
		}catch (err_MSXML2) {
			try {
				req = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (err_Microsoft) {
				if (typeof XMLHttpRequest != "undefined") {
					req = new XMLHttpRequest;
					if ( this.overrideMime && req.overrideMimeType ) {
						req.overrideMimeType( this.overrideMime );
					}
				}
			}
		}
		this.request = req;
	}
	
	this.setXMLHttpRequest = function ( rurl, rstring, rrsfunction ) {
		this.readystatefunction 	= rrsfunction;
		this.string 			= rstring;
		this.url 				= rurl;

		this.createXMLHttpRequest();
		if( this.request !== null ) {
			if( this.method == 'GET' ) {
				this.url = this.url+"?"+this.string;
				this.string = null;
			}
			
			try{
				this.request.open( this.method, this.url, this.sync, this.user, this.password );
				
				this.header['Accept'] = 'text/javascript, text/html, application/xml, text/xml, */*';
				
				if ( this.method == 'POST' ) {
					this.header['Content-Type']='application/x-www-form-urlencoded';
					if ( this.overrideMime && (navigator.userAgent.match(/Gecko\/(\d{4})/) || [0,2005])[1] < 2005) {
						// Workaround für ältere Mozilla-Browser
						this.header['Connection'] = 'close';
					}
				}else{
					this.header['Content-Type'] = (this.overrideMime) ? this.overrideMime : 'text/html';
				}
				if( typeof this.header == 'object' ) {
					for( var headval in this.header ) {
						this.request.setRequestHeader( headval , this.header[headval] );
					}
				}
				this.request.onreadystatechange = this.readystatefunction;
				this.request.send( this.string );
			}catch( e ){
				// Fehler bei der Verarbeitung
				if( this.smokeObject && this.useSmoke ) {
					this.hideSmoke();
				}
			}
		}
	}
	
	this.abortXMLHttpRequest = function () {
		if ( this.request !== null ) {
			this.request.abort();
		}
		if( this.smokeObject && this.useSmoke ) {
			this.hideSmoke();
		}
	}
}
