// JavaScript Document

/* Konami Code for MooTools; Author: Horseweapon */
Element.Events.konami = {
	base: 'keyup',
	condition: function(e){
		$clear(this.retrieve('konami_timeout'));
		var input = this.retrieve('konami_input',[]);
		input.push(e.key);
		if( input.join(',') == "up,up,down,down,left,right,left,right,b,a,enter" )
		{
			this.removeEvents('konami');
			return true;
		}
		this.store('konami_input',input).store('konami_timeout',(function(){this.eliminate('konami_input');}).delay(2000,this));
	}
};
var content, cheat, tweets, tweetset;
var undo = function(){
	$clear( cheat );
	$('main').empty();
	$('main').set('html',content);
	$('header').empty();
};
/*var boom = function(){
	$('main').empty();
	$('header').set('html','<a onclick="javascript:undo();">Undo</a>');
	new Swiff('images/DS.swf',{id:"desert_survivor",container:$('main'),width:640,height:480});
}*/
var alternate = [
	'a c-c-c-c-combo breaker.',
	'available in nearly all colours.',
	'ready to kick ass and chew bubblegum... and is all outta gum.',
	'a gentleman\'s game, however may contain harsh language and electronic violence.',
	'about to be eaten by a grue.',
	'suspecting that the princess is in another castle.',
	'a monster. RAWR!',
	'NaN.',
	'the reason people love you.',
	'getting Keyboard Cat ready to play you off.',
	'only in it for the lulz and the gold.',
	'level 80, and has a mount.',
	'going to let you enjoy that sweet, sweet taste of success.',
	'about to bring the chocolate rain.',
	'your father.',
	'in ur base, killing all ur d00dz.',
	'never gonna give you up, never gonna let you down, never gonna run around and desert you...',
	'the master of unlocking.',
	'serious business.',
	'startling the witch.',
	'crossing the streams'
]
var boom = function(){
	$('header').set('html','<a onclick="javascript:undo();">Undo</a>');
	var tech = function(){ $('main').set('html','<h2>What is TechBoom?</h2><p>Techboom is ' + alternate.getRandom() + '</p>') };
	tech();
	cheat = tech.periodical(5000);
}
/* TwitterPop */
var loadTweets = function(json){
	tweets = json.results;
	while(tweets.length < 3){ tweets[tweets.length] = {created_at: new Date().toString(), text: '<p>Techboom is ' + alternate.getRandom() + '</p>'}; }
}
var tweetpop = function(){
	$clear(tweetset);
	//debugger;
	var tweet = tweets.shift();
	tweets.push(tweet);
	var tweetdate = new Date(tweet.created_at);
	$$('#twitterpop div.tweet div.when')[0].set('html', tweetdate.toLocaleDateString() + ' - ' + tweetdate.toLocaleTimeString() );
	$$('#twitterpop div.tweet div.body')[0].set('html', tweet.text);
	var height = $$('#twitterpop div.tweet')[0].getSize().y;
	$('twitterpop').morph({
		opacity: 1,
		width: [0, 400],
		height: [0, (height + 10)],
		top: [275, (275 - (height / 2))],
		right: [150, 175]
	});
	tweetset = tweetout.delay(6000);
}
var tweetout = function(){
	$('twitterpop').tween('opacity', [1, 0]);
}
/* End TwitterPop */
