function BusyBox(id, varName, imageCount, imageNamePrefix, imageNameSuffix, imageDelay, width, height, url, offsetHeight) {
	this.id = id;
	this.ImageCount = imageCount;
	this.CurrentImageIndex = 0;
	this.ImageWidth = 0;
	this.ImageHeight = 0;
	this.ImageNamePrefix = imageNamePrefix;
	this.ImageNameSuffix = imageNameSuffix;
	this.ImageDelay = imageDelay;
	this.DivID = "BusyBoxDiv";
	this.ImgID = "BusyBoxImg";
	this.Enabled = true;
	this.Width = width;
	this.Height = height;
	this.OffsetHeight = offsetHeight;
	this.VarName = varName;
	this.timeout_id = null;
	this.CacheImages();
	this.BusyBoxUrl = url;
	this.IFrame = document.getElementById(this.id);
	this.Hide();
	if( this.BusyBoxUrl )
		this.LoadUrl(this.BusyBoxUrl);
	else
		this.RenderContent();
	if( !frames[this.id] )
		this.Enabled = false;
}

BusyBox.prototype.GetIFrameDocument = function() {
	var doc;	
	if( this.IFrame.contentDocument ) {
		// For NS6
		doc = this.IFrame.contentDocument; 
	} else if( this.IFrame.contentWindow ) {
		// For IE5.5 and IE6
		doc = this.IFrame.contentWindow.document;
	} else if( this.IFrame.document ) {
		// For IE5
		doc = this.IFrame.document;
	} else {
		doc = this.IFrame.document;
	}		
	return doc;
}

BusyBox.prototype.LoadUrl = function(url) {
	var IFrameDoc = this.GetIFrameDocument();
	IFrameDoc.location.replace(url);
}

BusyBox.prototype.RenderContent = function() {
	var doc = this.GetIFrameDocument();
	var style = " style='border:black 3px solid; position:absolute;' ";
	doc.open();
	doc.writeln("<body ondragstart='return false;' style='margin:0px; background-color:white'>");
	doc.writeln("   <div id='" + this.DivID + "' align=center " + style + ">");
	doc.writeln("      <img id='" + this.ImgID + "' src=''>");
	doc.writeln("      <br><h3>Processing</h3>");
	doc.writeln("   </div>");
	doc.writeln("</body>");
	doc.close();
}

BusyBox.prototype.Resize = function() {
		var div = frames[this.id].document.getElementById(this.DivID);
		this.IFrame.style.width = div.offsetWidth+"px";
		this.IFrame.style.height = div.offsetHeight+"px";
}

BusyBox.prototype.Center = function(offsetHeight) {
	if( !this.IFrame )
		return;
	var objLeft = (screen.width - this.IFrame.offsetWidth) / 2;
	var objTop = ((screen.height - this.IFrame.offsetHeight) / 2) + offsetHeight;
	this.IFrame.style.position = "absolute";
	this.IFrame.style.top = objTop+"px";
	this.IFrame.style.left = objLeft+"px";
}

BusyBox.prototype.CacheImages = function() {
	this.Images = new Array(this.ImageCount);
	for(var i = 0; i < this.ImageCount; i++) {
		this.Images[i] = new Image();
		this.Images[i].src = this.ImageNamePrefix + i + this.ImageNameSuffix;
	}
}

BusyBox.prototype.IsAnimating = function() {
	if( this.timeout_id == null)
		return false;
	else
		return true;
}

BusyBox.prototype.IsVisible = function() {
	var ifrm = document.getElementById(this.id);
	if( ifrm.style.visibility == "visible" && ifrm.style.width > 0 )
		return true;
	else
		return false;
}

BusyBox.prototype.Animate = function() {
	if( frames[this.id] )
		frames[this.id].document.getElementById(this.ImgID).src = this.Images[this.CurrentImageIndex].src;
	else
		// browser does not support frames
		document.getElementById(this.ImgID).src = this.Images[this.CurrentImageIndex].src;
	
	this.Resize();
	this.Center(this.OffsetHeight);
	this.CurrentImageIndex = (this.CurrentImageIndex + 1)%this.ImageCount;
	this.timeout_id = setTimeout(this.VarName + ".Animate();", this.ImageDelay);
}

BusyBox.prototype.StartAnimate = function() {
	if( this.IsAnimating() )
		return;
	this.Animate();
}

BusyBox.prototype.StopAnimate = function() {
	clearTimeout(this.timeout_id);
	this.timeout_id = null;
}

BusyBox.prototype.Hide = function() {	
//	new Effect.Opacity('bodybackground', { duration: 0.2, transition: Effect.Transitions.linear, from: 0.6, to: 0 });
	this.StopAnimate();
	this.IFrame.style.visibility = "hidden";
	this.IFrame.style.width = 0;
	this.IFrame.style.height = 0;
	if ($('bodybackground') != null) {
		$('bodybackground').remove(); //muss rein, damit das div ganz verschwindet
	}
}

BusyBox.prototype.Show = function() {
	if( !this.Enabled )
		return;
	if( this.IsAnimating() || this.IsVisible() )
		return;	
	this.Resize();
	this.Center(this.OffsetHeight);
	$('bodyGroesse').insert("<div id='bodybackground' class='bodybackground'></div>");
	new Effect.Opacity('bodybackground', { duration: 0.2, transition: Effect.Transitions.linear, from: 0, to: 0.6 });
 	this.IFrame.style.visibility = "visible";
	this.IFrame.style.zIndex = "999999";
	this.StartAnimate();	
}