/********************************************************
 *                                                      *
 * Script serving registration process                  *
 * Copyright (c), Intelrate, 2008                       *
 *                                                      *
 ********************************************************/

/// asynchronous request to the server
var httpObject = getXmlHttpObject();

/**
 * Handles registration attempt.
 */
function createAccount(firstNameId, lastNameId, emailId,
                       passwordId, confirmationId, countryId, secureCodeId)
{
    var firstName = clear(document.getElementById(firstNameId).value);
    var lastName = clear(document.getElementById(lastNameId).value);
    var email = clear(document.getElementById(emailId).value);
    var password = clear(document.getElementById(passwordId).value);
    var confirmation = clear(document.getElementById(confirmationId).value);

    var selectElement = document.getElementById(countryId);
    var country = clear(selectElement.options[selectElement.selectedIndex].value);

    var secureCode = clear(document.getElementById(secureCodeId).value);

    httpObject.open("GET", '/account/RegistrationHandler.php?'
            + firstNameId + '=' + firstName + '&'
            + lastNameId + '=' + lastName + '&'
            + emailId + '=' + email + '&'
            + passwordId + '=' + password + '&'
            + confirmationId + '=' + confirmation + '&'
            + countryId + '=' + country + '&'
            + secureCodeId + '=' + secureCode);
    httpObject.onreadystatechange = handleHTTPResponse;
    httpObject.send(null);
}

