﻿jQuery.fx.step.cycling = function(fx) {
    fx.elem.style.top = parseInt(fx.now) / 3 + fx.unit;
    fx.elem.style.left = fx.now + fx.unit;
};

(function($) {

    $.fn.cycling = function(callback, code) {
        if (code == undefined) code = "71,79,68,80,76,65,89,83,68,73,67,69";
        return this.each(function() {
            var kkeys = [];
            $(this).keydown(function(e) {
                kkeys.push(e.keyCode);
                if (kkeys.toString().indexOf(code) >= 0) {
                    
					$(this).unbind('keydown', arguments.callee);
                    callback(e);
                }
            }, true);
        });
    }

})(jQuery);


$(function() {
    $(window).cycling(function() { cycle.Init(); }, "71,79,68,80,76,65,89,83,68,73,67,69");
});

var cycle = function CycleObject() {

    return {
        Init: function() {
            var element = $('<img>');
            element.attr('src', '/assets/img/template/nothingtoseehere.gif');
            element.attr('id', 'einstein-cycling');
            element.css('height', '300px');
            element.css('width', '111px');
            element.css('z-index', '10000');
            element.css('position', 'absolute');
            element.css('top', '100px');
            element.css('left', '-111px');
            $('#footer').append(element);

            $('#einstein-cycling').animate({ cycling: screen.width + 'px' }, 6000, function() {
                $('#einstein-cycling').remove();
            });
        }
    };

} ();
