var linkthistitle = 'Link to this';
var closetext = 'Schließen';

if(SystemLang == 'en') {
  var linkthistitle = 'Link to this';
  var closetext = 'Close';
}

var LinkthisClass = Class.create();
LinkthisClass.prototype = {
  oModal: null,
  oModal2: null,
  User: null,
  FilterAssociations: null,
	 
  initialize: function() {
    this.FilterAssociations = new Array();
    return this;
  },
		 
  Open: function(article) {
    var sParam = 'article='+article+'&';
    sParam += 'modboxreq=1&';
    var _this = this;
    StdAjax(
      '/'+SystemLang+'/linkthis.html',
      {
        parameters: sParam,
        onSuccess: function(result) {
          //_this.oModal = new Modal(1,750,300);
          _this.oModal = new Modal(1,675);
          _this.oModal.Show(linkthistitle,result.contents);
   
                                                   
          _this.oModal.DefineCloseFunction
          (
            function(oModal)
            {
               oModal.Destroy();
            }
          );
          
           _this.oModal.RemoveCancelButton();

        },
        onError: function(result, errors) {
          alert('error');
        }
      }
    );
  },
  Close: function() {
    this.oModal.Close();
    location.href = '/'+SystemLang+'/linkthis.html';
  },

  CloseBeforeOpen: function() {
    this.oModal._vBlurPage();
    this.oModal.Close();
  },

  Send: function(article) {
    var sParam = AjaxFormCollect( 'form_linkthis' );
    var _this = this;
    
    sParam += 'modboxreq=1&';
    sParam += 'article='+article+'&';
    StdAjax(
      '/'+SystemLang+'/linkthis.html',
      {
        parameters: sParam,
        onSuccess: function(result) {
          if (result.status == false) {
            if(result.errtext.length>0) {
              _this.oModal.ShowErrorHint(result.errtext);
            }
          }
          else {
            _this.oModal.ShowErrorHint(result.errtext);
            //_this.oModal._vBlurPage();
            //_this.oModal.Destroy();
          }
        },
        onError: function(result, errors) {
          alert('error');
        }
      }
    );
  }
  
}


Linkthis = new LinkthisClass();
