Konami = function(callback){

    this.happn = {
         "addEventListener" : function(element, eventName, eventHandler, scope)
        {
            var scopedEventHandler = scope ? function(e) { eventHandler.apply(scope, [e]); } : eventHandler;
            if(document.addEventListener)
                element.addEventListener(eventName, scopedEventHandler, false);
            else if(document.attachEvent)
                element.attachEvent("on"+eventName, scopedEventHandler);
        }
    }
    this.targetFF = window;
    this.targetIE = document.body;


    this.callback=null;
    if(callback!==undefined)
        this.callback = callback;

    this.keysPressed  = [];
    this.timer        = false;
    this.konamiString = "38,38,40,40,37,39,37,39,66,65,13";
       // up, up, down, down, left, right, left, right, B, A, enter


}

Konami.prototype.setTimer = function() {
    var Konami = this;

    function timerRelay() {
        Konami.restartKonami();
    }

    if(this.timer==false){
        this.timer=true;
        setTimeout(timerRelay, 2000);
    }
}

Konami.prototype.attachEvent = function(){
    if (window.addEventListener) {
        this.setUpFirefox();
    }else if(document.body.attachEvent) {
        this.setUpIE();     

    }
}

Konami.prototype.restartKonami = function(){
    this.keysPressed=[];
    this.timer=false;
}

Konami.prototype.keyHandler = function(e){
    if(this.timer==false){
        this.setTimer();
    }
    this.keysPressed.push(e.keyCode );
    if (this.keysPressed.toString().indexOf(this.konamiString) >= 0 ){
        this.showKonami();
    }
}

Konami.prototype.setUpFirefox = function(){
    this.happn.addEventListener(this.targetFF,'keydown',this.keyHandler,this);
}


Konami.prototype.setUpIE = function(){
    this.happn.addEventListener(this.targetIE,'keydown',this.keyHandler,this);
}

Konami.prototype.showKonami = function(){

    if(this.callback!==null)
        this.callback.call();
    else
        alert('konamiiii');

}