function getFromSearchString( parm ) // Return yyy from search string =yyy&pa
{
 var r = '';
 var s = unescape( location.search ); 
 if ( s.length < 2 ) return r;
 s = s.substr( 1 );
 r = searchString( parm, s );
 return r;
}

function searchString( parm, s )
{
 var r = '';
 var sa = s.split( '&' );
 for ( var i = 0; i < sa.length; i++ )
 {
  var saa = sa[ i ].split( '=' );
  if ( saa[0] == parm ) { r = saa[1]; break; }
 }
 return r;
}

function allowableUserid( userid )
{
 var minLength = 1;
 var maxLength = 85;
 var allowable = '0123456789abcedfeghijklomnpqrstuvwxyz_-ABCDEFGHIJKLMNOPQRSTUVWXYZ';
 if ( userid.length < minLength ) { alert( 'The userid must be at least ' + minLength + ' characters long.' ); return false; }
 if ( userid.length > maxLength ) { alert( 'The userid cannot exceed ' + maxLength + ' characters.' ); return false; }
 for ( var i = 0; i < userid.length; i++ )
 {
  var c = userid.charAt( i );
  if ( allowable.indexOf( c ) < 0 ) { alert( 'The userid can only contain alphabetical characters, digits, hyphens and underscores.' ); return false; }
 }

}

// Relocate object with id "tmain" in centre of window. Works in Firefox and IE.

function centreTMain()
{
  
 var isIE = false;
 var nav = navigator.appName;
 if ( nav.indexOf( "Microsoft Internet Explorer" ) >= 0  ) isIE = true;
  
 var tmain = document.getElementById( "tmain" );
 var tHeight = tmain.offsetHeight;
 var tWidth = tmain.offsetWidth;
 var wHeight = 0; 
 var wWidth = 0;
 if ( isIE )
 { 
   wWidth  = document.all.wbody.clientWidth; 
   wHeight = document.all.wbody.clientHeight; 
 }
 else
 {
  var wBody = document.getElementById( "wbody" );
  wHeight = window.innerHeight;
  wWidth = window.innerWidth;
 }
 var x = Math.max( 0, ( wWidth - tWidth ) /  2 );
 var y = Math.max( 0, ( wHeight - tHeight ) / 2 );
 //alert( "isIE=" + isIE );
 //alert( "wHeight=" + wHeight + " tHeight=" + tHeight );
 //alert( "wWidth=" + wWidth + " tWidth=" + tWidth );
 tmain.style.top = y + "px";
 tmain.style.left = x + "px";
 tmain.style.visibility="visible";
 return;
}

function baction()
{
    var ok = true;
    var msg = "You must complete the following fields:\n";

    var scode = document.f1.scode.value;
    if ( scode == '' ) { ok = false; msg += "\nActivation code"; }

    var fname = document.f1.fname.value;
    if ( fname == '' ) { ok = false; msg += "\nFirst name"; }
	
    var lname = document.f1.lname.value;
    if ( lname == '' ) { ok = false; msg += "\nLast name"; }
	
    var userid = document.f1.uid.value;
    if ( userid == '' ) { ok = false; msg += "\nUserid"; } 
	
    var pw = document.f1.pw.value;
    if ( pw == '' ) { ok = false; msg += "\nPassword"; }
	
    var cfmpw = document.f1.cfmpw.value;
    if ( cfmpw == '' ) { ok = false; msg += "\nConfirm password"; }
		
    var eml = document.f1.eml.value;
    if ( eml == '' ) { ok = false; msg += "\nEmail"; }
	
	
    if ( ! ok ) { alert( msg ); return false; }
    if ( pw != cfmpw ) { alert( "Password and confirm password do not match." ); return false; }
    return allowableUserid( userid );
}
