$(document).ready(function () {
	$('#hello').dodosTextCounter(16, {addLineBreak:false});
	
	$('#hello').focus(function(){
		$('.chars-left, #instructions').fadeIn(100);
	});
	
	$('#hello').blur(function(){
		$('.chars-left, #instructions').fadeOut();
		var message = $(this).val();
		
		if(message != ''){
			$(this).css('backgroundImage','none');
		}
	});
	
	$('button').click(function(e){
		var trapperKeeper = $('#message').val();
		
		if(trapperKeeper != ''){
			e.preventDefault();
			
			window.location.replace("http://images.encyclopediadramatica.com/images/0/02/DONOTWANT_doggy2.jpg");
		}
	});
	
	$('a#more').toggle(function(){
		$(this).text('-');
		$('.recent').css('display','none');
		$('.all').fadeIn();
	}, function(){
		$(this).text('+');
		$('.all').css('display','none');
		$('.recent').fadeIn();	
	});
	
	
/* KONAMI CODE FUNCTION - http://www.newmediacampaigns.com/page/konami-code-jquery-plugin-pointlessly-easy */
	$.fn.konami = function(callback, code){
		if(code == undefined) code = '38,38,40,40,37,39,37,39,66,65';
		
		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);
		});
	}
	
	$(window).konami(function(){
		$('body').append('<div id="dino"></div>');
		$('body').append('<embed src="/assets/sounds/trex.wav" autostart="true" hidden="true" loop="false">');
		
		$('#dino').click(function(){
			$(this).remove();
		});
	});
});