function popupwindow(page,width,height)
 {
 OpenWin = this.open(page, "CtrlWindow","toolbar=No,menubar=No,location=No,scrollbars=No,resizable=No,status=No,width="+width+",height="+height+",left=150,top=150,");
 }

var validInt = '0123456789';
var validNums = '0123456789-.';
var validLetters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
var validNone = '';
var checkflagaccepted = "false";
var checkflagdeclined = "false";

function validateKeyPress(e, validSet)
{
var key;
var keychar;

if(window.event || !e.which) // IE
key = e.keyCode; // IE
else if(e) 
key = e.which; // Netscape
else
return true; // no validation

keychar = String.fromCharCode(key);
validSet += String.fromCharCode(8);

if (validSet.indexOf(keychar) < 0)
return false;

return true; 
}


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")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail Address")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail Address")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail Address")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail Address")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail Address")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail Address")
		    return false
		 }

 		 return true					
	}

function ValidateForm(){
	var emailID=document.form.email
	if (echeck(emailID.value)==false){
		emailID.focus()
		return false
	}
	return true
 }

function verifyPayment(convfee){
if(document.form.email.value != ""){
  return ValidateForm();
}
if(document.form.x_amount.value == ""){
  alert("Missing Amount.");
  document.form.x_amount.style.background = "#FF0000";
  document.form.x_amount.focus();
  return false;
}
if((document.form.x_amount.value == "0.00")||(document.form.x_amount.value == "0")){
  alert("Payments cannot be paid with a Zero Dollar \($0.00\) amount. Either this account has been balanced, handled offline, or the amount is invalid. Please contact us at 800-387-2270 if you feel this is in error.");
  return false;
}
if(document.form.balance.value != document.form.x_amount.value){
  alert("Amount being submitted must equal current account balance.");
  document.form.x_amount.style.background = "#FF0000";
  document.form.x_amount.focus();
  return false;
}
if(document.form.creditcardno.value == ""){
  alert("Missing Credit Card Number.");
  document.form.creditcardno.style.background = "#FF0000";
  document.form.creditcardno.focus();
  return false;
}
if(document.form.creditcardcode.value == ""){
  alert("Missing Credit Card Security Code.");
  document.form.creditcardcode.style.background = "#FF0000";
  document.form.creditcardcode.focus();
  return false;
}
if(!document.form.agree.checked){
  alert("For the convenience of paying online, there is a fee of $" + convfee + ". Otherwise contact us at 800-387-2270 Option 1 to make other payment type arrangements.");
  document.form.agree.style.background = "#FF0000";
  document.form.agree.focus();
  return false;
}
if(document.form.payerfname.value == ""){
  alert("Missing Payer's First Name.");
  document.form.payerfname.style.background = "#FF0000";
  document.form.payerfname.focus();
  return false;
}
if(document.form.payerlname.value == ""){
  alert("Missing Payer's Last Name.");
  document.form.payerlname.style.background = "#FF0000";
  document.form.payerlname.focus();
  return false;
}
if(document.form.payeradd.value == ""){
  alert("Missing Payer's Address.");
  document.form.payeradd.style.background = "#FF0000";
  document.form.payeradd.focus();
  return false;
}
if(document.form.payercity.value == ""){
  alert("Missing Payer's City.");
  document.form.payercity.style.background = "#FF0000";
  document.form.payercity.focus();
  return false;
}
if(document.form.payerzip.value == ""){
  alert("Missing Payer's Zip Code.");
  document.form.payerzip.style.background = "#FF0000";
  document.form.payerzip.focus();
  return false;
}
}

function verifyLogin(){
if(document.form.custno.value == ""){
  alert("Missing Account Number.");
  document.form.custno.style.background = "#FF0000";
  document.form.custno.focus();
  return false;
}
if(document.form.zip.value == ""){
  alert("Missing Zip Code.");
  document.form.zip.style.background = "#FF0000";
  document.form.zip.focus();
  return false;
}
}

function initdt(mf) {
var t = new Date;
mf.exp_month.value = t.getMonth() + 1;
mf.exp_year.value = t.getFullYear();
}
