function self(st)
{
	
	window.document.forms[0].target = "_self";

	window.document.forms[0].action = st;

	window.document.forms[0].submit();

}
function selfsub(st)
{
	
	window.document.forms[1].target = "_self";

	window.document.forms[1].action = st;

	window.document.forms[1].submit();

}
function LTrim(str)
/*
PURPOSE: Remove leading blanks from our string.
IN: str - the string we want to LTrim
*/
{
   var whitespace = new String(" \t\n\r");

   var s = new String(str);

   if (whitespace.indexOf(s.charAt(0)) != -1) {
      // We have a string with leading blank(s)...

      var j=0, i = s.length;

      // Iterate from the far left of string until we
      // don't have any more whitespace...
      while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
         j++;

      // Get the substring from the first non-whitespace
      // character to the end of the string...
      s = s.substring(j, i);
   }
   return s;
}

/*
==================================================================
RTrim(string) : Returns a copy of a string without trailing spaces.
==================================================================
*/
function RTrim(str)
/*
   PURPOSE: Remove trailing blanks from our string.
   IN: str - the string we want to RTrim

*/
{
   // We don't want to trip JUST spaces, but also tabs,
   // line feeds, etc.  Add anything else you want to
   // "trim" here in Whitespace
   var whitespace = new String(" \t\n\r");

   var s = new String(str);

   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
      // We have a string with trailing blank(s)...

      var i = s.length - 1;       // Get length of string

      // Iterate from the far right of string until we
      // don't have any more whitespace...
      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
         i--;


      // Get the substring from the front of the string to
      // where the last non-whitespace character is...
      s = s.substring(0, i+1);
   }

   return s;
}


/*
=============================================================
Trim(string) : Returns a copy of a string without leading or trailing spaces
=============================================================
*/
function Trim(str)
/*
   PURPOSE: Remove trailing and leading blanks from our string.
   IN: str - the string we want to Trim

   RETVAL: A Trimmed string!
*/
{
   return RTrim(LTrim(str));
}
/**/
function checkEmail(str){
	var textValue = str.value;
	var err=''
	if (textValue == ''){
		err += "Địa chỉ E-mail không hợp lệ";
		alert(err);
		str.focus();
		return false
	}
	if (textValue.indexOf('@') <= 0 || textValue.indexOf('@') == textValue.length -1){
		err += "Địa chỉ E-mail không hợp lệ ";		
	} else {
		var substr = textValue.substring(textValue.indexOf('@'),textValue.length);
		if (textValue.indexOf('.') <= 0) {
			err += "Địa chỉ E-mail không hợp lệ \n";
		}
	}
	if (err != '') { 
		alert(err); 
		str.focus();
		return false;
	}
	return true;
}

