function krimbox()
{
	this.layer = document.createElement('div');
	this.wrapper = document.createElement('div');
	this.notices = document.createElement('div');
	this.loadedWindows = 0;
	this.status = 0;
	this.onload = new Object();
	this.onunload = new Object();
	this.loading = new Object();
	this.oldTop = false;
	var self = this;
	
	
	this.startLoading = function(div)
	{
	
		if(typeof(div) != 'object') div = $get(div);
		if(this.loading[div.id] == 0)
			$get(div.id+'_loading').className = 'gates_tab_loading';
		this.loading[div.id]++;
	}
	

	this.stopLoading = function(div)
	{
		if(typeof(div) != 'object') div = $get(div);
		this.loading[div.id]--;
		if(this.loading[div.id] < 0) this.loading[div.id] = 0;
		if(this.loading[div.id] == 0)
		{
			$get(div.id+'_loading').className = '';
		}
	}
	
	this.changeTop = function(div)
	{
		if(this.oldTop) this.oldTop.style.zIndex = 50;
		div.style.zIndex = 60;
		this.oldTop = div;
	}
	
	this.addWindow = function(div,func,func2)
	{
		if(typeof(div) != 'object') div = $get(div);
		div.style.display = "none";
		this.loading[div.id] = 0;
		this.wrapper.appendChild(div);
		
		if(func && func != 'undefined')
			this.onload[div.id] = func;
		
		if(func2 && func2 != 'undefined')
			this.onunload[div.id] = func2;		
	}
	
	this.hideWindow = function(div)
	{
		if(typeof(div) != 'object') div = $get(div);
		if(this.onunload[div.id] && this.onunload[div.id] != 'undefined') this.onunload[div.id]();
		$('#'+div.id).slideUp("slow");

		this.loadedWindows--;
		
		if(this.loadedWindows < 0) this.loadedWindows = 0; //Fallback
		if(this.loadedWindows == 0 && this.layer.style.display != 'none') this.hideLayer();
	}
	
	this.showWindow = function(div,func,opt)
	{
		if(typeof(div) != 'object') div = $get(div);
		if(div.style.display == 'none') //Fenster ist ausgeblendet
		{
			if(this.status == 0) this.showLayer();
			div.style.display = 'inline';
			if(this.onload[div.id] && this.onload[div.id] != 'undefined') this.onload[div.id](opt);
			if(func && func != 'undefined') func(opt);
			this.loadedWindows++;
		}
	}

	this.hideLayer = function()
	{
		$('#'+this.layer.id).hide("slow");
		$('#'+this.wrapper.id).slideUp("slow");
		setTimeout(function() 
		{
			self.layer.style.display = 'none';
			self.wrapper.style.display = 'none';
		}, 500);
		
		this.status = 0;
	}
	
	this.showLayer = function()
	{
		$('#'+this.layer.id).show("slow");
		$('#'+this.wrapper.id).slideDown("slow");
		//this.layer.style.display = 'block';
		this.wrapper.style.display = 'block';
		this.status = 1;
	}
	
	this.quickDiv = function(style,append)
	{
		var div = document.createElement('div');
		div.className = style;
		append.appendChild(div);
	}
	
	this.createNotice = function(text,img)
	{
		var notice = document.createElement('div');
		notice.className = 'floating_notice';
		this.quickDiv('top',notice);
		this.quickDiv('mid',notice);
		this.quickDiv('bottom',notice);
		
		//Erstelle Content Table
		var table = document.createElement('table');
		table.cellPadding = 0;
		table.cellSpacing = 0;
		table.className = 'floating_notice_content';
		
		var content = document.createElement('div');
		var tbody = document.createElement('tbody');
		var tr = document.createElement('tr');
		var td1 = document.createElement('td');
		var td2 = document.createElement('td');
		
		content.className = 'notice_text';
		content.innerHTML = text;
		
		if(img && img != null && img != 'undefined')
		{
			var imgc = document.createElement('img');
			if(img.indexOf("http://") != -1)
				imgc.src = img;
			else
				imgc.src = _core_hurl+'_global/images/icons/'+img+'.gif';
			td1.appendChild(imgc);
		}
			
		td2.appendChild(content);
		tr.appendChild(td1);
		tr.appendChild(td2);
		tbody.appendChild(tr);
		table.appendChild(tbody);
		notice.appendChild(table);
		this.notices.appendChild(notice);
		$(notice).effect('bounce');
		setTimeout(function() { self.closeNotice(notice);},20000);
	}
	
	this.closeNotice = function(notice)
	{
		notice.parentNode.removeChild(notice);
		//$(notice).hide('scale'); //,false,1000,function(){ notice.parentNode.removeChild(notice);}
	}

	this.onresize = function()
	{
		var container_height;
		if (windowHeight > document.body.offsetHeight)
			container_height = windowHeight;
		else
			container_height = document.body.offsetHeight + 1;
		
		this.wrapper.style.height = container_height + "px";
    	this.layer.style.height = container_height + "px";
	}
	
	this.startup = function(spawn)
	{
		if(typeof(spawn) != 'object') spawn = $get(spawn);
		this.layer.id = 'gates_layer';
		this.wrapper.id = 'gates_wrapper';
		this.notices.id = 'gates_notices';
		spawn.appendChild(this.layer);
		spawn.appendChild(this.wrapper);
		spawn.appendChild(this.notices);
	}
}