// PassMasterVerify.action  v2.0 - April, 2009
// Copyright © 1999 by Walter Blady
// All rights reserved
function WBPassMasterVerify(action) {
	if (PMVVersion() && action[5].length > 0) {
		PMaction = action;
		if (action[1] == 3) {
			PMVCookieObject = new PMVCookie(document, action[5], "0", action[6], action[7], action[8]);
			PMVCookieObject.removeCookie();
			var to = setTimeout("PMVLogOut()", 1000);
			return;
		}
		try {
			PMassID;
		}
		catch (errorCode) {
			var mess = "PassMasterVerify can not find the password file.\n";
			mess += "You must link this script file to this page."
			alert(mess);
			PMVCookieObject = new PMVCookie(document, action[5], "0", action[6], action[7], action[8]);
			PMVCookieObject.removeCookie();
			PMVGoURL(action, action[2]);
			return;
		}
		var defaultUrl = eval("PMass_" + "0()");
		var goURL = defaultUrl;
		var cookieCrumbs = PMVGetCookie(action[5]);
		if (cookieCrumbs != "") {
			var cookieArray = cookieCrumbs.split("&");
			var id = cookieArray[0].substr(cookieArray[0].indexOf("=")+1, 99), pw = cookieArray[1];
			for (var i = 1; PMassID.toLowerCase() != "<end>"; i++) {
				var pmurl = eval("PMass_" + i + "()");
				if (id == PMassID && PMassPassw != "" && pw == PMassPassw) {
					goURL = pmurl != "" ? pmurl : defaultUrl;
					if (goURL != "") {
						if (action[1] == 0) {
							PMVGoURL(action, goURL);
							return;
						}
						else if (action[1] == 1 && window.location.href.indexOf(goURL) > -1) {
							return;
						}
						else if (action[1] == 2 && PMassPageCode == action[3]) {
							return;
						}
					}
				}
			}
			PMVInvalidOut(action, goURL);
		}
		else {
			PMVInvalidOut(action, PMaction[2]);
		}
	}
	return;
}
function PMVLogOut() {
	PMVGoURL(PMaction, PMaction[2]);
	return;
}
function PMVGoURL(action, goURL) {
	var params;
	if (action[4].length < 1) {
		window.location.href = goURL;
	}
	else {
		if (action[4].toLowerCase().indexOf("blank") != -1) {
			var PMVNewWindow = window.open(goURL,"PMnewWindow", "toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,favorites=yes,resizable=yes");
		}
		else {
			params = eval(action[4] + ".window.location");
			params.href = goURL;
		}
	}
	return;
}
function PMVInvalidOut(action, goURL) {
	var outURL = goURL != "" ? goURL : action[2];
	if (action[1] == 1 || action[1] == 2 || action[1] == 3) {
		if (self.opener) {
			opener.location.replace(outURL);
			self.window.close();
		}
		else {
			window.location.replace(outURL);
		}
	}
	return;
}
new PMVCookie();
PMVCookie.prototype.removeCookie = PMVRemoveCookie;
function PMVCookie(document, name, hours, path, domain, secure) {
	this.$document = document;
	this.$name = name;
	if (hours) this.$expires = new Date(new Date().getTime() + hours*86400000);
	else this.$expires = null;
	if (path) this.$path = path; else this.$path = null;
	if (domain) this.$domain = domain; else this.$domain = null;
	if (secure) this.$secure = secure; else this.$secure = false;
	return;
}
function PMVGetCookie(cookieTarget) {
	var cookieCrumbs = unescape(document.cookie);
	var cookieArray = cookieCrumbs.split("; ");
	cookieCrumbs = "";
	for (var i = 0; i < cookieArray.length; i++) {
		if (cookieArray[i].indexOf(cookieTarget) != -1) {
			cookieCrumbs = cookieArray[i];
			break;
		}
	}
	return cookieCrumbs;
}
function PMVRemoveCookie() {
	var cookie = this.$name + "=";
	if (this.$path) cookie += "; path=" + this.$path;
	if (this.$domain) cookie += "; domain =" + this.$domain;
	cookie += "; expires=Thu, 01-Jan-1970 00:00:01 GMT";
	this.$document.cookie = cookie;
	return;
}
function PMVDoCheck(pw, enctype) {
	if (pw != "") {
		var enc = "", dec = "", code = "";
		for (i = 0; i < pw.length; i++) {
			enc += PMDTH(pw.charCodeAt(i) + i);
			dec += String.fromCharCode(pw.charCodeAt(i));
		}
	}
	if (enctype == 0) code = enc;
	else if (enctype == 1) code = dec;
	else if (enctype == 2) {
		code = pw + "=" + enc;
	}
	return code;
}
function PMVVersion() {
	return true;
}
//
// PassMaster.action v2.0 - April, 2009
// Copyright © 1999 by Walter Blady
// All rights reserved
var PMisIE4 = navigator.appVersion.indexOf("MSIE 4") >= 0;
var PMW3C = document.getElementById ? true : false;
var PMisNav4 = navigator.appName.indexOf("Netscape") >= 0 && parseInt(navigator.appVersion.charAt(0)) == 4;
var PMChars = "0123456789ABCDEF";
function WBPassMaster(action) {
	if (PMVersion() && action[2].length > 0 && action[3].length > 0) {
		try {
			PMassID;
		}
		catch (errorCode) {
			var mess = "PassMasterVerify can not find the password file.\n";
			mess += "You must link this script file to this page."
			alert(mess);
			return;
		}
		PMassID = "", PMassPassw = "";
		var myForm = window.document[action[1]];
		if (PMisNav4 && action[5] && action[4].length > 0) {
			myForm = window.document[action[4]].document[action[1]];
			myForm.onsubmit = PMVDoFalse;
		}
		if (action[12] == 2) {
			if (myForm[action[3]].value != "") {
				window.prompt("The encoded pasword for " + myForm[action[3]].value + " is", PMVDoCheck(myForm[action[3]].value, 0));
				return;
			}
		}
		var defaultUrl = eval("PMass_" + "0()");
		for (var i = 1; PMassID.toLowerCase() != "<end>"; i++) {
			var pmurl = eval("PMass_" + i + "()");
			var psw = action[12] == 1 ? PMVDoCheck(myForm[action[3]].value, 0) : myForm[action[3]].value;
			if (myForm[action[2]].value == PMassID && PMassPassw != "" && psw == PMassPassw) {
				if (action[6] == 0 && action[7] != "") {
					var cookieCrumbs = PMassID + "&" + psw;
					PMCookieObject = new PMCookie(document, action[7], parseInt(action[8]), action[10], action[11], action[9]);
					PMCookieObject.storeCookie(cookieCrumbs);
				}
				myForm[action[3]].value = "";
				var goURL = pmurl != "" ? pmurl : defaultUrl;
				if (goURL != "") {
					var params;
					if (action[4].length < 1) {
						window.location.href = goURL;
					}
					else {
						if (action[4].toLowerCase().indexOf("blank") != -1) {
							var PMNewWindow = window.open(goURL,"PMnewWindow", "toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,favorites=yes,resizable=yes");
						}
						else {
							params = eval(action[4] + ".window.location");
							params.href = goURL;
						}
					}
				}
				return;
			}
		}
		myForm[action[3]].value = "";
		window.alert(PMWrongPassword());
	}
	return;
}
new PMCookie();
PMCookie.prototype.storeCookie = PMStoreCookie;
function PMCookie(document, name, hours, path, domain, secure) {
	this.$document = document;
	this.$name = name;
	if (hours) this.$expires = new Date(new Date().getTime() + hours*86400000);
	else this.$expires = null;
	if (path) this.$path = path; else this.$path = null;
	if (domain) this.$domain = domain; else this.$domain = null;
	if (secure) this.$secure = secure; else this.$secure = false;
	return;
}
function PMStoreCookie(value) {
	if (value == null) value = "";
	for (var prop in this) {
		if (prop.charAt(0) == "$" || (typeof this[prop]) == "function") {
			continue;
		}
		if (value != "") value += "&";
		value += prop + ":" + escape(this[prop]);
	}
	var cookie = this.$name + "=" + value;
	if (this.$expires) cookie += "; expires=" + this.$expires.toGMTString();
	if (this.$path) cookie += "; path=" + this.$path;
	if (this.$domain) cookie += "; domain=" + this.$domain;
	if (this.$secure) cookie += "; secure=" + secure;
	this.$document.cookie = cookie;
	return;
}
function PMDTH(dec) {
	if (dec > 255) {
		return null;
	}
	var i = dec % 16;
	var j = (dec - i) / 16;
	result = "";
	result += PMChars.charAt(j);
	result += PMChars.charAt(i);
	return result;
}
function PMVDoFalse() {
	return false;
}
function PMVersion() {
	return true;
}
//

