_onLoad = "preloadImages();";
not_here = "";
spc = / /g;
num = /[^0-9]/;
alphanum = /[^0-9A-Za-z@.,\-()\ ]/;
alphanum_error = " alpha-numeric characters only and .,@()-\n";

var ProgramDisclaimer = "PROGRAM DISCLAIMER\n" +
	"\n" +
	"The information presented in this program is intended for general use, and\n" +
	"may not apply to all circumstances. The program is not a definitive guide\n" +
	"to all applicable government legislation and regulation, and does not relieve\n" +
	"participants using this program from their responsibilities under the applicable\n" +
	"legislation and regulation. The program is provided as a public service, and we\n" +
	"do not guarantee the accuracy or completeness of, or assume liability for, the\n" +
	"information presented in this program.";

var TAXEs = new Array();
	TAXEs['AB'] = 0.05;
	TAXEs['BC'] = 0.05;
	TAXEs['MB'] = 0.05;
	TAXEs['NB'] = 0.13;
	TAXEs['NF'] = 0.13;
	TAXEs['NS'] = 0.13;
	TAXEs['NT'] = 0.05;
	TAXEs['NU'] = 0.05;
	TAXEs['ON'] = 0.05;
	TAXEs['PE'] = 0.05;
	TAXEs['QC'] = 0.05;
	TAXEs['SK'] = 0.05;
	TAXEs['YT'] = 0.05;

function checkPIN( f ) {
	var err = new String("");

	f.prefix.value = new String( f.prefix.value ).toUpperCase();

	if( f.prefix.value.length != 3 )
		err += "\tFirst section of PIN needs to be 3 characters long.\n";
	if( f.pin.value.length != 5 )
		err += "\tSecond section of PIN needs to be 5 characters long.\n";
	if( f.password.value.length == 0 )
		err += "\tPassword cannot be blank\n";
	
	if( err.length == 0 )
		return true;
	else {
		alert( "The following error(s) have been encontered:\n" + err );
		return false;
	}
}

function removeSpaces( f, field ) {
	eval( "var s = new String( f." + field + ".value );" );
	s = s.replace( spc, new String("") );
	eval( "f." + field + ".value = s.toUpperCase();" );
}

function checkEqualto( f, fields ) {
	var ok = new Boolean();

	eval( "ok = (f." + fields[0] + ".value == f." + fields[1] + ".value );" );

	if( ok == false )
		alert( fields[0] + " and " + fields[1] + " do not match." );
	
	return ok;
}

function checkAlphaNum( f, fields ) {
	var err = new String();
	var ok = new Boolean();

	for( x=0; x<fields.length; x++ ) {
		eval( "ok = alphanum.test( f." + fields[x] +  ".value );" );
		if( ok )
			err += "     " + fields[x] + " " + alphanum_error;
	}

	if( err.length ) {
		alert( "The following errors have been encountered: \n" + err );
		return false;
	} else return true;
}

function checkRequired( f, fields, fieldnames ) {
	var err = new String();
	var ok = new Boolean();

	for( x=0; x<fields.length; x++ ) {
		eval( "var Type = f." + fields[x] + ".type;" );
		switch( Type ) {
			case "text":
				eval( "ok = (f." + fields[x] + ".value.length > 0);" );
			break;
			case "textarea":
				eval( "ok = (f." + fields[x] + ".value.length > 0);" );
			break;
			case "select-one":
				eval( "ok = (f." + fields[x] + ".selectedIndex > 0);" );
			break;
		}
		if( !ok )
			err += "     " + ((fieldnames != null) ? fieldnames[x] : fields[x]) + " is required\n";
	}

	if( err.length ) {
		alert( "The following errors have been encountered: \n" + err );
		return false;
	} else return true;
}

function popMe(where,who,dX,dY) {
	var newwin=open(where,who,"width="+dX+",height="+dY+",scrollbars=yes,status=no,resize=no,toolbar=yes");
}

function round( number, X ) {
	X = ( !X ? 2 : X );

	Y = new String(Math.round( number * Math.pow(10, X) ) / Math.pow( 10, X ) );
	if( Y.indexOf(".") == -1 )
		Y = Y + ".00";
	if( Y.length - Y.indexOf(".") == 2 )
		Y = Y + "0";
	
	return Y;
}

function bon ( imgName ) {
   eval( "document [imgName].src = " + imgName + "1.src;" );
}

function boff ( imgName ) {
   eval( "document [imgName].src = " + imgName + ".src;" );
}

function Login() {
	document.forms['Login'].submit();
}

function MiniTest() {
	popMe( 'MiniTest.php', 'MiniTest', 580, 400 );
}

function newImage(arg) {
  if (document.images) {
    rslt = new Image();
    rslt.src = arg;
    return rslt;
  }
}

function changeImages() {
  if (document.images && (preloadFlag == true)) {
    for (var i=0; i<changeImages.arguments.length; i+=2) {
      document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
    }
  }
}

var preloadFlag = false;
function preloadImages() {
  if (document.images) {
    registerbottom_over = newImage("images/registerbottom-over.jpg");
    splashnavhome_over = newImage("images/splashnavhome-over.jpg");
    splashnavhelp_over = newImage("images/splashnavhelp-over.jpg");
    myprofile_over = newImage("images/myprofile-over.jpg");
    myprograms_over = newImage("images/myprograms-over.jpg");
    mytranscript_over = newImage("images/mytranscript-over.jpg");
    logout_over = newImage("images/logout-over.jpg");
    home_over = newImage("images/home-over.jpg");
    help_over = newImage("images/help-over.jpg");
    preloadFlag = true;
  }
}

