/*
	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("username").value = "";
	document.getElementById("_").value = "";
	document.getElementById("_").style.color = "black";
	if (document.getElementById("InitPage")) InitPage();
	document.getElementById("username").focus();
}
function Secure_Page(nAddress) {
	if (nAddress == 1)
		nAddress = "192.168.100.1";
	else
		nAddress = "www.advancedip.com.au";
	var newURL = "http://" + nAddress + "/Clientele_Index.html";
	open(newURL,"_blank","status=yes,toolbar=no,menubar=no,location=no,titlebar=no,resizable=no");
}
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("username").value) {
		case "lts":	
			document.forms[0].action = "cgi-bin/freight-data";
			break;
		case "hydro":	
			document.forms[0].action = "cgi-bin/hydro-data";
			break;
		case "liberty":	
			document.forms[0].action = "cgi-bin/liberty-data";
			break;
		case "mikel":
			document.forms[0].action = "cgi-bin/aip.data";
			break;
		default:
			document.forms[0].action = "cgi-bin/web";
	}
}
function CheckIt() {
/*
   An attempt to camouflage the password as it is being
   passed via the URL. WEB002 decodes it via internal subroutine 200.
*/
	var password = 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);
	}
	document.getElementById("_").style.color = "white";
	document.getElementById("_").value = start + newp + end;
}
