function tabinfoboard(num) {
	 for(i=1; i<=4;i++){
		   document.getElementById('infoboard'+i).style.display = "none";
		   document.getElementById('infotab'+i).style.backgroundColor = "#CCCCCC";
	 }
	 document.getElementById('infoboard'+num).style.display = "block";
	 document.getElementById('infotab'+num).style.backgroundColor = "#9F9F9F";
	 document.getElementById('addpicture').style.display = "none";
}

function closetabinfoboard() {
	 for(i=1; i<=4;i++){
		   document.getElementById('infoboard'+i).style.display = "none";
		   document.getElementById('infotab'+i).style.backgroundColor = "#CCCCCC";
		   document.getElementById('addpicture').style.display = "none";
	 }
}

function actcode(id) {
	 for(i=1; i<=2;i++){
		   document.getElementById('code'+i+'left').style.display = "none";
		   document.getElementById('imcode'+i).style.display = "none";
	 }
	 document.getElementById('code'+id+'left').style.display = "block";
	 document.getElementById('imcode'+id).style.display = "block";
	 document.getElementById('addpicture').style.display = "none";
}


function tabcode(id) {
	 for(i=1; i<=4;i++){
		   document.getElementById('infoboard'+i).style.display = "none";
		   document.getElementById('infotab'+i).style.backgroundColor = "#CCCCCC";
	 }
	 document.getElementById('infoboard4').style.display = "block";
	 document.getElementById('infotab4').style.backgroundColor = "#9F9F9F";
	 for(i=1; i<=2;i++){
		   document.getElementById('code'+i+'left').style.display = "none";
		   document.getElementById('imcode'+i).style.display = "none";
	 }
	 document.getElementById('code'+id+'left').style.display = "block";
	 document.getElementById('imcode'+id).style.display = "block";
	 document.getElementById('addpicture').style.display = "none";
}

function addpicture() {
	  document.getElementById('addpicture').style.display = "block";
}

function infoboardtopcontent(num) {
	 for(i=1; i<=3;i++){
		   document.getElementById('infoboarduser'+i).style.display = "none";
		   document.getElementById('topuser'+i).style.backgroundColor = "";
	 }
	 document.getElementById('infoboarduser'+num).style.display = "block";
	 document.getElementById('topuser'+num).style.backgroundColor = "#757575";
}


function infoboarduser(num) {
	 for(i=1; i<=2;i++){
		   document.getElementById('infoboarduser'+i).style.display = "none";
	 }
	 document.getElementById('infoboarduser'+num).style.display = "block";
}


function showmod(num) {
	 if(num == 1){
		  document.getElementById('showmod').style.display = "block";
	 }else{
		  document.getElementById('showmod').style.display = "none";
	 }
}

function undisabled(num) {
	 for(i=1; i<=9;i++){
		   document.getElementById('image'+i).disabled = true;
	 }
	 if(num == 2){
	      for(i=2; i<=9;i++){
		     document.getElementById('image'+i).disabled = false;
		  }
	 }else{
	      document.getElementById('image'+num).disabled = false;
	 }
}

function checkreg() {
	 document.getElementById('_regname').innerHTML = "ชื่อ";
	 document.getElementById('_regpass').innerHTML = "รหัสผ่าน";
	 document.getElementById('_regrepass').innerHTML = "ยืนยันรหัสผ่าน";
	 document.getElementById('_regmail').innerHTML = "อีเมล์";

	 var uname=document.userinfoboard.regname;
	 var upass=document.userinfoboard.regpass;
	 var repass=document.userinfoboard.regrepass;
	 var email=document.userinfoboard.regmail;


    if(uname.value=="") 
     {
	 document.getElementById('_regname').innerHTML = "<span class=\"inputerror\">กรุณาใส่ชื่อ</span>";
	 uname.focus() ;
     return false ;
     }
    if(upass.value=="") 
     {
	 document.getElementById('_regpass').innerHTML = "<span class=\"inputerror\">กรุณาใส่รหัสผ่าน</span>";
	 upass.focus() ;
     return false ;
     }
    if(repass.value=="") 
     {
	 document.getElementById('_regrepass').innerHTML = "<span class=\"inputerror\">กรุณายืนยันรหัสผ่าน</span>";
	 repass.focus() ;
     return false ;
     }
    if(upass.value != repass.value) 
     {
	 document.getElementById('_regrepass').innerHTML = "<span class=\"inputerror\">ยืนยันรหัสผ่านไม่ถูกต้อง</span>";
	 repass.focus() ;
     return false ;
     }

    if(email.value=="") 
     {
	 document.getElementById('_regmail').innerHTML = "<span class=\"inputerror\">กรุณาใส่อีเมล์</span>";
	 email.focus() ;
     return false ;
     }
	 if (email.value.indexOf('@', 0) == -1 || email.value.indexOf('.', 0) == -1)
	{ 
	 document.getElementById('_regmail').innerHTML = "<span class=\"inputerror\">อีเมล์ไม่ถูกต้อง</span>";
	 email.focus() ;
     return false ;
	 }

	 //document.getElementById('submit').disabled = true;
	 document.userinfoboard.action="./_req/userinfoboard.php";
	 document.userinfoboard.submit();
}

