$(function() {
	var options = {
		beforeSubmit: function() {
			$.blockUI('Posting your comment...');
		},
		success: function(responseText) {
			if(responseText.match('no-auth')) {
				$.blockUI('You must be logged in before you can comment on this article');
				window.location = '/login';
			} else {
				$("#PostContent").val('').focus();
				$.unblockUI();
				window.location.reload();
				// clearTimeout(fetch_timeout);
				// fetch_new_posts();
			}
		}
	};
	$("div.posts div.submit form").ajaxForm(options);
	
	$("a.reply").livequery("click", function() {
		$("#PostContent").val('@'+$(this).attr('rel')+': ').focus();
		return false;
	});
	// fetch_new_posts();
	// $("#PostContent").focus();
	
	
	// Header Text
	$("h2 span").qtip({
		content: {
			text: "Go to the newspaper's front page"
		},
		show: {
			delay: 10,
			effect: {
				length: 50
			}
		},
		hide: 'mouseout',
		position: {
			corner: {
				target: 'topMiddle',
				tooltip: 'centerMiddle'
			}
		},
		show: {
			effect: {
				length: 600,
				type: 'fade'
			}
		},		
		style: {
		width: 235,
		padding: 5,
		tip: 'bottomMiddle',
		name: 'blue',
		color: '#fff',
		background: '#4485C4',
		border: {
		         width: 5,
		         radius: 5,
		         color: '#4485C4'
		      }
	}
	});
	// Header Image
	$("h2 a.imgreplacement").qtip({
		content: {
			text: "Go to your personal O-MAMA page"
		},
		show: {
			delay: 10,
			effect: {
				length: 50
			}
		},
		hide: 'mouseout',
		position: {
			corner: {
				target: 'topMiddle',
				tooltip: 'centerMiddle'
			}
		},
		show: {
			effect: {
				length: 600,
				type: 'fade'
			}
		},		
		style: {
		width: 215,
		padding: 5,
		tip: 'bottomMiddle',
		name: 'blue',
		color: '#fff',
		background: '#4485C4',
		border: {
		         width: 5,
		         radius: 5,
		         color: '#4485C4'
		      }
	}
	});
});