function validateLogin(a,b){
	if(a=="" ||  b ==""){
		alert("Please input the valid login and password");
		return false;
	}
	else{
		/* no action*/
	}
}

var validphone = /^([0-9]{7,15})$/;
function mValidate(mform){
	if(mform.mfname.value==""){
		alert("Please fill in Menber's Name");
		mform.mfname.focus();
		return false;
	}
	else if(mform.mlname.value==""){
		alert("Please fill in Team member Birthday's date");
		mform.mlname.focus();
		return false;
	}
	else if(mform.memail.value==""){
		alert("Please fill in member's email");
		mform.memail.focus();
		return false;
	}
	else if ((mform.memail.value!="") && (checkemail(mform.memail.value)==false)) {
		alert("Please fill in a valid member's email");
		mform.memail.focus();
	}
	else if(mform.mpassword.value==""){
		alert("Please fill in Team member Birthday's year");
		mform.mpassword.focus();
		return false;
	}
	else{
		mform.submit();
	}
}

function checkemail(str) {
	var filter =/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,7}|\d+)$/i;
	return (filter.test(str))
}

function ShowImage(sImageName)
{
   window.open(sImageName, "Image", "width=250,height=250,status=no,resizable=yes,scrollbars=yes");
}
function ShowFile(sFileName)
{
   window.open(sFileName, "File", "width=550,height=550,status=no,resizable=yes,scrollbars=yes");
}
function PopupChatroom(pathurl)
{
	window.open(pathurl,"Chatroom","menubar=no,width=800,height=600,toolbar=no,resizable=yes,scrollbars=yes");
}

function validateRegiserForm(objForm){
	if(objForm.email.value == ""){
		alert("กรุณากรอกอีเมล");
		objForm.email.focus();
		return false;
	}
		else if(objForm.email.value.indexOf('@')==-1)
	{
   		alert("กรุณากรอกอีเมลให้ถูกต้อง");
    	objForm.email.focus();
		return false;
	}
		else if(objForm.email.value.indexOf('.')==-1)
	{
   		alert("กรุณากรอกอีเมลให้ถูกต้อง");
    	objForm.email.focus();
		return false;
	}
		else if(objForm.loginname.value == ""){
		alert("กรุณากรอกล็อกอินเนมให้ถูกต้อง");
		objForm.loginname.focus();
			return false;
	}
		else if(objForm.password.value == ""){
		alert("กรุณากรอกพาสเวิร์ดให้ถูกต้อง");
		objForm.password.focus();
			return false;
	}
	else if(objForm.fullname.value == ""){
		alert("กรุณากรอกชื่อและนามสกุลให้ถูกต้อง");
		objForm.fullname.focus();
		return false;
	}
	else{
				return true;
	}
}



function validateForgotPasswordForm(objForm){
	if(objForm.email.value == ""){
		alert("กรุณากรอกอีเมล");
		objForm.email.focus();
		return false;
	}
		else if(objForm.email.value.indexOf('@')==-1)
	{
   		alert("กรุณากรอกอีเมลให้ถูกต้อง");
    	objForm.email.focus();
		return false;
	}
		else if(objForm.email.value.indexOf('.')==-1)
	{
   		alert("กรุณากรอกอีเมลให้ถูกต้อง");
    	objForm.email.focus();
		return false;
	}
		else if(objForm.loginname.value == ""){
		alert("กรุณากรอกล็อกอินเนมให้ถูกต้อง");
		objForm.loginname.focus();
			return false;
	}
	else{
				return true;
	}
}
/*
function addClickHandlers() {
   $("select.openSite", this).change(function() {
     $("#target").load(this.href, addClickHandlers);
   });
 }
 $(document).ready(addClickHandlers);
*/
 // function for เว็บไซต์ที่เกี่ยวข้อง

 $(document).ready(function(){
  $("select.optSite").change(function () {
          $("select option:selected").each(function () {
					if($(this).val() != ""){
						window.open($(this).val());
					}
              });
        })
  });

