var submitcount=0;
var Count=0;
function delchk(strin){
	var strdump;
	strdump=new String(strin);
	if (confirm(strdump)){
		return true;
	}
	else{ 
      	return false; 
	}
}

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.fcomment.submit();   
	}
   }
 }

 function validate(){
	if (document.fcomment.names.value == ""){
		alert("Please entered your name ..");
		document.fcomment.names.focus();
		return false;
	}
	if (document.fcomment.email.value == ""){
		alert("Please enter your email ..");
		document.fcomment.email.focus();
		return false;
	}
	if (document.fcomment.comment.value == ""){
		alert("Please enter your comment ..");
		document.fcomment.comment.focus();
		return false;
	}
	if (document.fcomment.comment.value.length >500){
		alert("กรุณาใช้ ความยาวไม่เกิน 500 ตัวอักษร/ความคิดเห็น");
		document.fcomment.comment.focus();
		return false;
	}
	
	if (document.fcomment.email.value != ""){
		checkEmail = document.fcomment.email.value;
			if ((checkEmail.indexOf('@') < 0) || ((checkEmail.charAt(checkEmail.length-4) != '.') && (checkEmail.charAt(checkEmail.length-3) != '.'))) {
			alert("You have entered an invalid email address. Please try again.");
			document.fcomment.email.focus();
			return false;
			}
	}
	  return true; 
}


function newwin( U , w,  h , c ,s) 
{ 
	winny=window.open( U  ,"theWindow","toolbar=0,status=0,scrollbars="+c+",resizable="+s+",width="+w+",height="+h+"");        
    winny.focus() 
}

