var FormTidy = new Class({
    Implements: [Options, Events],
    options: {
        formClass:'formtidy',
        onFormReady:false
    },
    initialize: function(options) {
        this.setOptions(options);
        if(!Browser.Engine.gecko) { return false; }
        $$('.' + this.options.formClass).each(function(el,index) {
            // el.fade('hide');
            var list_items = el.getElements('li'); 
            if($chk(list_items) && list_items.length > 0) {
                list_items.each(function(li,ind) {
                    var lab = li.getFirst('label');
                    if($chk(lab)) {
                        var sp = new Element('span', {
                            'class': '',
                            'styles': {
                                'display': 'block',
                                'width': (lab.getStyle('width').toInt()) + 'px'
                            }
                        });
                        sp.set('html', lab.get('html'));
                        lab.empty();
                        lab.setStyle('display','-moz-inline-box');
                        lab.adopt(sp);
                    }     
                });
            }
            // el.fade('show');
        });
        // Allow designers to use their own 'Ready' callback (passed in with the options).
        return this.fireEvent('onFormReady', [this]);   
    }
});

window.addEvent('domready', function() {
    // *** FormTidy ||
    var myoptions = {
        formClass:'cmxform',
        onFormReady:function() {
            // Designers use this function to do stuff when the Form is Tidy (after tidy() has finished).
        }
    };
    var TidyForm = new FormTidy(myoptions);
    // *** End FormTidy ||
});
