// ##############################
function echeck(str) {

    var at = "@"
    var dot = "."
    var lat = str.indexOf(at)
    var lstr = str.length
    var ldot = str.indexOf(dot)
    if (str.indexOf(at) == -1) {
        alert("Invalid e-mail address entered")
        return false
    }

    if (str.indexOf(at) == -1 || str.indexOf(at) == 0 || str.indexOf(at) == lstr) {
        alert("Invalid e-mail address entered")
        return false
    }

    if (str.indexOf(dot) == -1 || str.indexOf(dot) == 0 || str.indexOf(dot) == lstr) {
        alert("Invalid e-mail address entered")
        return false
    }

    if (str.indexOf(at, (lat + 1)) != -1) {
        alert("Invalid e-mail address entered")
        return false
    }

    if (str.substring(lat - 1, lat) == dot || str.substring(lat + 1, lat + 2) == dot) {
        alert("Invalid e-mail address entered")
        return false
    }

    if (str.indexOf(dot, (lat + 2)) == -1) {
        alert("Invalid e-mail address entered")
        return false
    }

    if (str.indexOf(" ") != -1) {
        alert("Invalid e-mail address entered")
        return false
    }

    return true
}


// ##############################
function checkEnter(e) { //e is event object passed from function invocation
var characterCode //literal character code will be stored in this variable

if(e && e.which){ //if which property of event object is supported (NN4)
e = e
characterCode = e.which //character code is contained in NN4's which property
}
else{
e = event
characterCode = e.keyCode //character code is contained in IE's keyCode property
}

if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
//document.forms[0].submit() //submit the form
return false
}
else{
return true
}

}

// ##############################
function Right(str, n)
{
      if (n <= 0)
          return "";
      else if (n > String(str).length)
          return str;
      else
   {
          var iLen = String(str).length;
          return String(str).substring(iLen, iLen - n);
      }
}

function isDefined(variable){

return (typeof(window[variable]) == 'undefined')? false : true;

}

// ##############################
function parseCCInfo(which) {
    var swipeInfo = document.billPayForm.ccSwipe.value;
    if (swipeInfo == '') {
        return;
    }
    // see if there is a full compliment of data
    if (swipeInfo.indexOf("^") == -1) {
        if (swipeInfo == "ZZZ") {
            return;
        } else {
        alert("Error reading card from 1-2 swiper ... please try again");
        return;
        }
    }
    // split
    dataAry = swipeInfo.split("^");
    //alert(dataAry[0]);
    //alert(dataAry[1]);
    //alert(dataAry[2]);

    yearVal = dataAry[2].substring(0, 2);
    monVal = dataAry[2].substring(2, 4);
    //alert(yearVal);
    //alert(monVal);
    //document.billPayForm.disccExpMonth.disabled=false;
    document.billPayForm.disccExpMonth.value = monVal;
    document.billPayForm.ccExpMonth.value = monVal;
    //document.billPayForm.disccExpMonth.disabled=true;

    document.billPayForm.disccExpYear.disabled = false;
    document.billPayForm.disccExpYear.value = yearVal;
    document.billPayForm.ccExpYear.value = yearVal;
    document.billPayForm.disccExpYear.disabled = true;

    ccNumber = dataAry[0].substring(2);
    //alert(ccNumber);
    document.billPayForm.disccNumber.value = ccNumber;
    document.billPayForm.ccNumber.value = ccNumber;

    // split the name
    if (Right(dataAry[1], 1) == "/") {                // just the name
        var nameString = dataAry[1].replace("/", "");
        dataAry2 = nameString.split(" ");
        var data0 = dataAry2[0];
        var data1 = dataAry2[1];
        var data2 = dataAry2[2];
    } else {                                             // company card- which includes last/first name
        if (dataAry[1].indexOf("/", 1) == -1) {
            alert("Unable to parse data on card");
            return false;
        } else {
            dataAry2 = dataAry[1].split("/");
            var data0 = dataAry2[0];
            var data1 = dataAry2[1];
            var data2 = "";
        }
    }

    //alert ("0:"+dataAry2[0]);
    //alert ("1:"+dataAry2[1]);
    //alert ("2:"+dataAry2[2]);
    if (data0 != "") {              // at least 1 part
        if (data1 != "") {           // at least 2 parts
            if (data2 != "") {       // at least 3 parts
                document.billPayForm.disfirstName.value = data0 + " " + data1;
                document.billPayForm.firstName.value = data0 + " " + data1;
                document.billPayForm.dislastName.value = data2;
                document.billPayForm.lastName.value = data2;
            } else {
                // only 2 parts 
                document.billPayForm.disfirstName.value = data1;
                document.billPayForm.firstName.value = data1;
                document.billPayForm.dislastName.value = data0;
                document.billPayForm.lastName.value = data0;
            }
        } else {
            // only 1 part
            document.billPayForm.disfirstName.value = data0;
            document.billPayForm.firstName.value = data0;
            document.billPayForm.dislastName.value = data0;
            document.billPayForm.lastName.value = data0;
        }
    } else {
        // 0 parts
    }

    document.billPayForm.magStripe.value = swipeInfo;

    // document.billPayForm.ccSwipe.value="ZZZ";

    //    document.billPayForm.amount.focus();

    //  ##################


    return false;

}

// ##############################
function checkrequiredBillpayCardSaleManual(which) {

    var pass = true;
    fieldlist = "";

    var bgBad = '#dddddd';
    var bgGood = "white";
    var amount = document.billPayForm.amount.value;

    if (document.images) {
        for (i = 0; i < which.length; i++) {
            var tempobj = which.elements[i];
            //		if (tempobj.name=="firstName" && tempobj.value=='') {
            //			fieldlist = "First Name";
            //			pass=false;
            //			break;
            //		}
            //		if (tempobj.name=="lastName" && tempobj.value=='') {
            //			fieldlist = "Last Name";
            //			pass=false;
            //			break;
            //		}
            if (tempobj.name == "customerNumber" && tempobj.value == '') {
                fieldlist = "(Customer ID)";
                pass = false;
                break;
            }
            if (tempobj.name == "ccNumber" && tempobj.value == '') {
                fieldlist = "Card Number";
                pass = false;
                break;
            }
            if (tempobj.name == "ccExpMonth" && tempobj.value == '') {
                fieldlist = "Expiration Month";
                pass = false;
                break;
            }
            if (tempobj.name == "ccExpYear" && tempobj.value == '') {
                fieldlist = "Expiration Year";
                pass = false;
                break;
            }
            if (tempobj.name == "ccThreeDigit" && tempobj.value == '') {
                fieldlist = "CVV2/CID";
                pass = false;
                break;
            }
            if (tempobj.name == "amount" && tempobj.value == '') {
                fieldlist = "Amount";
                pass = false;
                break;
            }
            if (tempobj.name == "address1" && tempobj.value == '') {
                fieldlist = "Billing Address";
                pass = false;
                break;
            }
            if (tempobj.name == "zip" && tempobj.value == '') {
                fieldlist = "Billing Zip";
                pass = false;
                break;
            }
        }
    }

    if (amount == '0') {
        document.billPayForm.submit.value = "Submit";
        alert("Please enter a valid amount");
        return false;
    }

    if (!pass) {
        document.billPayForm.Submit.value = "Submit";
        document.billPayForm.Submit.disabled = false;
        setColor(tempobj, bgBad);
        alert("" + fieldlist + " is required.");
        //	tempobj.focus();
        //	tempobj.blur();
        return false;
    }
    else {
        document.billPayForm.Submit.value = "Please wait...";
        document.billPayForm.Submit.disabled = true;
        return true;
    }
}


// ##############################
function parseCCInfo123(which) {
    var swipeInfo = document.billPayForm.ccSwipe.value;
    if (swipeInfo == '') {
        return;
    }
    // see if there is a full compliment of data
    if (swipeInfo.indexOf("^") == -1) {
        if (swipeInfo == "ZZZ") {
            return;
        } else {
            alert("Error reading card from 1-2-3 swiper ... please try again");
            return;
        }
    }
// split
    //alert(swipeInfo);
    dataAry = swipeInfo.split("^");
    //alert(dataAry[0]);
    //alert(dataAry[1]);
    //alert(dataAry[2]);

    yearVal = dataAry[2].substring(0, 2);
    monVal = dataAry[2].substring(2, 4);
    //alert(yearVal);
    //alert(monVal);
    //document.billPayForm.disccExpMonth.disabled=false;
    document.billPayForm.disccExpMonth.value = monVal;
    document.billPayForm.ccExpMonth.value = monVal;
    //document.billPayForm.disccExpMonth.disabled=true;

    document.billPayForm.disccExpYear.disabled = false;
    document.billPayForm.disccExpYear.value = yearVal;
    document.billPayForm.ccExpYear.value = yearVal;
    document.billPayForm.disccExpYear.disabled = true;

    ccNumber = dataAry[0].substring(2);
    //alert(ccNumber);
    document.billPayForm.disccNumber.value = ccNumber;
    document.billPayForm.ccNumber.value = ccNumber;

    // split the name
    if (Right(dataAry[1], 1) == "/") {                // just the name
        var nameString = dataAry[1].replace("/", "");
        dataAry2 = nameString.split(" ");
        var data0 = dataAry2[0];
        var data1 = dataAry2[1];
        var data2 = dataAry2[2];
    } else {                                             // company card- which includes last/first name
        if (dataAry[1].indexOf("/", 1) == -1) {
            alert("Unable to parse data on card");
            return false;
        } else {
            dataAry2 = dataAry[1].split("/");
            var data0 = dataAry2[0];
            var data1 = dataAry2[1];
            var data2 = "";
        }
    }

    //alert ("0:"+dataAry2[0]);
    //alert ("1:"+dataAry2[1]);
    //alert ("2:"+dataAry2[2]);
    if (data0 != "") {              // at least 1 part
        if (data1 != "") {           // at least 2 parts
            if (data2 != "") {       // at least 3 parts
                document.billPayForm.disfirstName.value = data0 + " " + data1;
                document.billPayForm.firstName.value = data0 + " " + data1;
                document.billPayForm.dislastName.value = data2;
                document.billPayForm.lastName.value = data2;
            } else {
                // only 2 parts 
                document.billPayForm.disfirstName.value = data1;
                document.billPayForm.firstName.value = data1;
                document.billPayForm.dislastName.value = data0;
                document.billPayForm.lastName.value = data0;
            }
        } else {
            // only 1 part
            document.billPayForm.disfirstName.value = data0;
            document.billPayForm.firstName.value = data0;
            document.billPayForm.dislastName.value = data0;
            document.billPayForm.lastName.value = data0;
        }
    } else {
        // 0 parts
    }

    document.billPayForm.magStripe.value = swipeInfo;
    document.billPayForm.ccSwipe.value = "ZZZ";

    //    document.billPayForm.ccSwipe.value="ZZZ";

    document.billPayForm.amount.focus();

    return false;

}

