// loadajax for loadpage
function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}

function gotoLink(url){
	location.href=url;
}

function loadFunc(){
	
}

function loadPrt(){
	window.print();
}

//-------------Ajax Core---------------------------------------
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;
	
}

function changWall(color){
	//alert(color);
	//document.body.style.backgroundColor=color;
	document.colorForm.bgcolorVar.value=color;
	document.colorForm.action=document.colorForm.url.value;
	document.colorForm.submit();
}

function checkemail(em){
	 // do something 
	var x = em;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x)) {
		//alert('YES! Correct email address');
		return true;
	}else{
		
		return false;
	}
 }
 
 function submitEmail(){
	 if(document.mform.em.value == ""){
		 alert('กรุณากรอก Email ของท่านค่ะ');
	 }else if(!checkemail(document.mform.em.value)){
		 alert('Email ของคุณไม่ถูกต้องค่ะ');
	 }else{
		 document.mform.action=document.mform.url.value;
		 document.mform.submit();
	 }
	 
 }
 
 var opchk=0;
 
 function openEm(){
	 if(opchk==0){
		 opchk=1;
		 document.getElementById("emBox").style.display="block";
	 }else if(opchk==1){
		 opchk=0;
		 document.getElementById("emBox").style.display="none";
	 }
 }
 
 function fwEm(){
	 if(document.semail.sem.value == "" || document.semail.fem.value == ""){
		 alert('กรุณากรอก Email ให้ครบค่ะ');
	 }else if(!checkemail(document.semail.sem.value)){
		 alert('Email ที่ต้องการส่งไม่ถูกต้องค่ะ');
	 }else if(!checkemail(document.semail.fem.value)){
		 alert('Email ของคุณไม่ถูกต้องค่ะ');
	 }else{
		 document.semail.action=document.semail.url.value;
		 document.semail.submit();
	 }
 }
 
 function openEml(){
	 var show=document.getElementById('emBox').style.display;
	 
	 if(show=='none'){
		 //alert(show);
		 $('#emBox').slideDown(600);
	 }else{
		 $('#emBox').slideUp(600);
	 }
 }
