function dialog() {
this.width = "500px";
this.close = true;
this.fixedcenter = true;
this.parent;

  if (typeof dialog._initialized == "undefined") {
     
    dialog.prototype.build = function () {
      var this_obj = this;
      this.LOADING = new Loading("Loading Message, please wait...");
      this.LOADING.modal = false;  
      this.obj = new YAHOO.widget.Dialog("popup_dialog",  
          			{ width:this.width,           			 
          			  close:this.close,
                  fixedcenter:this.fixedcenter,
        					draggable:false,
        					zindex:9999,
        					modal:true,
        					visible:false,
        					underlay:"none" 
          			 }); 
      this.obj.beforeShowEvent.subscribe(function() {
        this_obj.LOADING.start();
      });
      this.obj.showEvent.subscribe(function() { 
        this_obj.LOADING.destroyLoading();
      });		
    }
    
	  dialog.prototype.setParent = function( parent ) {
		  this.parent = parent;
	  }
    
    dialog.prototype.close_button = function () {
      var hide = function(e, thisobj){
		  thisobj.hide();
	  };
      ///////////////////////////////////////////////////////////////////////
      this.obj.cfg.setProperty("buttons", [ { text:"Close", handler:{fn:hide,obj:this}, isDefault:true } ]);
    }
    
    dialog.prototype.set_width = function () { 
      this.obj.cfg.setProperty("width", "700px");
    }
    /////////////////////////////////////////////////////////////////////////////////////

	dialog.prototype.create = function( heder, bdy, type, callback ) { 
		var t = bdy;

		this.obj.setHeader( heder );
		this.obj.setBody( bdy );
		this.obj.render(document.body);
		this.obj.bringToTop();

		this.obj.cfg.setProperty( "close", false );
		this.setProperties( type, callback );
		this.obj.center();
		this.obj.show();
	};

	dialog.prototype.setProperties = function( type, callback ) {
		switch( type ) {
		case "Ok":
			this.obj.cfg.setProperty( "buttons", [{ text:"Ok", handler:{fn:callback[0],obj:this.parent}, isDefault:true }]);
			break;
		case "YesNo":
			this.obj.cfg.setProperty(
				"buttons",
				[
					{text:"Yes",handler:{fn:callback[0],obj:this.parent},isDefault:true},
					{text:"No",handler:{fn:callback[1],obj:this.parent}}
				]
			);
			break;
		case "Loading":
			this.obj.cfg.setProperty( "buttons", [] );
			this.obj.cfg.setProperty( "width", "250px" ); // set small for loading image
			break;
		case "Form":
			this.obj.cfg.setProperty( "width", "540px" ); // set wide for forms
			this.obj.cfg.setProperty(
				"buttons",
				[
					{text:"Submit",handler:{fn:callback[0],obj:this.parent},isDefault:true},
					{text:"Cancel",handler:{fn:callback[1],obj:this.parent}}
				]
			);
		}
	};

	dialog.prototype.setDefaultProperties = function() {
		this.obj.cfg.setProperty( "width", "500px" );
		this.obj.cfg.setProperty( "fixedcenter", true );
		this.obj.cfg.setProperty( "close", true );
	};
   
	dialog.prototype.hide = function() {
		this.obj.cfg.setProperty( "fixedcenter", true );
		this.obj.cfg.setProperty( "close", true );
		this.obj.hide();
	};
 
    dialog._initialized = true;
  } 
} 
