function show_submenu01() {
document.getElementById("submenu01").style.left = (document.body.clientWidth - 962)/2 + 150;
document.getElementById("submenu01").style.top= 227;
document.getElementById("submenu01").style.visibility = "visible";
}

function show_submenu02() {
document.getElementById("submenu02").style.left = (document.body.clientWidth - 962)/2 + 150;
document.getElementById("submenu02").style.top= 276;
document.getElementById("submenu02").style.visibility = "visible";
}

function show_submenu03() {
document.getElementById("submenu03").style.left = (document.body.clientWidth - 962)/2 + 150;
document.getElementById("submenu03").style.top= 298;
document.getElementById("submenu03").style.visibility = "visible";
}

function show_submenu05() {
document.getElementById("submenu05").style.left = (document.body.clientWidth - 962)/2 + 150;
document.getElementById("submenu05").style.top= 355;
document.getElementById("submenu05").style.visibility = "visible";
}

function show_submenu06() {
document.getElementById("submenu06").style.left = (document.body.clientWidth - 962)/2 + 150;
document.getElementById("submenu06").style.top= 389;
document.getElementById("submenu06").style.visibility = "visible";
}

function hide_submenu01() {
document.getElementById("submenu01").style.visibility = "hidden";
}

function hide_submenu02() {
document.getElementById("submenu02").style.visibility = "hidden";
}

function hide_submenu03() {
document.getElementById("submenu03").style.visibility = "hidden";
}

function hide_submenu05() {
document.getElementById("submenu05").style.visibility = "hidden";
}

function hide_submenu06() {
document.getElementById("submenu06").style.visibility = "hidden";
}

function SearchForm(frm){
	if(frm.keyword.value.length < 1)	{
		alert("กรุณากรอกคำที่ต้องการค้นหาด้วยค่ะ");
		frm.keyword.focus();	
		return false;
	} 
	return true;
}

function jumppage(sel)
{
   var i = sel.selectedIndex
  	document.frmnews.cid.value = sel.options[i].value;
	document.frmnews.target = "_self";
	document.frmnews.submit();
}

function PopupPicture(pic) {
var xleft = (screen.availWidth-400)/2
var xtop =(screen.availHeight-400)/2
 windowReference = this.open('hotel_picture.asp?pic='+pic,'windowName','width=400,height=400,left='+xleft+',top='+xtop+',menubar=0,toolbar=0,status=0,scrollbars=1,resizable=0');
}

function checkValidDate(cmbDay, cmbMonth, cmbYear){

 var nDay = cmbDay.options[cmbDay.options.selectedIndex].value;
 var nMonth = cmbMonth.options[cmbMonth.options.selectedIndex].value;
 var nYear = cmbYear.options[cmbYear.options.selectedIndex].value;
 
 if(nDay == 0 || nMonth == 0 || nYear == 0)
  return;
 
 var nMaxDay = 0;
 
 if(nMonth == 4 || nMonth == 6 || nMonth == 9 || nMonth == 11)
  nMaxDay = 30;
 else if(nMonth == 2) {
  if(nYear % 4 == 0 && (nYear % 100 != 0 || nYear % 400 == 0))
   nMaxDay = 29;
  else
   nMaxDay = 28;
 }
 else
  nMaxDay = 31;
 
 if(nDay > nMaxDay)
  for(var i = 0; i < 31; i++)
   if(cmbDay[i].value == nMaxDay){
    //alert("วันที่ที่ถูกเลือกไม่ถูกต้อง");
    alert("The system change your selected date\nPlease checked date again");
    cmbDay.options.selectedIndex = i;
    }
}

function isEmailFormat(emailStr) {
var emailPat=/^(.+)@(.+)$/
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
var validChars="\[^\\s" + specialChars + "\]"
var quotedUser="(\"[^\"]*\")"
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
var atom=validChars + '+'
var word="(" + atom + "|" + quotedUser + ")"
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
var MsgErr="";   
var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
	MsgErr=MsgErr+"Email address seems incorrect (check @ and .'s) ";
	return MsgErr;
}
else
{
  var user=matchArray[1]
  var domain=matchArray[2]
  if (user.match(userPat)==null) {
    MsgErr=MsgErr+"The username doesn't seem to be valid. ";
	return MsgErr;
   }
  var IPArray=domain.match(ipDomainPat)
   if (IPArray!=null) {
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
	        MsgErr=MsgErr+"Destination IP address is invalid ! ";
			return MsgErr;
	     }//IF
		}//for
     }//IP Array
   var domainArray=domain.match(domainPat)
   if (domainArray==null) {
	 MsgErr=MsgErr+"The domain name doesn't seem to be valid.";
	 return MsgErr;
     }
    var atomPat=new RegExp(atom,"g")
    var domArr=domain.match(atomPat)
    var len=domArr.length
    if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3) {
     MsgErr=MsgErr+"The address must end in a three-letter domain, or two letter country.";
	 return MsgErr;
    }
   if (len<2) {
     MsgErr=MsgErr+"This address is missing a hostname!";
	 return MsgErr;
   } 
 }//End  Match
return "0";
}
