// JavaScript Document
function showhide(id){
	tmp= document.getElementById(id);
if(tmp.style.display== "none")
	tmp.style.display= "block";
else if(tmp.style.display= "block")
	tmp.style.display= "none";
}
function checkfaqform(f){
// Email:
	var regex = /^(([\-\w]+)\.?)+@(([\-\w]+)\.?)+\.[a-zA-Z]{2,4}$/;
	if(f.faq_email.value=="" || f.faq_email.value==null){
		window.alert(T_EMAIL_REQUIRED);
		f.faq_email.focus();
		return false;
	}	
	if (!regex.test(f.faq_email.value)){
		window.alert(T_EMAIL_TYPE);
		f.faq_email.focus();
		return false;
	}
//content
	if(f.faq_content.value=="" || f.faq_content.value==null){
		window.alert(T_CONTENT_REQUIRED);
		f.faq_content.focus();
		return false;
	}
//scode	
	if(f.scode.value=="" || f.scode.value==null){
		window.alert("Number NULL");
		f.scode.focus();
		return false;
	}
check_scode(f);
return false;
}
function checkcontactform(f){
//name 
	if(f.ct_name.value=="" || f.ct_name.value==null){
		window.alert(T_NAME_REQUIRED);
		f.ct_name.focus();
		return false;
	}

	if (isNaN(f.ct_name.value)==false){
		window.alert(T_NAME_TYPE);
		f.ct_name.focus();
		return false;
	}	
//email
	var regex = /^(([\-\w]+)\.?)+@(([\-\w]+)\.?)+\.[a-zA-Z]{2,4}$/;
	if(f.ct_email.value=="" || f.ct_email.value==null){
		window.alert(T_EMAIL_REQUIRED);
		f.ct_email.focus();
		return false;
	}
	if (!regex.test(f.ct_email.value)){
		window.alert(T_EMAIL_TYPE);
		f.ct_email.focus();
		return false;
	}
//Subject
	if(f.ct_subject.value=="" || f.ct_subject.value==null){
		window.alert(T_SUBJECT_REQUIRED);
		f.ct_subject.focus();
		return false;
	}
//content
	if(f.ct_content.value=="" || f.ct_content.value==null){
		window.alert(T_CONTENT_REQUIRED);
		f.ct_content.focus();
		return false;
	}
//scode	
	if(f.scode.value=="" || f.scode.value==null){
		window.alert("Number NULL");
		f.scode.focus();
		return false;
	}
	check_scode(f);
	return false;
}
function checkcontactform2(f){
//name 
	if(f.ct_name.value=="" || f.ct_name.value==null){
		window.alert(T_NAME_REQUIRED);
		f.ct_name.focus();
		return false;
	}

	if (isNaN(f.ct_name.value)==false){
		window.alert(T_NAME_TYPE);
		f.ct_name.focus();
		return false;
	}	
//email
	var regex = /^(([\-\w]+)\.?)+@(([\-\w]+)\.?)+\.[a-zA-Z]{2,4}$/;
	if(f.ct_email.value=="" || f.ct_email.value==null){
		window.alert(T_EMAIL_REQUIRED);
		f.ct_email.focus();
		return false;
	}
	if (!regex.test(f.ct_email.value)){
		window.alert(T_EMAIL_TYPE);
		f.ct_email.focus();
		return false;
	}
//content
	if(f.ct_content.value=="" || f.ct_content.value==null){
		window.alert(T_CONTENT_REQUIRED);
		f.ct_content.focus();
		return false;
	}
//scode	
	if(f.scode.value=="" || f.scode.value==null){
		window.alert("Number NULL");
		f.scode.focus();
		return false;
	}
	
	check_scode2(f);
	return false;
}
function CheckQuickContact(f){
//name 
	if(f.ct_name.value=="" || f.ct_name.value==null){
		window.alert(T_NAME_REQUIRED);
		f.ct_name.focus();
		return false;
	}

	if (isNaN(f.ct_name.value)==false){
		window.alert(T_NAME_TYPE);
		f.ct_name.focus();
		return false;
	}	
//email
	var regex = /^(([\-\w]+)\.?)+@(([\-\w]+)\.?)+\.[a-zA-Z]{2,4}$/;
	if(f.ct_email.value=="" || f.ct_email.value==null){
		window.alert(T_EMAIL_REQUIRED);
		f.ct_email.focus();
		return false;
	}
	if (!regex.test(f.ct_email.value)){
		window.alert(T_EMAIL_TYPE);
		f.ct_email.focus();
		return false;
	}
//content
	if(f.ct_content.value=="" || f.ct_content.value==null){
		window.alert(T_CONTENT_REQUIRED);
		f.ct_content.focus();
		return false;
	}
//scode	
	if(f.scode.value=="" || f.scode.value==null){
		window.alert("Number NULL");
		f.scode.focus();
		return false;
	}
	check_scode(f);
    return false;
}
function RegisterForm(f){	
//email
	var regex = /^(([\-\w]+)\.?)+@(([\-\w]+)\.?)+\.[a-zA-Z]{2,4}$/;
	if(f.email.value=="" || f.email.value==null){
		window.alert(T_EMAIL_REQUIRED);
		f.email.focus();
		return false;
	}
	if (!regex.test(f.email.value)){
		window.alert(T_EMAIL_TYPE);
		f.email.focus();
		return false;
	}
//email2
	if(f.email_2.value=="" || f.email_2.value==null){
		window.alert(T_EMAIL_2_REQUIRED);
		f.email_2.focus();
		return false;
	}
	if (!regex.test(f.email_2.value)){
		window.alert(T_EMAIL_2_TYPE);
		f.email_2.focus();
		return false;
	}
	if (f.email_2.value != f.email.value){
		window.alert(T_EMAIL_2);
		f.email_2.focus();
		return false;
	}
//password
	
	if(f.password.value=="" || f.password.value==null || f.password.value.length<6){
		window.alert(T_PASS_REQUIRED);
		f.password.focus();
		return false;
	}
	if(f.password2.value=="" || f.password2.value==null || f.password.value.length<6){
		window.alert(T_PASS_CONFIRM);
		f.password2.focus();
		return false;
	}
	if(f.password.value != f.password2.value){
		window.alert(T_PASSERR)
		f.password2.focus();
		return false;
	}
	//name 
	if(f.ct_name.value=="" || f.ct_name.value==null){
		window.alert(T_NAME_REQUIRED);
		f.ct_name.focus();
		return false;
	}

	if (isNaN(f.ct_name.value)==false){
		window.alert(T_NAME_TYPE);
		f.ct_name.focus();
		return false;
	}	
	if(f.scode.value=="" || f.scode.value==null){
		window.alert(T_CODE_TYPE);
		f.scode.focus();
		return false;
	}
	
return esnc_aform(f);
}
function LosePassForm(f){	
//email
	var regex = /^(([\-\w]+)\.?)+@(([\-\w]+)\.?)+\.[a-zA-Z]{2,4}$/;
	if(f.email.value=="" || f.email.value==null){
		window.alert(T_EMAIL_REQUIRED);
		f.email.focus();
		return false;
	}
	if (!regex.test(f.email.value)){
		window.alert(T_EMAIL_TYPE);
		f.email.focus();
		return false;
	}
}
function CheckTourCus(f){
	//name 
	if(f.name.value=="" || f.name.value==null){
		window.alert(T_NAME_REQUIRED);
		f.name.focus();
		return false;
	}
	if (isNaN(f.name.value)==false){
		window.alert(T_NAME_TYPE);
		f.name.focus();
		return false;
	}
	//email
	var regex = /^(([\-\w]+)\.?)+@(([\-\w]+)\.?)+\.[a-zA-Z]{2,4}$/;
	if(f.email.value=="" || f.email.value==null){
		window.alert(T_EMAIL_REQUIRED);
		f.email.focus();
		return false;
	}
	if (!regex.test(f.email.value)){
		window.alert(T_EMAIL_TYPE);
		f.email.focus();
		return false;
	}
	//remail
	if(f.re_email.value!=f.email.value){
		window.alert(T_RE_EMAIL);
		f.re_email.focus();
		return false;
	}
	//person 
	if(f.person.value=="" || f.person.value==null){
		window.alert(T_PERSON_REQUIRED);
		f.person.focus();
		return false;
	}
	//time
	if(f.time.value=="" || f.time.value==null){
		window.alert(T_PERSON_REQUIRED);
		f.time.focus();
		return false;
	}
	//date
	if(f.date.value=="" || f.date.value==null){
		window.alert(T_DATE_REQUIRED);
		f.date.focus();
		return false;
	}
	//scode
	if(f.scode.value=="" || f.scode.value==null){
		window.alert(T_CODE_TYPE);
		f.scode.focus();
		return false;
	}
check_scode(f);
return false;
}

