$().ready(function() {
	var container = $('#submitErrors');
	// validate the form when it is submitted
	var validator = $("#paymentform").validate({
		errorContainer: container,
		errorLabelContainer: $("ol", container),
		wrapper: 'li',
		meta: "validate",
		errorClass: "error",
		rules: {
			BillingFirstNameTextBox: "required",
			BillingLastNameTextBox: "required",
			BillingAddressTextBox: "required",
			BillingCityTextBox: "required",
			BillingZipTextBox: "required",
			BillingEmailTextBox: {
				required: true,
				email: true
			},
			AmountTextBox: {
				required: true,
				number: true
			},
			CreditCardNumberTextBox: {
				required: true,
				creditcard: true
			},
			CVVTextBox: {
				required: true,
				digits: true
			},
			AgreeCheckBox: "required",
			AgreementNameTextBox: "required"
		},
		
		messages: {
			BillingFirstNameTextBox: "Please specify your first name",
			BillingLastNameTextBox: "Please specify your last name",
			BillingAddressTextBox: "Please specify your billing address",
			BillingCityTextBox: "Please specify your billing city",
			BillingZipTextBox: "Please specify your billing Zip",
			BillingEmailTextBox: {
				required: "We need your email address to contact you",
				email: "Please enter a valid email address"
			},
			AmountTextBox: {
				required: "Enter the amount value",
				number: "Amount should be the number value"
			},
			CreditCardNumberTextBox: {
				required: "Please specify your Credit Card number",
				creditcard: "Please specify the correct Credit Card number"
			},
			CVVTextBox: {
				required: "Please specify your Security Code (CVV)",
				digits: "Use the digits only for the Security Code (CVV)"
			},
			AgreeCheckBox: "Please confirm with the checkbox that you are agree with our agreement",
			AgreementNameTextBox: "Please enter your name in the agreement form"
		},
		
		showErrors: function(errorMap, errorList) {
			var paypalErr=$('#paypalErrors');
			
			if(paypalErr && paypalErr.hide) {
				paypalErr.hide();
			}
			
			this.defaultShowErrors();
		}
		
	});
});

