function Inint_AJAX() {
   try { return new ActiveXObject("Msxml2.XMLHTTP");  } catch(e) {} //IE
   try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {} //IE
   try { return new XMLHttpRequest();  } catch(e) {} //Native Javascript
   alert("XMLHttpRequest not supported");
   return null;
	};
	
////////////////////////////////////////////////////////////////////////////////////////////////////////

function show_page(module) {

     var req=Inint_AJAX(); 

     document.getElementById("main").innerHTML='<div align="center"><br><br><img src="images/loading_liferay.gif" alt="loading"><br><br><font size="2" color="#FF9900">Loading...</font></div>';
     req.onreadystatechange = function () {
          if (req.readyState==4) {
               if (req.status==200) {
                    var data=req.responseText;
				    document.getElementById("main").innerHTML=data;
               }
          }
     };
     req.open("GET", module, true);
   	 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8 ");		   
 
	 req.send(null);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////
function show_pagehotel(module) {

     var req=Inint_AJAX(); 

     document.getElementById("main").innerHTML='<div align="center"><br><br><font size="2" color="#FF9900">Loading...</font></div>';
     req.onreadystatechange = function () {
          if (req.readyState==4) {
               if (req.status==200) {
                    var data=req.responseText;
				    document.getElementById("main").innerHTML=data;
               }
          }
     };
     req.open("GET", "Thailand_hotel.php"+module, true);
   	 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8 ");		   
 
	 req.send(null);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
function show_pagerecom(module) {

     var req=Inint_AJAX(); 

     document.getElementById("main").innerHTML='<div align="center"><br><br><font size="2" color="#FF9900">Loading...</font></div>';
     req.onreadystatechange = function () {
          if (req.readyState==4) {
               if (req.status==200) {
                    var data=req.responseText;
				    document.getElementById("main").innerHTML=data;
               }
          }
     };
     req.open("GET", module+".php", true);
   	 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8 ");		   
 
	 req.send(null);
}


////////////////////////////////////////////////////////////////////////////////////////////////////////

function sendRequestTextPost(module) {

     var req=Inint_AJAX(); 
  
	  if(document.form_contact.sender.value==""){ alert('Please insert yoru e-mail'); return false;}
	  if(document.form_contact.subject.value==""){ alert('Please insert subject'); return false;}
	  
	   var  sender=escape(document.getElementById("sender").value);
	   var  choose=escape(document.getElementById("choose").value);  
	   var  subject=escape(document.getElementById("subject").value);
	   var  detail=escape(document.getElementById("detail").value);
	 
     document.getElementById("mailform").innerHTML='<div align="center"><br><br><font size="2" color="#FF9900">Sending...</font></div>';
     
	 req.onreadystatechange = function () { 
          if (req.readyState==4) { 
               if (req.status==200) { 
                    
					 document.getElementById("mailform").innerHTML="<br><br><div align=\"center\"><font color=\"#FF3300\">Your Message has been sent.</font><br><br><br><br>"; 
					
			   }
          }
     }
     req.open("POST", module, true);
   	 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8 ");		   
 
	 req.send("&choose="+choose+"&sender="+sender+"&subject="+subject+"&detail="+detail);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////

function sendRequestLink(module) {

     var req=Inint_AJAX(); 
     if(document.form_link_ex.sender.value==""){ alert('Please insert yoru e-mail'); return false;}
 	 
	   var  sender=escape(document.getElementById("sender").value);
	   var  link_ex=escape(document.getElementById("link_ex").value);  
	   var  title_ex=escape(document.getElementById("title_ex").value);
	   var  des_ex=escape(document.getElementById("des_ex").value);
	 

     document.getElementById("link_exc").innerHTML='<div align="center"><br><br><font size="2" color="#FF9900">Sending...</font></div>';
     
	 req.onreadystatechange = function () { 
          if (req.readyState==4) { 
               if (req.status==200) {  
				document.getElementById("link_exc").innerHTML="<div style=\"font-family: Arial, Helvetica, sans-serif; font-size: 18px; color: #FF3300; text-align: center; margin-top:50px;\">Thank you. <br>Your Link Exchange has been sent to us.<br>Please wiat for our Confirm Email within 3 days.</div>"; 
			   }
          }
     }
 	 req.open("POST", module, true);
   	 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8 ");		   

	 req.send("&link_ex="+link_ex+"&sender="+sender+"&title_ex="+title_ex+"&des_ex="+des_ex);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////

function view_hotel(module) {

     var req=Inint_AJAX(); 

     document.getElementById("div_hotel").innerHTML='<div align="center"><br><br><font size="2" color="#FF9900">Loading...</font></div>';
     req.onreadystatechange = function () {
          if (req.readyState==4) {
               if (req.status==200) {
                    var data=req.responseText;
				    document.getElementById("div_hotel").innerHTML=data;
               }
          }
     };
     req.open("GET", module, true);
   	 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8 ");		   
 
	 req.send(null);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////

function getCommentBox(module,feedID) {

     var req=Inint_AJAX(); 
     document.getElementById("commentText").innerHTML='<br><br><div align="center"><img src="../images/loading_liferay.gif" alt="loading"><br><font size="2" color="#FF9900">Loading...</font><br><br></div>';
     req.onreadystatechange = function () {
          if (req.readyState==4) {
               if (req.status==200) {
				   var data=req.responseText;
				    document.getElementById("commentText").innerHTML=data;
               }
          }
     };
     req.open("GET", module+"?feedID="+feedID+"&"+ new Date().getTime() + Math.random(), true);
   	 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8 ");		   
 
	 req.send(null);
}

/////////////////////////
function sendRequestComment(module) {

     var req=Inint_AJAX(); 
		   
		   var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		   var  displayName=escape(document.getElementById("displayName").value);
	       var  emialName=escape(document.getElementById("emialName").value);  
	       var  commentDetail=escape(document.getElementById("commentDetail").value);
		   var  hidFID=document.getElementById("hidFID").value;
		   var  hidCapChar=document.getElementById("hidCapChar").value;  
		   		  
			if(displayName=="" && emialName=="" && commentDetail==""){
							
									document.getElementById("displayName").style.backgroundColor="#FFD2D2";
									document.getElementById("displayName").style.borderColor="#669900";
									
									document.getElementById("emialName").style.backgroundColor="#FFD2D2";
									document.getElementById("emialName").style.borderColor="#669900";
									
									document.getElementById("commentDetail").style.backgroundColor="#FFD2D2";
									document.getElementById("commentDetail").style.borderColor="#669900";
									displayValidAlert('../comments/clcikValidDetail.php?msg=Please Insert Your Display Name , Email and Comment&rd'+new Date().getTime() + Math.random());
									
			} else if(displayName=="" && emialName==""){
							
									document.getElementById("displayName").style.backgroundColor="#FFD2D2";
									document.getElementById("displayName").style.borderColor="#669900";
									
									document.getElementById("emialName").style.backgroundColor="#FFD2D2";
									document.getElementById("emialName").style.borderColor="#669900";
											
									document.getElementById("commentDetail").style.backgroundColor="#FFF";
									document.getElementById("commentDetail").style.borderColor="#669900";				
									displayValidAlert('../comments/clcikValidDetail.php?msg=Please Insert Your Display Name and Email&rd'+new Date().getTime() + Math.random());
									
			} else if(displayName=="" && commentDetail==""){

									document.getElementById("displayName").style.backgroundColor="#FFD2D2";
									document.getElementById("displayName").style.borderColor="#669900";
									
									document.getElementById("emialName").style.backgroundColor="#FFF";
									document.getElementById("emialName").style.borderColor="#669900";
											
									document.getElementById("commentDetail").style.backgroundColor="#FFD2D2";
									document.getElementById("commentDetail").style.borderColor="#669900";	
									displayValidAlert('../comments/clcikValidDetail.php?msg=Please Insert Your Display Name and Comment&rd'+new Date().getTime() + Math.random());

		    } else if(emialName=="" && commentDetail==""){
									
									document.getElementById("displayName").style.backgroundColor="#FFF";
									document.getElementById("displayName").style.borderColor="#669900";
									
									document.getElementById("emialName").style.backgroundColor="#FFD2D2";
									document.getElementById("emialName").style.borderColor="#669900";
											
									document.getElementById("commentDetail").style.backgroundColor="#FFD2D2";
									document.getElementById("commentDetail").style.borderColor="#669900";										
									displayValidAlert('../comments/clcikValidDetail.php?msg=Please Insert Your Email and Comment&rd'+new Date().getTime() + Math.random());
									
			} else if(displayName==""){
							
									document.getElementById("displayName").style.backgroundColor="#FFD2D2";
									document.getElementById("displayName").style.borderColor="#669900";

									document.getElementById("emialName").style.backgroundColor="#FFF";
									document.getElementById("emialName").style.borderColor="#669900";	
									
									document.getElementById("commentDetail").style.backgroundColor="#FFF";
									document.getElementById("commentDetail").style.borderColor="#669900";
									displayValidAlert('../comments/clcikValidDetail.php?msg=Please Insert Your Display Name&rd'+new Date().getTime() + Math.random());
									
			} else if(emialName==""){
							
									document.getElementById("emialName").style.backgroundColor="#FFD2D2";
									document.getElementById("emialName").style.borderColor="#669900";
									
									document.getElementById("displayName").style.backgroundColor="#FFF";
									document.getElementById("displayName").style.borderColor="#669900";			

									document.getElementById("commentDetail").style.backgroundColor="#FFF";
									document.getElementById("commentDetail").style.borderColor="#669900";
									displayValidAlert('../comments/clcikValidDetail.php?msg=Please Insert Your Email&rd'+new Date().getTime() + Math.random());
									
			} else if(commentDetail==""){

									document.getElementById("emialName").style.backgroundColor="#FFF";
									document.getElementById("emialName").style.borderColor="#669900";
									
									document.getElementById("displayName").style.backgroundColor="#FFF";
									document.getElementById("displayName").style.borderColor="#669900";			

									document.getElementById("commentDetail").style.backgroundColor="#FFD2D2";
									document.getElementById("commentDetail").style.borderColor="#669900";
									displayValidAlert('../comments/clcikValidDetail.php?msg=Please Insert Your Comment'+new Date().getTime() + Math.random());
				
			} else if (!filter.test(emialName)){
									document.getElementById("emialName").style.backgroundColor="#FFD2D2";
									document.getElementById("emialName").style.borderColor="#669900";
						            displayValidAlert('../comments/clcikValidDetail.php?msg=Sorry, Invalid Email Account&rd'+new Date().getTime() + Math.random());
			}  else {	
				     document.getElementById("commentText").innerHTML='<br><br><div align="center"><br><br><img src="../images/loading_liferay.gif" alt="loading"><br><font size="2" color="#FF9900">Loading...</font><br><br></div>';				 
					 req.onreadystatechange = function () { 
						  if (req.readyState==4) { 
							   if (req.status==200) { 
									getCommentBox('../comments/comment_reply.php',hidFID);
							   		document.getElementById("displayName").style.backgroundColor="#FFF";
									document.getElementById("displayName").style.borderColor="#669900";
									document.getElementById("emialName").style.backgroundColor="#FFF";
									document.getElementById("emialName").style.borderColor="#669900";
							   }
						  }
					 }
					 
					 req.open("POST", module+"?"+new Date().getTime() + Math.random(), true);
					 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8 ");		   
				
					 req.send("&displayName="+displayName+"&emialName="+emialName+"&hidFID="+hidFID+"&hidCapChar="+hidCapChar+"&commentDetail="+commentDetail);
		 } 
}
//////////////////
function clickOK(){
	var closeConfirmRemove = document.getElementById('divClickOK');
		closeConfirmRemove.style.display = "none";
}