/*  sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
*/
function ShowGame(pathurl,w,h)
{
   if(!w && !h){
	   window.open(pathurl, "Game", "width=1000,height=700,status=no,resizable=yes,scrollbars=yes");
   }
   else
   {
	   window.open(pathurl, "Game", "width="+w+",height="+h+",status=no,resizable=yes,scrollbars=yes");
   }
}


$(document).ready(function(){
   // ค้นหา a ลิงก์ที่อยู่ใต้ section ใดๆ
   $("a")
   	.filter("#middle_content .q")
	   .click(function(){
	   		//กำหนด path ที่จะไปดึงหน้าปลายทางมาแสดงผล
			var oPath=this.name + ".php";
			//ส่วนที่ต้องการแสดงผล
			$('#quest').load(oPath);
		 })
 	  .end()
 });
 
 
 $(document).ready(function(){
   // ค้นหา a ลิงก์ที่อยู่ใต้ section ใดๆ
   $("input")
   	.filter("#quest")
	   .submit(function(){
	   		//กำหนด path ที่จะไปดึงหน้าปลายทางมาแสดงผล
			var oPath="questionthanks.php";
			//ส่วนที่ต้องการแสดงผล
			$('#quest').load(oPath);
		 })
 	  .end()
 });
 
 
 /* HOVER ACTION */
 sfHover = function() {
	// Find all unordered lists.
	var ieNavs = document.getElementsByTagName('ul');
	for(i=0; i<ieNavs.length; i++) {
		var ul = ieNavs[i];
		// If they have a class of nav add the menu hover.
		if(ul.className == "nav")
			setHover(ul);
	}

}

function setHover(nav) {
	var ieULs = nav.getElementsByTagName('ul');
	if (navigator.appVersion.substr(22,3)!="5.0") {
		// IE script to cover <select> elements with <iframe>s
		for (j=0; j<ieULs.length; j++) {
			var ieMat=document.createElement('iframe');
			if(document.location.protocol == "https:")
				/*ieMat.src="//0";*/
				ieMat.src="javascript:false";
			else
				ieMat.src="javascript:false";
			ieMat.scrolling="no";
			ieMat.frameBorder="0";
			ieMat.style.width=ieULs[j].offsetWidth+"px";
			ieMat.style.height=ieULs[j].offsetHeight+"px";
			ieMat.style.zIndex="-1";
			if(ieULs[j].childNodes[0]) {
					ieULs[j].insertBefore(ieMat, ieULs[j].childNodes[0]);
			}
			ieULs[j].style.zIndex="101";
		}
		// IE script to change class on mouseover
		var ieLIs = nav.getElementsByTagName('li');
		for (var i=0; i<ieLIs.length; i++) if (ieLIs[i]) {
			// Does this LI have children? If so add a sfnode class.
			if (ieLIs[i].getElementsByTagName("UL").length>0){
				ieLIs[i].className+=" sfnode";
			}
			
			// Add a sfhover class to the li.
			ieLIs[i].onmouseover=function() {this.className+=" sfhover";}
			ieLIs[i].onmouseout=function() {this.className=this.className.replace(' sfhover', '');}
		}
	} else {
		// IE 5.0 doesn't support iframes so hide the select statements on hover and show on mouse out.
		// IE script to change class on mouseover
		var ieLIs = document.getElementById('rollovermenu').getElementsByTagName('li');
		for (var i=0; i<ieLIs.length; i++) if (ieLIs[i]) {
			ieLIs[i].onmouseover=function() {this.className+=" sfhover";hideSelects();}
			ieLIs[i].onmouseout=function() {this.className=this.className.replace(' sfhover', '');showSelects()}
		}
	}
}

// If IE 5.0 hide and show the select statements.
function hideSelects(){
	var oSelects=document.getElementsByTagName("select");
	for(var i=0;i<oSelects.length;i++)
		oSelects[i].className+=" hide";
}

function showSelects(){
	var oSelects=document.getElementsByTagName("select");
	for(var i=0;i<oSelects.length;i++)
		oSelects[i].className=oSelects[i].className.replace(" hide","");
}

// Run this only for IE.
if (window.attachEvent) window.attachEvent('onload', sfHover);
// end