// ##############################
function checkrequiredDailyLog(which) {

    var pass = true;
    fieldlist = "";

    var bgBad = '#dddddd';
    var bgGood = "white";

    if (document.images) {
        for (i = 0; i < which.length; i++) {
            var tempobj = which.elements[i];
            if (tempobj.name == "transDate" && tempobj.value == '') {
                fieldlist = "Transaction Date";
                pass = false;
                break;
            }
        }
    }

    if (!pass) {
        document.billPayForm.Submit.value = "Submit";
        document.billPayForm.Submit.disabled = false;
        setColor(tempobj, bgBad);
        if (swipedData == true) {
            return false;
        } else {
            alert("" + fieldlist + " is required.");
            //	tempobj.focus();
            //	tempobj.blur();
            return false;
        }
    }
    else {
        document.billPayForm.Submit.value = "Please wait...";
        document.billPayForm.Submit.disabled = true;
        return true;
    }
}

// ##############################
function checkrequiredBillpayCardSaleSwipe(which) {

    var pass = true;
    fieldlist = "";

    var bgBad = '#dddddd';
    var bgGood = "white";
    var amount = document.billPayForm.amount.value;

    var swipedData = false;

    if (document.billPayForm.ccSwipe.value != "" && document.billPayForm.ccSwipe.value != "ZZZ" && document.billPayForm.swiper123.value == 'X') {
        document.billPayForm.Submit.value = "Submit";
        document.billPayForm.Submit.disabled = false;
        return false;
    }

    if (document.billPayForm.amount.value == "") {
        document.billPayForm.Submit.value = "Submit";
        document.billPayForm.Submit.disabled = false;
        if (document.billPayForm.ccSwipe.value != "") {            // form was submitted as a result of the swipe
        } else {
            //document.billPayForm.ccSwipe.value = "ZZZ";
            //alert("");
        }
        alert("Please enter the amount");
        return false;
    }

    if (document.images) {
        for (i = 0; i < which.length; i++) {
            var tempobj = which.elements[i];
            //		if (tempobj.name=="firstName" && tempobj.value=='') {
            //			fieldlist = "First Name";
            //			pass=false;
            //			break;
            //		}
            //		if (tempobj.name=="lastName" && tempobj.value=='') {
            //			fieldlist = "Last Name";
            //			pass=false;
            //			break;
            //		}
            if (tempobj.name == "customerNumber" && tempobj.value == '') {
                fieldlist = "(Customer ID)";
                pass = false;
                break;
            }
            if (tempobj.name == "ccNumber" && tempobj.value == '') {
                fieldlist = "Card Number";
                pass = false;
                break;
            }
            if (tempobj.name == "ccExpMonth" && tempobj.value == '') {
                fieldlist = "Expiration Month";
                pass = false;
                break;
            }
            if (tempobj.name == "ccExpYear" && tempobj.value == '') {
                fieldlist = "Expiration Year";
                pass = false;
                break;
            }
            if (tempobj.name == "amount" && tempobj.value == '') {
                fieldlist = "Amount";
                pass = false;
                break;
            }
            //            if (tempobj.name == "ccSwipe" && tempobj.value == 'ZZZ') {
            //                swipedData = true;
            //            }
        }
    }

    if (amount == '0') {
        document.billPayForm.Submit.value = "Submit";
        document.billPayForm.Submit.disabled = false;
        alert("Please enter a valid amount");
        return false;
    }

    if (!pass) {
        document.billPayForm.Submit.value = "Submit";
        document.billPayForm.Submit.disabled = false;
        setColor(tempobj, bgBad);
        if (swipedData == true) {
            return false;
        } else {
            alert("" + fieldlist + " is required.");
            //	tempobj.focus();
            //	tempobj.blur();
            return false;
        }
    }
    else {
        document.billPayForm.Submit.value = "Please wait...";
        document.billPayForm.Submit.disabled = true;
        return true;
    }
}


// ##############################
function checkrequiredBillpayCashSaleManual(which) {

    var pass = true;
    fieldlist = "";

    var bgBad = '#dddddd';
    var bgGood = "white";
    var amount = document.billPayForm.amount.value;

    if (document.images) {
        for (i = 0; i < which.length; i++) {
            var tempobj = which.elements[i];
            if (tempobj.name == "customerNumber" && tempobj.value == '') {
                fieldlist = "(Customer ID)";
                pass = false;
                break;
            }
            if (tempobj.name == "amount" && tempobj.value == '') {
                fieldlist = "Amount";
                pass = false;
                break;
            }
        }
    }

    if (amount == '0') {
        document.billPayForm.Submit.value = "Submit";
        document.billPayForm.Submit.disabled = false;
        alert("Please enter a valid amount");
        return false;
    }

    if (!pass) {
        document.billPayForm.Submit.value = "Submit";
        document.billPayForm.Submit.disabled = false;
        setColor(tempobj, bgBad);
        alert("" + fieldlist + " is required.");
        //	tempobj.focus();
        //	tempobj.blur();
        return false;
    }
    else {
        document.billPayForm.Submit.value = "Please wait...";
        document.billPayForm.Submit.disabled = true;
        return true;
    }
}


// ##############################
function checkrequiredBillpayCheckSaleManual(which) {

    var pass = true;
    fieldlist = "";

    var bgBad = '#dddddd';
    var bgGood = "white";
    var amount = document.billPayForm.amount.value;

    if (document.images) {
        for (i = 0; i < which.length; i++) {
            var tempobj = which.elements[i];
            //		if (tempobj.name=="firstName" && tempobj.value=='') {
            //			fieldlist = "Card Holder name";
            //			pass=false;
            //			break;
            //		}
            if (tempobj.name == "customerNumber" && tempobj.value == '') {
                fieldlist = "(Customer ID)";
                pass = false;
                break;
            }
            if (tempobj.name == "bankRoutingNumber" && tempobj.value == '') {
                fieldlist = "Bank Routing Number";
                pass = false;
                break;
            }
            if (tempobj.name == "bankAccountNumber" && tempobj.value == '') {
                fieldlist = "Bank Account Number";
                pass = false;
                break;
            }
            if (tempobj.name == "amount" && tempobj.value == '') {
                fieldlist = "Amount";
                pass = false;
                break;
            }
        }
    }

    if (amount == '0') {
        document.billPayForm.Submit.value = "Submit";
        document.billPayForm.Submit.disabled = false;
        alert("Please enter a valid amount");
        return false;
    }

    if (!pass) {
        document.billPayForm.Submit.value = "Submit";
        document.billPayForm.Submit.disabled = false;
        setColor(tempobj, bgBad);
        alert("" + fieldlist + " is required.");
        //	tempobj.focus();
        //	tempobj.blur();
        return false;
    }
    else {
        document.billPayForm.Submit.value = "Please wait...";
        document.billPayForm.Submit.disabled = true;
        return true;
    }
}

// ##############################
function checkrequiredBillpayCheckSaleSwipe(which) {

    var pass = true;
    fieldlist = "";

    var bgBad = '#dddddd';
    var bgGood = "white";
    var amount = document.billPayForm.amount.value;

    if (document.images) {
        for (i = 0; i < which.length; i++) {
            var tempobj = which.elements[i];
            //		if (tempobj.name=="firstName" && tempobj.value=='') {
            //			fieldlist = "Card Holder name";
            //			pass=false;
            //			break;
            //		}
            if (tempobj.name == "customerNumber" && tempobj.value == '') {
                fieldlist = "(Customer ID)";
                pass = false;
                break;
            }
            if (tempobj.name == "bankRoutingNumber" && tempobj.value == '') {
                fieldlist = "Bank Routing Number";
                pass = false;
                break;
            }
            if (tempobj.name == "bankAccountNumber" && tempobj.value == '') {
                fieldlist = "Bank Account Number";
                pass = false;
                break;
            }
            if (tempobj.name == "amount" && tempobj.value == '') {
                fieldlist = "Amount";
                pass = false;
                break;
            }
        }
    }

    if (amount == '0') {
        document.billPayForm.Submit.value = "Submit";
        document.billPayForm.Submit.disabled = false;
        alert("Please enter a valid amount");
        return false;
    }

    if (!pass) {
        document.billPayForm.Submit.value = "Submit";
        document.billPayForm.Submit.disabled = false;
        setColor(tempobj, bgBad);
        alert("" + fieldlist + " is required.");
        //	tempobj.focus();
        //	tempobj.blur();
        return false;
    }
    else {
        document.billPayForm.Submit.value = "Please wait...";
        document.billPayForm.Submit.disabled = true;
        return true;
    }
}


