/*jQuery.validator.addMethod(
	"selectNone",
	function(value, element) {
		if (element.value == "none")
		{
			return false;
		}
		else return true;
	},
	title
	);
*/
jQuery.validator.addMethod(
	"postcode",
	// checks if delivery address in uk and if is checks for postcode formating
	function(value) {

		var this_delivery_country = $('#country').val();

		if(this_delivery_country == "GB"){
			return /\b([A-Pa-pR-Ur-uWYZwyz][A-Ha-hK-Yk-y0-9][A-Ha-hJKSTUWjkstuw0-9]?[ABEHMNPRVWXYabehmnprvwxy0-9]?)*[0-9][ABabD-Hd-hJLjlN-Un-uW-Zw-z]{2}\b/.test(value);
		}
		else{
			return true;
		}
	},
	"Postcode format incorrect"
	);


jQuery.validator.addMethod(
	"selectDatesEndMonth",
	// checks if start year same and start month > end month
	function(value){

		var this_end_year = 2000+parseInt(value);
		var this_start_month = parseInt($('#cc_start_month').val());
		var this_end_month = $('#cc_end_month').val();
        this_end_month = this_end_month.replace(/^[ 0]+/,'');
		var this_start_year = 2000+parseInt($('#cc_start_year').val());

		if((this_start_year == this_end_year)&&(this_start_month >= this_end_month)){
			return false;
		}
		else{
			return true;
		}
        return false;
	},
	"Start date is greater then expire date"
	);

jQuery.validator.addMethod(
	"selectDatesEndExpired",
	// checks if card has expired
	function(value){

        var date = new Date();
        var THIS_MONTH = date.getMonth();

		var this_end_year = 2000+parseInt(value);
		var THIS_YEAR = (new Date).getFullYear();
		var this_end_month = $('#cc_end_month').val();
        this_end_month = this_end_month.replace(/^[ 0]+/,'');

		if((THIS_YEAR == this_end_year)&&(THIS_MONTH > this_end_month)){
			return false;
		}
		else{
			return true;
		}
    },
	EndExpired
	);

jQuery.validator.addMethod(
	"selectDatesStartExpired",
	// checks if start date in the past
	function(value){

        var date = new Date();
		var THIS_MONTH = date.getMonth();
		var THIS_YEAR = (new Date).getFullYear();
		var this_start_month = $('#cc_start_month').val();
        this_start_month = this_start_month.replace(/^[ 0]+/,'');
		var this_start_year = 2000+parseInt($('#cc_start_year').val());

		if((THIS_YEAR == this_start_year)&&(THIS_MONTH < this_start_month)){
			return false;
		}
		else{
			return true;
		}
	},
	StartExpired
	);
