/**
 * bugreport.js
 *
 * Version history (please keep backward compatible):
 * 1.0, 2009-07-01: Thomas Schedler
 *
 * @author Thomas Schedler <tsh@massiveart.com>
 * @version 1.0
 */

var Bugreport = Class.create({

  initialize: function() {
    this.FormId = '';
    this.blnIsValidateForm = true;   
    this.viewId = null;
  },

  /**
   * send Bugreport
   */
  sendBugReportForm: function(buttonEl, formId) {
    this.addBusyClass(buttonEl);
    this.FormId = formId;

    /**
     * Mail
     */
    if($(this.FormId+'Mail') && $F(this.FormId+'Mail').blank()){
      $(this.FormId+'MailHeadline').addClassName('missing');
      $(this.FormId+'Mail').addClassName('missinginput');
      $(this.FormId+'Mail').activate();
      this.removeBusyClass(buttonEl);
      return false;
    }else{
      $(this.FormId+'MailHeadline').removeClassName('missing');
      $(this.FormId+'Mail').removeClassName('missinginput');
    }

    /**
     * Area
     */
    if($(this.FormId+'Area') && $F(this.FormId+'Area').blank()){
      $(this.FormId+'AreaHeadline').addClassName('missing');
      $(this.FormId+'Area').addClassName('missinginput');
      $(this.FormId+'Area').activate();
      this.removeBusyClass(buttonEl);
      return false;
    }else{
      $(this.FormId+'AreaHeadline').removeClassName('missing');
      $(this.FormId+'Area').removeClassName('missinginput');
    }

    /**
     * Description
     */
    if($(this.FormId+'Description') && $F(this.FormId+'Description').blank()){
      $(this.FormId+'DescriptionHeadline').addClassName('missing');
      $(this.FormId+'Description').addClassName('missinginput');
      $(this.FormId+'Description').activate();
      this.removeBusyClass(buttonEl);
      return false;
    }else{
      $(this.FormId+'DescriptionHeadline').removeClassName('missing');
      $(this.FormId+'Description').removeClassName('missinginput');
    }

    /**
     * submit now form
     */
    if($(this.FormId)){
      $(this.FormId).submit();
    }

  },

  /**
   * addBusyClass
   */
  addBusyClass: function(busyElement) {
    if($(busyElement)){
      $(busyElement).addClassName('busywhite');
    }
  },

  /**
   * removeBusyClass
   */
  removeBusyClass: function(busyElement) {
    if($(busyElement)){
      $(busyElement).removeClassName('busywhite');
    }
  },

  /**
   * addBusyClassExtended
   */
  addBusyClassExtended: function(busyElement, cssClass) {
    if($(busyElement)){
      $(busyElement).addClassName(cssClass);
    }
  },

  /**
   * addBusyClassExtendedWithSize
   */
  addBusyClassExtendedWithSize: function(busyElement, cssClass, elementWidth, elementHeight) {
    if($(busyElement)){
      $(busyElement).setStyle({width: elementWidth+'px', height: elementHeight+'px'});
      $(busyElement).addClassName(cssClass);
    }
  },

  /**
   * addBusyClassExtendedWithHeight
   */
  addBusyClassExtendedWithHeight: function(busyElement, cssClass, elementHeight) {
    if($(busyElement)){
      $(busyElement).setStyle({height: elementHeight+'px'});
      $(busyElement).addClassName(cssClass);
    }
  },

  /**
   * removeBusyClassExtended
   */
  removeBusyClassExtended: function(busyElement, cssClass) {
    if($(busyElement)){
      $(busyElement).setStyle({width: 'auto', height: 'auto'});
      $(busyElement).removeClassName(cssClass);
    }
  },

  /**
   * removeBusyClassExtendedWithoutHeight
   */
  removeBusyClassExtendedWithoutHeight: function(busyElement, cssClass) {
    if($(busyElement)){
      $(busyElement).setStyle({height: 'auto'});
      $(busyElement).removeClassName(cssClass);
    }
  }
});