function checklogin() {
	 document.getElementById('_infoname').innerHTML = "ชื่อ";
	 document.getElementById('_infopass').innerHTML = "รหัสผ่าน";

	 var uname=document.userinfoboard.infoname;
	 var upass=document.userinfoboard.infopass;

    if(uname.value=="") 
     {
	 document.getElementById('_infoname').innerHTML = "<span class=\"inputerror\">กรุณาใส่ชื่อ</span>";
	 uname.focus() ;
     return false ;
     }
    if(upass.value=="") 
     {
	 document.getElementById('_infopass').innerHTML = "<span class=\"inputerror\">กรุณาใส่รหัสผ่าน</span>";
	 upass.focus() ;
     return false ;
     }

	 //document.getElementById('submit').disabled = true;
	 document.userinfoboard.action="./_req/userinfoboard.php";
	 document.userinfoboard.submit();
}

function checkforget() {
	document.getElementById('_regmail').innerHTML = "อีเมล์";
	var email=document.userinfoboard.forgetmail;

    if(email.value=="") 
     {
	 document.getElementById('_forget').innerHTML = "<span class=\"inputerror\">กรุณาใส่อีเมล์</span>";
	 email.focus() ;
     return false ;
     }
	 if (email.value.indexOf('@', 0) == -1 || email.value.indexOf('.', 0) == -1)
	{ 
	 document.getElementById('_forget').innerHTML = "<span class=\"inputerror\">อีเมล์ไม่ถูกต้อง</span>";
	 email.focus() ;
     return false ;
	 }

	 //document.getElementById('submit').disabled = true;
	 document.userinfoboard.action="./_req/userinfoboard.php";
	 document.userinfoboard.submit();
}

function checkreport() {
	document.getElementById('_report').innerHTML = "แจ้งกระทู้ไม่เหมาะสม";
	var txtreport=document.freport.report;

    if(txtreport.value=="") 
     {
	 document.getElementById('_report').innerHTML = "<span class=\"inputerror\">แจ้งกระทู้ไม่เหมาะสม</span>";
	 txtreport.focus() ;
     return false ;
     }
	 document.freport.action="./_req/report.php";
	 document.freport.submit();
}

function openselect(form){
	var newIndex = form.iselect.selectedIndex; 
		cururl = form.iselect.options[newIndex].value; 
		window.location.assign(cururl); 
} 


function rusure() { 
	if (confirm("โปรดยืนยันการลบ?")) { 
		return true; 
	} else { 
		return false;
	} 
} 


function checksearch()
{
	 var q=document.issearch.q.value
		 if (q == "") {
		     alert("โปรดกรอกข้อมูลในช่องค้นหา");
			 issearch.q.focus();
			 return false;
		 }else{
			 return true; 
		 }
}


function callAHAH(url, pageElement, callMessage, errorMessage) {
     document.getElementById(pageElement).innerHTML = callMessage;
     try {
     req = new XMLHttpRequest(); /* e.g. Firefox */
     } catch(e) {
       try {
       req = new ActiveXObject("Msxml2.XMLHTTP");  /* some versions IE */
       } catch (e) {
         try {
         req = new ActiveXObject("Microsoft.XMLHTTP");  /* some versions IE */
         } catch (E) {
          req = false;
         } 
       } 
     }
     req.onreadystatechange = function() {responseAHAH(pageElement, errorMessage);};
     req.open("GET",url,true);
     req.send(null);
  }

function responseAHAH(pageElement, errorMessage) {
   var output = '';
   if(req.readyState == 4) {
      if(req.status == 200) {
         output = req.responseText;
         document.getElementById(pageElement).innerHTML = output;
         } else {
         document.getElementById(pageElement).innerHTML = errorMessage+"\n"+output;
         }
      }
  }



function selectgroup(form) { 
	var newIndex = form.gid.selectedIndex; 
		id = form.gid.options[newIndex].value; 
		document.getElementById('disbutton').style.display = "none";
		callAHAH('./_req/selgroup.php?cid='+id, 'infoboardshow', '<img src="./_img/tranloader.gif" border="0" /> Loading Please Wait...', 'Error'); 
}

function groupid(id) { 
		document.getElementById('disbutton').style.display = "none";
		callAHAH('./_req/selgroup.php?cid='+id, 'infoboardshow', '<img src="./_img/tranloader.gif" border="0" /> Loading Please Wait...', 'Error'); 
}


