// Clay County custom JavaScript
// Lutz Mueller, 4/9/2009
// call in MainHeader.ascx

function clearCCInfo1() {
	// for actual entry page (credit card)
	x = document.getElementById("mCreditAccountInfo_mCreditCardNumber");
	if(x!=null) {
		x.value="";
		document.getElementById("mCreditAccountInfo_mCardExpirationDate").value="";
		document.getElementById("mCreditAccountInfo_mCardVerificationCode").value="";
	}
	// for actual entry page (eCheck)
	x = document.getElementById("mCheckingAccountInfo_mCheckingAccountNumber");
	if(x!=null) {
		x.value="";
		document.getElementById("mCheckingAccountInfo_mVerifyCheckingAccountNumber").value="";
		document.getElementById("mCheckingAccountInfo_mCountyAssignedPIN").value="";
	}
	

	// confirmation pages for eCheck and for credit card are very similar. 
	// unfortunately, the table (mPaymentInfoConfirmation_mGrid_RealDataGrid) is not organized the same way.
	// the following lines are criteria for the determination of which page we're on.
	checkoutECheck = document.getElementById("mShoppingCart_mFeeEcheck") && !document.getElementById("mShoppingCart_mFeeCredit");
	checkoutCredit = document.getElementById("mShoppingCart_mFeeCredit") && !document.getElementById("mShoppingCart_mFeeECheck");
	
	if(checkoutECheck) {
		y = document.getElementById("mPaymentInfoConfirmation_mGrid_RealDataGrid");
		if(y!=null) {
			if(y.children) {
				z = y.children[0];
				cc = z.rows[4].cells[1];
			} else {
				y = y.childNodes[0];
				cc = y.rows[4].cells[1];
			}
			s = "";
			for(i=0;i<cc.innerHTML.length-4;i++) {
				s=s+"*";
			}
			cc.innerHTML=s+cc.innerHTML.substr(cc.innerHTML.length-4,4);
		}
	}
	if(checkoutCredit) {
		// for confirmation page (credit card)
		y = document.getElementById("mPaymentInfoConfirmation_mGrid_RealDataGrid");
		//y = document.getElementById("GridField");
		if(y!=null) {
			if(y.children) {
				// IE DOM
				z = y.children[0];
				cc = z.children[0].rows[4].cells[1];
				sc = z.children[0].rows[5].cells[1];
				ed = z.children[0].rows[6].cells[1];
			} else {
				// firefox DOM
				y = y.getElementsByTagName("table");
				cc = y[0].rows[4].cells[1];
				sc = y[0].rows[5].cells[1];
				ed = y[0].rows[6].cells[1];
			}
			s = "";
			for(i=0;i<cc.innerHTML.length-4;i++) {
				s=s+"*";
			}
			cc.innerHTML=s+cc.innerHTML.substr(cc.innerHTML.length-4,4);
			sc.innerHTML="&nbsp;";
			ed.innerHTML="&nbsp;";
		}
	}
}

function newOnLoad() {
	if(origOnLoad) {
		eval(origOnLoad);
	}
	setTimeout("clearCCInfo1();",300);
}

var origOnLoad = document.onload;
document.onLoad=newOnLoad();