function CheckShopcart(f){//edited by trung.le May, 04, 2011
	//name 
	if(f.name.value=="" || f.name.value==null){
		window.alert(T_NAME_REQUIRED);
		f.name.focus();
		return false;
	}
	if (isNaN(f.name.value)==false){
		window.alert(T_NAME_TYPE);
		f.name.focus();
		return false;
	}
	//country
	if(f.country.value=="Select"){
		window.alert(T_COUNTRY_REQUIRED);
		f.country.focus();
		return false;
	}
	//email
	var regex = /^(([\-\w]+)\.?)+@(([\-\w]+)\.?)+\.[a-zA-Z]{2,4}$/;
	if(f.email.value=="" || f.email.value==null){
		window.alert(T_EMAIL_REQUIRED);
		f.email.focus();
		return false;
	}
	if (!regex.test(f.email.value)){
		window.alert(T_EMAIL_TYPE);
		f.email.focus();
		return false;
	}
	// confirm email
	if(f.reemail.value!=f.email.value){
		window.alert(T_RE_EMAIL);
		f.reemail.focus();
		return false;
	}
	// phhone
	if(f.phone.value=="" || f.phone.value==null){
		window.alert(T_PHONE_REQUIRED);
		f.phone.focus();
		return false;
	}

	if (isNaN(f.phone.value)){
		window.alert(T_PHONE_TYPE);
		f.phone.focus();
		return false;
	}
	//scode
	if(f.scode.value=="" || f.scode.value==null){
		window.alert(T_CODE_TYPE);
		f.scode.focus();
		return false;
	}
	//check term
	if(f.check_term.checked==false){
		window.alert(T_CHECK_TERM);
		f.check_term.focus();
		return false;
	}
check_scode(f);
return false;
}
function fshopcartSubmit(f){
  f.submit();	
}
function check_scode(f){
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
var page = "process.php?act=checkscode&scode="+f.scode.value;
var obj= document.getElementById("scode_text");
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
	   if(xmlhttp.responseText!="TRUE"){
		  //obj.src = xmlhttp.responseText;
		  
		  document.getElementById("scode_error").innerHTML =  T_SCODE_INVALID;
		  window.alert(T_SCODE_INVALID);
		  f.scode.select();
	   }else{
		  fshopcartSubmit(f); 
	   }
    }
  }
