document.observe("dom:loaded", function() {
    // the element in which we will observe all clicks and capture
    // ones originating from pagination links
    var container = $(document.body)

    if (container) {
        var img = new Image
        img.src = '/images/spinner.gif'

        function createSpinner() {
            return new Element('img', {
                src: img.src,
                'class': 'spinner'
            })
        }

        container.observe('click', function(e) {
            var el = e.element()
            if (el.match('.pagination a')) {
                el.up('.pagination').insert(createSpinner())
                new Ajax.Request(el.href, {
                    method: 'get'
                })
                e.stop()
            }
        })
    }
})


var ipn_timer = 0;
function wait_check_ipn ()
{
    new Ajax.Request('/payments/ipn', {
        method:     'post'
    });
    ipn_timer = setTimeout("wait_check_ipn()", 5000)
}

