Flights = function(config) {
  // configurable {
  this.url = ''; // required url to good.ru
  this.width = 800;
  this.height = 480;
  this.padding = 15;
  // }
  $.extend(this, config);
  
  this.win_selector = null;
  this.mask = null;
}

Flights.prototype = {
  show: function() {
    this.getMask().show();
    var center = utils.Effects.Frame.getViewCenter();
    var left = center.left - Math.round(this.getWinWidth() / 2);
    var top = center.top - Math.round(this.getWinHeight() / 2);
    this.getWinEl().show().offset({
      left: left > 0 ? left : 0,
      top: top > 0 ? top : 0
    });
  },
  
  hide: function() {
    this.getWinEl().hide();
    this.getMask().hide();
  },
  
  _createWin: function() {
    var $markup = $('<div class="flights win"><iframe width="' + this.width + '" height="' + this.height + '" src="' + this.url + '" frameBorder="0" scrolling="auto"></iframe><div class="close"></div></div>');
    $markup.appendTo('body')
            .width(this.width)
            .height(this.height)
            .css({ padding: this.padding });
    $('.close', $markup).click($.proxy(this.onClickClose, this));
    
    return $markup;
  },
  
  getWinWidth: function() {
    return this.width + this.padding * 2;
  },
  
  getWinHeight: function() {
    return this.height + this.padding * 2;
  },
  
  getMask: function() {
    if(!this.mask) {
      this.mask = new utils.Effects.Mask();
    }
    return this.mask;
  },
  
  getWinEl: function() {
    if(!this.win_selector) {
      this.win_selector = this._createWin().getIdSelector();
    }
    return $(this.win_selector);
  },
  
  onClickClose: function() {
    this.hide();
  }
}
