PasswordDialog = function(){

	this.dlg = new YAHOO.ext.BasicDialog("pwd-dlg", { 
	        modal:true,
	        autoCreate:{
				id: 'pwd-dlg',
				tag: 'form',
				method: 'post',
				onSubmit: 'return false'
			},
	        width:350,
	        title: 'Wachtwoord vergeten?',
	        height:180,
	        shadow:true,
	        minWidth:150,
	        minHeight:100
	});
	this.dlg.addKeyListener(27, this.dlg.hide, this.dlg);
	var btn = this.dlg.addButton('Opvragen', function(){
		var email = getEl('pwd-dlg-email').dom.value;
		btn.disable();
		YAHOO.util.Connect.asyncRequest('post', 'index2.php?action=retrievePassword&email=' + email, {success: function(o,b){
		 	if (o.responseText.lastIndexOf('false') == -1) {
				YAHOO.ext.MessageBox.alert('Wachtwoord opvragen', 'Een email met daarin uw wachtwoord is naar uw emailadres gestuurd.');
				this.dlg.hide();
			} else {
				YAHOO.ext.MessageBox.alert('Wachtwoord opvragen', 'Het opgegeven emailadres is onjuist.');						
			}
			btn.enable();					
		}.createDelegate(this)});                         				 
		
	}, this);
	this.dlg.addButton('Sluiten', this.dlg.hide, this.dlg);			
				
	this.dlg.body.appendChild(getEl('pwd-dlg-bd'));																
	getEl('pwd-dlg-bd').setStyle('display', 'block');						
}

PasswordDialog.prototype = {

	show : function(){
		this.dlg.show();		
	}

}

