if (FJ.Infidel === undefined) alert('infidel.js (ajaxyforms.js) must be included first');
else {
	FJ.Infidel.Forms = Class.create({
	
		CLASSNAME: 'Infidel.Forms',
	
		initialize: function() {
			
			this.activate_ajaxy_forms();
			
		},
		
		activate_ajaxy_forms: function() {
			// moving between forms
			$A($$('a.form-navigation')).each(function(elem) {
				$(elem).observe('click', function(event) {
					event.stop();
					
					var elem = $(event.element());
					var active_form = $(event.findElement('form')).up();
					active_form.setStyle({'display': 'none'});
					
					var new_form = $A(active_form.siblings()).find(function (el) {
						return el.hasClassName(("#{rel}-form-tab").interpolate({'rel': elem.readAttribute('rel')}));
					}.bind(this));
					
					if (new_form) new_form.setStyle({'display': 'block'});
				}.bind(this));
			}.bind(this));
		},
		
		show_form:function() {
			var new_form = $A(active_form.siblings()).find(function(el) {
				return el.hasClassName(("#{rel}-form-tab").interpolate({'rel': elem.readAttribute('rel')}));
			}.bind(this)).show();
		}
		
	});
	
	// mixin modules
	FJ.Infidel.Forms.addMethods(FJ.Modules.BaseModule);
	
	// singleton
	FJ.ajaxyforms = function () {
		var instance = FJ.get_singleton("Infidel.Forms");
		if (instance == null) instance = FJ.set_singleton("Infidel.Forms", new FJ.Infidel.Forms());
		return instance;
	}
	
}
