// PassMasterVerify.action  v2.1 - April, 2009
// Copyright © 1999 by Walter Blady
// All rights reserved
function WBPassMasterVerify(action) {
	if (PMVVersion() && action[5].length > 0) {
		PMaction = action;
		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;
		}
		if (action[1] == 3) {
			var PMVCookieObject = new PMVCookie(document, action[5], "0", action[6], action[7], action[8]);
			PMVCookieObject.removeCookie();
			var to = setTimeout("PMVLogOut()", 1000);
			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], cd = cookieArray[2];
			for (var i = 1; PMassID.toLowerCase() != "end"; i++) {
				var pmurl = eval("PMass_" + i + "()");
				if (id == PMassID && PMassPassw != "" && pw == PMassPassw) {
					goURL = pmurl != "" ? pmurl : defaultUrl;
					if (PMassDateLimit != "") {
						if (PMVCheckDate(PMassDateLimit)) {
							PMVCookieObject = new PMVCookie(document, action[5], "0", action[6], action[7], action[8]);
							PMVCookieObject.removeCookie();
							var to = setTimeout("PMVLogOut()", 500);
							return;
						}
					}
					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() {
	PMVInvalidOut(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 PMVDoVis(obj) {
	if (obj != "") {
		var e = "", k = "";
		for (var i = 0; i < obj.length; i++) {
			e += obj.charCodeAt(i)^127;
		}
	}
	k = e << 1;
	return Math.abs(k^e);
}
function PMVCheckDate(date) {
	var thisDate = new Date();
	var thisHour = thisDate.getHours();
	var thisMinute = thisDate.getMinutes();
	var thisSecond = thisDate.getSeconds();
	thisDate = Date.parse(thisDate);
	userFinalDate = date.indexOf(":") == -1 ? eval(new Date(date + " " + thisHour + ":" + thisMinute + ":" + thisSecond)) : new Date(date);
	userFinalDate = Date.parse(userFinalDate);
	return thisDate > userFinalDate;
}
function PMVVersion() {
	return true;
}
//
// PassMaster.action v2.1 - 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 = "PassMaster 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]];
		myForm.jumpToURL = PMGotoURL;
		myForm.path = action[4];
		if (PMisNav4 && action[5] && myForm.path.length > 0) {
			myForm = window.document[myForm.path].document[action[1]];
			myForm.onsubmit = PMVDoFalse;
		}
		if (action[12] == 2) {
			if (myForm[action[3]].value != "" && myForm[action[3]].value.length <= 13) {
				window.prompt(myForm[action[3]].value, PMVDoVis(myForm[action[3]].value, 0));
			}
			else {
				window.prompt("The password limit is 13 characters - " + myForm[action[3]].value, myForm[action[3]].value.substr(0, 13));
			}
			return;
		}
		var psw = action[12] == 1 ? PMVDoVis(myForm[action[3]].value, 0) : myForm[action[3]].value;
		for (var i = 1; PMassID.toLowerCase() != "end"; i++) {
			myForm.exitURL = eval("PMass_" + i + "()") != "" ? eval("PMass_" + i + "()") : eval("PMass_" + "0()");
			if (myForm[action[2]].value == PMassID && PMassPassw != "" && psw == PMassPassw) {
				if (PMVLogOut && PMassDateLimit != "") {
					if (PMVCheckDate(PMassDateLimit)) {
						PMVCookieObject = new PMVCookie(document, action[5], "0", action[6], action[7], action[8]);
						PMVCookieObject.removeCookie();
						var to = setTimeout("PMVLogOut()", 500);
						return;
					}
				}
				if (action[6] == 0 && action[7] != "") {
					var cookieCrumbs = PMassID + "&" + psw;
					var PMCookieObject = new PMCookie(document, action[7], parseInt(action[8]), action[10], action[11], action[9]);
					PMCookieObject.storeCookie(cookieCrumbs);
				}
				var c = PMVGetCookie(action[7])
				myForm[action[3]].value = "";
				if (myForm.exitURL != "") {
					myForm.jumpToURL();
				}
				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 PMGotoURL() {
	var params;
	if (this.path.length < 1) {
		window.location.href = this.exitURL;
	}
	else {
		if (this.path.toLowerCase().indexOf("blank") != -1) {
			var PMNewWindow = window.open(this.exitURL,"PMnewWindow", "toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,favorites=yes,resizable=yes");
		}
		else {
			params = eval(this.path + ".window.location");
			params.href = this.exitURL;
		}
	}
return;
}
function PMVDoFalse() {
	return false;
}
function PMVersion() {
	return true;
}
//