// ##############################
// ##############################
// ##############################
// ##############################
function checkrequiredPayoutReport(which) {
var pass=true;
fieldlist = '';
  var bgBad = "#DDDDDD";
  var bgGood = "white";
if (document.images) {
	for (i=0;i<which.length;i++) {
		var tempobj=which.elements[i];
		if (tempobj.name=="resellerID" && tempobj.value=='X') {
	        fieldlist = "Reseller is required.";
	        pass=false;
	        break;
	    }
		if (tempobj.name=="accountExecID" && tempobj.value=='X') {
	        fieldlist = "Account Exec is required.";
	        pass=false;
	        break;
	    }
		if (tempobj.name=="month" && tempobj.value=='X') {
	        fieldlist = "Month is required.";
	        pass=false;
	        break;
	    }
        if (tempobj.name=="year" && tempobj.value=='X') {
	        fieldlist = "Year is required.";
	        pass=false;
	        break;
        }
	}
}
if (!pass) {
	setColor(tempobj, bgBad);
	alert(fieldlist);
	document.form1.submit.value = "Submit";
	tempobj.focus();
	tempobj.blur();
	return false;
}
else
return true;
}

// ##############################
function checkrequiredContactUs(which) {
var pass=true;
fieldlist = '';
  var bgBad = "#DDDDDD";
  var bgGood = "white";
if (document.images) {
    for (i=0;i<which.length;i++) {
	    var tempobj=which.elements[i];
	    if (tempobj.name=="Name" && tempobj.value=='') {
            fieldlist = "Please enter your name.";
            pass=false;
            break;
        }
        if (tempobj.name == "Email" && tempobj.value == '') {
            fieldlist = "Please enter your e-mail address.";
            pass = false;
            break;
        }
        if (tempobj.name == "Company" && tempobj.value == '') {
            fieldlist = "Please enter your company name.";
            pass = false;
            break;
        }
        if (tempobj.name == "Phone" && tempobj.value == '') {
            fieldlist = "Please enter your phone number.";
            pass = false;
            break;
        }
        if (tempobj.name == "captchacode" && tempobj.value == '') {
            fieldlist = "Please enter the Security Code.";
			pass=false;
			break;
		}
    }
}
if (document.PVAMailform.Comments.value == "") {
    alert("Please tell us how we can help you");
    return false;
}


if (!pass) {
    document.PVAMailform.submit.value="Submit";
	setColor(tempobj, bgBad);
	alert(fieldlist);
	tempobj.focus();
	tempobj.blur();
	return false;
}
else
return true;
}

// ##############################
function checkrequiredAPIKeyRequest(which) {
var pass=true;
fieldlist = '';
  var bgBad = "#DDDDDD";
  var bgGood = "white";
if (document.images) {
    for (i=0;i<which.length;i++) {
	    var tempobj=which.elements[i];
	    if (tempobj.name=="clientID" && tempobj.value=='') {
            fieldlist = "Please enter your Secure Bill Pay.NET Client ID.";
            pass=false;
            break;
        }
        if (tempobj.name=="email" && tempobj.value=='') {
            fieldlist = "Please enter your Merchant Login Name.";
            pass=false;
            break;
        }
        if (tempobj.name=="password" && tempobj.value=='') {
            fieldlist = "Please enter your Merchant Password.";
            pass=false;
            break;
        }
		if (tempobj.name=="captchacode" && tempobj.value=='') {
            fieldlist = "Please enter the Security Code.";
			pass=false;
			break;
		}
    }
}
if (!pass) {
    document.PVAMailform.submit.value="Submit";
	setColor(tempobj, bgBad);
	alert(fieldlist);
	tempobj.focus();
	tempobj.blur();
	return false;
}
else
return true;
}

// ##############################
function checkrequiredAccountSetup(which) {

var pass=true;
fieldlist = "";

  var bgBad = '#dddddd';
  var bgGood = "white";
  
if (document.images) {
	for (i=0;i<which.length;i++) {
		var tempobj=which.elements[i];
		if (tempobj.name=="clientName" && tempobj.value=='') {
			fieldlist = "Company Name";
			pass=false;
			break;
		}
		if (tempobj.name=="address" && tempobj.value=='') {
			fieldlist = "Address";
			pass=false;
			break;
		}
		if (tempobj.name=="city" && tempobj.value=='') {
			fieldlist = "City";
			pass=false;
			break;
		}
		if (tempobj.name=="stateID" && tempobj.value=='X') {
			fieldlist = "State";
			pass=false;
			break;
		}
		if (tempobj.name=="zip" && tempobj.value=='') {
			fieldlist = "Zip Code";
			pass=false;
			break;
		}
		if (tempobj.name == "email" && tempobj.value == '') {
		    fieldlist = "Email";
		    pass = false;
		    break;
		}
		if (tempobj.name == "email" && tempobj.value != '') {
		    if (echeck(tempobj.value)== false) {
		        return false;
		    }
		}
		if (tempobj.name == "contactFirstName" && tempobj.value == '') {
			fieldlist = "First Name";
			pass=false;
			break;
		}
		if (tempobj.name=="contactLastName" && tempobj.value=='') {
			fieldlist = "Last Name";
			pass=false;
			break;
		}
		if (tempobj.name=="contactTitle" && tempobj.value=='') {
			fieldlist = "Title";
			pass=false;
			break;
		}
		if (tempobj.name=="contactPhone" && tempobj.value=='') {
			fieldlist = "Phone";
			pass=false;
			break;
		}
		if (tempobj.name=="contactEmail" && tempobj.value=='') {
			fieldlist = "Email";
			pass=false;
			break;
		}
		if (tempobj.name == "contactEmail" && tempobj.value != '') {
		    if (echeck(tempobj.value)== false) {
		        return false;
		    }
		}
		if (tempobj.name=="businessTypeID" && tempobj.value=='X') {
			fieldlist = "Type of Business";
			pass=false;
			break;
		}
		if (tempobj.name=="captchacode" && tempobj.value=='') {
            fieldlist = "Security Code";
			pass=false;
			break;
		}
	}
}

if (!pass) {
    document.billPayForm.Submit.value = "Submit";
    document.billPayForm.Submit.disabled = false;
    setColor(tempobj, bgBad);
	alert(""+fieldlist+" is required.");
	tempobj.focus();
	tempobj.blur();
	return false;
}
else {
    document.billPayForm.Submit.value = "Please wait...";
    document.billPayForm.Submit.disabled = true;
    return true;
}
}

// ##############################
function checkrequiredMerchantProfile(which) {

    var pass = true;
    fieldlist = "";

    var bgBad = '#dddddd';
    var bgGood = "white";

    var pwd1 = document.billPayForm.password.value;
    var pwd2 = document.billPayForm.verifyPassword.value;

    if (document.images) {
        for (i = 0; i < which.length; i++) {
            var tempobj = which.elements[i];
            if (tempobj.name == "clientName" && tempobj.value == '') {
                fieldlist = "Company Name";
                pass = false;
                break;
            }
            if (tempobj.name == "address" && tempobj.value == '') {
                fieldlist = "Address";
                pass = false;
                break;
            }
            if (tempobj.name == "city" && tempobj.value == '') {
                fieldlist = "City";
                pass = false;
                break;
            }
            if (tempobj.name == "stateID" && tempobj.value == 'X') {
                fieldlist = "State";
                pass = false;
                break;
            }
            if (tempobj.name == "zip" && tempobj.value == '') {
                fieldlist = "Zip Code";
                pass = false;
                break;
            }
            if (tempobj.name == "email" && tempobj.value == '') {
                fieldlist = "Email";
                pass = false;
                break;
            }
            if (tempobj.name == "email" && tempobj.value != '') {
                if (echeck(tempobj.value) == false) {
                    return false;
                }
            }
            if (tempobj.name == "contactFirstName" && tempobj.value == '') {
                fieldlist = "First Name";
                pass = false;
                break;
            }
            if (tempobj.name == "contactLastName" && tempobj.value == '') {
                fieldlist = "Last Name";
                pass = false;
                break;
            }
            if (tempobj.name == "contactTitle" && tempobj.value == '') {
                fieldlist = "Title";
                pass = false;
                break;
            }
            if (tempobj.name == "contactPhone" && tempobj.value == '') {
                fieldlist = "Phone";
                pass = false;
                break;
            }
            if (tempobj.name == "contactEmail" && tempobj.value == '') {
                fieldlist = "Email";
                pass = false;
                break;
            }
            if (tempobj.name == "contactEmail" && tempobj.value != '') {
                if (echeck(tempobj.value) == false) {
                    return false;
                }
            }
            if (tempobj.name == "password" && tempobj.value == '') {
                fieldlist = "Password";
                pass = false;
                break;
            }
            if (tempobj.name == "verifyPassword" && tempobj.value == '') {
                fieldlist = "Verify Password";
                pass = false;
                break;
            }
        }
    }

    if (pwd1 != pwd2) {
        alert("Passwords do not match - please try again.")
        document.billPayForm.Submit1.value = "Save Changes";
        document.billPayForm.Submit2.value = "Save Changes";
        return false;
    }

    if (!pass) {
        setColor(tempobj, bgBad);
        document.billPayForm.Submit1.value = "Save Changes";
        document.billPayForm.Submit2.value = "Save Changes";
        alert("" + fieldlist + " is required.");
        tempobj.focus();
        tempobj.blur();
        return false;
    }
    else
        return true;
}

