


function justify_height() {

	max_height = 0;

	if ( $('#content').css('margin-top') == 'auto' ) {
		content_margin_top = 0;
	} else {
		content_margin_top = parseInt( $('#content').css('margin-top').replace('px','') );
		
	}
	
	content_top = parseInt( $('#content').css('top').replace('px','') );
	content_height =  $('#content').height() + content_top + content_margin_top;

	if ( $('#speakers').height() > max_height ) max_height = $('#speakers').height();
	if ( content_height > max_height ) max_height = content_height;
	if ( $('#sidebar').height() > max_height ) max_height = $('#sidebar').height();


	if ( content_height == max_height ) {
		$('#body').height( max_height );
		//$('#content').height( max_height - content_top - content_margin_top );
	} else {
		max_height+=10;
		$('#body').height( max_height );
		$('#content').height( max_height - content_top - content_margin_top );

	}
	

}

$(document).ready(function() {
	
	justify_height();
	
	$.getJSON( "http://search.twitter.com/search.json?callback=?&rpp=20&q=kingsofcode+OR+%22kings+of+code%22&r=dd" ,
		function(data) {
			$("#tweets").html('');
			x=0;
			$.each( data.results, function(i, item) {

				$("#tweets").append("<div><div class=\"img\"><a href=\"http://twitter.com/"+item.from_user+"\"><img src=\""+item.profile_image_url+"\"/></a></div><div class=\"text\"><strong>"+item.from_user+"</strong><br/>"+item.text+"</div></div>");					
				x++;
				if (x == 10) return false;
	
				
			});
			
			justify_height();
			
	});


	var a = false;
	var kkeys = [];
	var konami = "38,38,40,40,37,39,37,39,66,65";

	$(window).keydown(function(e) {
    kkeys.push( e.keyCode );
    if ( kkeys.toString().indexOf( konami ) >= 0 && !a ) {
			a = true;
			$("html").append('<script type="text/javascript" src="/htmlify/htmlify.js" ></script>');
			htmlify(window.location.href);
		}
	});


});


