function fixHeightForPattern(element, borderImgWidth) {
	$(element).setStyle('height', ((Math.ceil(($(element).getStyle('height').toInt())/borderImgWidth))*borderImgWidth));
}
function fixWidthForPattern(element, borderImgHeight) {
	$(element).setStyle('width', ((Math.ceil(($(element).getStyle('width').toInt())/borderImgHeight))*borderImgHeight));
}
function ccValidator(sender, args)
{
  var ccString = args.Value.replace("-", "");
  args.IsValid = luhn_check(ccString);
}
function luhn_check(s)
{
  var sum = 0;
  var alt = false;
  var numvar = 0;
  for(var i = s.length - 1; i >= 0; i--)
  {
   numvar = parseInt(s.charAt(i));
   if(alt)
   {
     numvar *= 2;
     if(numvar > 9)
     {
       numvar -= 9;
     }
   }
   sum += numvar;
   alt = !alt;
  }
  if (sum != 0 && sum % 10 == 0)
    return true;
  else
    return false;
}
function ccExpValidator(sender, args)
{
  var ccExpString = args.Value;
  args.IsValid = isCCExpDateValid(ccExpString);
}
function isCCExpDateValid(s){
  var today = new Date();
  var testDate = new Date((today.getMonth()+1) + "/1/" + today.getFullYear());
  
  var inputArray = s.split("/");
  if(inputArray[1].length == 2)
  {
    inputArray[1] = "20" + inputArray[1];
  }
  var inputDate = new Date(inputArray[0] + "/1/" + inputArray[1]);
  
  return (inputDate >= testDate);
}