function popUpImage(sImgPath, iImgW, iImgH) {
           var sHeader = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n<html>\n<head>\n<title>Credit Card Verification Number</title>\n</head>\n<body>\n\n";

           var sFooter = "</body>\n</html>";
           var oWin = window.open("about:blank", null, "width=" + (iImgW+15) + ",height=" + (iImgH+40) + ",left=50,top=1,directories=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,toolbar=0");
           oWin.document.open();
           oWin.document.write(sHeader);
           oWin.document.write("<div align=center><IMG SRC=\"" + sImgPath + "\" width=" + iImgW + " height=" + iImgH + " border=0><br>\n");
           oWin.document.write("");
           oWin.document.write("<a href=\"javascript:window.close();\" style=\"font-size:8pt;font-weight:normal;font-family:arial;color:blue\">close window</a></div>");
           oWin.document.write(sFooter);
           oWin.document.close();
}
 

function isCreditCard(theCardNumber) {
 //
// This function validates a credit card entry.
// If the checksum is ok, the function returns true.
//
   var ccNum;
   var odd = 1;
   var even = 2;
   var calcCard = 0;
   var calcs = 0;
   var ccNum2 = "";
   var aChar = '';
   var cc;
   var r; 
	// if (ccNum.substr(6,1) == "*")
		// return true; 
	 
   ccNum = theCardNumber; 
   
	//if (ccNum.charAt(0) == '*') return true; 
	 // check visa
 //if ((document.docForm.BillccType[0].checked) && !(ccNum.substr(0,1) == "4")) {

		//return false;
	//} 
	//check master card
//	if ((document.docForm.BillccType[1].checked) && !(ccNum.substr(0,1) == "5")) {
	//	return false;
	//} 
	
		
	/* // check american express, don't go thru algorithm if so
if ((document.docForm.BillccType[2].checked) && !(ccNum.substr(0,1) == "3")) {
		alert("shouldnot be here")
	  return false;
	} 
*/
	//if (document.docForm.BillccType[2].checked) {
		//alert("here");
		//return true;
	//}
	//else { //do the rest
	
	for(var i = 0; i != ccNum.length; i++) {
      aChar = ccNum.substring(i,i+1);
      if(aChar == '-') {
         continue;
      }
      ccNum2 = ccNum2 + aChar;
   }

   cc = parseInt(ccNum2);
   
   if(cc == 0) {
      return false;
   }

   r = ccNum.length / 2;

   if(ccNum.length - (parseInt(r)*2) == 0) {
      odd = 2;
      even = 1;
   }

   for(var x = ccNum.length - 1; x > 0; x--) {
      r = x / 2;
      if(r < 1) {
         r++;
      }

      if(x - (parseInt(r) * 2) != 0) {
         calcs = (parseInt(ccNum.charAt(x - 1))) * odd;
      }
      else {
         calcs = (parseInt(ccNum.charAt(x - 1))) * even;
      }
      if(calcs >= 10) {
         calcs = calcs - 10 + 1;
      }
      calcCard = calcCard + calcs;
   }

   calcs = 10 - (calcCard % 10);

   if(calcs == 10) {
      calcs = 0;
   }

   if(calcs == (parseInt(ccNum.charAt(ccNum.length - 1)))) {
      return true;
   }
   else {
      return false;
   }
//}
}

function getTheMonth() {
	var today = new Date();
	var MonM = today.getMonth();
	MonM += 01;
	return MonM;
}

function getTheYear() {
	var today = new Date();
	var YeaR = today.getUTCFullYear();
	var Year1 = " ";
	Year1 = YeaR.toString();
	Year1 = Year1.substr(2,2);
	return Year1;
}

function validExpDate(PMonth, PYear) {
	var todayMonth1 = getTheMonth();
	var todayYear1 = getTheYear();
	var todayMonth = todayMonth1.toString();
	var todayYear = todayYear1.toString();
	if (todayMonth.length == 1) {
		todayMonth = "0" + todayMonth;
	}

	if ((PYear < todayYear) || (PYear == todayYear && PMonth < todayMonth)) {
		return false;
	}
	else {
		return true;
	}	
} 
function submitIt(theForm) { 
	if (!(isCreditCard(theForm.BillccNumber.value))) {
	   alert("Invalid credit card number\rPlease re-enter the card number\ror choose correct Visa or Master Card");
		theForm.BillccNumber.focus();
		theForm.BillccNumber.select();
		return false;
	}  
	if (!(validExpDate(theForm.BillccMonth[theForm.BillccMonth.selectedIndex].value, theForm.BillccYr[theForm.BillccYr.selectedIndex].value))) {
		alert("The card expiration date is invalid, or  this credit card has expired");
		theForm.BillccNumber.focus();
		theForm.BillccNumber.select();
		return false;
	} 
	if (theForm.CVVValue.value.length < 3) {
	   alert("Please enter the 3-4 digit Credit Card Verification Number located on the back of your card");
		theForm.CVVValue.focus();
		theForm.CVVValue.select();
		return false;
	}  
}