// ##############################
function checkrequiredCapturePassword(which) {

    var pass = true;
    fieldlist = "";

    var bgBad = '#dddddd';
    var bgGood = "white";

    var pwd1 = document.billPayForm.password.value;
    var pwd2 = document.billPayForm.verifyPassword.value;

    if (document.images) {
        for (i = 0; i < which.length; i++) {
            var tempobj = which.elements[i];
            if (tempobj.name == "password" && tempobj.value == '') {
                fieldlist = "Password";
                pass = false;
                break;
            }
            if (tempobj.name == "verifyPassword" && tempobj.value == '') {
                fieldlist = "Verify Password";
                pass = false;
                break;
            }
        }
    }

    if (pwd1 != pwd2) {
        alert("Passwords do not match - please try again.")
        document.billPayForm.submit.value = "Submit";
        return false;
    }

    if (!pass) {
        setColor(tempobj, bgBad);
        document.billPayForm.Submit.value = "Submit";
        document.billPayForm.Submit.disabled = false;
        alert("" + fieldlist + " is required.");
        tempobj.focus();
        tempobj.blur();
        return false;
    }
    else {
        document.billPayForm.Submit.value = "Please wait...";
        document.billPayForm.Submit.disabled = true;
        return true;
    }
}


// ##############################
function checkrequiredBillpayClientReceipt(which) {

var pass=true;
fieldlist = "";

  var bgBad = '#dddddd';
  var bgGood = "white";
 
  
if (document.images) {
	for (i=0;i<which.length;i++) {
		var tempobj=which.elements[i];
		if (tempobj.name=="clientReceiptName" && tempobj.value=='') {
			fieldlist = "Receipt Name";
			pass=false;
			break;
		}
	}
}

if (!pass) {
    document.billPayForm.Submit.value = "Submit";
    document.billPayForm.Submit.disabled = false;
    setColor(tempobj, bgBad);
	alert(""+fieldlist+" is required.");
	tempobj.focus();
	tempobj.blur();
	return false;
}
else {
    document.billPayForm.Submit.value = "Please wait...";
    document.billPayForm.Submit.disabled = true;
    return true;
}
}

// ##############################
function checkrequiredBillpayClientUser(which) {

var pass=true;
fieldlist = "";

  var bgBad = '#dddddd';
  var bgGood = "white";
 
    var pwd1 = document.billPayForm.password.value;  
    var pwd2 = document.billPayForm.verifyPassword.value; 
  
if (document.images) {
	for (i=0;i<which.length;i++) {
		var tempobj=which.elements[i];
		if (tempobj.name=="firstName" && tempobj.value=='') {
			fieldlist = "First Name";
			pass=false;
			break;
		}
		if (tempobj.name=="lastName" && tempobj.value=='') {
			fieldlist = "Last Name";
			pass=false;
			break;
		}
		if (tempobj.name=="email" && tempobj.value=='') {
			fieldlist = "Email";
			pass=false;
			break;
		}
		if (tempobj.name == "email" && tempobj.value != '') {
		    if (echeck(tempobj.value)== false) {
		        return false;
		    }
		}
		if (tempobj.name=="login" && tempobj.value=='') {
			fieldlist = "Login";
			pass=false;
			break;
		}
		if (tempobj.name=="sourceKey" && tempobj.value=='') {
			fieldlist = "Source Key";
			pass=false;
			break;
		}
		if (tempobj.name=="password" && tempobj.value=='') {
			fieldlist = "Password";
			pass=false;
			break;
		}
		if (tempobj.name=="verifyPassword" && tempobj.value=='') {
			fieldlist = "Verify Password";
			pass=false;
			break;
		}
		if (tempobj.name == "deviceID" && tempobj.value == 'X') {
		    fieldlist = "Device";
		    pass = false;
		    break;
		}
		if (tempobj.name == "clientReceiptID" && tempobj.value == 'X') {
		    fieldlist = "Receipt Template";
		    pass = false;
		    break;
		}
		if (tempobj.name == "receiptFormatID" && tempobj.value == 'X') {
			fieldlist = "Receipt Format";
			pass=false;
			break;
		}
	}
}

if (pwd1!=pwd2) {
    document.billPayForm.Submit.value = "Submit";
    document.billPayForm.Submit.disabled = false;
    alert("Passwords do not match");
    return false;
}
  
if (!pass) {
    document.billPayForm.Submit.value = "Submit";
    document.billPayForm.Submit.disabled = false;
    setColor(tempobj, bgBad);
	alert(""+fieldlist+" is required.");
	tempobj.focus();
	tempobj.blur();
	return false;
}
else {
    document.billPayForm.Submit.value = "Please wait...";
    document.billPayForm.Submit.disabled = true;
    return true;
}
}

// ##############################
function checkrequiredBillpayCaptureLogin(which) {

var pass=true;
fieldlist = "";

  var bgBad = '#dddddd';
  var bgGood = "white";
  
if (document.images) {
	for (i=0;i<which.length;i++) {
		var tempobj=which.elements[i];
		if (tempobj.name=="login" && tempobj.value=='') {
			fieldlist = "Username";
			pass=false;
			break;
		}
		if (tempobj.name=="password" && tempobj.value=='') {
			fieldlist = "Password";
			pass=false;
			break;
		}
	}
}

if (!pass) {
    document.form1.Submit.value = "Log In";
	setColor(tempobj, bgBad);
	alert(""+fieldlist+" is required.");
	tempobj.focus();
	tempobj.blur();
	return false;
}
else {
    document.form1.Submit.value = "Please wait...";
    document.form1.Submit.disabled = true;
    return true;
}
}

// ##############################
function checkrequiredBillpayVTerm(which) {

    var pass = true;
    fieldlist = "";

    var bgBad = '#dddddd';
    var bgGood = "white";

    if (document.images) {
        for (i = 0; i < which.length; i++) {
            var tempobj = which.elements[i];
            if (tempobj.name == "username" && tempobj.value == '') {
                fieldlist = "Username";
                pass = false;
                break;
            }
            if (tempobj.name == "password" && tempobj.value == '') {
                fieldlist = "Password";
                pass = false;
                break;
            }
        }
    }

    if (!pass) {
        document.form99.Submit.value = "Log In";
        setColor(tempobj, bgBad);
        alert("" + fieldlist + " is required.");
        tempobj.focus();
        tempobj.blur();
        return false;
    }
    else {
//        document.form99.Submit.value = "Please wait...";
//        document.form99.Submit.disabled = true;
        return true;
    }
}


// ##############################
function checkrequiredBillpayVTerm2(which) {

    var pass = true;
    fieldlist = "";

    var bgBad = '#dddddd';
    var bgGood = "white";

    if (document.images) {
        for (i = 0; i < which.length; i++) {
            var tempobj = which.elements[i];
            if (tempobj.name == "username" && tempobj.value == '') {
                fieldlist = "Username";
                pass = false;
                break;
            }
            if (tempobj.name == "password" && tempobj.value == '') {
                fieldlist = "Password";
                pass = false;
                break;
            }
        }
    }

    if (!pass) {
        document.form22.Submit.value = "Log In";
        setColor(tempobj, bgBad);
        alert("" + fieldlist + " is required.");
        tempobj.focus();
        tempobj.blur();
        return false;
    }
    else {
//        document.form22.Submit.value = "Please wait...";
//        document.form22.Submit.disabled = true;
        return true;
    }
}


// ##############################
function checkrequiredBillpayVTerm2(which) {

    var pass = true;
    fieldlist = "";

    var bgBad = '#dddddd';
    var bgGood = "white";

    if (document.images) {
        for (i = 0; i < which.length; i++) {
            var tempobj = which.elements[i];
            if (tempobj.name == "username" && tempobj.value == '') {
                fieldlist = "Username";
                pass = false;
                break;
            }
            if (tempobj.name == "password" && tempobj.value == '') {
                fieldlist = "Password";
                pass = false;
                break;
            }
        }
    }

    if (!pass) {
        document.form99.Submit.value = "Log In";
        setColor(tempobj, bgBad);
        alert("" + fieldlist + " is required.");
        tempobj.focus();
        tempobj.blur();
        return false;
    }
    else {
        document.form99.Submit.value = "Please wait...";
        document.form99.Submit.disabled = true;
        return true;
    }
}


// ##############################
function checkrequiredBillpayCapture(which) {

    var pass = true;
    fieldlist = "";

    var bgBad = '#dddddd';
    var bgGood = "white";

    if (document.images) {
        for (i = 0; i < which.length; i++) {
            var tempobj = which.elements[i];
            if (tempobj.name == "email" && tempobj.value == '') {
                fieldlist = "Username";
                pass = false;
                break;
            }
            if (tempobj.name == "password" && tempobj.value == '') {
                fieldlist = "Password";
                pass = false;
                break;
            }
        }
    }

    if (!pass) {
        document.form55.Submit.value = "Log In";
        setColor(tempobj, bgBad);
        alert("" + fieldlist + " is required.");
        tempobj.focus();
        tempobj.blur();
        return false;
    }
    else {
        document.form55.Submit.value = "Please wait...";
        document.form55.Submit.disabled = true;
        return true;
    }
}


// ##############################
function checkrequiredBillpayCaptureEmail(which) {

    var pass = true;
    fieldlist = "";

    var bgBad = '#dddddd';
    var bgGood = "white";

    if (document.images) {
        for (i = 0; i < which.length; i++) {
            var tempobj = which.elements[i];
            if (tempobj.name == "email" && tempobj.value == '') {
                fieldlist = "Email";
                pass = false;
                break;
            }
        }
    }

    if (!pass) {
        document.form56.Submit.value = "Log In";
        setColor(tempobj, bgBad);
        alert("" + fieldlist + " is required.");
        tempobj.focus();
        tempobj.blur();
        return false;
    }
    else {
        document.form56.Submit.value = "Please wait...";
        document.form56.Submit.disabled = true;
        return true;
    }
}



