

$ = jQuery
context = window
context.JK ||= {};

class JamTrackUtils
  constructor: () ->
    @logger = context.JK.logger
    @rest = new context.JK.Rest();

  init: () =>

  # check if the shopping cart should be shown
  checkShoppingCart: () =>
    @rest.getShoppingCarts().done(this.displayCartIcon)

  displayCartIcon: (carts) =>
    cartLink = $("#header-shopping-cart")
    if carts.length > 0
      cartLink.removeClass("hidden")
    else
      cartLink.addClass("hidden")

  compareAddress: (billing, shipping) =>
    billing.address1 == shipping.address1 &&
    billing.address2 == shipping.address2 &&
    billing.zip == shipping.zip &&
    billing.city == shipping.city &&
    billing.country == shipping.country;


# global instance
context.JK.JamTrackUtils = new JamTrackUtils()