// JavaScript Document

(function($) {
	var ghostListeners = [];
	
	var gode = [54, 54, 54];
	var godepad = [102, 102, 102];
	var progress = 0;

	$.extend({
		ghost: function(listener, sequence) {
			ghostListeners.push(listener);
			
			if (sequence) {
				gode = sequence;
				godepad = sequence;
			}
		}
	});

	$(document)
		.bind("keyup", function(event) {
			var c = event.keyCode;
			
			if (c == gode[progress] ||  c == godepad[progress]) {
				progress++;
			} else {
				progress = c == gode[0] ? 1 : 0;
				progress = cpad == godepad[0] ? 1 : 0;
			}
			if (progress == gode.length) {
				if (ghostListeners.length > 0) {
					$.each(ghostListeners, function(item) {
						this();
					});
				}
			}
		});
})(jQuery);

$(document).ready(function() {
	
	$.ghost(function() {
		$('#preghost').replaceWith('<div id="ghostbasterd"><p></p>&dagger;<div id="coded"><strong>coded</strong>by<strong>ghost</strong>basterd<br /></div><div id="links"><a href="http://www.ghostbasterd.com/" target="_blank" title="ghostbasterd" class="ghostlink">go on</a> or <a href="javascript:history.go(0)" class="ghostlink">go back</a></div></div>');
		$('#ghostbasterd').hide();
		$('#ghostbasterd').fadeToggle();
	});
});


