if(window['console'] === undefined) window.console = { log: function(){} };

Custom = Class.create();
Custom.prototype = {
    initialize: function() {

        this.pos = 0;
        this.current = 0;
        this.images = Array();
        this.canMove = true;
                
        new BackgroundLoader('http://blanqo.eu/build/images/body-bg-nl.jpg', {
            onLoad: this.onLoad,
            onInitialize: this.onInitialize,
            onComplete: this.onComplete,
            id: "background",
            swfLocation: "http://blanqo.eu/build/flash/BackgroundLoader.swf"
        });
    },
    onLoad: function(json) {
        $('loadbar').style.width = json.prettyPercentage;
        $('loadbar').update("Achtergrond wordt ingeladen: " + json.prettyPercentage);
    },
    onInitialize: function() {
        new AdBlock('background');
    },
    onComplete: function() {
        $('loadbar').remove();
    },
    viewer: function() {
        var x = 1;
        for (var i = 0; i < $('slide').childNodes.length; i++) {
            if ($('slide').childNodes[i].tagName == 'A') {
                this.images.push($('slide').childNodes[i]);
                //$('slidecontrol_' + x).observe('click', function(e){this.view(e)}.bind(this));
                $('slidecontrol_' + x).onclick = function(event) { this.view(event); return false; }.bind(this);
                x++;
            }
        }
    },
    view: function(event) {
        event = event || window.event;
        if (this.canMove) {
            this.canMove = false;
            var target = event.target || event.srcElement;
            var image = target.id.match(/[0-9]/)-1;
            var x = 0;
            if (image > this.current) {
                x = ((image-this.current) * -417)
            } else if (image < this.current) {
                x = ((this.current - image) * 417);
            }
            new Effect.Move('slide', { x: x, y: 0, afterFinish: function() {this.canMove = true}.bind(this)});
            target.className = 'current';
            $('slidecontrol_' + (this.current+1)).className = '';
            this.current = image;
        }
    }
}

document.observe('dom:loaded', function(){
    new Custom();
})