/********************************************************
 *                                                      *
 * Script serving registration process                  *
 * Copyright (c), Intelrate, 2008                       *
 *                                                      *
 ********************************************************/

/// asynchronous request to the server
var httpObject = getXmlHttpObject();

/**
 * Handles recover password attempt.
 */
function recoverPassword(emailId, secureCodeId)
{
    var email = clear(document.getElementById(emailId).value);
    var secureCode = clear(document.getElementById(secureCodeId).value);

    var params = emailId + '=' + email + '&' + secureCodeId + '=' + secureCode;

    httpObject.open("GET", '/account/PasswordRecoveryHandler.php?' + params, true);
    httpObject.onreadystatechange = handleHTTPResponse;
    httpObject.send(null);    
}

/**
 * Hendles changing password.
 */
function changePassword(oldPasswordId, newPasswordId, newConfirmationId) 
{
	var oldPassword = clear(document.getElementById(oldPasswordId).value);
	var newPassword = clear(document.getElementById(newPasswordId).value);
	var newConfirmation = clear(document.getElementById(newConfirmationId).value);
	
	var params = oldPasswordId + '=' + oldPassword
                + '&' + newPasswordId + '=' + newPassword
                + '&' + newConfirmationId + '=' + newConfirmation;

	httpObject.open("GET", '/account/profile/ChangePasswordHandler.php?' + params, true);
	httpObject.onreadystatechange = handleHTTPResponse;
	httpObject.send(null);    
}