// ##############################
function checkrequiredBillpayProfile(which) {

    var pass = true;
    fieldlist = "";

    var bgBad = '#dddddd';
    var bgGood = "white";

    if (document.images) {
        for (i = 0; i < which.length; i++) {
            var tempobj = which.elements[i];
            if (tempobj.name == "email" && tempobj.value == '') {
                fieldlist = "Username";
                pass = false;
                break;
            }
            if (tempobj.name == "password" && tempobj.value == '') {
                fieldlist = "Password";
                pass = false;
                break;
            }
        }
    }

    if (!pass) {
        document.form65.Submit.value = "Log In";
        setColor(tempobj, bgBad);
        alert("" + fieldlist + " is required.");
        tempobj.focus();
        tempobj.blur();
        return false;
    }
    else {
        //document.form65.Submit.value = "Please wait...";
        //document.form65.Submit.disabled = true;
        return true;
    }
}


// ##############################
function checkrequiredBillpayProfileEmail(which) {

    var pass = true;
    fieldlist = "";

    var bgBad = '#dddddd';
    var bgGood = "white";

    if (document.images) {
        for (i = 0; i < which.length; i++) {
            var tempobj = which.elements[i];
            if (tempobj.name == "email" && tempobj.value == '') {
                fieldlist = "Email";
                pass = false;
                break;
            }
        }
    }

    if (!pass) {
        document.form66.Submit.value = "Log In";
        setColor(tempobj, bgBad);
        alert("" + fieldlist + " is required.");
        tempobj.focus();
        tempobj.blur();
        return false;
    }
    else {
        document.form66.Submit.value = "Please wait...";
        document.form66.Submit.disabled = true;
        return true;
    }
}


// ##############################
function checkrequiredBillpayLogin(which) {

    var pass = true;
    fieldlist = "";

    var bgBad = '#dddddd';
    var bgGood = "white";

    if (document.images) {
        for (i = 0; i < which.length; i++) {
            var tempobj = which.elements[i];
            if (tempobj.name == "email" && tempobj.value == '') {
                fieldlist = "Username";
                pass = false;
                break;
            }
            if (tempobj.name == "password" && tempobj.value == '') {
                fieldlist = "Password";
                pass = false;
                break;
            }
        }
    }

    if (!pass) {
        document.form1.Submit.value = "Log In";
        setColor(tempobj, bgBad);
        alert("" + fieldlist + " is required.");
        tempobj.focus();
        tempobj.blur();
        return false;
    }
    else {
        document.form1.Submit.value = "Please wait...";
        document.form1.Submit.disabled = true;
        return true;
    }
}

// ##############################
function checkrequiredBillpayEmail(which) {

var pass=true;
fieldlist = "";

  var bgBad = '#dddddd';
  var bgGood = "white";
  
if (document.images) {
	for (i=0;i<which.length;i++) {
		var tempobj=which.elements[i];
		if (tempobj.name == "email" && tempobj.value == '') {
			fieldlist = "Email";
			pass=false;
			break;
		}
	}
}

if (!pass) {
    document.form2.Submit.value = "Submit";
	setColor(tempobj, bgBad);
	alert(""+fieldlist+" is required.");
	tempobj.focus();
	tempobj.blur();
	return false;
}
else {
    document.form2.Submit.value = "Please wait...";
    document.form2.Submit.disabled = true;
    return true;
}
}

// ##############################
function checkrequiredBillpayExport(which) {

var pass=true;
fieldlist = "";

  var bgBad = '#dddddd';
  var bgGood = "white";
  
if (document.images) {
	for (i=0;i<which.length;i++) {
		var tempobj=which.elements[i];
		if (tempobj.name=="startDate" && tempobj.value=='') {
			fieldlist = "Start Date";
			pass=false;
			break;
		}
		if (tempobj.name=="endDate" && tempobj.value=='') {
			fieldlist = "End Date";
			pass=false;
			break;
		}
	}
}

if (!pass) {
	setColor(tempobj, bgBad);
	document.billPayForm.Submit.value = "Submit";
	alert(""+fieldlist+" is required.");
	tempobj.focus();
	tempobj.blur();
	return false;
}
else {
    document.billPayForm.Submit.value = "Please wait...";
    document.billPayForm.Submit.disabled = true;
    return true;
}
}

// ##############################
function checkrequiredBillpay1(which) {

var pass=true;
fieldlist = "";

  var bgBad = '#dddddd';
  var bgGood = "white";
 
  var acctNum = document.billPayForm.accountNumber.value;  
  var verifyacctNum = document.billPayForm.verifyAccountNumber.value;  
  var amount = document.billPayForm.amount.value;  
  var acceptCC = document.billPayForm.acceptCC.value;  
  var enableACH = document.billPayForm.enableACH.value;  
 
//alert(acceptCC);
//alert(enableACH);
   
  //var ccPayment = 0;
  //var achPayment = 0;
    var ccPayment = document.billPayForm.paymentTypeID[0].checked;
    var achPayment = document.billPayForm.paymentTypeID[1].checked;
  /* 
  if (acceptCC==1) { 
alert("A");
    ccPayment = document.billPayForm.paymentTypeID[0].checked;
    if (enableACH==1) {
alert("B");
        achPayment = document.billPayForm.paymentTypeID[1].checked;
    }
  } else {
alert("C");
    if (enableACH==1) {
alert("D");
        achPayment = document.billPayForm.paymentTypeID[0].checked;
    }
  }
   */
   
if (document.images) {
	for (i=0;i<which.length;i++) {
		var tempobj=which.elements[i];
		if (tempobj.name=="accountNumber" && tempobj.value=='') {
			fieldlist = "Account Number";
			pass=false;
			break;
		}
		if (tempobj.name=="verifyAccountNumber" && tempobj.value=='') {
			fieldlist = "Verify Account Number";
			pass=false;
			break;
		}
		if (tempobj.name=="firstName" && tempobj.value=='') {
			fieldlist = "First Name";
			pass=false;
			break;
		}
		if (tempobj.name=="lastName" && tempobj.value=='') {
			fieldlist = "Last Name";
			pass=false;
			break;
		}
		if (tempobj.name=="phone1" && tempobj.value=='') {
			fieldlist = "Area Code";
			pass=false;
			break;
		}
		if (tempobj.name=="phone2" && tempobj.value=='') {
			fieldlist = "Phone";
			pass=false;
			break;
		}
		if (tempobj.name=="phone3" && tempobj.value=='') {
			fieldlist = "Phone";
			pass=false;
			break;
		}
		if (tempobj.name=="email" && tempobj.value=='') {
			fieldlist = "Email";
			pass=false;
			break;
		}
		if (tempobj.name == "email" && tempobj.value != '') {
		    if (echeck(tempobj.value)== false) {
		        return false;
		    }
		}
		if (ccPayment==true && tempobj.name=="ccTypeID" && tempobj.value=='X') {
			fieldlist = "Credit Card Type";
			pass=false;
			break;
		}
		if (ccPayment==true && tempobj.name=="ccNumber" && tempobj.value=='') {
			fieldlist = "Credit Card Number";
			pass=false;
			break;
		}
		if (ccPayment==true && tempobj.name=="ccExpMonth" && tempobj.value=='0') {
			fieldlist = "Expiration Month";
			pass=false;
			break;
		}
		if (ccPayment==true && tempobj.name=="ccExpYear" && tempobj.value=='0') {
			fieldlist = "Expiration Year";
			pass=false;
			break;
		}
		if (ccPayment==true && tempobj.name=="ccThreeDigit" && tempobj.value=='') {
			fieldlist = "3-digit Security Code";
			pass=false;
			break;
		}
		if (achPayment==true && tempobj.name=="bankRoutingNumber" && tempobj.value=='') {
			fieldlist = "Bank Routing Number";
			pass=false;
			break;
		}
		if (achPayment==true && tempobj.name=="bankAccountNumber" && tempobj.value=='') {
			fieldlist = "Bank Account Number";
			pass=false;
			break;
		}
		if (achPayment==true && tempobj.name=="baTypeID" && tempobj.value=='0') {
			fieldlist = "Bank Account Type";
			pass=false;
			break;
		}
		if (tempobj.name=="address1" && tempobj.value=='') {
			fieldlist = "Billing Address";
			pass=false;
			break;
		}
		if (tempobj.name=="city" && tempobj.value=='') {
			fieldlist = "Billing City";
			pass=false;
			break;
		}
		if (tempobj.name=="stateID" && tempobj.value=='X') {
			fieldlist = "Billing State";
			pass=false;
			break;
		}
		if (tempobj.name=="zip" && tempobj.value=='') {
			fieldlist = "Zip Code";
			pass=false;
			break;
		}
		if (tempobj.name=="captchacode" && tempobj.value=='') {
			fieldlist = "Security Code";
			pass=false;
			break;
		}
	}
}

if (amount=='0') {
    alert("Please enter a valid amount");
    return false;
}  

if (acctNum != verifyacctNum) {
    alert("Account numbers do not match");
    return false;
}  

if (ccPayment==false && achPayment==false) {
    alert("Please select a payment type");
    return false;
}

if (!pass) {
    document.billPayForm.Submit.value = "Submit for Processing";
    document.billPayForm.Submit.disabled = false;
    setColor(tempobj, bgBad);
    alert("" + fieldlist + " is required.");
    tempobj.focus();
    tempobj.blur();
    return false;
}
else {
    document.billPayForm.Submit.value = "Please wait...";
    document.billPayForm.Submit.disabled = true;
    return true;
}
}

