(function($){
  BBCS.namespace('error');
  
  //sends an error message to server
  BBCS.error.report = function(msg) {
    $.ajax({
      url: '/error/report',
      type: 'GET',
      data: {message:msg}
    })
  }
  
  //shows error modal that something went wrong
  BBCS.error.blockUI = function(layoutName) {
    $.ajax({
      url: '/error/' + layoutName,
      type: 'GET',
      success: function(html) {
        html = $(html);
        $.unblockUI();
        $.blockUI({
          message: html,
          css: {
            textAlign: 'left',
            cursor: 'default',
            border: 'none',
            backgroundColor: '#fff',
            width: 'auto',
            height: 'auto',
            top: 100,
            position: 'fixed'
          },
          overlayCSS: {
            cursor: 'default'
          }
        });
        html.find('h1 a').click(function() { $.unblockUI(); });
      }
    });
  }
  
  BBCS.error.unableToAddProductModal = function() {
    BBCS.error.blockUI('adding_product_error');
  }
  
  
})(jQuery)
