var MooHole = new Class({
    Implements: [Options, Events],
    options:
    {
        container: null,
        imgContainer: null,
        path: null,
        currHole: 1
    },
    initialize: function(options)
    {
        this.setOptions(options);
        this.fxIn  = null;
        this.fxOut = null;
        this.request = new Request.HTML({
            onSuccess: function(responseTree, responseElements, responseHTML, responseJavaScript){
                this.fxIn = new Fx.Tween(this.options.container, {
                    property: 'opacity',
                    onComplete: function()
                    {
                        var container = $(this.options.container);
                        container.empty();
                        container.set('html', responseHTML);
                        this.fxOut = new Fx.Tween(container, {property: 'opacity'}).start(1);
                    }.bind(this)
                }).start(0);
            }.bind(this)
        });
    },
    load: function(i)
    {
        if(this.options.currHole == i)
            return;
        
        this.request.cancel();
        if(this.fxOut)
            this.fxOut.cancel();
        if(this.fxIn)
            this.fxIn.cancel();
        
        var file = this.options.path + 'hole' + i + '.htm';
        this.request.get(file);
        this.options.currHole = i;
    }

});
    
window.addEvent('domready', function(){
    hole = new MooHole({
        container: 'holeInfo',
        imgContainer: 'holeImgContainer',
        path: 'holes/'
    });

});