// ##############################
function checkrequiredBillpayCardSale(which) {

var pass=true;
fieldlist = "";

  var bgBad = '#dddddd';
  var bgGood = "white";
 
  var acctNum = document.billPayForm.accountNumber.value;  
  var verifyacctNum = document.billPayForm.verifyAccountNumber.value;  
  var amount = document.billPayForm.amount.value;  
  var acceptCC = document.billPayForm.acceptCC.value;  
  var enableACH = document.billPayForm.enableACH.value;  
 
//alert(acceptCC);
//alert(enableACH);
   
  //var ccPayment = 0;
  //var achPayment = 0;
    var ccPayment = true;
    var achPayment = false;
  /* 
  if (acceptCC==1) { 
alert("A");
    ccPayment = document.billPayForm.paymentTypeID[0].checked;
    if (enableACH==1) {
alert("B");
        achPayment = document.billPayForm.paymentTypeID[1].checked;
    }
  } else {
alert("C");
    if (enableACH==1) {
alert("D");
        achPayment = document.billPayForm.paymentTypeID[0].checked;
    }
  }
   */
   
if (document.images) {
	for (i=0;i<which.length;i++) {
		var tempobj=which.elements[i];
		if (tempobj.name=="accountNumber" && tempobj.value=='') {
			fieldlist = "Account Number";
			pass=false;
			break;
		}
		if (tempobj.name=="verifyAccountNumber" && tempobj.value=='') {
			fieldlist = "Verify Account Number";
			pass=false;
			break;
		}
		if (tempobj.name=="firstName" && tempobj.value=='') {
			fieldlist = "First Name";
			pass=false;
			break;
		}
		if (tempobj.name=="lastName" && tempobj.value=='') {
			fieldlist = "Last Name";
			pass=false;
			break;
		}
		if (tempobj.name=="phone1" && tempobj.value=='') {
			fieldlist = "Area Code";
			pass=false;
			break;
		}
		if (tempobj.name=="phone2" && tempobj.value=='') {
			fieldlist = "Phone";
			pass=false;
			break;
		}
		if (tempobj.name=="phone3" && tempobj.value=='') {
			fieldlist = "Phone";
			pass=false;
			break;
		}
		if (tempobj.name=="email" && tempobj.value=='') {
			fieldlist = "Email";
			pass=false;
			break;
		}
		if (tempobj.name == "email" && tempobj.value != '') {
		    if (echeck(tempobj.value)== false) {
		        return false;
		    }
		}
		if (ccPayment==true && tempobj.name=="ccTypeID" && tempobj.value=='X') {
			fieldlist = "Credit Card Type";
			pass=false;
			break;
		}
		if (ccPayment==true && tempobj.name=="ccNumber" && tempobj.value=='') {
			fieldlist = "Credit Card Number";
			pass=false;
			break;
		}
		if (ccPayment==true && tempobj.name=="ccExpMonth" && tempobj.value=='0') {
			fieldlist = "Expiration Month";
			pass=false;
			break;
		}
		if (ccPayment==true && tempobj.name=="ccExpYear" && tempobj.value=='0') {
			fieldlist = "Expiration Year";
			pass=false;
			break;
		}
		if (ccPayment==true && tempobj.name=="ccThreeDigit" && tempobj.value=='') {
			fieldlist = "3-digit Security Code";
			pass=false;
			break;
		}
		if (achPayment==true && tempobj.name=="bankRoutingNumber" && tempobj.value=='') {
			fieldlist = "Bank Routing Number";
			pass=false;
			break;
		}
		if (achPayment==true && tempobj.name=="bankAccountNumber" && tempobj.value=='') {
			fieldlist = "Bank Account Number";
			pass=false;
			break;
		}
		if (achPayment==true && tempobj.name=="baTypeID" && tempobj.value=='0') {
			fieldlist = "Bank Account Type";
			pass=false;
			break;
		}
		if (tempobj.name=="address1" && tempobj.value=='') {
			fieldlist = "Billing Address";
			pass=false;
			break;
		}
		if (tempobj.name=="city" && tempobj.value=='') {
			fieldlist = "Billing City";
			pass=false;
			break;
		}
		if (tempobj.name=="stateID" && tempobj.value=='X') {
			fieldlist = "Billing State";
			pass=false;
			break;
		}
		if (tempobj.name=="zip" && tempobj.value=='') {
			fieldlist = "Zip Code";
			pass=false;
			break;
		}
		if (tempobj.name=="captchacode" && tempobj.value=='') {
			fieldlist = "Security Code";
			pass=false;
			break;
		}
	}
}

if (amount=='0') {
    alert("Please enter a valid amount");
    document.billPayForm.Submit.value = "Submit";  
    return false;
}  

if (acctNum != verifyacctNum) {
    document.billPayForm.Submit.value = "Submit";  
    alert("Account numbers do not match");
    return false;
}  

if (ccPayment==false && achPayment==false) {
    document.billPayForm.Submit.value = "Submit";  
    alert("Please select a payment type");
    return false;
}  

if (!pass) {
    document.billPayForm.Submit.value = "Submit";  
	setColor(tempobj, bgBad);
	alert(""+fieldlist+" is required.");
	tempobj.focus();
	tempobj.blur();
	return false;
}
else {
    document.billPayForm.Submit.value = "Please wait...";
    document.billPayForm.Submit.disabled = true;
    return true;
}
}

// ##############################
function checkrequiredBillpayCheckSale(which) {

var pass=true;
fieldlist = "";

  var bgBad = '#dddddd';
  var bgGood = "white";
 
  var acctNum = document.billPayForm.accountNumber.value;  
  var verifyacctNum = document.billPayForm.verifyAccountNumber.value;  
  var amount = document.billPayForm.amount.value;  
  var acceptCC = document.billPayForm.acceptCC.value;  
  var enableACH = document.billPayForm.enableACH.value;  
 
//alert(acceptCC);
//alert(enableACH);
   
  //var ccPayment = 0;
  //var achPayment = 0;
    var ccPayment = false;
    var achPayment = true;
  /* 
  if (acceptCC==1) { 
alert("A");
    ccPayment = document.billPayForm.paymentTypeID[0].checked;
    if (enableACH==1) {
alert("B");
        achPayment = document.billPayForm.paymentTypeID[1].checked;
    }
  } else {
alert("C");
    if (enableACH==1) {
alert("D");
        achPayment = document.billPayForm.paymentTypeID[0].checked;
    }
  }
   */
   
if (document.images) {
	for (i=0;i<which.length;i++) {
		var tempobj=which.elements[i];
		if (tempobj.name=="accountNumber" && tempobj.value=='') {
			fieldlist = "Account Number";
			pass=false;
			break;
		}
		if (tempobj.name=="verifyAccountNumber" && tempobj.value=='') {
			fieldlist = "Verify Account Number";
			pass=false;
			break;
		}
		if (tempobj.name=="firstName" && tempobj.value=='') {
			fieldlist = "First Name";
			pass=false;
			break;
		}
		if (tempobj.name=="lastName" && tempobj.value=='') {
			fieldlist = "Last Name";
			pass=false;
			break;
		}
		if (tempobj.name=="phone1" && tempobj.value=='') {
			fieldlist = "Area Code";
			pass=false;
			break;
		}
		if (tempobj.name=="phone2" && tempobj.value=='') {
			fieldlist = "Phone";
			pass=false;
			break;
		}
		if (tempobj.name=="phone3" && tempobj.value=='') {
			fieldlist = "Phone";
			pass=false;
			break;
		}
		if (tempobj.name=="email" && tempobj.value=='') {
			fieldlist = "Email";
			pass=false;
			break;
		}
		if (tempobj.name == "email" && tempobj.value != '') {
		    if (echeck(tempobj.value) == false) {
		        return false;
		    }
		}
		if (ccPayment == true && tempobj.name == "ccTypeID" && tempobj.value == 'X') {
			fieldlist = "Credit Card Type";
			pass=false;
			break;
		}
		if (ccPayment==true && tempobj.name=="ccNumber" && tempobj.value=='') {
			fieldlist = "Credit Card Number";
			pass=false;
			break;
		}
		if (ccPayment==true && tempobj.name=="ccExpMonth" && tempobj.value=='0') {
			fieldlist = "Expiration Month";
			pass=false;
			break;
		}
		if (ccPayment==true && tempobj.name=="ccExpYear" && tempobj.value=='0') {
			fieldlist = "Expiration Year";
			pass=false;
			break;
		}
		if (ccPayment==true && tempobj.name=="ccThreeDigit" && tempobj.value=='') {
			fieldlist = "3-digit Security Code";
			pass=false;
			break;
		}
		if (achPayment==true && tempobj.name=="bankRoutingNumber" && tempobj.value=='') {
			fieldlist = "Bank Routing Number";
			pass=false;
			break;
		}
		if (achPayment==true && tempobj.name=="bankAccountNumber" && tempobj.value=='') {
			fieldlist = "Bank Account Number";
			pass=false;
			break;
		}
		if (achPayment==true && tempobj.name=="baTypeID" && tempobj.value=='0') {
			fieldlist = "Bank Account Type";
			pass=false;
			break;
		}
		if (tempobj.name=="address1" && tempobj.value=='') {
			fieldlist = "Billing Address";
			pass=false;
			break;
		}
		if (tempobj.name=="city" && tempobj.value=='') {
			fieldlist = "Billing City";
			pass=false;
			break;
		}
		if (tempobj.name=="stateID" && tempobj.value=='X') {
			fieldlist = "Billing State";
			pass=false;
			break;
		}
		if (tempobj.name=="zip" && tempobj.value=='') {
			fieldlist = "Zip Code";
			pass=false;
			break;
		}
		if (tempobj.name=="captchacode" && tempobj.value=='') {
			fieldlist = "Security Code";
			pass=false;
			break;
		}
	}
}

if (amount=='0') {
    document.billPayForm.Submit.value = "Submit";  
    alert("Please enter a valid amount");
    return false;
}  

if (acctNum != verifyacctNum) {
    document.billPayForm.Submit.value = "Submit";  
    alert("Account numbers do not match");
    return false;
}  

if (ccPayment==false && achPayment==false) {
    document.billPayForm.Submit.value = "Submit";  
    alert("Please select a payment type");
    return false;
}  

if (!pass) {
    document.billPayForm.Submit.value = "Submit";  
	setColor(tempobj, bgBad);
	alert(""+fieldlist+" is required.");
	tempobj.focus();
	tempobj.blur();
	return false;
}
else {
    document.billPayForm.Submit.value = "Please wait...";
    document.billPayForm.Submit.disabled = true;
    return true;
}
}

