function onKonamiCode(fn) {
    var codes = (function(){
            var c = [38,38,40,40,37,39,37,39,66,65];
            onKonamiCode.requireEnterKey && c.push(13);
            return c;
        })(),
        expecting = function(){
            expecting.codes = expecting.codes || Array.apply({}, codes);
            expecting.reset = function() { expecting.codes = null; };
            return expecting.codes;
        },
        handler = function(e) {
            if (expecting()[0] == (e||window.event).keyCode) {
                expecting().shift();
                if (!expecting().length) {
                    expecting.reset();
                    fn();
                }
            } else { expecting.reset(); }
        };
    window.addEventListener ?
        window.addEventListener('keydown', handler, false)
        : document.attachEvent('onkeydown', handler);
}

/*!
 * jQuery Conditional Plugin v1.0
 * http://outwestmedia.com/jquery-plugins/conditional/
 *
 * Released: 2009-09-07
 * Version: 1.0
 *
 * Copyright (c) 2009 Jonathan Sharp, Out West Media LLC.
 * Dual licensed under the MIT and GPL licenses.
 * http://docs.jquery.com/License
 *
 * Usage:
 * 	[Basic]
 *
 */
/**
	Basic
	 $('selector')
		.If('hasClass', 'foo')
			.find('> child')
				.doSomething()
			.end()
		.Else()
			.doSomethingElse()
		.end();
	
	Complex
		.If('attr', 'title', 'Some Title')
		.If('hasClass', 'foo', false)
	
	Functions
		.If(function() { return this == that; })
	
	Else
		.Else()
		or
		.Else('conditions')
*/
(function($) {
	$.fn.If = function() {
		var test;
		if ( arguments[0] === true || arguments[0] === false ) {
			test = arguments[0];
		} else if ( $.isFunction(arguments[0]) ) {
			test = arguments[0].apply(this, Array.prototype.slice.call(arguments, 1));
		} else {
			test = this[arguments[0]].apply(this, $.makeArray( arguments[1] ) );
			if ( arguments.length == 3 ) {
				test = ( test == arguments[2] );
			}
		}
		this._ifTest = !!test;
		if ( test ) {
			
		}
		var ret = this.pushStack( this );
		ret._ifTest = false;
		return ret;
	};
	$.fn.Else = function() {
		var prev = this.end();
		if ( ! prev._ifTest ) {
			if ( arguments.length > 0 ) {
				var ret = $.fn.If.apply(this, arguments);
				if ( ret._ifTest !== false ) {
					return ret;
				}
			} else {
				return this;
			}
		}
		return this.pushStack( [] );
	};
	$.fn.orIfEmpty = function(fn) {
		if ( this.length == 0 ) {
			fn.call(this);
		}
		return this;
	};
})(jQuery);

