// JavaScript Document

function comment()
{
var comment=document.forms["commentform"]["comment"].value
var name=document.forms["commentform"]["name"].value
var email=document.forms["commentform"]["email"].value
var auto=document.forms["commentform"]["auto"].value
var capchaenter=document.forms["commentform"]["capchaenter"].value
var capchaans=document.forms["commentform"]["capchaans"].value

var submitcomment=true;

if (name == ""){document.getElementById("hiddenname").style.display = "block";submitcomment=false;}else{document.getElementById("hiddenname").style.display = "none";}
if (comment == ""){document.getElementById("hiddencomment").style.display = "block";submitcomment=false;}else{document.getElementById("hiddencomment").style.display = "none";}
if (email == ""){document.getElementById("hiddenemail").style.display = "block";submitcomment=false;}else{document.getElementById("hiddenemail").style.display = "none";}

$.ajax({
	url: "scripts/capcha.php?capchaans="+capchaans+"&capchaenter="+capchaenter,
	success: function(data){
	if(data=="false")
		{
		document.getElementById("hiddencapcha").style.display = "block";
		submitcomment=false;
		}else{
			document.getElementById("hiddencapcha").style.display = "none";
			if (submitcomment)
				{
					document.getElementById("load").style.display = "block"
					comment=comment.replace(/&/g, "and");
					$.ajax({
						
						  url: "scripts/comment.php?auto="+auto+"&name="+name+"&email="+email+"&comment="+comment,
						  success: function(data){
							if(data!="")
							{
								document.getElementById("newcomment").style.display = "block"
								document.getElementById("newcomment").innerHTML = data;
								document.getElementById("load").style.display = "none"
								$(document).ready(function(){
									$("#add").slideUp("slow");
									document.getElementById("clear").style.display = "none";
								});

							}
						
						  }
					});
				}

			}
	}
});

}
