var dialog = new function(){
  var IDs = {
    video:   0,
    generic: 0
  };

  this.generic = function(title, name, width, height, cleanup) {
    var dlg, options;
    options = { content: { id: '#dialog-' + name }, dialog: {} };
    
    // Build up the options from any parameters passed in
    if( title !== undefined  ){ options.content.title = title; }
    if( name !== undefined   ){ options.content.URL = '/include/dialogs/' + name + '.html'; }
    if( width !== undefined  ){ options.dialog.width = width; }
    if( height !== undefined ){ options.dialog.height = height; }
    
    // Create the dialog
    dlg = $.DialogEx(options);
    
    // If cleanup is set to true, go to town on the dialog when it is closed.
    if( cleanup !== undefined && cleanup === true )
    {
      dlg.bind('dialogclose', function(event, ui){
        // Destroy the dialog
        dlg.dialog( 'destroy' );
        // Remove the content
        $(options.content.id).remove();
      });
    }
    
    // Open the dialog
    dlg.dialog('open');
    
    // Just a counter for the number of dialogs loaded
    IDs.generic++;
  };
  
  this.coupon = function(code) { dialog.generic('<span style="color: #f00;">' + code + '</span> &ndash; Coupon Code Disclaimer', code); };
  this.error  = function(title, file, width, height) { dialog.generic('<span style="color: #f00;">' + title + '</span>', file, width, height); };

  this.GC_Terms  = function(){ dialog.generic('Gift Card Terms &amp; Conditions',                                      'GC-Terms'); }
  this.SHIP      = function(){ dialog.generic('<span style="color: #f00;">SHIP</span> &ndash; Coupon Code Disclaimer', 'SHIP'    ); }
  this.TPO       = function(){ dialog.generic('Discount Disclaimer', 'TPO'); }
  this.PEEL      = function(){ dialog.generic('Coupon PEEL Disclaimer', 'PEEL'); }
  this.SUNSHINE  = function(){ dialog.generic('Coupon SUNSHINE Disclaimer', 'SUNSHINE'); }
  this.sizeguide = function(){ dialog.generic('Honeybell Size Guide', 'sizeguide'); }

  this.checkoutInvalidAddress = function(){ dialog.error('Attention', 'checkout-invalid-address', 400, 100); };
  this.checkoutDeliveryError  = function(){ dialog.error('Attention', 'checkout-delivery-error',  400, 100); };
  this.checkoutSaveAddress    = function(){ dialog.error('Attention', 'checkout-save-address',    400, 100); };
  this.checkoutSaveDelivery   = function(){ dialog.error('Attention', 'checkout-save-delivery',   400, 100); };
};
