msg_EmailEQ = "Please insert the same email address again.";
msg_CCExpiry_m = "Please insert the expiry month of your credit card";
msg_CCExpiry_y = "Please insert the expiry year of your credit card";


//msg_isName = "Field \"Name\" can contain letters and spaces only";
jQuery.validator.addMethod("isNotZero", function(value, element) { 
if ($("#cc").attr("checked") == false) { return true; } else {
	var valore = parseInt(value,10);
	if (value == 0) { return false; } else { return true; }
}
});

jQuery.validator.addMethod("isExpiryDate", function(value, element){
	if ($("#cc").attr("checked") == false) {
		return true;
	}
	else {
		if (value != 0 && $("#cc_expiry_year option:selected").val() != 0) {
			// controllo che non sia ancora scaduta
			var o = new Date();
			tM = o.getMonth() + 1;
			tY = o.getFullYear();
			if ($("#cc_expiry_year option:selected").val() < tY) {
				return false;
			}
			else 
				if ($("#cc_expiry_year option:selected").val() == tY) {
					if ($("#cc_expiry_month option:selected").val() < tM) {
						alert($("#cc_expiry_month option:selected").val());
						return false;
					}
					else {
						return true;
					}
				}
				else {
					return true;
				}
			//return true;
		}
		else {
			$("#cc_expiry_year").addClass("error");
			return false;
		}
	}
}, "Your credit card has expired.");




jQuery.validator.addMethod("isName", function(value, element) { 
var i=new RegExp("^[a-zA-Z ]+$");
return i.test(value);
}, "Field \"Name\" can contain letters and spaces only");

jQuery.validator.addMethod("isSurname", function(value, element) { 
var i=new RegExp("^[a-zA-Z ']+$");
return i.test(value);
}, "Field \"Surname\" can contain letters, spaces and ' only");

jQuery.validator.addMethod("isPhone", function(value, element) { 
	if (value == '') return true;
	var valore = parseInt(value,10);
	var i = new RegExp("^[0-9]+$");
	if(valore == 0) return false;
	return i.test(value);
}, "The telephone number is not correct. Please insert numbers only.");

jQuery.validator.addMethod("isCVC", function(value, element) { 
if ($("#cc").attr("checked") == false) {
	return true;
}
else {
	var i = new RegExp("^[0-9]{3,4}$");
	return i.test(value);
}
}, "CVC code is invalid.");