<script src="{openzc:field.template/}assets/system/js/jquery.min.js"></script>
<script src="{openzc:field.template/}assets/system/js/checkout.js"></script>
<script src="{openzc:field.template/}assets/system/js/openzc.js"></script>
<script type="text/javascript">
    $(function(){
      var creditly = Creditly.initialize(
          '.expiration-month-and-year',
          '.credit-card-number',
          '.security-code',
          '#payment_gateway_description');
    });
	$(".field__input").each(function(){
	  var Parent=$(this).parent().parent();
	  if($(this).val().length>0){
		  if(!$(Parent).is('field--show-floating-label')){
			$(Parent).addClass('field--show-floating-label');
		  }
	  }
	  $(this).change(function(){
		  if(!$(Parent).is('field--show-floating-label') && $(this).val().length>0){
			$(Parent).addClass('field--show-floating-label');
		  }
		  if($(Parent).is('field--show-floating-label') && $(this).val().length==0){
			$(Parent).removeClass('field--show-floating-label');
		  }
	  });
    });
	$(".credit-card-number").on("changed_input keypress keydown keyup", function (e) {
		var cartType=$("#payment_gateway_description").html();
		$(".payment-icon").addClass('payment-icon--unknown');
		$(".payment-icon--"+cartType).removeClass('payment-icon--unknown');
		$(".payment-icon--"+cartType).addClass('payment-icon--known');
	});
	$(".order-summary-toggle__text").click(function(){
		if($("#order-summary").hasClass("order-summary--is-collapsed")){
			$("#order-summary").addClass("order-summary--is-expanded");
			$("#order-summary").removeClass("order-summary--is-collapsed");
		}else{
			$("#order-summary").removeClass("order-summary--is-expanded");
			$("#order-summary").addClass("order-summary--is-collapsed");
		}
		$(this).removeClass("order-summary-toggle__text--show");
		$(".order-summary-toggle__text--hide").addClass("order-summary-toggle__text--show");
		$(".order-summary-toggle__text").removeClass("order-summary-toggle__text--hide");
		$(this).addClass("order-summary-toggle__text--hide");
	});
	$("#checkout_different_billing_address_true").click(function(){
		$("#section--billing-address__different").removeClass("hidden");
	});
	$("#checkout_different_billing_address_false").click(function(){
		$("#section--billing-address__different").addClass("hidden");
	});
	$(".checkout_payment_gateway").click(function(){
		var current=$(this).val();
		$(".payment-gateway-subfields").addClass("hidden");
		$(".payment-gateway-subfields input").attr("disabled","true");
		$("#payment-gateway-subfields-"+current).removeClass("hidden");
		$("#payment-gateway-subfields-"+current+" input").removeAttr("disabled");
	});
	
  </script>