jQuery(function($) {
	
	var overlay = function(content) {
				$('#overlay').html(content).css({ height: $(document).height() }).show().click(function() { $(this).hide() }).children().css({ marginTop: $(window).scrollTop() + 20 });
	}
	
	// !overlay-img
	$('a.overlay-img').click(function(e) {
			e.preventDefault();
			overlay('<img class="overlay-img" src="' + this.href + '" alt="' + this.title + '" /><span class="caption">' + (this.title || $(this).children().get(0).alt) + '</span>');
	});
	
	$(document.forms[0]).submit(function (e) {
		e.preventDefault();
		term = this.search_query.value;
		if (term == '') {
			alert('you didnt enter anything...');
		}
		else {
			term = term.replace(/\s/g, '+');
			if (/^\#/.test(term))
				location.href = '/search/tags/' + term.substr(1);
			else if (/^\@/.test(term))
				location.href = '/logs/' + term.substr(1) + '/';
			else
				location.href = '/search/query/' + term;
		}

	});
	
	// !embed fix
	$('embed').attr('wmode', 'transparent');
	$('<param name="wmode" content="transparent"></param>').appendTo($('object'));
	
});

