/*
 * Avoid Form Double Send Request
 * 
 * require jQuery 1.3.2
 * 
 * Created by Takayoshi Itou.
 * 
 */

if (! $.fn.avoidDoubleRequest) {
    $.fn.avoidDoubleRequest = function() {
        var allow = true;

       var target = $(this);
        if (target.is('form')) {
            target.submit(function() {
                if (allow) {
                    allow = false;
                    return true;
                } else {
                    target.attr('action', 'javascript:void(0)');
                    return false;
                }
            });

        } else if (target.is('a')) {
            target.click(function() {
                if (allow) {
                    allow = false;
                    return true;
                } else {
                    target.attr('href', 'javascript:void(0)');
                    return false;
                }
            });
        }
    };
    
    $(function() {
        $('.avoid_double_request').avoidDoubleRequest();
    });
}
