// JavaScript Config
var loading = "<div id=\"loading\" class=\"loading\"><img src='img/ajax-loader.gif' /> Loading...</div>";
$(document).ready(function() {
	$("#content").empty();
	$("#content").append(loading);
	$("#content").load("comments.php").show('slow');
}); 
function getPage(p) {	
	$("#content").empty();
	$("#content").append(loading);
	$("#content").load("comments.php?page="+p).show('slow');		
}
function addCom() {
	$.post("addmsg.php", { nick: $("#nick").val(), msg: $("#msg").val(), captcha: $("#captcha").val(), captcha2: $("#captcha2").val() },
  	function(data){
		$("#erg").html(data);	
    	$("#content").empty();
		$("#content").append(loading);
		$("#content").load("comments.php").show('slow');
	});
	clearForm();
}
function clearForm() {
	$(':input').each(function() {
		var type = this.type;
		var tag = this.tagName.toLowerCase(); // normalize case
		if (type == 'text' || type == 'password' || tag == 'textarea')
			this.value = "";
		else if (type == 'checkbox' || type == 'radio')
			this.checked = false;
		else if (tag == 'select')
			this.selectedIndex = -1;
	});
};


