function RegisterDialog(dialogId) {
	this.dialogId = 'register-dlg';
	this.openerId = 'registerButton';
	YAHOO.util.Event.addListener(window, 'load', this.initialize, this, true);
}

RegisterDialog.prototype = {
	
	dialogId : null,
	
	openerId : null,
	
	dialog : null,
	
	innerTabId : 'registerInnerTab',
	
	showBtn : null,
	
	initOpen : false,
	
	submitUrl : 'ajaxRequests.php',
	
	submitButton : null,
	
	updateManager : null,
	
	initialize : function() {
		 this.showBtn = getEl(this.openerId);
		 YAHOO.util.Event.addListener(this.openerId, 'click', this.showDialog, this, true);
	},
	
	showDialog : function(){
	    if(!this.dialog){ // lazy initialize the dialog and only create it once
	        this.dialog = new YAHOO.ext.LayoutDialog(this.dialogId, { 
	                width:525,
                    height:325,
                    shadow:true,
                    minWidth:460,
                    minHeight:250,
                    center: {
                        autoScroll:true,
                        tabPosition: 'top',
                        closeOnTab: true,
                        alwaysShowTabs: true
                    }
	        });
	        this.dialog.addKeyListener(27, this.dialog.hide, this.dialog);
	        this.dialog.addButton('Close', this.dialog.hide, this.dialog);
			this.submitButton = this.dialog.addButton('Submit', this.submitClick, this);
			
			var layout = this.dialog.getLayout();
	        this.dialog.beginUpdate();
			
			var newUserTab = new YAHOO.ext.ContentPanel('registerTab', {title: 'Register'});
			this.updateManager = new YAHOO.ext.UpdateManager('registerTab');
			layout.add('center', newUserTab);
			layout.getRegion('center').showPanel('registerTab');
	        this.dialog.endUpdate();
	    }
		
	    this.dialog.show(this.showBtn.dom);
	},
	
	regsiter : function() {
		var callback = {
			success:this.handleAddSuccess,
			failure:this.handleFailure,
			scope: this
		}
		YAHOO.util.Connect.setForm(document.getElementById('userAddForm'));
		this.dialog.getLayout().getRegion('center').getActivePanel().setContent(YAHOO.ext.UpdateManager.defaults.indicatorText);
		var transaction = YAHOO.util.Connect.asyncRequest('POST', this.submitUrl, callback); 
	},
	
	submitClick : function() {
		if(document.getElementById('userAddForm') != null) {
			this.updateManager.formUpdate(document.getElementById('userAddForm'));
		}else {
			this.dialog.hide();
		}
	},
	
	handleSubmit : function() {
		if(document.getElementById('userAddForm') == null) {
			this.submitButton.disable();
		}
	},
	
	handleAddSuccess : function(response) {
		this.dialog.getLayout().getRegion('center').getActivePanel().setContent(response.responseText);
	},
	
	handleFaulre : function() {
		alert('failure');
	}
	
}