var nextUI = "http://websms.fido.page.ca/2way/";
function slwc_processHandlerRegister () {
/* onreadystate change function for registration handler */
var registrationFormTable, registrationForm, thankyouMsg, thankyouBox;
var _status = "";
switch ( xmlhttp.readyState ) {
case 4:
if ( xmlhttp.status == "200") {
registrationFormTable = document.getElementById ( "registrationForm" );
registrationForm = document.getElementById ( "slwc_registerForm" );
thankyouBox = document.getElementById ( "thankyouBox" );
thankyouMsg = document.getElementById ( "thankyouMsg" );
xml = xmlhttp.responseXML;
_status = slwc_getXMLNodeValue ( xml.getElementsByTagName ( "status")[0] );
if ( _status == "OK" ) {
registrationFormTable.style.display = "none";
if ( thankyouMsg ) {
thankyouMsg.innerHTML = thankyouMsg.innerHTML.replace ( /###/,
slwc_getXMLNodeValue ( xml.getElementsByTagName ( "destaddress")[0] ) );
thankyouBox.style.display = "block";
}
appStatus.hide();
// if we are the account-details page, back to main menu we go.
if ( document.location.href.indexOf ( "account-details" ) > -1 ) {
document.location.href = "http://websms.fido.page.ca/2way/menu.php";
}
if ( document.location.href.indexOf ( "user-info" ) > -1 ) {
document.location.href = "http://websms.fido.page.ca/2way/user-maint.php";
}
}
else {
appStatus.setText(_status);
registrationForm.reset();
registrationForm["__LFN"].focus();
//appStatus.setText(ERROR_SLWC_REGISTRATION_FAILED);
}
}
else {
switch ( xmlhttp.status.toString() ) {
case "404":
appStatus.setText(ERROR_RPC_HTTP + " - " + ERROR_RPC_HTTP_404
+ "
" + ERROR_USR_INSTR);
break;
default:
appStatus.setText(ERROR_RPC_HTTP + " - " + xmlhttp.status
+ "
" + ERROR_USR_INSTR);
break;
}
return;
}
break;
case 3:
appStatus.setText(MSG_WAITINGRESPONSE);
break;
default:
break;
}
}
function slwc_onRegisterSubmit ( registerForm ) {
if ( slwc_validateAcctDetails ( registerForm ) && slwc_validateCreds ( registerForm ) ) {
appStatus.show();
//logonForm.disabled = true;
/* data looks good, lets do our http request.... */
/* ALSO NOTE: RPC_URL only points to /rpc directory, the form's (registerForm)
'action' property is the url actually posted to. */
xmlhttp.open ( "POST", RPC_URL, true );
xmlhttp.setRequestHeader ( "Content-Type", "application/x-www-form-urlencoded" );
xmlhttp.onreadystatechange = slwc_processHandlerRegister;
xmlhttp.send( slwc_makePostString ( registerForm, true ) );
return false;
}
return false;
}
function slwc_submitAuthCode ( strAuthCode ) {
if ( slwc_validateAuthCode ( strAuthCode ) ) {
appStatus.show();
//logonForm.disabled = true;
/* data looks good, lets do our http request.... */
xmlhttp.open ( "POST", RPC_URL + AUTHCODE_ACTION , true );
xmlhttp.setRequestHeader ( "Content-Type", "application/x-www-form-urlencoded" );
xmlhttp.onreadystatechange = slwc_processAuthCode;
xmlhttp.send( "authCode=" + strAuthCode );
return false;
}
}
function slwc_processAuthCode () {
var authCodeTable, thankyouMsg, thankyouBox, thankyouHeader;
var _status = "";
var forwardUrl = "";
switch (xmlhttp.readyState)
{
case 4:
if ( xmlhttp.status == "200")
{
authCodeTable = document.getElementById ( "authCodeBox" );
thankyouBox = document.getElementById ( "thankyouBox" );
thankyouMsg = document.getElementById ( "thankyouMsg" );
thankyouHeader = document.getElementById ( "thankyouHeader" );
xml = xmlhttp.responseXML;
_status = slwc_getXMLNodeValue ( xml.getElementsByTagName ( "status")[0] );
if ( _status == "OK" )
{
authCodeTable.style.display = "none";
thankyouHeader.innerHTML = MSG_REGISTRATIONSUCCESS;
thankyouMsg.innerHTML = MSG_REGISTRATIONFORWARD;
thankyouBox.style.display = "block";
appStatus.hide();
setTimeout ( "document.location.replace('"+ nextUI +"')", 3000 );
//slwc_logonUsr( slwc_makePostString ( ) );
}
else
{
errAlert(_status);
//appStatus.setText(_status);
//appStatus.setText(ERROR_SLWC_REGISTRATION_FAILED);
}
}
else
{
switch ( xmlhttp.status.toString() )
{
case "404":
appStatus.setText(ERROR_RPC_HTTP + " - " + ERROR_RPC_HTTP_404
+ "
" + ERROR_USR_INSTR);
break;
default:
appStatus.setText(ERROR_RPC_HTTP + " - " + xmlhttp.status
+ "
" + ERROR_USR_INSTR);
break;
}
return;
}
break;
case 3:
appStatus.setText(MSG_WAITINGRESPONSE);
break;
default:
break;
}
}
function slwc_validateAuthCode ( authCode, strNextFunctionIfValid ) {
if ( ( authCode == "" ) || ( authCode.length != 5 ) ) {
errAlert ( ERROR_SLWC_BAD_AUTHCODE );
return false;
}
if ( strNextFunctionIfValid )
eval ( strNextFunctionIfValid + "()" );
return true;
}
function slwc_getAuthCode () {
document.getElementById ( "registrationForm" ).style.display = "none";
document.getElementById ( "thankyouBox" ).style.display = "none";
document.getElementById ( "authCodeBox" ).style.display = "block";
}
function init()
{
if (inRegistrationProcess)
slwc_getAuthCode();
var form = document.getElementById('slwc_registerForm');
if (!form)
return;
var i;
for (i = 0; i < form.elements.length; i++)
{
switch(form.elements[i].type)
{
case "text": case "password":
form.elements[i].value="";
}
}
form.elements["__LFN"].focus();
}