// ##############################
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=="loginName" && tempobj.value=='') {
			fieldlist = "Login Name";
			pass=false;
			break;
		}
		if (tempobj.name=="password" && tempobj.value=='') {
			fieldlist = "Password";
			pass=false;
			break;
		}
	}
}

if (!pass) {
	setColor(tempobj, bgBad);
	alert(""+fieldlist+" is required.");
	tempobj.focus();
	tempobj.blur();
	return false;
}
else
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);
	alert(""+fieldlist+" is required.");
	tempobj.focus();
	tempobj.blur();
	return false;
}
else
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;  
 
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=="ccTypeID" && tempobj.value=='X') {
			fieldlist = "Credit Card Type";
			pass=false;
			break;
		}
		if (tempobj.name=="ccNumber" && tempobj.value=='') {
			fieldlist = "Credit Card Number";
			pass=false;
			break;
		}
		if (tempobj.name=="ccExpMonth" && tempobj.value=='X') {
			fieldlist = "Expiration Month";
			pass=false;
			break;
		}
		if (tempobj.name=="ccExpYear" && tempobj.value=='X') {
			fieldlist = "Expiration Year";
			pass=false;
			break;
		}
		if (tempobj.name=="ccThreeDigit" && tempobj.value=='') {
			fieldlist = "3-digit Security Code";
			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 (amount=='0') {
    alert("Please enter a valid amount");
    return false;
}  

if (acctNum != verifyacctNum) {
    alert("Account numbers do not match");
    return false;
}  

if (!pass) {
	setColor(tempobj, bgBad);
	alert(""+fieldlist+" is required.");
	tempobj.focus();
	tempobj.blur();
	return false;
}
else
return true;
}

// ##############################
function setColor(el, bg) {
  if (el.style) el.style.backgroundColor = bg;
}

// ##############################
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.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.focus();
field.select();
   }
}

// ##############################
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]+"'");
}
