if(window['console'] === undefined) window.console = {log: function(){}};

var Custom = Class.create({
    initialize: function() {
        new BackgroundLoader('images/bg.jpg', {
            onLoad: this.onLoad,
            onInitialize: this.onInitialize,
            onComplete: this.onComplete,
            id: "background",
            swfLocation: "media/BackgroundLoader.swf"
        });

        if ($('mail')) {
            $('mail').writeAttribute('href', $('mail').readAttribute('href').replace('.nospam.', '@'));
            $('mail').update($('mail').innerHTML.replace('.nospam.', '@'));
        }
    },
    loadBackground: function(img) {
        new BackgroundLoader('images/backgrounds/' + img, {
            onLoad: this.onLoad,
            onInitialize: this.onInitialize,
            onComplete: this.onComplete,
            id: "background",
            swfLocation: "media/BackgroundLoader.swf"
        });
    },
    onLoad: function(json) {
        //var height = [Math.round(json.percentLoaded-(json.percentLoaded / 4)), '%'].join('');
        $('loadbar').style.height = json.prettyPercentage;
    },
    onInitialize: function() {
        new AdBlock('background');
    },
    onComplete: function() {
        $('loadbar').morph('opacity: 0', {duration: 1});
    }
});

document.observe('dom:loaded', function(){
    new Custom();
});
