
function isBlank(str) {
 if ( str.value == "" || str.value == null ) {
   return false;
 }
 return true;
}

function checkEmail(jk) {
 if ( jk.value.indexOf("@") + "" != "-1" &&
      jk.value.indexOf(".")+ "" != "-1" &&
      jk.value != "" ) {
   return true;
 }
  else {
   return false;
  }
}

function checkAmt(amt) {
var valid = "0123456789.";
var ok = "yes";
var temp;
var decimalpos=-1;
 if ( amt.value=="") {
    return false;
 }
for (var i=0; i<amt.value.length; i++) {
temp = "" + amt.value.substring(i, i+1);
if (valid.indexOf(temp) == "-1") ok = "no";
if (temp==".") {
     if (decimalpos == -1) {
             decimalpos=i;
             if ((decimalpos != (amt.value.length-2)) && (decimalpos != (amt.value.length-3))) ok = "no";
      }
     else ok = "no";
}
}
if (ok=="no"){
    return false;
 }
else 
    return true;
}
function checkForm(creditcard) {
 if (isBlank(creditcard.name)==false) {
  alert("Please enter your Name !");
  creditcard.name.focus();
  return false;
 }
 if ( creditcard.amt.value=="") {
    alert("Sorry! You forgot to enter the amount you would like to donate!");
	creditcard.amt.focus();
    return false;
 }
if (checkAmt(creditcard.amt)=="false"){
    alert("Please enter a valid amount");
    creditcard.amt.focus();
    return false;
 }
if ((creditcard.amt.value < 500) || (creditcard.amt.value > 50000))
{alert("Kindly consider writing a cheque for this amount. Thank You");
 creditcard.amt.focus();
 return false;
}
 if (isBlank(creditcard.address)==false) {
  alert("Please enter your street address ?");
  creditcard.address.focus();
  return false;
 }
 if (isBlank(creditcard.country)==false) {
  alert("Please enter the Country");
  creditcard.country.focus();
  return false;
 }
 if (isBlank(creditcard.phone)==false) {
  alert("Could you please enter your contact Phone Number?");
  creditcard.phone.focus();
  return false;
 }
 if (isBlank(creditcard.email)==false) {
  alert("May we ask you for your Email Address ?");
  creditcard.email.focus();
  return false;
 }
 if ( checkEmail(creditcard.email)==false) {
   alert("Your email address does not look right...Can you please check and re-enter ?");
   creditcard.email.focus();
   return false;
 }
 nowDate = new Date();
milliseconds = nowDate.getTime();
creditcard.Order_Id.value = "SSSMM"+milliseconds;
creditcard.Amount.value = creditcard.amt.value;
creditcard.Merchant_Id.value = "M_kratma_1619";
creditcard.billing_cust_name.value = creditcard.name.value;
creditcard.billing_cust_address.value = creditcard.address.value;
creditcard.billing_cust_country.value = creditcard.country.value;
creditcard.billing_cust_tel.value = creditcard.phone.value;
creditcard.billing_cust_email.value = creditcard.email.value;
creditcard.delivery_cust_name.value = creditcard.name.value;
creditcard.delivery_cust_address.value = creditcard.address.value;
creditcard.delivery_cust_tel.value = creditcard.phone.value;
 return true;
}

function ccycheck(b14,creditcard) {
 if ( creditcard.amt.value=="") {
    alert("Sorry! You forgot to enter the amount you would like to donate!");
	creditcard.amt.focus();
    return false;
 }
if (checkAmt(creditcard.amt) == false){
    alert("Please enter a valid amount");
    creditcard.amt.focus();
    return false;
 }
b14.Amount.value=creditcard.amt.value;
return true;
}