// ##############################
function calcRequestPayment(which,foo) {

    var amount = document.billPayForm.amount.value;
    var pmtPlanMonthlyAmt = document.billPayForm.pmtPlanMonthlyAmt.value;
    var pmtPlanMonths = document.billPayForm.pmtPlanMonths.value;
    var pmtPlanFinalAmt = document.billPayForm.pmtPlanFinalAmt.value;

    if (amount=='' || amount=='0') {
        document.billPayForm.pmtPlanMonths.value = '';
        document.billPayForm.pmtPlanMonthlyAmt.value = '';
    } else {
        if (foo=='1' && pmtPlanMonthlyAmt!='' && pmtPlanMonthlyAmt!='0') {             // just tabbed out of monthly payment amount, so calc months
            pmtPlanMonths = (Math.round(parseInt(amount / pmtPlanMonthlyAmt) * 100) / 100);
            // if we cant divide evenly, then add a month
            if (amount % pmtPlanMonthlyAmt==0) {
//                pmtPlanMonths = pmtPlanMonths - 1
            } else {
//                pmtPlanMonths = pmtPlanMonths + 1
            }     
            document.billPayForm.pmtPlanMonths.value = pmtPlanMonths;
            pmtPlanFinalAmt = Math.round((amount % pmtPlanMonthlyAmt) * 100) / 100;
            document.billPayForm.pmtPlanFinalAmt.value = pmtPlanFinalAmt;
            document.billPayForm.pmtPlanFinalAmtCalc.value = pmtPlanFinalAmt;
        } else {
//            if (foo=='2' && pmtPlanMonths!='' && (pmtPlanMonthlyAmt=='' || pmtPlanMonthlyAmt=='0')) {                       // just tabbed out of months, so calc monthly payment amount
            if (foo=='2' && pmtPlanMonths!='' && (pmtPlanMonthlyAmt=='' || pmtPlanMonthlyAmt=='0')) {                       // just tabbed out of months, so calc monthly payment amount
                pmtPlanMonthlyAmt = Math.round((amount / pmtPlanMonths) * 100) / 100;
                document.billPayForm.pmtPlanMonthlyAmt.value = pmtPlanMonthlyAmt;
                pmtPlanFinalAmt = Math.round((amount % pmtPlanMonthlyAmt) * 100) / 100;
                document.billPayForm.pmtPlanFinalAmt.value = pmtPlanFinalAmt;
                document.billPayForm.pmtPlanFinalAmtCalc.value = pmtPlanFinalAmt;
            } else {
//                document.billPayForm.pmtPlanMonths.value = '';
  //              document.billPayForm.pmtPlanMonthlyAmt.value = '';
            }
        }
    }   
}

// ##############################
function validateAccountNumber(which,fmt,title) {
    var accountNumber = document.billPayForm.accountNumber.value;
    var verifyAccountNumber = document.billPayForm.verifyAccountNumber.value;
//alert('old:'+fmt);
    var fmt = fmt.replace(/\%/g,"");
//alert('new:'+fmt);  
    var val1="";
    var fmt1=""; 
    var msg="";  
    var msg1="";  

    if (accountNumber=='' || verifyAccountNumber=='') {
//        msg = fmt+' is required';
    } else {  
        // see if the account numbers match
        if (accountNumber!=verifyAccountNumber) {
            msg = title+' and Verify '+title+' do not match - please re-enter';
        } else { 
            // see if the length of account number is the length of the format
            if (verifyAccountNumber.length!=fmt.length) {
                msg = title+' must be '+fmt.length+' characters';
            } else {
                // spin through the entered value and see if it matches the required format
                var err=false;
                for(i = 0; i < fmt.length; i++){
                    j = i + 1; 
                    if (j==1) {
                        msg1 = "1st";
                    } else {
                        if (j==2) {
                            msg1 = "2nd";
                        } else {
                            if (j==3) {
                                msg1 = "3rd";
                            } else {
                                msg1 = j+"th";
                            }
                        }
                    }          
//alert('i:'+i+' value:'+verifyAccountNumber.substring(i,j)+' format:'+fmt.substring(i,j));
                    val1=verifyAccountNumber.substring(i,j);
                    fmt1=fmt.substring(i,j);
                    if (fmt1=='*' || fmt1==' ') {
                    } else {
                        if (fmt1=='+') {
                            if (!IsNumeric(val1)) {         // must be numeric
                                msg = 'Invalid '+title+' format entered:\n\n'+verifyAccountNumber+'\n\n'+msg1+' character must be numeric.\n\nPlease check your '+title+' and re-enter.';
                                i = 99;
                            }
                        } else {
                            if (fmt1=='@') {
                                if (!IsAlpha(val1)) {         // must be alpha
                                    msg = 'Invalid '+title+' format entered:\n\n'+verifyAccountNumber+'\n\n'+msg1+' character must be alpha.\n\nPlease check your '+title+' and re-enter.';
                                    i = 99;
                                } 
                            } else { 
                                if (fmt1.toLowerCase()!=val1.toLowerCase()) {                       // must be literal
                                    msg = 'Invalid '+title+' format entered:\n\n'+verifyAccountNumber+'\n\n'+msg1+' character must be "'+fmt1.toLowerCase()+'".\n\nPlease check your '+title+' and re-enter.';
                                    i = 99;
                                }
                            }
                        }  
                    }
                }
            }
        }
    }
    if (msg!='') {
        alert(msg);
        document.billPayForm.verifyAccountNumber.value="";
        document.billPayForm.accountNumber.focus();
        return false;
    }  
}

// ##############################
function IsNumeric(sText) {
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;

   for (q = 0; q < sText.length && IsNumber == true; q++) 
      { 
      Char = sText.charAt(q); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
}

// ##############################
function IsAlpha(sText) {
   var ValidChars = 'abcdefghijklmnopqrstuvwxyz';
   var IsAlph=true;
   var Char1;
   var Char2;

   for (q = 0; q < sText.length && IsAlph == true; q++) 
      { 
      Char1 = sText.toLowerCase(); 
      if (ValidChars.indexOf(Char1) == -1) 
         {
         IsAlph = false;
         }
      }
   return IsAlph;
   
}

// ##############################
function checkrequiredBillpay2(which) {

    var pass=true;
    fieldlist = "";

      var bgBad = '#dddddd';
      var bgGood = "white";
     

    if (document.images) {
	    for (i=0;i<which.length;i++) {
		    var tempobj=which.elements[i];
	    }
    }


    if (!pass) {
        setColor(tempobj, bgBad);
        alert("" + fieldlist + " is required.");
        tempobj.focus();
        tempobj.blur();
        return false;
    }
    else {
        document.billPayForm.Submit.value = "Please wait...";
        document.billPayForm.Submit.disabled = true;
        return true;
    }
}

// ##############################
function setColor(el, bg) {
  if (el.style) el.style.backgroundColor = bg;
}

// ##############################
function deleteImage(which) {

	var agree=confirm("Are you sure you want to delete this image?\n\nThis action cannot be undone!");
	if (agree)
		return true ;
	else
		return false ;
}


// ##############################
function deleteCustomField(which) {

	var agree=confirm("Are you sure you want to delete this user defined field?\n\nThis action cannot be undone!");
	if (agree)
		return true ;
	else
		return false ;
}


// ##############################
function deleteUser(which) {

    var agree = confirm("Are you sure you want to delete this user?\n\nThis action cannot be undone!");
    if (agree)
        return true;
    else
        return false;
}

// ##############################
function deleteReceipt(which) {

    var agree = confirm("Are you sure you want to delete this receipt?\n\nThis action cannot be undone!");
    if (agree)
        return true;
    else
        return false;
}


// ##############################
function voidTrans(which) {

	var agree=confirm("Are you sure you want to void this transaction?\n\nThis action cannot be undone!");
	if (agree)
		return true ;
	else
		return false ;
}


// ##############################
function validate(field) {
    var valid = "0123456789"
    var ok = "yes";
    var temp;
    for (var i = 0; i < field.value.length; i++) {
        temp = "" + field.value.substring(i, i + 1);
        if (valid.indexOf(temp) == "-1") ok = "no";
    }
    if (ok == "no") {
        alert("Invalid entry!  Only numbers are accepted!");
        field.value = "";
        field.focus();
        field.select();
    }
}

// ##############################
function validateCCMonth(field) {
    var valid = "0123456789"
    var ok = "yes";
    var temp;
    for (var i = 0; i < field.value.length; i++) {
        temp = "" + field.value.substring(i, i + 1);
        if (valid.indexOf(temp) == "-1") ok = "no";
    }
    if (ok == "no") {
        alert("Invalid entry!  Only numbers are accepted!");
        field.value = "";
        field.focus();
        field.select();
    } else {
        if (field.value.length > 0) {
            // check to make sure the number is between 1 and 12
            if (field.value < 1 || field.value > 12) {
                alert("Invalid entry!  Expiration Month must be between 01 and 12!");
                field.value = "";
                field.focus();
                field.select();
            }
        }
    }
}

// ##############################
function validate2(field) {
var valid = "0123456789."
var ok = "yes";
var temp;
for (var i=0; i<field.value.length; i++) {
temp = "" + field.value.substring(i, i+1);
if (valid.indexOf(temp) == "-1") ok = "no";
}
if (ok == "no") {
alert("Invalid entry!  Only numbers and decimal are accepted!");
field.value="";
field.focus();
field.select();
   }
}

// ###################################
function check_date(field){
var checkstr = "0123456789";
var DateField = field;
var Datevalue = "";
var DateTemp = "";
var seperator = ".";
var day;
var month;
var year;
var leap = 0;
var err = 0;
var i;
   err = 0;
   DateValue = DateField.value;
   /* Delete all chars except 0..9 */
   for (i = 0; i < DateValue.length; i++) {
	  if (checkstr.indexOf(DateValue.substr(i,1)) >= 0) {
	     DateTemp = DateTemp + DateValue.substr(i,1);
	  }
   }
   DateValue = DateTemp;
   /* Always change date to 8 digits - string*/
   /* if year is entered as 2-digit / always assume 20xx */
   if (DateValue.length == 6) {
      DateValue = DateValue.substr(0,4) + '20' + DateValue.substr(4,2); }
   if (DateValue.length != 8) {
      err = 19;}
   /* year is wrong if year = 0000 */
   year = DateValue.substr(4,4);
   if (year == 0) {
      err = 20;
   }
   /* Validation of month*/
   month = DateValue.substr(0,2);
   if ((month < 1) || (month > 12)) {
      err = 21;
   }
   /* Validation of day*/
   day = DateValue.substr(2,2);
   if (day < 1) {
     err = 22;
   }
   /* Validation leap-year / february / day */
   if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0)) {
      leap = 1;
   }
   if ((month == 2) && (leap == 1) && (day > 29)) {
      err = 23;
   }
   if ((month == 2) && (leap != 1) && (day > 28)) {
      err = 24;
   }
   /* Validation of other months */
   if ((day > 31) && ((month == "01") || (month == "03") || (month == "05") || (month == "07") || (month == "08") || (month == "10") || (month == "12"))) {
      err = 25;
   }
   if ((day > 30) && ((month == "04") || (month == "06") || (month == "09") || (month == "11"))) {
      err = 26;
   }
   /* if 00 ist entered, no error, deleting the entry */
   if ((day == 0) && (month == 0) && (year == 00)) {
      err = 0; day = ""; month = ""; year = ""; seperator = "";
   }
   /* if no error, write the completed date to Input-Field (e.g. 13.12.2001) */
   if (err == 0) {
      DateField.value = month + seperator + day + seperator + year;
   }
   /* Error-message if err != 0 */
   else {
      alert("Date is incorrect!\n\nMust use format: mm/dd/yyyy");
      DateField.select();
	  DateField.focus();
   }
}

