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

var Custom = Class.create({
    initialize: function() {
        this.contentOpacity = 1.0;

        this.pusher();

        this.tickerDir = 'left';

        this.backgrounds = ['more3.jpg', 'blue gril.jpg', 'frites.jpg', 'graffity.jpg', 'hotlips.jpg', 'multiculti.jpg', 'opa.jpg', 'oranje.jpg', 'fatboy-pink.jpg'];

        var background = (typeof(customBackground) != 'undefined') ? customBackground : this.backgrounds[Math.floor(Math.random()*this.backgrounds.length)];

        this.loadBackground(background);

        if ($('flashcontainer')) this.home();

        if ($('content')) {
            Event.observe(document.onresize ? document : window, "resize", this.pusher.bind(this));
            if ($('close')) $('close').observe('click', this.hideContent.bind(this));
        }
        
        if ($('mail')) {
            $('mail').writeAttribute('href', $('mail').readAttribute('href').replace('.nospam.', '@'));
            $('mail').update($('mail').innerHTML.replace('.nospam.', '@'));
        }

        if ($('ticker')) this.ticker();

        $$('.tagcloud').each(function(s){this.tagcloud(s)}.bind(this));

    },
    ticker: function() {

        /*
        var slideTo = (this.tickerDir == 'left') ? -1950 : 0;
        this.tickerDir = (this.tickerDir == 'left') ? 'right' : 'left';
        $('slide').morph('left: ' + slideTo + 'px;', {duration: 30, after: this.ticker.bind(this), transition: 'linear'});
        */

       var flashvars = {};

        var params = {
          menu: "false",
          allowScriptAccess: "always",
          bgcolor: '#ffffff',
          wmode: 'transparent'
        };

        var attributes = {
            id: "ticker"
        };

        swfobject.embedSWF('media/HorizontalTicker.swf', "ticker", '330', '22', "9.0.0","js/expressInstall.swf", flashvars, params, attributes);
    },
    tagcloud: function(e) {
        var flashvars = {};

        var params = {
          menu: "false",
          allowScriptAccess: "always",
          bgcolor: '#ffffff',
          wmode: 'transparent'
        };

        var attributes = {
            id: "tagcloud-" + e.id
        };

        swfobject.embedSWF('media/tagclouds/' + e.id + '/' + e.id + '.swf', "tagcloud-container", '310', '430', "9.0.0","js/expressInstall.swf", flashvars, params, attributes);
    },
    home: function() {
        var flashvars = {};

        var params = {
          menu: "false",
          allowScriptAccess: "always",
          bgcolor: '#ffffff',
          wmode: 'transparent'
        };

        var attributes = {
            id: "index"
        };
        
        swfobject.embedSWF('index.swf', "flashcontainer", '487', '470', "9.0.0","js/expressInstall.swf", flashvars, params, attributes);
    },
    pusher: function() {
        var h = document.viewport.getDimensions().height;
        h = (h > 827) ? h - 827 : 30;
        $('pusher').style.height = h + 'px';
    },
    hideContent: function() {
        var o = (this.contentOpacity > 0.1) ? 0.1 : 1.0;
        var h = (this.contentOpacity > 0.1) ? 35 : 470;

        var i = $$('.inner')[0];

        if (Prototype.Browser.IE7 && o < 1.0) i.toggle();

        $('content').morph('opacity: ' + o + '; height: ' + h + 'px;', {duration: 1, after: function(){
            if (Prototype.Browser.IE7 && o > 0.1) i.toggle();
        }});
    
        this.contentOpacity = o;
    },
    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();
});

Prototype.Browser.IE6 = Prototype.Browser.IE && parseInt(navigator.userAgent.substring (navigator.userAgent.indexOf("MSIE")+5))==6;
Prototype.Browser.IE7 = Prototype.Browser.IE && !Prototype.Browser.IE6;