var easterEgg = {
    konami : '38,38,40,40,37,39,37,39,66,65',
    konamiCheck : new Array(),
    image : '',
    interval: 0,
    position: -100,
    actions: new Array('easterEgg.michaelIt()','easterEgg.bugIt()','easterEgg.nomnomIt()','easterEgg.downloadIt()','easterEgg.peanutbutterIt()'),

    start:function(image)
    {
        $(document).keydown(easterEgg.keydown);
        easterEgg.image = image;
    },

    keydown:function(e)
    {
        easterEgg.konamiCheck.push(e.which);
        if(easterEgg.konamiCheck.toString() == easterEgg.konami)
        {
            easterEgg.doIt();
            easterEgg.konamiCheck = new Array();
        }else if(easterEgg.konami.indexOf(easterEgg.konamiCheck.toString()) == -1)
        {
            easterEgg.konamiCheck = new Array();
        }
    },

    doIt:function()
    {
        easterEgg.stopIt();
        eval(easterEgg.actions[Math.round(Math.random()*(easterEgg.actions.length-1))]);
        
    },

    stopIt:function()
    {
        $('[id^="easteregg"]').remove();
        clearInterval(easterEgg.interval);
    },


    michaelIt:function()
    {
        div = '<div id="easteregg" style="position:absolute;bottom:0;left:-100px"><img src="http://www.on-d-mand.nl/easteregg.gif"></div>';
        $('body').append(div);
        easterEgg.interval = setInterval(easterEgg.michaelMove,10);
    },

    michaelMove:function()
    {
        position = $('#easteregg').position().left+2;
        $('#easteregg').css('left',position+'px');
        if($('#easteregg').position().left > $('body').width() )
        {
            easterEgg.stopIt();
        }
    },

    bugIt:function()
    {
        for(i=0;i<20;i++)
        {
            div = '<div id="easteregg'+i+'" style="position:absolute;bottom:'+(Math.random()*$('body').height())+'px;left:'+(Math.random()*$('body').width())+'px"><img src="http://www.on-d-mand.nl/easteregg2.gif"></div>';
            $('body').append(div);
        }
        easterEgg.interval = setTimeout(easterEgg.stopIt,10000);
    },

    nomnomIt:function()
    {
        div = '<div id="easteregg" style="position:absolute;bottom:0px;right:283px"><img src="http://www.on-d-mand.nl/easteregg3.gif"></div>';
        $('body').append(div);
        easterEgg.interval = setTimeout(easterEgg.stopIt,10000);
    },

    downloadIt:function()
    {
        div = '<div id="easteregg" style="position:absolute;bottom:'+(($('body').height()/2)-130)+'px;left:'+(($('body').width()/2)-245)+'px"><img src="http://www.on-d-mand.nl/easteregg4.gif"></div>';
        $('body').append(div);
        easterEgg.interval = setTimeout(easterEgg.stopIt,10000);
    },

    peanutbutterIt:function()
    {
        div = '<div id="easteregg" style="position:absolute;top:'+(Math.random()*$('body').height())+'px;left:'+(Math.random()*$('body').width())+'px"><img src="http://www.on-d-mand.nl/easteregg5.gif"></div>';
        $('body').append(div);
        div = '<div id="easteregg2" style="position:absolute;top:'+(Math.random()*$('body').height())+'px;left:'+(Math.random()*$('body').width())+'px;color:#cccc00;font-size:30px;font-weight:bold;text-align:center">PEANUTBUTTER JELLY TIME</div>';
        $('body').append(div);
        easterEgg.interval = setInterval(easterEgg.peanutbutterMove,700);
        setTimeout(easterEgg.stopIt,15000);
    },

    peanutbutterMove:function()
    {
        width = Math.random()*255;
        $('#easteregg').css({
                                left :(Math.random()*$('body').width()),
                                top :(Math.random()*$('body').height())
        });

        $('#easteregg img').css({
                                    width : width,
                                    height: width
                                });
        $('#easteregg2').css({
                                left :(Math.random()*$('body').width()),
                                top :(Math.random()*$('body').height())
        });
    }
}

$(document).ready(function(){
          easterEgg.start();
});
