/*
 * Mootools Class for the Quick Response Form
 * 
 */
var ContactForm = new Class({

  Implements: [Options],

  options: {
    defaults: {}
  },


  initialize: function (container, options) {

    this.setOptions(options);

    if ($type(container) == 'element')
      this.container = container;
    else
      this.container = $(container);

    if (!this.container)
      return false;

    // fix the container height;
    var size = this.container.getSize();
    if (Browser.Engine.trident) {
      this.container.setStyle('height', size.y)
    } else {
      this.container.setStyle('min-height', size.y)
    }

    this.initForm();
  },

  initForm: function () {

    // remove the cursor
    this.container.setStyle('cursor', '');
    this.container.getElements('*').each(function (el) {
      el.setStyle('cursor', '');
    });

    // fix the form onSubmit if it's there
    this.formElem = this.container.getElement('form');
    if (this.formElem) {
      this.formElem.addEvent('submit', this.submitForm.bindWithEvent(this));
    }

  },

  submitForm: function (event) {

    // cancel the default event
    event.preventDefault();

    // show the cursors
    this.container.setStyle('cursor', 'wait');
    this.container.getElements('*').each(function (el) {
      el.setStyle('cursor', 'wait');
    });

    // send the form

    var myHTMLRequest = new Request.HTML({
      url: this.formElem.action,
      onComplete: this.initForm.bind(this),
      update: this.container
    }).post(this.formElem);

  }
});


	
