/*
 * Mootools Class for the Quick Response Form
 * 
 */
var QuickForm = new Class({
	
	Implements: [Options],  
			
	initialize: function(container, options) {
		
		this.setOptions(options);	
		
		if ($type(container) == 'element')
			this.container = container;
		else
			this.container = $(document.getElement(String(container)));
			
		if (!this.container) 
			return false;
			
		this.initForm();
	},	
	
	initForm: function() {
		
		this.container.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();			
								
		// send the form
		var myHTMLRequest = new Request.HTML({
			url: this.formElem.action,
			onSuccess: this.initForm.bind(this),
			update: this.container
		}).post(this.formElem);	
		
		//
		this.container.setStyle('cursor', 'wait');

	}	
});

	
