Dialog = function( el, options ){

    var o = {
        modal: true,
        title: '',
        height: 0,
        width: 300
    };

    this.options = jQuery.extend( o, options );

    this.el = el;

    this.init();
    this.draw();
};

Dialog.prototype.init = function(){
};

Dialog.prototype.resize = function(){
    $('#TB_ajaxContent').height('auto');
	TB_HEIGHT = $('#TB_ajaxContent').height();
	tb_position();
};

Dialog.prototype.draw = function(){

    $('#dialogContent').remove();
    this.$dom = $('<div id="dialogContent" />').appendTo('body');
    this.$dom.append( this.el );

    height = this.options.height ? this.options.height : 155;

    tb_show( this.options.title, '#TB_inline?height='+height+'&width='+this.options.width+'&inlineId=dialogContent&modal='+(this.options.modal?'true':'false') );
    if( ! this.options.height ){
        this.resize();
    }

    if( ! this.options.modal ){
	    document.onkeyup = function(e){
			if (e == null) { // ie
				keycode = event.keyCode;
			} else { // mozilla
				keycode = e.which;
			}
			if(keycode == 27){ // close
				tb_remove();
			}
		};
    }
};