xmlhttp.open("GET",page,true);
xmlhttp.send(null);
return false;
}
function check_scode2(f){
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
var page = "process.php?act=checkscode&scode="+f.scode.value;
var obj= document.getElementById("scode_text");
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
	   if(xmlhttp.responseText!="TRUE"){
		  //obj.src = xmlhttp.responseText;
		  
		  document.getElementById("scode_error2").innerHTML =  T_SCODE_INVALID;
		  window.alert(T_SCODE_INVALID);
		  f.scode.select();
	   }else{
		  fshopcartSubmit(f); 
	   }
    }
  }
xmlhttp.open("GET",page,true);
xmlhttp.send(null);
return false;
}
function checkSendEmail(f){	
//name 
	if(f.sm_name.value=="" || f.sm_name.value==null){
		window.alert(T_NAME_REQUIRED);
		f.sm_name.focus();
		return false;
	}

	if (isNaN(f.sm_name.value)==false){
		window.alert(T_NAME_TYPE);
		f.sm_name.focus();
		return false;
	}
//email1
	var regex = /^(([\-\w]+)\.?)+@(([\-\w]+)\.?)+\.[a-zA-Z]{2,4}$/;
	if(f.sm_email1.value=="" || f.sm_email1.value==null){
		window.alert(T_EMAIL_REQUIRED);
		f.sm_email1.focus();
		return false;
	}
	if (!regex.test(f.sm_email1.value)){
		window.alert(T_EMAIL_TYPE);
		f.sm_email1.focus();
		return false;
	}
//email recipients
	var regex = /^(([\-\w]+)\.?)+@(([\-\w]+)\.?)+\.[a-zA-Z]{2,4}$/;
	if(f.sm_email2.value=="" || f.sm_email2.value==null){
		window.alert(T_EMAIL_RECIPITENS); 	
		f.sm_email2.focus();
		return false;
	}
	if (!regex.test(f.sm_email2.value)){
		window.alert(T_EMAIL_TYPE);
		f.sm_email2.focus();
		return false;
	}
//content
	if(f.sm_content.value=="" || f.sm_content.value==null){
		window.alert(T_CONTENT_REQUIRED);
		f.sm_content.focus();
		return false;
	}
//code spam
	if(f.scode.value=="" || f.scode.value==null){
		window.alert("Number null.");
		f.scode.focus();
		return false;
	}
	check_scode(f);
return false;
}
function checkRadio(o)
{
var get = document.getElementsByName(o);
for (var i=0; i < get.length; i++){
   if (get[i].checked){
      var rad_val = get[i].value;
      }
   }
   if(rad_val) return true;
   else return false;
}
function CheckVisa(f){	
//name
	if(f.txtname.value=="" || f.txtname.value==null){
		window.alert(T_NAME_REQUIRED);
		f.txtname.focus();
		return false;
	}

	if (isNaN(f.txtname.value)==false){
		window.alert(T_NAME_TYPE);
		f.txtname.focus();
		return false;
	}
//email
	var regex = /^(([\-\w]+)\.?)+@(([\-\w]+)\.?)+\.[a-zA-Z]{2,4}$/;
	if(f.txtemail.value=="" || f.txtemail.value==null){
		window.alert(T_EMAIL_REQUIRED);
		f.txtemail.focus();
		return false;
	}	
	if (!regex.test(f.txtemail.value)){
		window.alert(T_EMAIL_TYPE);
		f.txtemail.focus();
		return false;
	}
//Phone
	if(f.txtphone.value=="" || f.txtphone.value==null){
		window.alert(T_PHONE_REQUIRED);
		f.txtphone.focus();
		return false;
	}
	if (isNaN(f.txtphone.value)){
		window.alert(T_PHONE_TYPE);
		f.txtphone.focus();
		return false;
	}
//date 1
	if(f.txtdate_1.value=="" || f.txtdate_1.value==null){
		window.alert(T_ARRIVAL_DATE_REQUIRED);
		f.txtdate_1.focus();
		return false;
	}
//date 2
	if(f.txtdate_2.value=="" || f.txtdate_2.value==null){
		window.alert(T_EXIT_DATE_REQUIRED);
		f.txtdate_2.focus();
		return false;
	}
//Port of Arrival
	if(f.txtport_ariival.value=="" || f.txtport_ariival.value==null){
		window.alert(T_PORT_OF_ARRIVAL_REQUIRED);
		f.txtport_ariival.focus();
		return false;
	}
//name0
	if(f.name0.value=="" || f.name0.value==null){
		window.alert(T_FULL_NAME_REQUIRED);
		f.name0.focus();
		return false;
	}
//gender 
	if(!checkRadio('gender0')){
		window.alert('Gender not null');
		return false;
	}
//birth
	if(f.birthofdate0.value=="" || f.birthofdate0.value==null){
		window.alert(T_BIRTH_REQUIRED);
		f.birthofdate0.focus();
		return false;
	}
//country
	if(f.country0.value=='select'){
		window.alert(T_COUNTRY_REQUIRED);
		f.country0.focus();
		return false;
	}
//passport number
	if(f.passportnumber0.value=="" || f.passportnumber0.value==null){
		window.alert(T_PASSPORT_REQUIRED);
		f.passportnumber0.focus();
		return false;
	}
//Date of expiry
	if(f.dateofexpiry0.value=="" || f.dateofexpiry0.value==null){
		window.alert(T_EXPIRY_REQUIRED);
		f.dateofexpiry0.focus();
		return false;
	}
}

