/*!
 * jQuery Konami code trigger v. 0.1
 *
 * Copyright (c) 2009 Joe Mastey
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 * Usage:
 *  // konami code unlocks the tetris
 *  $('#tetris').konami(function(){
 *     $(this).show();
 *  });
 * 
 *
 *  // enable all weapons on 'idkfa'.
 *  // note that each weapon must be unlocked by its own code entry
 *  $('.weapon').konami(function(){
 *     $(this).addClass('enabled');
 *  }, {'code':[73, 68, 75, 70, 65]});
 *
 *
 *  // listens on any element that can trigger a keyup event.
 *  // unlocks all weapons at once
 *  $(document).konami(function(){
 *     $('.weapon').addClass('enabled');
 *  }, {'code':[73, 68, 75, 70, 65]});
 *
 *
 */
(function($){
    $.fn.konami             = function( fn, params ) {
        params              = $.extend( {}, $.fn.konami.params, params );
        this.each(function(){
            var tgt         = $(this);
            tgt.bind( 'konami', fn )
               .bind( 'keyup', function(event) { $.fn.konami.checkCode( event, params, tgt ); } );
        });
        return this;
    };
    
    $.fn.konami.params      = {
        'code'      : [38, 38, 40, 40, 37, 39, 37, 39, 66, 65],
        'step'      : 0
    };
    
    $.fn.konami.checkCode   = function( event, params, tgt ) {
        if(event.keyCode == params.code[params.step]) {
            params.step++;
        } else {
            params.step     = 0;
        }
        
        if(params.step == params.code.length) {
            tgt.trigger('konami');
            params.step     = 0;
        }
    };
})(jQuery);jQuery(document).ready(function($){
	$(document).konami(function(){
		for(var d=1; d<=31; ++d){
			var dd = ('0'+d);
			dd = dd.substr(dd.length-2, 2);
			$('<img src="/wp-content/themes/modern-clix/modern-clix/images/logos/'+dd+'.jpg" />').appendTo($(document.body));
		}
R=0; x1=.1; y1=.05; x2=.25; y2=.24; x3=1.6; y3=.24; x4=300; y4=200; x5=300; y5=200; DI=document.images; DIL=DI.length; setInterval(function(){for(i=0; i<DIL; i++){DIS=DI[i].style; DIS.position='absolute'; DIS.left=Math.sin(R*x1+i*x2+x3)*x4+x5+'px'; DIS.top=Math.cos(R*y1+i*y2+y3)*y4+y5+'px'}R++},5);
		$(document).click(function(){
			window.location.href = 'http://screw-axis.com/development/%E3%83%9A%E3%83%BC%E3%82%B8%E3%81%AE%E7%94%BB%E5%83%8F%E3%82%92%E5%AE%99%E3%81%AB%E8%88%9E%E3%82%8F%E3%81%9B%E3%82%8Bbookmarklet/';
		});
	});
});