// ###################################
function check_date2(field){
var checkstr = "0123456789";
var DateField = field;
var Datevalue = "";
var DateTemp = "";
var seperator = "/";
var day;
var month;
var year;
var leap = 0;
var err = 0;
var i;
   err = 0;
   DateValue = DateField.value;
   /* Delete all chars except 0..9 */
   for (i = 0; i < DateValue.length; i++) {
	  if (checkstr.indexOf(DateValue.substr(i,1)) >= 0) {
	     DateTemp = DateTemp + DateValue.substr(i,1);
	  }
   }
   DateValue = DateTemp;
   /* Always change date to 8 digits - string*/
   /* if year is entered as 2-digit / always assume 20xx */
   if (DateValue.length == 6) {
      DateValue = DateValue.substr(0,4) + '20' + DateValue.substr(4,2); }
   if (DateValue.length != 8) {
      err = 19;}
   /* year is wrong if year = 0000 */
   year = DateValue.substr(4,4);
   if (year == 0) {
      err = 20;
   }
   /* Validation of month*/
   month = DateValue.substr(0,2);
   if ((month < 1) || (month > 12)) {
      err = 21;
   }
   /* Validation of day*/
   day = DateValue.substr(2,2);
   if (day < 1) {
     err = 22;
   }
   /* Validation leap-year / february / day */
   if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0)) {
      leap = 1;
   }
   if ((month == 2) && (leap == 1) && (day > 29)) {
      err = 23;
   }
   if ((month == 2) && (leap != 1) && (day > 28)) {
      err = 24;
   }
   /* Validation of other months */
   if ((day > 31) && ((month == "01") || (month == "03") || (month == "05") || (month == "07") || (month == "08") || (month == "10") || (month == "12"))) {
      err = 25;
   }
   if ((day > 30) && ((month == "04") || (month == "06") || (month == "09") || (month == "11"))) {
      err = 26;
   }
   /* if 00 ist entered, no error, deleting the entry */
   if ((day == 0) && (month == 0) && (year == 00)) {
      err = 0; day = ""; month = ""; year = ""; seperator = "";
   }
   /* if no error, write the completed date to Input-Field (e.g. 13.12.2001) */
   if (err == 0) {
      DateField.value = month + seperator + day + seperator + year;
   }
   /* Error-message if err != 0 */
   else {
      alert("Date is incorrect!\n\nMust use format: mm/dd/yyyy");
      err = 0; day = ""; month = ""; year = ""; seperator = "";
      DateField.value = month + seperator + day + seperator + year;
      DateField.select();
	  DateField.focus();
   }
}

// ###################################
 function check_time(field) { 
    var TimeField = field;
 
    // regular expression to match required time format 
    re = /^\d{1,2}:\d{2}([ap]m)?$/; 
    if (TimeField.value != '' && !TimeField.value.match(re)) { 
        alert("Invalid time format: " + TimeField.value+"\n\nTimes should be entered using 12:34am format"); 
        TimeField.value=""; 
        TimeField.focus(); 
        return false; 
    }
}  
 

// ##############################
function gtpage(url,frname,height,width) {

        var p1 = 'toolbar=no,'
        var p2 = 'location=no,'
        var p3 = 'directories=no,'
        var p4 = 'status=no,'
        var p5 = 'menubar=no,'
        var p6 = 'resizable=no,'
        var p7 = 'scrollbars=no,'
        var p8=  'copyhistory=no,'
        var p9 = 'width='+width+',';
        var p10 = 'height='+height
        var props = p1+p2+p3+p4+p5+p6+p7+p8+p9+p10;

        themainwindow = window.open(url,frname,props);
        themainwindow.focus();

     }


// ##############################
function gtpage2(url,frname,height,width) {

        var p1 = 'toolbar=no,'
        var p2 = 'location=no,'
        var p3 = 'directories=no,'
        var p4 = 'status=no,'
        var p5 = 'menubar=no,'
        var p6 = 'resizable=yes,'
        var p7 = 'scrollbars=yes,'
        var p8=  'copyhistory=no,'
        var p9 = 'width='+width+',';
        var p10 = 'height='+height
        var props = p1+p2+p3+p4+p5+p6+p7+p8+p9+p10;

        themainwindow = window.open(url,frname,props);
        themainwindow.focus();

     }

// ##############################
function printpage() {
	window.print();
}

// ##############################
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

// ##############################
var type = "IE";	//Variable used to hold the browser name

BrowserSniffer();

// ##############################
//detects the capabilities of the browser
function BrowserSniffer() {
	if (navigator.userAgent.indexOf("Opera")!=-1 && document.getElementById) type="OP";		//Opera
	else if (document.all) type="IE";														//Internet Explorer e.g. IE4 upwards
	else if (document.layers) type="NN";													//Netscape Communicator 4
	else if (!document.all && document.getElementById) type="MO";							//Mozila e.g. Netscape 6 upwards
	else type = "IE";		//I assume it will not get here
}

// ##############################
//Displays the generic browser type
function whatBrows() {
	window.alert("Browser is : " + type);
}

// ##############################
//Puts the contents of str into the layer id
//id is the name of the layer
//str is the required content
//Works with all browsers except Opera
function ChangeContent(id, str) {
	if (type=="IE") {
		document.all[id].innerHTML = str;
	}
	if (type=="NN") { 
		document.layers[id].document.open();
		document.layers[id].document.write(str);
		document.layers[id].document.close();
	}
	if (type=="MO" || type=="OP") {
		document.getElementById(id).innerHTML = str;
	}
}

// ##############################
//Change the color of the layer background
//id is the name of the layer
//color is the required color
//Works with all browsers except NN4
function ChangeLayerBgColor(id, color){
	if (type=="IE") document.all[id].style.backgroundColor=color;
	if (type=="NN") document.layer['id'].bgColor=color;
	if (type=="MO" || type=="OP") document.getElementById(id).style.backgroundColor=color;
}

// ##############################
//Show and hide a layer
//id is the name of the layer
//action is either hidden or visible
//Seems to work with all versions NN4 plus other browsers
function ShowLayer(id, action){
	if (type=="IE") eval("document.all." + id + ".style.visibility='" + action + "'");
	if (type=="NN") eval("document." + id + ".visibility='" + action + "'");
	if (type=="MO" || type=="OP") eval("document.getElementById('" + id + "').style.visibility='" + action + "'");
}
// ##############################
function RefreshImage(valImageId) {
	var objImage = document.images[valImageId];
	if (objImage == undefined) {
		return;
	}
	var now = new Date();
	objImage.src = objImage.src.split('?')[0] + '?x=' + now.toUTCString();
}
