var popup___form_element = function(form_id, options) {

	var $			= jQuery;
	var __this__	= this;

	var defaults	= {
			"stub_url"			: "/site/jscript/colorbox/iframe_content/form_submission_post_stub.html"
		,	"width_percent"		: 0.9
		,	"height_percent"	: 0.9
	};

	this.form		= $('#' + form_id);
	this.options	= $.extend(defaults, options);

	this.initialize_text = function() {
		var text_fields;
		if (typeof this.options.text_fields === 'undefined') {			// can disable by setting option to an empty array ( ie: options = {"text_fields":[]} )
			text_fields = $('input:text', this.form);
		}
		else {
			text_fields = this.options.text_fields;
		}
		$.each(text_fields, function(i, text_field){
			if (!(text_field instanceof jQuery)) {text_field = $(text_field);}
			text_field.keydown(function(event) {
				if (event.keyCode == '13') {
					event.preventDefault();
					__this__.submit_form();
				}
			});
		});
	};

	this.initialize_submit = function() {
		var submit_elements;
		if (typeof this.options.submit_elements === 'undefined') {		// can disable by setting option to an empty array ( ie: options = {"submit_elements":[]} )
			submit_elements = $(':submit', this.form);
		}
		else {
			submit_elements = this.options.submit_elements;
		}
		$.each(submit_elements, function(i, submit_element){
			if (!(submit_element instanceof jQuery)) {submit_element = $(submit_element);}
			submit_element.click(function(event) {
				event.preventDefault();
				__this__.submit_form();
			});
		});
	};

	this.submit_form = function() {
		var method, url;
			// url    = http://colorpowered.com/colorbox/
			// script = $('div.callout + div.info table:first td:first-child').each(function(){console.log('"'+$(this).text()+'",')});
		var option_whitelist = ["transition","speed","href","title","rel","width","height","innerWidth","innerHeight","initialWidth","initialHeight","maxWidth","maxHeight","scalePhotos","scrolling","iframe","inline","html","photo","opacity","open","preloading","overlayClose","slideshow","slideshowSpeed","slideshowAuto","slideshowStart","slideshowStop","current","previous","next","close","onOpen","onLoad","onComplete","onCleanup","onClosed"];
		var options = {};
		$.each(option_whitelist, function(i, key){
			if (typeof __this__.options[key] != 'undefined') {
				options[key] = __this__.options[key];
			}
		});
		options.iframe = true;

		if (typeof __this__.options.method === 'undefined') {
			method = __this__.form.attr('method');
		}
		else {
			method = __this__.options.method;
		}
		method = method.toLowerCase();

		if (typeof __this__.options.hook___pre_serialize === 'function') {
			__this__.options.hook___pre_serialize(__this__.form);
		}

		if (method === 'get') {
			url  = __this__.form.attr('action');
			url += (url.indexOf('?') > 0)? '&' : '?';
			url += __this__.form.serialize();
		}
		if (method === 'post') {
			url  = __this__.options.stub_url;
			url += '?__action__=' + encodeURIComponent( __this__.form.attr('action') ) + '&' + __this__.form.serialize();
		}
		options.href = url;

		if ( (typeof __this__.options.width  === 'undefined') && (typeof __this__.options.innerWidth  === 'undefined') ) {
			var width_percent  = parseFloat(__this__.options.width_percent);
			options.width  = Math.round( $(window).width()  * width_percent  ) + 'px';
		}
		if ( (typeof __this__.options.height === 'undefined') && (typeof __this__.options.innerHeight === 'undefined') ) {
			var height_percent = parseFloat(__this__.options.height_percent);
			options.height = Math.round( $(window).height() * height_percent ) + 'px';
		}

		if (typeof __this__.options.hook___pre_submit === 'function') {
			__this__.options.hook___pre_submit(__this__.form);
		}

		$.fn.colorbox(options);
	};

	this.initialize = function() {
		if (this.form.length === 1) {
			this.initialize_text();
			this.initialize_submit();
		}
	};

	this.initialize();
};
