//Works only with jQuery 1.1.2 or upper
var box1 = new PopUpBox();
box1.setText("Das ist eine Info Box!");
box1.setPaddingLeft(25);

var box2 = new PopUpBox();
box2.setText("Dood whats up here?");
box2.setPaddingLeft(25);

function PopUpBox(){
	
	this.elementID = null;
	
	this.parent = null;
	this.text = "";
	
	this.width = 134;
	this.height = null; //null: it will be automatically grow
	
	this.init = function(){
		
	}
	
	this.handle = function( parent ){
		this.parent = $( parent );
		
		//check if Html-Element exists
		if( !this.elementID ){ //gibts noch nicht
			
			this.elementID = new Date().getTime();
			
			this.parent.before( this.getHtmlCode( this.elementID, this.text ) );
			
			var ref = this;
			$("#"+this.elementID).mouseout( function() { ref.hide(); } );
			this.parent.mouseout( function() { ref.hide(); } );
			
			//setDimensions
			$("#"+this.elementID).css("width", this.width);
			$("#"+this.elementID).css("height", this.height);
			
			//setPaddings
			if( $.browser.msie ){
				$("#"+this.elementID).css("margin-left", this.paddingLeftIE);
				$("#"+this.elementID).css("margin-top", this.paddingTopIE);
			}else{
				$("#"+this.elementID).css("margin-left", this.paddingLeft);
				$("#"+this.elementID).css("margin-top", this.paddingTop);
			}								
			
			this.show();
			
		}else{ //gibts schon
			
			this.show();
			
		}
	}
	
	
	this.show = function(){
		$("#"+this.elementID).show();
	}								
	this.hide = function(){
		$("#"+this.elementID).hide();
	}
	
	
	this.setText = function( text ){
		this.text = text;
	}								
	this.getText = function(){
		return this.text;
	}
	
	
	this.setWidth = function( width ){
		this.width = width;
	}
	this.unsetWidth = function( ){
		this.width = null;
	}
	this.getWidth = function(){
		return this.width;
	}
	
	
	this.setHeight = function( height ){
		this.height = height;
	}
	this.unsetHeight = function( ){
		this.height = null;
	}								
	this.getHeight = function(){
		return this.height;
	}
	
	this.setPaddingLeft = function( padding ){
		this.paddingLeft = padding;
	}								
	this.setPaddingTop = function( padding ){
		this.paddingTop = padding;
	}
	this.setPaddingLeftIE = function( padding ){
		this.paddingLeftIE = padding;
	}								
	this.setPaddingTopIE = function( padding ){
		this.paddingTopIE = padding;
	}
	
	this.getHtmlCode = function(elementID, text){
		
		//return this.html = '<div id="'+elementID+'" class="popUpBox"><div class="roundedcornr_box"><div class="roundedcornr_top"><div></div></div><div class="roundedcornr_content"><div class="boxcontent">'+text+'</div></div><div class="roundedcornr_bottom"><div></div></div></div></div>';
		return this.html = '<div id="'+elementID+'" class="popUpBox"><table class="box" cellpadding="0" cellspacing="0"><tr><td class="tl">&nbsp;</td><td class="tm">&nbsp;</td><td class="tr">&nbsp;</td></tr><tr><td class="mm" colspan="3">'+text+'</td></tr><tr><td class="bl">&nbsp;</td><td class="bm">&nbsp;</td><td class="br">&nbsp;</td></tr></table></div>';
	}

}
