
(function($) {
	$(function() {
		// Check if hash is "nyt_indlaeg". If so, open the debate form
		(function() {
			var url = window.location.href;
			var hash = /^.*?(?:#(.*))?$/.exec(url)[1];
			
			if(hash == 'nyt_indlaeg') {
				$('form#plaza_new_post').show();
			}
		})();
		
		// Dynamicly apply '#nyt_indlaeg' to the return url
		$('.article_buttons.bottom a.forum.new_post').click(function() {
			var form_return_url = $('form#login-form input[name=return_url]');
			
			form_return_url.val(form_return_url.val().replace(/^(.*)#.*$/, "$1") + '#nyt_indlaeg');
		});
	});
})(jQuery);

