function WufooForm() {
	this.host = 'wufoo.com',
	this.userName = '',
	this.formHash = '',
	this.ssl = false,
	this.autoResize = true,
	this.height = '',
	this.width = '100%',
	this.frameUrl = '',
	this.defaultValues = '',
	this.key = '',
	this.initialize = function(params) {
		for(key in params) {
			this[key] = params[key];
		}
		this.key = this.formHash + '' + Math.floor(Math.random()*1000000);
		this.gFU();
		this.aE(window, 'message', this.bindMethod(this.sWF, this));
	},
	this.gFU = function() {
		var url = '';
		url += this.dS();
		url += this.userName + '.' + this.host + '/embed/' + this.formHash + '/';
		url += 'def/embedKey=' + this.key;
		if(this.defaultValues != '') url += '&'+this.defaultValues;
		if(this.ssl == false) url += '&secure=false';
		this.frameUrl = url;
	},
	this.gFPU = function() {
		var url = '';
		url += this.dS();
		url += this.userName + '.' + this.host + '/forms/' + this.formHash + '/';
		if(this.ssl == false) url += 'http/true/';
		return url;
	}
	this.aRS = function() {
		var self = this;
		setTimeout(function() {
			var script = document.createElement("script");        
	    	script.setAttribute("src", "http://"+self.host+"/forms/height.js?embedKey="+self.key+"&variable="+self.formHash+"&timestamp = "+ new Date().getTime().toString());
	    	script.setAttribute("type","text/javascript");     
	    	document.body.appendChild(script);
		}, 50);
	},
	this.resizeForm = function(ret) {
		if(this.autoResize == true && ret.height) document.getElementById('wufooForm'+this.formHash).height = ret.height
	},
	this.dS = function() {
		if(this.ssl == true) return 'https://';
		else return 'http://';
	},
	this.gFM = function() {
		var src = '<iframe id="wufooForm'+this.formHash+'" height="'+this.height+'" allowTransparency="true" frameborder="0" scrolling="no" style="width:'+this.width+';border:none"'+
		 		  'src="'+this.frameUrl+'"><a href="'+this.gFPU()+'" title="html form" rel="nofollow">Fill out my Wufoo form!</a></iframe>';
		return src;
	},
	this.display = function() {
		document.write(this.gFM());
		if(!window.postMessage) this.aE(document.getElementById('wufooForm'+this.formHash), 'load', this.bindMethod(this.aRS, this));
	},
	this.sWF = function(event) {
		if (event.origin != 'http://' + this.userName + '.' + this.host &&
		    event.origin != 'https://' + this.userName + '.' + this.host) {
		    return;
		}
		if(this.autoResize == true) {
			var data = event.data.split('|');
			if(data[1] && data[1] == this.key) {
				document.getElementById('wufooForm'+this.formHash).height = data[0];
			}
		}
	},
	this.aE = function( obj, type, fn ) {
		if ( obj.attachEvent ) {
		    obj["e"+type+fn] = fn;
		    obj[type+fn] = function() { obj["e"+type+fn]( window.event ) };
		    obj.attachEvent( "on"+type, obj[type+fn] );
		  } 
		  else{
		    obj.addEventListener( type, fn, false );	
		  }
	},
	this.bindMethod = function(method, scope) {
		return function() {
			method.apply(scope,arguments);
		}
	}
	
}