var submitcount=0;
function checksubmit() {               
      if (submitcount == 0) {
         submitcount++;
         return true;
      } else {
        alert("This form has already been submitted.");
        return false;
      }
 }

function submitFunction() {
   if (validate()) { 
     if (checksubmit()) {
	   document.PostForm.submit();   
	}
   }
 }

function validate(){
	
	
  if (PostForm.message.value=="") {
	  alert("A valid comment  is required."); 
	  document.PostForm.message.focus();
	   return false;
  }  
  if (PostForm.sender.value=="") {
      alert("A valid From is required."); 
	  document.PostForm.sender.focus();
	   return false;
  } 
   if (PostForm.passcode.value=="") {
      alert("A valid Code is required."); 
	  document.PostForm.passcode.focus();
	   return false;
  } 
  PostForm.Submit.disabled = true;
  return true; 
}

<!---------------------------------------------->

function priveiw_img(img_src,caption){
			//alert(img_src);
			window.setTimeout("loading_('"+img_src+"','"+caption+"');", 300); // 
			document.getElementById('img_loading_inside').style.height = "auto";
			document.getElementById('img_loading_inside').innerHTML="<img src='../../optionphoto/loading.gif'   border='0' /> Photo Loading..";
} 

function loading_(img_src,caption){
			document.getElementById('img_slide_inside').innerHTML="<img src='"+img_src+"' width='275'  border='0' />";
			document.getElementById('caption_slide_inside').innerHTML=""+caption;
			document.getElementById('img_loading_inside').innerHTML="";
			document.getElementById('img_loading_inside').style.height = "0px";
}

function loading_disable(){
 document.getElementById("commentlist_loading_div").innerHTML=""; 
}
var xmlHttp;
function addComment(newsid,message,sender,code)
{ 
//alert(''+newsid+'\n'+ message+'\n'+sender+'\n'+code);
if (newsid=="") {
	  alert("A valid News ID  is required."); 
	  //document.PostForm.message.focus();
	   return false;
  } 
 if (message=="") {
	  alert("A valid comment  is required."); 
	  document.PostForm.message.focus();
	   return false;
  }  
  if (sender=="") {
      alert("A valid From is required."); 
	  document.PostForm.sender.focus();
	   return false;
  } 
   if (code=="") {
      alert("A valid Code is required."); 
	  document.PostForm.passcode.focus();
	   return false;
  } 
   if (code!=document.PostForm.code_hidden.value) {
      alert("A valid Code is not compare."); 
	  document.PostForm.passcode.focus();
	   return false;
  } 
PostForm.Submit.disabled = true;
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }

var url="/optionphoto/comment_add.php";
url=url+"?newsid="+newsid+"&message="+message+"&sender="+sender+"&passcode="+code;
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function stateChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
	 window.setTimeout('loading_disable()',500);
	 document.getElementById("commentlist_div").innerHTML=xmlHttp.responseText ;
	 document.getElementById("commentlist_loading_div").innerHTML="<img src='../../optionphoto/loading.gif'   border='0' />Loading..";
	 PostForm.Submit.disabled = false;
	 PostForm.passcode.value="";
	 PostForm.sender.value="";
	 PostForm.message.value="";
	 } 
}
function GetXmlHttpObject()
{
		var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 		xmlHttp=new XMLHttpRequest();
 }
  catch (e)
 {
 //Internet Explorer
 try
  {
  		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }return xmlHttp;
}