/**/
function checkContact (f) {
	companyName = f.txthoten.value;
	
	if (Trim(companyName) == "") {
		alert('Vui lòng nhập họ tên của bạn.');
		f.txthoten.focus();
		return false;
	}
	if (!checkEmail(f.txtemail)) {
		return false
	}
	address = f.txtdiachi.value;
	if (Trim(address) == "") {
		alert('Vui lòng nhập địa chỉ của bạn.');
		f.txtdiachi.focus();
		return false;
	}

	catId = f.txtnoidung.value;
	if (Trim(catId) == "") {
		alert('Vui lòng nhập thông tin liên hệ.');
		f.txtnoidung.focus();
		return false;
	}
	
	return true;	
}
function checkTailors(f)
{
	txthoten = f.txthoten.value;
	if (Trim(txthoten) == "") {
		alert('Vui lòng nhập họ tên của bạn');
		f.txthoten.focus();
		return false;
	}
	if (!checkEmail(f.txtemail)) {
		return false
	}
	txtdiachi = f.txtdiachi.value;
	if (Trim(txtdiachi) == "") {
		alert('Vui lòng nhập địa chỉ liên hệ');
		f.txtdiachi.focus();
		return false;
	}
	catId = f.txtnoidung.value;
	if (catId == "") {
		alert('Please, put in your content');
		f.txtnoidung.focus();
		return false;
	}
	
	return true;	
}
// check book tour
/**/
function checkBookTour (f) {
	txthoten = f.txthoten.value;
	
	if (Trim(txthoten) == "") {
		alert('Vui lòng nhập họ tên của bạn');
		f.txthoten.focus();
		return false;
	}
	if (!checkEmail(f.txtemail)) {
		return false
	}
	address = f.txtdiachi.value;
	if (Trim(address) == "") {
		alert('Vui lòng nhập địa chỉ của bạn');
		f.txtdiachi.focus();
		return false;
	}
	telephone = f.txtdt.value;
	if (Trim(telephone) == "") {
		alert('Vui lòng nhập số điện thoại liên hệ');
		f.txtdt.focus();
		return false;
	}
	cmbcategory = f.cmbcategory.value;
	
	if (Trim(cmbcategory) == "0") {
		alert('Vui lòng chọn mã tour');
		f.cmbcategory.focus();
		return false;
	}
	
	subCathotel = f.cmbcat.value;
	if (subCathotel == "0") {
		alert('Vui lòng chọn loại khách sạn');
		f.cmbcat.focus();
		return false;
	}

	subCatroom = f.cmbroomcat.value;
	if (subCatroom == "0") {
		alert('Vui lòng chọn loại phòng');
		f.cmbroomcat.focus();
		return false;
	}
	txtnguoilon = f.txtnguoilon.value;
	if (txtnguoilon == "0") {
		alert('Vui lòng nhập số lượng khách');
		f.txtnguoilon.focus();
		return false;
	}
	return true;	
}
// check book hotel
/**/
function checkBookHotel (f) {
	companyName = f.txthoten.value;
	if (Trim(companyName) == "") {
		alert('Vui lòng nhập họ tên của bạn');
		f.txthoten.focus();
		return false;
	}
	if (!checkEmail(f.txtemail)) {
		return false
	}
	address = f.txtdiachi.value;
	if (Trim(address) == "") {
		alert('Vui lòng nhập địa chỉ của bạn');
		f.txtdiachi.focus();
		return false;
	}
	telephone = f.txtdt.value;
	if (Trim(telephone) == "") {
		alert('Vui lòng nhập số điện thoại liên hệ');
		f.txtdt.focus();
		return false;
	}
	
	cmbcategory= f.cmbcategory.value;
	if (cmbcategory == "0") {
		alert('Vui lòng chọn tên khách sạn');
		f.cmbcategory.focus();
		return false;
	}
	
	subCatroom = f.cmbroomcat.value;
	if (subCatroom == "0") {
		alert('Vui lòng chọn loại phòng');
		f.cmbroomcat.focus();
		return false;
	}
	subCatAdult = f.txtnguoilon.value;
	if (subCatAdult == "0") {
		alert('Vui lòng nhập số lượng hành khách');
		f.txtnguoilon.focus();
		return false;
	}
	subCatId = f.txtngaykh.value;
	if (subCatId == "") {
		alert('Vui lòng nhập ngày nhận phòng');
		f.txtngaykh.focus();
		return false;
	}
	subCatdateout= f.txtngayve.value;
	if (subCatdateout == "") {
		alert('Vui lòng nhập ngày trả phòng');
		f.txtngayve.focus();
		return false;
	}
	return true;	
}
// check book Flight
/**/
function checkBookFlight (f) {
	companyName = f.txthoten.value;
	if (Trim(companyName) == "") {
		alert('Vui lòng nhập họ tên của bạn');
		f.txthoten.focus();
		return false;
	}
	if (!checkEmail(f.txtemail)) {
		return false
	}
	address = f.txtdiachi.value;
	if (Trim(address) == "") {
		alert('Vui lòng nhập địa chỉ của bạn');
		f.txtdiachi.focus();
		return false;
	}
	telephone = f.txtdt.value;
	if (Trim(telephone) == "") {
		alert('Vui lòng nhập số điện thoại liên hệ');
		f.txtdt.focus();
		return false;
	}
	txtloaive = f.txtloaive.value;
	
	if (Trim(txtloaive) == "") {
		alert('Vui lòng nhập loại vé');
		f.txtloaive.focus();
		return false;
	}
	txtnoidung = f.txtnoidung.value;
	if (txtnoidung == "") {
		alert('Vui lòng nhập thông tin chuyến bay');
		f.txtnoidung.focus();
		return false;
	}

	
	return true;	
}
// check book Flight
/**/
function checkBookVehicle (f) {
	companyName = f.txthoten.value;
	if (Trim(companyName) == "") {
		alert('Vui lòng nhập họ tên của bạn');
		f.txthoten.focus();
		return false;
	}
	if (!checkEmail(f.txtemail)) {
		return false
	}
	address = f.txtdiachi.value;
	if (Trim(address) == "") {
		alert('Vui lòng nhập địa chỉ của bạn');
		f.txtdiachi.focus();
		return false;
	}
	telephone = f.txtdt.value;
	if (Trim(telephone) == "") {
		alert('Vui lòng nhập số điện thoại liên hệ');
		f.txtdt.focus();
		return false;
	}
	contactPerson = f.txtloaixe.value;
	
	if (Trim(contactPerson) == "") {
		alert('Vui lòng nhập loại xe');
		f.txtloaixe.focus();
		return false;
	}
	catId = f.cmbroomcat.value;
	if (catId == "") {
		alert('Vui lòng chọn số chổ');
		f.cmbroomcat.focus();
		return false;
	}
	
	
	subCatdateout= f.txtngaykh.value;
	if (subCatdateout == "") {
		alert('Vui lòng chọn ngày khởi hành');
		f.txtngaykh.focus();
		return false;
	}
	txtngayve= f.txtngayve.value;
	if (txtngayve == "") {
		alert('Vui lòng chọn ngày về');
		f.txtngayve.focus();
		return false;
	}
	return true;	
}
/* book tailor*/
function checkBookTailor(f)
{
	companyName = f.txthoten.value;
	if (Trim(companyName) == "") {
		alert('Vui lòng nhập họ tên của bạn');
		f.txthoten.focus();
		return false;
	}
	if (!checkEmail(f.txtemail)) {
		return false
	}
	address = f.txtdiachi.value;
	if (Trim(address) == "") {
		alert('Vui lòng nhập địa chỉ của bạn');
		f.txtdiachi.focus();
		return false;
	}
	telephone = f.txtdt.value;
	if (Trim(telephone) == "") {
		alert('Vui lòng nhập số điện thoại liên hệ');
		f.txtdt.focus();
		return false;
	}
	subCatId = f.txtngaykh.value;
	if (subCatId == "") {
		alert('Vui lòng chọn ngày khởi hành');
		f.txtngaykh.focus();
		return false;
	}
	txtdays = f.txtdays.value;
	
	if (Trim(txtdays) == "0") {
		alert('Nhập số ngày đi');
		f.txtdays.focus();
		return false;
	}	
	cmbcat = f.cmbcat.value;
	if (cmbcat == "0") {
		alert('Vui lòng chọn loại khách sạn');
		f.cmbcat.focus();
		return false;
	}

	subCatroom = f.cmbroomcat.value;
	if (subCatroom == "0") {
		alert('Vui lòng chọn loại phòng');
		f.cmbroomcat.focus();
		return false;
	}
	
	txtnguoilon = f.txtnguoilon.value;
	if (txtnguoilon == "0") {
		alert('Vui lòng nhập số lượng khách');
		f.txtnguoilon.focus();
		return false;
	}
	txtdiemden = f.txtdiemden.value;
	
	if (Trim(txtdiemden) == "") {
		alert('Vui lòng nhập những điểm đến');
		f.txtdiemden.focus();
		return false;
	}


	return true;	
}	
//**/
/*Search tour*/
function checkSearch(f)
{
	
	subrequest = f.txtdiemden.value;
	if (subrequest == "") {
		alert('Vui lòng nhập từ khóa tìm kiếm');
		f.txtdiemden.focus();
		return false;
	}
	
	return true;	
}



