jQuery(document).ready(function() {
	trigger();
});

function trigger () {
	var t = setTimeout("liveComments()", 20000);	
}

function liveComments() {
	jQuery.ajax({
		type: "POST",
		url: "../functions.php",
		data: "live_comments=1",
		success: function(msg){
			// alert(msg)
			if (msg !="<div class=\"livecomments\"></div>") {
				if (jQuery(".livecomments").size() == "0") {
					jQuery(msg).insertAfter('#container').hide().fadeIn("fast");
				} else {
				// alert(msg)
					jQuery(".livecomments").replaceWith(msg);
				}
			} else {
				jQuery(".livecomments").fadeOut("fast").remove();
			}
			// alert(functionName);
			// jQuery(functionName).prev().replaceWith(msg);
			// jQuery(functionName).prev().fadeOut("fast").fadeIn("fast")
			// setTimeout(liveComments(), 100000);	
			trigger();
			afterAjax();
		}
	})

}
