formManagerCallback = function(result, form){
	if (result == true) {
		var myform = $(form.id);
		try {
			var el = myform.parentNode.parentNode.select('.ajaxAction')[0];
		} 
		catch (e) {
			var el = myform.parentNode.parentNode.select('.ajaxAction')[0];
		}
		if(el)
			el.show();
		myform.hide();
	}
}
PropertyFormHandler = Class.create();
PropertyFormHandler.prototype = {
	initialize: function( formEl ){
		this.formEl = $(formEl);
		Event.observe( this.formEl, 'submit', this.__submitted.bindAsEventListener( this ) );
	},
	__submitted: function( event ){
		this.formEl.request(
			{
				onSuccess: this.cb_submitted.bind( this )
			}
		);
		Event.stop( event );
		return false;
	},
	cb_submitted: function( xhr, ajax ){
		try{
			if(!ajax){
				try{
					var el = this.formEl.parentNode.parentNode.select( '.thanks' )[0];
					var el2 = this.formEl.parentNode.parentNode.select( '.ajaxAction' )[0];
				}
				catch( e ){
					var el = this.formEl.parentNode.parentNode.select( '.thanks' )[0];
					var el2 = this.formEl.parentNode.parentNode.select( '.ajaxAction' )[0];
				}
				el.show();
				if (el2) {
					el2.hide();
				}
				this.formEl.hide();				
			} else {
				var ajaxResponse = ajax.split('*');
				if(ajaxResponse[0] == '0'){
					try{
						var el = this.formEl.parentNode.parentNode.select( '.thanks' )[0];
						var el2 = this.formEl.parentNode.parentNode.select( '.ajaxAction' )[0];
					}
					catch( e ){
						var el = this.formEl.parentNode.parentNode.select( '.thanks' )[0];
						var el2 = this.formEl.parentNode.parentNode.select( '.ajaxAction' )[0];
					}
					el.show();
					if (el2) {
						el2.hide();
					}
					this.formEl.hide();
				} else if(ajaxResponse[0] == '1') {				
					//alert(ajaxResponse[1]);				
				}
			}						
		}catch(e){
			//alert(e);
		}
	},
	showForm: function(){
		this.formEl.show();
		try{
			var el = this.formEl.parentNode.parentNode.select( '.thanks' )[0];
		}
		catch( e ){
			var el = this.formEl.parentNode.parentNode.select( '.thanks' )[0];
		}
		el.hide();
	}
}
//Do Not use document.Observe('dom:loaded'). This is not supported by Prototype 1.5
Event.observe(window, 'load', function(){
	var els = $$('.PropertyForm');
	for( fc = 0; fc < els.length; fc++ ){
		try{
			new PropertyFormHandler( els[fc] );
		}catch(e){
			//alert( e );
		}
	}
});
