
function self(st)
{
	
	window.document.forms[0].target = "_self";

	window.document.forms[0].action = st;

	window.document.forms[0].submit();

}
function IsNumeric(sText)
{

	var ValidChars = "0123456789.";
	var IsNumber=true;	
	var Char;
	for (i = 0; i < sText.length && IsNumber == true; i++) 	
	{ 	
		Char = sText.charAt(i); 
		if (ValidChars.indexOf(Char) == -1) 	
		{		
			IsNumber = false;		
		}	
	}	
	return IsNumber;
}
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 += "E-mail not value";
		alert(err);
		str.focus();
		return false
	}
	if (textValue.indexOf('@') <= 0 || textValue.indexOf('@') == textValue.length -1){
		err += "E-mail not value";		
	} else {
		var substr = textValue.substring(textValue.indexOf('@'),textValue.length);
		if (textValue.indexOf('.') <= 0) {
			err += "E-mail not value \n";
		}
	}
	if (err != '') { 
		alert(err); 
		str.focus();
		return false;
	}
	return true;
}
function checkMail(f)
{
	if (!checkEmail(f.txtemail)) {
	return false
	}
	return true;
}
/**/

function MM_goToURL() { //v3.0

  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;

  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");

}

function chkremove(ctrChkName) {

  fg = false;

  with (document.forms[0]) {

	 len = elements.length;

     for(var ii=0; ii<len; ii++) {

		if ((elements[ii].name == ctrChkName) && (elements[ii].checked)) {

			fg = true;

			break;

		}

	}

  }

  return(fg)

}

 function setchecked(val,ctrChkName) {

  with (document.forms[0]) {

	 len = elements.length;

     for(var ii=0; ii<len; ii++) {

		if (elements[ii].name == ctrChkName) {

			elements[ii].checked = val;

		}

	}

  }

}
function checkCompany(f)
{
	companyName	= f.txtCompany.value;

	if (Trim(companyName) == "") {
		alert('Vui lòng nhập tên công ty');
		f.txtCompany.focus();
		return false;
	}
	txtAddress	= f.txtAddress.value;
	if (Trim(txtAddress)== "")
	{
		alert('Nhập địa chỉ công ty');
		f.txtAddress.focus();
		return false;
	}
	txtPhone	= f.txtPhone.value;
	if (Trim(txtPhone)== "")
	{
		alert('Nhập số điện thoại công ty');
		f.txtPhone.focus();
		return false;
	}
	if (!checkEmail(f.txtEmail)) 
	{
		
		return false
	}
	if (!checkEmail(f.txtemailcontact)) 
	{
		
		return false
	}
	if (!checkEmail(f.txtemailabroad)) 
	{
		
		return false
	}
	if (!checkEmail(f.txtemailticket)) {
		
	return false
	}
	return true;
}
/*kiem tra thong tin tour*/
function checkTour(f) {
	
	cmbcat = f.cmbcat.value;
	
	if (Trim(cmbcat) == "0") {
		alert('Vui lòng chọn loại tour');
		f.cmbcat.focus();
		return false;
	}
	txttourcode = f.txttourcode.value;
	
	if (Trim(txttourcode) == "") {
		alert('Vui lòng nhập mã tour');
		f.txttourcode.focus();
		return false;
	}
	
	txtdays = f.txtdays.value;
	if (!IsNumeric(txtdays)) {
		alert('Số ngày đi phải là số');
		f.txtdays.focus();
		return false;
	}
	
	txtnights = f.txtnights.value;
	if (!IsNumeric(txtnights)) {
		alert('Số đêm đi phải là số');
		f.txtnights.focus();
		return false;
	}
	
	
	txtitinerary = f.txtitinerary.value
	if (txtitinerary =="")
	{
		alert('Vui lòng nhập hành trình chuyến đi');
		f.txtitinerary.focus();
		return false;
	}
	/*txtemail_contact = f.txtemail_contact.value
	if (txtemail_contact !="")
	{
		if (!checkEmail(f.txtemail_contact)) {
			return false
		}
	}
	txtemail_order = f.txtemail_order.value
	if (txtemail_order !="")
	{
		if (!checkEmail(f.txtemail_order)) {
			return false
		}
	}
	txtemail_recruit = f.txtemail_recruit.value
	if (txtemail_recruit !="")
	{
		if (!checkEmail(f.txtemail_recruit)) {
			return false
		}
	}
	return true;	*/
}
function checkNewsletter(f)
{
	txtsubject = f.txtsubject;
	if (!checkEmail(txtsubject)) 
	{
		
		return false
	}
	
	return true;
}
/**/
function checkGallery(f)
{
	cmbcat = f.cmbcat.value
	if (cmbcat == "0")
	{
		alert('Vui lòng chọn tên chủ đề');
		f.cmbcat.focus();
		return false;
	}
	txtnotice = f.txtnotice.value;
	if (txtnotice == "")
	{
		alert('Vui lòng nhập tiêu đề');
		f.txtnotice.focus();
		return false;
	}
	return true;
}
function checkvndncn(f)
{
	cmbcat = f.cmbcat.value
	if (cmbcat == "0")
	{
		alert('Vui lòng chọn tên chủ đề');
		f.cmbcat.focus();
		return false;
	}
	txtnotice = f.txtnotice.value;
	if (txtnotice == "")
	{
		alert('Vui lòng nhập tiêu đề');
		f.txtnotice.focus();
		return false;
	}
	return true;
}
function checkGroup(f)
{
	txtcat = f.txtcat.value
	if (txtcat == "")
	{
		alert('Vui lòng nhập tên loại tour');
		f.txtcat.focus();
		return false;
	}
	return true;
}
/**/
function checkProgram(f)
{
	cmbcat = f.cmbcat.value
	if (cmbcat == "0")
	{
		alert('Vui lòng chọn tên loại tour');
		f.cmbcat.focus();
		return false;
	}
	txtnotice = f.txtcat.value;
	if (txtnotice == "")
	{
		alert('Vui lòng nhập tên chương trình');
		f.txtcat.focus();
		return false;
	}
	return true;
}
function checkGroup(f)
{
	txtcat = f.txtcat.value
	if (txtcat == "")
	{
		alert('Vui lòng nhập tên chủ đề');
		f.txtcat.focus();
		return false;
	}
	return true;
}
function checkTeam(f)
{
	cmbcat = f.cmbcat.value
	if (cmbcat == "0")
	{
		alert('Vui lòng chọn tên chủ đề');
		f.cmbcat.focus();
		return false;
	}
	txtsubject = f.txtsubject.value;
	if (txtsubject == "")
	{
		alert('Vui lòng nhập tên trò chơi');
		f.txtsubject.focus();
		return false;
	}
	
	return true;
	
}
function checkTitle(f)
{
	txtsubject = f.txtsubject.value
	if (txtsubject == "")
	{
		alert('Vui lòng nhập tiêu đề');
		f.txtsubject.focus();
		return false;
	}
	return true;
}
function checkSubject(f)
{
	txtsubject = f.txtsubject.value
	if (txtsubject == "")
	{
		alert('Vui lòng nhập tên chủ đề');
		f.txtsubject.focus();
		return false;
	}
	return true;
}
function checkCity(f)
{
	txtcat = f.txtcat.value
	if (txtcat == "")
	{
		alert('Vui lòng nhập tên quốc gia hoặc tỉnh thành');
		f.txtcat.focus();
		return false;
	}
	return true;
}
function checkHotel(f)
{
	cmbcat = f.cmbcat.value
	if (cmbcat == "0")
	{
		alert('Vui lòng chọn châu lục hoặc quốc gia');
		f.cmbcat.focus();
		return false;
	}
	cmbprogram = f.cmbprogram.value
	if (cmbprogram == "0")
	{
		alert('Vui lòng chọn tỉnh thành hoặc quốc gia');
		f.cmbprogram.focus();
		return false;
	}
	txthotel_name = f.txthotel_name.value
	if (txthotel_name == "")
	{
		alert('Vui lòng nhập tên khách sạn');
		f.txthotel_name.focus();
		return false;
	}
	txtaddress = f.txtaddress.value
	if (txtaddress == "")
	{
		alert('Vui lòng nhập địa chỉ khách sạn');
		f.txtaddress.focus();
		return false;
	}
	return true;
}
function checkTransport(f)
{
	cmbcat = f.cmbcat.value
	if (cmbcat == "0")
	{
		alert('Vui lòng nhập tên loại phương tiện');
		f.cmbcat.focus();
		return false;
	}
	txtnotice = f.txtnotice.value
	if (txtnotice == "")
	{
		alert('Vui lòng nhập tên phương tiện');
		f.txtnotice.focus();
		return false;
	}
	return true;
}
function checkNews(f)
{
	
	cmbsub = f.cmbsub.value
	if (cmbsub == "0")
	{
		alert('Vui lòng chọn chủ đề');
		f.cmbsub.focus();
		return false;
	}
	txtsubject = f.txtsubject.value
	if (txtsubject == "")
	{
		alert('Vui lòng nhập tiêu đề tin tức');
		f.txtsubject.focus();
		return false;
	}
	txtshortintro = f.txtshortintro.value
	if (txtshortintro == "")
	{
		alert('Vui lòng nhập nội dung giới thiệu ngắn');
		f.txtshortintro.focus();
		return false;
	}
	txtauthor = f.txtauthor.value
	if (txtauthor == "")
	{
		alert('Vui lòng nhập tác giả bài viết');
		f.txtauthor.focus();
		return false;
	}
	return true;
}
function checkProject(f)
{
	txtsubject = f.txtsubject.value
	if (txtsubject == "")
	{
		alert('Vui lòng nhập tên');
		f.txtsubject.focus();
		return false;
	}
	
	
	return true;
}
function checkBanner(f)
{
	txttendn = f.txttendn.value
	if (txttendn == "")
	{
		alert('Vui lòng nhập tên');
		f.txttendn.focus();
		return false;
	}
	return true;
}
function checkCat(f)
{
	cmbsub = f.cmbsub.value
	
	if (cmbsub == "0")
	{
		alert('Vui lòng chọn nhóm tour');
		f.cmbsub.focus();
		return false;
	}
	txtsubject = f.txtsubject.value
	if (txtsubject == "")
	{
		alert('Vui lòng nhập tên loại tour');
		f.txtsubject.focus();
		return false;
	}
	/*txtshortintro = f.txtshortintro.value
	if (txtshortintro == "")
	{
		alert('Vui lòng nhập nội dung giới thiệu');
		f.txtshortintro.focus();
		return false;
	}	*/
}
function checkDestination(f)
{
	cmbcat = f.cmbcat.value
	if (cmbcat == "0")
	{
		alert('Vui lòng chọn châu lục hoặc quốc gia');
		f.cmbcat.focus();
		return false;
	}
	cmbprogram = f.cmbprogram.value
	if (cmbprogram == "0")
	{
		alert('Vui lòng chọn tỉnh thành hoặc quốc gia');
		f.cmbprogram.focus();
		return false;
	}
	txthotel_name = f.txthotel_name.value
	if (txthotel_name == "")
	{
		alert('Vui lòng nhập tên điểm tham quan');
		f.txthotel_name.focus();
		return false;
	}
	
	return true;
}
function checkRate(f)
{
	txtsubject = f.txtsubject.value
	if (txtsubject == "")
	{
		alert('Vui lòng nhập tên ngoại tệ');
		f.txtsubject.focus();
		return false;
	}
	
	
	txtbuy = f.txtbuy.value
	if (txtbuy == "")
	{
		alert('Vui lòng nhập giá trị');
		f.txthotel_name.focus();
		return false;
	}
	
	
	txtsell = f.txtsell.value
	if (txtsell == "")
	{
		alert('Vui lòng nhập giá trị');
		f.txtsell.focus();
		return false;
	}
	
	return true;
}