function checkSendMail(f)
{
	if (!checkEmail(f.txtemail)) {
	return false
	}
	if (!checkEmail(f.txtemailsend)) {
	return false
	}
	return true;
}
/* Tim kiem hotel*/
function checkSearchTour(f)
{
	
	cmbcategory = f.cmbcategory.value;
	
	if (cmbcategory == "") {
		alert('Vui lòng chọn chương trình');
		f.cmbcategory.focus();
		return false;
	}
	
	return true;
}
/* Tim kiem hotel*/
function checkFaqs(f)
{
	
	companyName = f.txthoten.value;
	if (Trim(companyName) == "") {
		alert('Vui lòng nhập họ tên của bạn');
		f.txthoten.focus();
		return false;
	}
	if (!checkEmail(f.txtemail)) {
		return false
	}
	address = f.txtdiachi.value;
	if (Trim(address) == "") {
		alert('Vui lòng nhập địa chỉ của bạn');
		f.txtdiachi.focus();
		return false;
	}
	
	
	txtnoidung = f.txtnoidung.value;
	
	if (Trim(txtnoidung) == "") {
		alert('Vui lòng nhập ý kiến của bạn ');
		f.txtnoidung.focus();
		return false;
	}
	return true;
}
function checkPutword(f)
{
	txtnoidung = f.word.value;
	
	if (Trim(txtnoidung) == "") {
		alert('Vui lòng nhập từ cần tra cứu ');
		f.word.focus();
		return false;
	}
	return true;
}
