function feedtact(selector, submiturl) {
	var formobj = $$(selector);
	
	// Add the container and the button
	formobj.set('html', '<a id="ft-link" href="#feedback">Feedback</a><div id="ft-container"><a id="ft-cancel" href="#cancel">cancel</a>'+formobj.get('html')+'</div>');
	
	// Add the feedtact class
	formobj.addClass('feedtact');
	$$('div.feedtact input, div.feedtact textarea, div.feedtact button, div.feedtact select').addClass('ft');
	var el = $$('div.feedtact');
	var sl = new Fx.Slide('ft-container', {
		duration: 300,
		onComplete: function() {
			if (!this.open) {
				$$('div#ft-container').setStyle('display','none');
				el.set('tween', {duration: 300});
				el.tween('width', '46px');
			}
		}
	});
	sl.hide();
	$$('div#ft-container').setStyle('display','none');
	
	var cancel = $$('a#ft-cancel');
	var button = $$('a#ft-link');
	
	
	cancel.addEvents({
		'click': function(){
			button.fireEvent('click');
			return false;
		}
	});
	
	button.addEvents({
		'click': function(){
			// Browsers will jump from the outline so blur the element to avoid
			$(this).blur();
			
			// If the form is currently minimized
			if (!$(this).hasClass('open')) {
				// Set it to opened
				$(this).addClass('open');
				
				el.set('tween', {
					duration: '300',
					onComplete: function(){
						// Reenable submit button if its already been used
						$('ft-submit').set('disabled','').set('html','send');
						
						// if any error messages still exist, kill em
						if ($('ft-error')) {
							$('ft-error').destroy();
						}
						$('ft-container').removeClass('hasError');
						
						// Set all select boxes to empty
						var selectinputs = $$('div#ft-container select');
						$each(selectinputs, function(elem, value) {
							$(elem).set('value', '');
							$(elem).removeClass('form-error');
						});
						// After the animation, go through each input and textarea element
						var textinputs = $$('div#ft-container input, div#ft-container textarea');
						$each(textinputs, function(elem, value) {
							
							// Clear the fft-filled class if it exists (if they abondoned the form)
							$(elem).removeClass('ft-filled');
							$(elem).removeClass('form-error');
							
							// Set the value of the field to whatever the label is
							$(elem).set('value', $(elem).getPrevious('label').get('html'));
							
							// On focus of each element set clear the label text and style it as filled
							$(elem).addEvents({
								'focus': function() {
									if (!$(elem).hasClass('ft-filled')) {
										$(elem).addClass('ft-filled');
										$(elem).set('value','');
									}
								},
								'blur': function() {
									if ($(elem).get('value') != $(elem).getPrevious('label').get('html')) {
										// If empty, go back to label text
										if ($(elem).get('value') == '') {
											$(elem).removeClass('ft-filled');
											$(elem).set('value', $(elem).getPrevious('label').get('html'));
										} else {
											$(elem).addClass('ft-filled');
										}
									} else {
										$(elem).removeClass('ft-filled');
									}
								}
							});
							
							// Display the form after all the events are hooked
							//$$('div#ft-container').setStyle('display','block');
							$$('div#ft-container').setStyle('display','block');
							sl.slideIn();
						});
					}
				});
				el.tween('width', '546px');
			} else {
				// Set it to closed
				$(this).removeClass('open');
				
				
				sl.slideOut();
			}
			
			return false;
		}
	});
	
	// Require the fields with the required class and submit xhr
	$('ft-submit').addEvents({
		'click':function(){
			var error = false;
			var textfields = $$('div.feedtact input.required, div.feedtact textarea.required');
			var submit_vals = {};
			$each(textfields, function(elem, value){
				if (!$(elem).hasClass('ft-filled')) {
					// not valid
					error = true;
					//$(elem).setStyle('border', '1px solid #E9645D');
					$(elem).addClass('form-error');
				} else {
					// valid
					//$(elem).setStyle('border', '1px solid #999999');
					$(elem).removeClass('form-error');
					if ($(elem).get('value')) {
						submit_vals[$(elem).get('name')] = $(elem).get('value');
					} else {
						submit_vals[$(elem).get('name')] = $(elem).get('html');
					}
				}
			});
			var selectfields = $$('div.feedtact select.required');
			$each(selectfields, function(elem, value){
				if (!$(elem).get('value')) {
					// not valid
					error = true;
					$(elem).addClass('form-error');
				} else {
					// valid
					$(elem).removeClass('form-error');
					submit_vals[$(elem).get('name')] = $(elem).get('value');
				}
			});
			// Check valid emails on inputs with email class
			var emails = $$('div.feedtact .validemail');
			$each(emails, function(elem, value) {
				if (!(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test($(elem).get('value')))) {
					error = true;
					$(elem).addClass('form-error');
				} else  {
					$(elem).removeClass('form-error');
				}
			});
			if (error) {
				// If there is an error, give the error message
				if (!$('ft-container').hasClass('hasError')) {
					$('ft-container').addClass('hasError');
					new Element('span').set('html','Please make sure all fields are filled out correctly. Thank you.').set('id', 'ft-error').inject('ft-container');
				}
			} else {
				// remove the error message if it exists
				if ($('ft-error')) {
					$('ft-error').destroy();
					$('ft-container').removeClass('hasError')
				}
				
				// Submit the form via AJAX
				var jsonRequest = new Request.JSON({url: submiturl}).post(submit_vals);
				
				// Disable the button
				$('ft-submit').set('disabled','disabled');
				
				// Set the button to thank you message
				$('ft-submit').set('html', 'Thanks!');
				
				// Wait a few seconds and close window
				(function(){ button.fireEvent('click'); }).delay(1000);
			}
			// stop the page from refreshing
			return false;
		}
	});
}
