/*
 * 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;
			
		this.initForm();
	},	
	
	initForm: function() {
		
		this.container.setStyle('cursor', '');
		
		// fix the form onSubmit if it's there
		this.formElem = this.container;
		if (this.formElem) {
			
			// init the quick_name field
			$(this.formElem.contact_name).addEvents({
				
				'focus': function(elem) {
					if (this.options.defaults.contact_name && elem.value == this.options.defaults.contact_name) {
						elem.value = '';
					}
					elem.setStyle('color', '#000');
				}.bind(this, this.formElem.contact_name),
				
				'blur': function(elem) {
					if (this.options.defaults.contact_name && elem.value == '') {
						elem.value = this.options.defaults.contact_name;
						elem.setStyle('color', '');					
					}
					elem.removeClass('error');
					
				}.bind(this, this.formElem.contact_name)
				
			});
			if (this.formElem.contact_name.value != this.options.defaults.contact_name && !this.formElem.contact_name.hasClass('error')) {
				this.formElem.contact_name.setStyle('color', '#000');
			}
			
			
			// init the contact_email field
			$(this.formElem.contact_email).addEvents({
				
				'focus': function(elem) {
					if (this.options.defaults.contact_email && elem.value == this.options.defaults.contact_email) {
						elem.value = '';
					}
					elem.setStyle('color', '#000');
				}.bind(this, this.formElem.contact_email),
				
				'blur': function(elem) {
					if (this.options.defaults.contact_email && elem.value == '') {
						elem.value = this.options.defaults.contact_email;
						elem.setStyle('color', '');
					}					
					elem.removeClass('error');
				}.bind(this, this.formElem.contact_email)
				
			});
			if (this.formElem.contact_email.value != this.options.defaults.contact_email && !this.formElem.contact_email.hasClass('error')) {
				this.formElem.contact_email.setStyle('color', '#000');
			}
			
			
			// init the contact_comments field
			$(this.formElem.contact_comments).addEvents({
				
				'focus': function(elem) {
					if (this.options.defaults.contact_comments && elem.value == this.options.defaults.contact_comments) {
						elem.value = '';
					}
					elem.setStyle('color', '#000');
				}.bind(this, this.formElem.contact_comments),
				
				'blur': function(elem) {
					if (this.options.defaults.contact_comments && elem.value == '') {
						elem.value = this.options.defaults.contact_comments;
						elem.setStyle('color', '');
					}					
					elem.removeClass('error');
				}.bind(this, this.formElem.contact_comments)
				
			});
			if (this.formElem.contact_comments.value != this.options.defaults.contact_comments && !this.formElem.contact_comments.hasClass('error')) {
				this.formElem.contact_comments.setStyle('color', '#000');
			}
			
		}	
		
	}
});

	