window.addEvent('domready', function(){
    function make_ajax_forms(){
        $$('.ajax_form').each(function(form){
            form.getElement('input[type=submit]').addEvent('click', function(e){
                new Event(e).stop();
                if (window.location['pathname'].contains('more-info')){
                    url = 'form-only'
                }else{
                    url = 'more-info/form-only'
                }
                form.set('send', {
                    url: url,
                    onRequest: function(){
                        form.getElements('input, textarea').each(function(el){
                            el.disabled = 1
                        })
                    },
                    onSuccess: function(html){
                        form.getElements('input, textarea').each(function(el){
                            el.disabled = 0
                        })
                        $('more_info_form').set('html', html)
                        make_ajax_forms();
                    },
                    onFailure: function(){
                        form.getElements('input, textarea').each(function(el){
                            el.disabled = 0
                        })
                    }
                });
                form.send();
            });
        })
    }
    make_ajax_forms();
});