function CheckFaq(f){
//name 
	if(f.ct_name.value=="" || f.ct_name.value==null){
		window.alert(T_NAME_REQUIRED);
		f.ct_name.focus();
		return false;
	}

	if (isNaN(f.ct_name.value)==false){
		window.alert(T_NAME_TYPE);
		f.ct_name.focus();
		return false;
	}	
//email
	var regex = /^(([\-\w]+)\.?)+@(([\-\w]+)\.?)+\.[a-zA-Z]{2,4}$/;
	if(f.ct_email.value=="" || f.ct_email.value==null){
		window.alert(T_EMAIL_REQUIRED);
		f.ct_email.focus();
		return false;
	}
	if (!regex.test(f.ct_email.value)){
		window.alert(T_EMAIL_TYPE);
		f.ct_email.focus();
		return false;
	}
//Subject
	if(f.ct_subject.value=="" || f.ct_subject.value==null){
		window.alert(T_SUBJECT_REQUIRED);
		f.ct_subject.focus();
		return false;
	}
//content
	if(f.ct_content.value=="" || f.ct_content.value==null){
		window.alert(T_CONTENT_REQUIRED);
		f.ct_content.focus();
		return false;
	}
//scode	
	if(f.scode.value=="" || f.scode.value==null){
		window.alert("Number NULL");
		f.scode.focus();
		return false;
	}
	check_scode(f);
return false;
}
