function begin()
{
var t=0;
for (var i = 0; i < document.PaymentForm.CardCu.length; i++)
if (document.PaymentForm.CardCu.options[i].value=="CMR")
t=i;
document.PaymentForm.CardCu.options[t].selected=true;
}
function ValidCard(CreditCard){
// Valid Input Syntax:
// Type1: **************** (16 columns)
// Type2: **** **** **** **** (19)
// Type3: ****-****-****-**** (19)
// Input is a credit card number in the form of a string.
// Validates numbers which use a "double-add-double MOD 10"
// check digit Output is False if not valid, True if valid.
var Validity = false; // Assume invalid card
var LN = CreditCard.length; // Get input value length
if ((16 <= LN) && (LN <= 19)){
LN --;
CheckSum = 0; // start with 0 checksum
Dbl = false; // Start with a non-doubling
//------------------------------------------------------------
// Beginning backward loop through string
//-------------------------------------------------------------
for (Idx = LN; Idx >= 0; Idx --){
Digit = CreditCard.substr(Idx, 1); // Isolate character
if (("0" <= Digit && Digit <= "9")
|| Digit == " " || Digit == "-"){
if (Digit != " " && Digit != "-"){ // Skip connector
Digit -= "0"; // Remove ASCII bias
if (Dbl){ // If in the "double-add" phase
Digit += Digit; // Then double first
if (Digit > 9){ // Cast nines
Digit -= 9;
}
}
Dbl = !Dbl; // Flip doubling flag
CheckSum += Digit; // Add to running sum
if (CheckSum > 9){ // Cast tens
CheckSum -= 10; // Same as MOD 10, but faster
}
}
} else {
return(Validity); // Invalid
}
}
Validity = (CheckSum == 0) ? true : false; // Must sum to 0
}
return(Validity);
}
function check(){
if (document.PaymentForm.cardtype.value=="NONE") alert("You must select a card type"); else
// if (document.PaymentForm.expire2.value=="02" && (document.details.expire1.value=="01" ||
// document.PaymentForm.expire1.value=="02")) alert("You must enter a valid expiry date"); else
if (document.PaymentForm.cardname.value=="") alert("You must enter a name"); else
if (document.PaymentForm.SecurityCode.value=="") alert("You must enter the Security Code"); else
if (document.PaymentForm.cardno.value=="") alert("You must enter a card number"); else
if (!ValidCard(document.PaymentForm.cardno.value)) alert("Invalid card number"); else
document.PaymentForm.submit();
}
function ExpandTxt(In) {
if (In == 1) {
document.getElementById('txt1').style.display = '';
document.getElementById('txt2').style.display = 'none';
document.getElementById('txt3').style.display = 'none';
}
if (In == 2) {
document.getElementById('txt1').style.display = 'none';
document.getElementById('txt2').style.display = '';
document.getElementById('txt3').style.display = 'none';
}
if (In == 3) {
document.getElementById('txt1').style.display = 'none';
document.getElementById('txt2').style.display = 'none';
document.getElementById('txt3').style.display = '';
}
}