function self(st)
{
	
	window.document.forms[0].target = "_self";

	window.document.forms[0].action = st;

	window.document.forms[0].submit();

}
function self_detail(st)
{
	
	window.document.forms[1].target = "_self";

	window.document.forms[1].action = st;

	window.document.forms[1].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 += "Đị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 checkWebsite(str){
	var textValue = str.value;
	
	var err=''
	
		if (textValue.indexOf('.') <= 0) {
			err += "Địa chỉ website không hợp lệ \n";
	}
	
	else if (textValue.indexOf('http://') < 0) {
			err += "Địa chỉ website không hợp lệ \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 doCheckOne()
{
	var alen = document.forms[0].elements.length;
	
	var isChecked = true;
	for (var i = 0 ; i < alen ;  i++)
	{
		if(document.forms[0].elements[i].type == "checkbox")
		{
			if(document.forms[0].elements[i].name != "chkall")
			{
				if(document.forms[0].elements[i].checked == false)
				{
					isChecked = false;
				}
			}
		}
	}
}
