function sniffer () {
agent = navigator.userAgent.toLowerCase();
this.major = parseInt(navigator.appVersion, 10);
this.minor = parseFloat(navigator.appVersion);
this.ie = (agent.indexOf("msie") != -1);
this.mozilla = (agent.indexOf("mozilla") != -1);
this.firefox = (agent.indexOf("firefox") != -1);
this.ie55 = (this.ie && (this.major == 4) && (agent.indexOf("msie 5.5") != -1));
this.ie6 = (this.ie && (agent.indexOf("msie 6.0") != -1));
this.ie7 = (this.ie && (agent.indexOf("msie 7.0") != -1));
this.ie8 = (this.ie && (agent.indexOf("msie 8.0") != -1));
this.safari = (agent.indexOf("safari") != -1);
if (this.ie && !this.ie55 && !this.ie6 && !this.ie7 && !this.ie8)
this.ie7 = true;
// this.mac = (agent.indexOf("mac") != -1);
this.mac = (agent.indexOf("mac") != -1 && agent.indexOf("safari") == -1);
}
function CopyArrayValues (ArrayFrom, ArrayTo) {
for (fld in ArrayFrom) {
ArrayTo[fld] = ArrayFrom[fld];
}
}
function _CInt(V) {
return (parseInt(V, 10));
}
function validateNumeric (n) {
if (n.value.indexOf("$") == 0) { n.value = n.value.substring(1); } // remove leading dollar
var num = "0123456789.,$";
var retValue = true;
if (n.value.charAt(0) == '-' || n.value.charAt(0) == '+' || (num.indexOf(n.value.charAt(0)) > -1))
retValue = true;
else
retValue = false;
for (var I = 1; I < n.value.length; I++)
if (num.indexOf(n.value.charAt(I)) == -1)
retValue = false;
return retValue;
}
function getNumericPart (n) {
var num = "0123456789.,";
var retValue = 0;
var sindex = 0;
if (typeof n == "string") {
if (n.charAt(0) == '-' || n.charAt(0) == '+') {
sindex = 1;
}
for (var I = sindex; I < n.length; I++) {
if (num.indexOf(n.charAt(I)) == -1)
break;
}
retValue = n.substring (0, I);
}
else
retValue = n;
return retValue;
}
function RmNonNum (M, NuNum) {
// remove non-numeric chars with two different modes of usage
if (M == 0) {
if (NuNum.value.length > 0) {
// remove "," for conversion
if (NuNum.value.indexOf(",") != -1)
NuNum.value = NuNum.value.replace(/,/g, "");
// remove "$" for conversion
if (NuNum.value.indexOf("$") != -1)
NuNum.value = NuNum.value.replace(/\$/g, "");
// remove multiple "." for conversion
var P = NuNum.value.indexOf(".");
if (P != -1) {
if (NuNum.value.indexOf(".", P + 1) != -1) {
alert ("More than decimal place was entered, removing extra periods!");
NuNum.value = NuNum.value.replace(/\./g, "");
NuNum.value = NuNum.value.substring(0, P) + "." + NuNum.value.substring(P);
}
}
}
return NuNum.value;
}
else {
if (NuNum.length > 0) {
// remove "," for conversion
if (NuNum.indexOf(",") != -1)
NuNum = NuNum.replace(/,/g, "");
// remove "$" for conversion
if (NuNum.indexOf("$") != -1)
NuNum = NuNum.replace(/\$/g, "");
// remove multiple "." for conversion
var P = NuNum.indexOf(".");
if (P != -1) {
if (NuNum.indexOf(".", P + 1) != -1) {
alert ("More than decimal place was entered, removing extra periods!");
NuNum = NuNum.replace(/\./g, "");
NuNum = NuNum.substring(0, P) + "." + NuNum.substring(P);
}
}
}
return NuNum;
}
}
function FPNFormat (FPNum) {
NuNum = FPNum;
// remove non-numeric chars
NuNum.value = RmNonNum(0, FPNum);
// Number format the Total
var dotindex = NuNum.value.indexOf(".");
var dotsize = NuNum.value.length;
if (dotindex < 0) {
NuNum.value += ".00";
}
else {
NuNum.value = (Math.round (NuNum.value * 100)) + .49;
NuNum.value = parseFloat(NuNum.value / 100);
dotindex = NuNum.value.indexOf(".");
if (dotindex < 0)
NuNum.value += ".00";
else
if ((NuNum.value.length - dotindex) == 2)
NuNum.value += "0";
else
NuNum.value = NuNum.value.substr (0, dotindex + 3);
}
return NuNum.value;
}
function FPNFormatZS (FPNum, Fmt) {
NuNum = FPNum;
if (FPNum.value == "0" || FPNum.value == "") {
NuNum.value = "";
}
else {
if (NuNum.value.indexOf("$") == 0) { NuNum.value = FPNum.value.substring(1); } // remove leading dollar
var T = "";
for (I = 0; I < FPNum.value.length; I++) {
C = FPNum.value.substring (I, I+1);
if ((C.charCodeAt(0) >= 48 && C.charCodeAt(0) <= 57) || C.charCodeAt(0) == 46 || (I == 0 && C.charCodeAt(0) == 45))
T += C;
}
FPNum.value = T;
// check if negative and reformat w/o "-"
var NegNum = 0;
if (parseFloat(FPNum.value) < 0) {
NegNum = 1;
FPNum.value = 0 - T;
}
// Number format the Total
var Fmtdotindex = Fmt.length - Fmt.indexOf(".") - 1;
var dotindex = FPNum.value.indexOf(".");
var dotsize = FPNum.value.length;
if (dotindex < 0) {
switch (Fmtdotindex) {
case 1:
NuNum.value += ".0";
break;
case 2:
NuNum.value += ".00";
break;
case 3:
NuNum.value += ".000";
break;
}
}
else {
switch (Fmtdotindex) {
case 1:
NuNum.value = (Math.round (FPNum.value * 10)) + .49;
NuNum.value = parseFloat(NuNum.value / 10);
dotindex = NuNum.value.indexOf(".");
if (dotindex < 0)
NuNum.value += ".0";
else
NuNum.value = NuNum.value.substr (0, dotindex + 2);
break;
case 2:
NuNum.value = (Math.round (FPNum.value * 100)) + .49;
NuNum.value = parseFloat(NuNum.value / 100);
dotindex = NuNum.value.indexOf(".");
if (dotindex < 0)
NuNum.value += ".00";
else
if ((NuNum.value.length - dotindex) == 2)
NuNum.value += "0";
else
NuNum.value = NuNum.value.substr (0, dotindex + 3);
break;
case 3:
NuNum.value = (Math.round (FPNum.value * 1000)) + .49;
NuNum.value = parseFloat(NuNum.value / 1000);
dotindex = NuNum.value.indexOf(".");
if (dotindex < 0)
NuNum.value += ".000";
else {
switch (NuNum.value.length - dotindex) {
case 3:
NuNum.value += "00";
break;
case 2:
NuNum.value += "0";
break;
default:
NuNum.value = NuNum.value.substr (0, dotindex + 4);
break;
}
}
break;
}
}
if ((typeof Fmt) != "undefined" && Fmt.length) {
if (Fmt == "#,##0.00" || Fmt == "$#,##0.00") {
var pindex = NuNum.value.indexOf(".");
var wnum = NuNum.value.substring (0, pindex);
var n3 = wnum.substring (wnum.length - 3);
wnum = wnum.substring (0, wnum.length - 3);
while (wnum.length > 3) {
n3 = wnum.substring (wnum.length - 3) + "," + n3;
wnum = wnum.substring (0, wnum.length - 3);
}
if (wnum.length) {
n3 = wnum + "," + n3;
}
var dnum = NuNum.value.substring (NuNum.value.length - 3);
NuNum.value = n3 + dnum;
if (Fmt.indexOf("$") == 0)
NuNum.value = "$" + NuNum.value;
}
else
if (Fmt == "$#,###" || Fmt == "#,###") {
var pindex = NuNum.value.indexOf(".");
var wnum = NuNum.value.substring (0, pindex);
var n3 = wnum.substring (wnum.length - 3);
wnum = wnum.substring (0, wnum.length - 3);
while (wnum.length > 3) {
n3 = wnum.substring (wnum.length - 3) + "," + n3;
wnum = wnum.substring (0, wnum.length - 3);
}
if (wnum.length) {
n3 = wnum + "," + n3;
}
NuNum.value = n3;
if (Fmt.indexOf("$") == 0)
NuNum.value = "$" + NuNum.value;
}
}
if (NegNum) { NuNum.value = "-" + NuNum.value; } // reformat with "-"
}
return NuNum.value;
}
function TparseFloat (FPNumStr) {
// remove non-numeric chars
FPNumStr = RmNonNum(1, FPNumStr);
if (isNaN(parseFloat(FPNumStr)))
return 0;
else
return (parseFloat(FPNumStr));
}
function isEmpty (str) {
for (var I = 0; I < str.length; I++) {
if (str.charAt(I) != " ")
return false;
}
return true;
}
function CountTextLines (TLine) {
var LCount = 1;
for (var I = 0; I < TLine.length; I++) {
if (TLine.charAt(I) == "\n")
++LCount;
}
return LCount;
}
function CountBRLines (TLine) {
var LCount = 1;
var tlen = TLine.length;
var i = 0;
while (i < (tlen - 4)) {
var j = i + 4;
if (TLine.substring (i, j) == "
" || TLine.substring (i, j) == "
")
++LCount;
++i;
}
return LCount;
}
function FindTextLineEnd (TLine, MaxLines) {
var LCount = 1;
var CCount = 0;
for (var I = 0; I < TLine.length; I++) {
if (TLine.charAt(I) == "\n")
++LCount;
++CCount;
if (LCount > MaxLines)
break;
}
return CCount;
}
function CountTextChars (TLine) {
var CCount = 0;
for (var I = 0; I < TLine.length; I++) {
if (TLine.charAt(I) != "\n" && TLine.charAt(I) != "\r")
++CCount;
}
return CCount;
}
function CnvToBRs (TLine) {
var RLine = "";
for (var I = 0; I < TLine.length; I++) {
if (TLine.charAt(I) != "\n" && TLine.charAt(I) != "\r") {
RLine += TLine.charAt(I);
}
else {
RLine += "
";
I += 1;
}
}
return RLine;
}
function LimitInputArea (OrigString, MAXL, MAXC) {
var TargetString = OrigString;
var lcnt = CountTextLines (TargetString);
var ccnt = CountTextChars (TargetString);
if (lcnt > MAXL || ccnt > MAXC) {
var msg = "Imprint Area has more than " + MAXL + " lines or more than " + MAXC + " chars";
alert (msg);
if (ccnt > MAXC) {
var s = TargetString;
TargetString = s.substring (0, MAXC - 1);
lcnt = CountTextLines (TargetString);
}
if (lcnt > MAXL) {
ccnt = FindTextLineEnd (TargetString, MAXL);
var s = TargetString;
TargetString = s.substring (0, ccnt-2);
}
}
return TargetString;
}
function _TodaysDate () {
TDate = new Date();
var cDate = "";
if (parseInt(TDate.getMonth(), 10) + 1 < 10)
cDate += "0";
cDate += ("" + parseInt(TDate.getMonth() + 1, 10));
cDate += "/";
if (TDate.getDate() < 10)
cDate += "0";
cDate += ("" + TDate.getDate());
cDate += "/";
cDate += ("" + TDate.getFullYear());
return cDate;
}
function GetDateValue (S) {
return (Date.UTC(S.substr(6, 4), S.substr(0, 2) - 1, S.substr(3, 2)));
}
function _ModalDlg (U, H, W, T, L) {
// example of full screen, centered dialog:
// _ModalDlg (YourURL, -1, -1, -1, -1);
// if height or width is -1, use the full screen values
var ih = H;
var iw = W;
if (H == -1) { ih = window.window.screen.availHeight; }
if (W == -1) { iw = window.window.screen.availWidth; }
var features = "dialogHeight: " + ih + "px; dialogWidth: " + iw + "px; ";
// if top and left is -1, center on the screen
if (T == -1 && L == -1) {
features += "center: Yes; ";
}
else {
// use specific top and left position values
features += "dialogTop: " + T + "px; dialogLeft: " + L + "px; ";
features += "center: No; ";
}
// misc features as desired
features += "edge: Raised; help: No; ";
features += "resizable: No; status: No; unadorned: No;";
// display a modal dialog with specified URL and features
window.showModalDialog(U,window, features);
}
function _fldsReFmt(F, O) {
switch (_fldsTyp[F]) {
case "NUMERIC":
if (O.value.length) {
var dotindex = _fldsFmt[F].length - _fldsFmt[F].indexOf(".") - 1;
if (_fldsFmt[F].indexOf("#,##") != -1 || dotindex == 1 || dotindex == 3) {
O.value = FPNFormatZS(O, _fldsFmt[F]);
}
else {
if (_fldsFmt[F].length) {
O.value = FPNFormat(O);
}
}
}
break;
case "DATE":
if (O.value.length) {
O.value = ReFmtDate(O.value, _fldsFmt[F]);
}
break;
}
}
function autoTab(input,len, e) {
var keyCode = (isNN) ? e.which : e.keyCode;
var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
if(input.value.length >= len && !containsElement(filter,keyCode)) {
input.value = input.value.slice(0, len);
input.form[(getIndex(input)+1) % input.form.length].focus();
}
function containsElement(arr, ele) {
var found = false, index = 0;
while(!found && index < arr.length)
if(arr[index] == ele)
found = true;
else
index++;
return found;
}
function getIndex(input) {
var index = -1, i = 0, found = false;
while (i < input.form.length && index == -1)
if (input.form[i] == input)index = i;
else i++;
return index;
}
return true;
}
function KeyPress_Form(evt) {
var K = evt.keyCode;
// now, do something with the Esc-key
if (K == 27) {
K = 0;
}
evt.keyCode = K;
}
function KeyDown_Form(evt) {
var K = evt.keyCode;
var A = 0;
// check for alt-key state
if (_AltKey == 1) { // alt-key, get next key
_AltKey = 0;
A = K;
}
if (((typeof _AltKey) == "undefined" || _AltKey == 0) && K == 18) { // alt-key pressed
_AltKey = 1;
A = 0;
}
}
function Validtest (frm, prm) {
if (prm) {
var msg = "Are you finished filling out this form?";
if (!confirm (msg)) {
return false;
}
}
var I = 0;
var errfld = null;
var errfldindex = 9999;
var errmsg = "";
var SubmitID = MakeSubmitID();
for (I = 0; I < frm.elements.length; I++) {
if (frm.elements[I].className == "fldrequired") {
if (isEmpty(frm.elements[I].value)) {
errmsg += "\rYou MUST enter ";
errmsg += frm.elements[I].name;
if (frm.elements[I].tabIndex < errfldindex) {
errfld = frm.elements[I];
errfldindex = frm.elements[I].tabIndex;
}
}
}
}
if (errmsg != "") {
alert (errmsg);
errmsg = "";
returnCode = false;
if (errfld != null)
errfld.focus();
}
else
returnCode = true;
if (returnCode == true) {
}
return (returnCode);
}