(function($){
	$.youtubeResize = function() {
		$('embed[src*="youtube.com"]').each(function(){
			sizeRatio = $(this).attr('width') / $(this).attr('height');
			newWidth = $(this).parent().parent().width();
			newHeight = Math.round(newWidth / sizeRatio);
			$(this)
				.attr('width', newWidth)
				.attr('height', newHeight)
				.parent()
					.attr('width', newWidth)
					.attr('height', newHeight);
		});
	};
})(jQuery);

jQuery(document).ready(function($){
	var searchDefault = $('.searchInput:first').val();
	$('.searchInput').bind('focus blur', function(){
		switch ( $(this).val() ) {
			case '':
				$(this).val(searchDefault);
				break;
			case searchDefault:
				$(this).val('');
		}
	});

	$('.edit,.actions').hide();
	$('.post,.comment')
		.bind('mouseenter', function(){
			$(this).find('.edit,.actions').show();
		})
		.bind('mouseleave', function(){
			$(this).find('.edit,.actions').hide();
		});

	$.youtubeResize();
});
