/*
	Functions for the Clientele Software Logon Screen
	Pacific West Data Pty Ltd --- 2010
*/
function InitScreenPage() {
	document.getElementById("Header_Div").innerHTML = "<h1>" + document.forms[0].name + "</h1>";
	document.getElementById("__").value = "";
	document.getElementById("_").value = "";
	document.getElementById("__").style.color = "black";
	document.getElementById("_").style.color = "black";
	document.getElementById("__").focus();
}
function ChangeAction() {
/* 
  Attempt to change to different CGI scripts which have specific application.
  This is probably not the best way to do it but I need to be able to branch at this
  point. If you can find a better way then implement and document it please.
*/
	switch (document.getElementById("__").value) {
		case "lts":	
			document.forms[0].action = "cgi-bin/freight-data";
			break;
		case "hydro":	
			document.forms[0].action = "cgi-bin/hydro-data";
			break;
		default:
			document.forms[0].action = "cgi-bin/web";
	}
}
function CheckIt() {
/*
   An attempt to camouflage the username and password as it is being
   passed via the URL. WEB002 decodes it via internal subroutine 200.
*/
	var password = document.getElementById("_").value;
	var username = document.getElementById("__").value;
	var b = "0123456789abcdefghijklmnopqrstuvwxyz";
	var start = "", end = ""; newp = "", newu = "";
	for (var x=0; x<30; x++) {
		var c = Math.ceil(Math.random() * 26);
		start += b.substr(c,1);
		end += b.substr(26-c,1);
	}
	for (x=0; x<password.length; x++) {
		var c = Math.ceil(Math.random() * 26);
		newp += password.substr(x,1) + b.substr(c,1);
	}
	for (x=0; x<username.length; x++) {
		var c = Math.ceil(Math.random() * 26);
		newu += username.substr(x,1) + b.substr(c,1);
	}
	document.getElementById("__").style.color = "white";
	document.getElementById("_").style.color = "white";
	document.getElementById("_").value = start + newp + end;
	document.getElementById("__").value = end + newu + start;
}