$(document).ready(function() {
	$("#forgot_password_div").dialog({
		bgiframe: true,
		autoOpen: false,
		height: 260,
		modal: true,
		resizable:false,
		buttons: {

			Cancel: function() {
				$(this).dialog('close');
			},
			'Generate new password': function() {
				if(confirm('Are you sure you want your password to be reset?')) {
					$.getJSON(
						'/ajax.php',
						{fl: 'common', f: 'forgotPass', nick: $('#nick_mail').val()},
						function(data) {
							if(data.error)
								alert('There was an error: ' + data.error);
							else
								alert('Your password was reset. Check the email address registered with us to retrieve your new password.');
						}
					);
				}
				$(this).dialog('close');
			}
		},
	});
	$('#forgot_password').click(function() {
		$('#forgot_password_div').dialog('open');
		return false;
	});
	$('#generate_new_pass').click(function() {
		return false;
	});
});
