// JavaScript Document
function isCharsInBag (s, bag)
{  
	var i;
	for (i = 0; i < s.length; i++)
	{   
		var c = s.charAt(i);
		if (bag.indexOf(c) == -1) return false;
	}
	return true;
}
function isCharsInBagRB (s, bag)
{  
	var i;
	for (i = 0; i < s.length; i++)
	{   
		var c = s.charAt(i);
		if (!bag.indexOf(c) == -1) return false;
	}
	return true;
}
function EC(e, message){
    var re = /^([A-Za-z0-9\_\-]+\.)*[A-Za-z0-9\_\-]+@[A-Za-z0-9\_\-]+(\.[A-Za-z0-9\_\-]+)+$/;
    var sEMail = e.value;
    if (sEMail==""){
	alert("Chua nhap dia chi Email !");
	e.focus();
	return (false);
		}
		else if (sEMail.search(re) == -1){
	alert(message);
	e.select()
	e.focus()
	return (false);
	}
	else{
	return (true);
    }
}
/*
	Author: vutt <vutt@von-inc.com>
	Date: 30/11/2007
	Description: Khoi tao danh sach cac ki tu khong cho phep
*/
function isBlackListTag(strCheck)
{
	var arrList = new Array();
	arrList[0] = "<";
	arrList[1] = ">";
	arrList[2] = "=";
	arrList[3] = "#";
	arrList[4] = "[";
	arrList[5] = "]";
	arrList[6] = "{";
	arrList[7] = "}";
	arrList[8] = "*";
	arrList[9] = "^";
	arrList[10] = "~";
	arrList[11] = "\$";
	for(var i=0;i<arrList.length;i++)
	{
		if(strCheck.indexOf(arrList[i])>=0)	
		{
			return true;	
		}
	}
	return false;
}
/*
	Author: vutt <vutt@von-inc.com>
	Date: 30/11/2007
	Description:Kiem tra gia tri nhap vao
*/
function checkInputNormalText(strCheck)
{
    var strMessage = strCheck; 
    if (strMessage=="")
	{		 	
		return (false);
	}
	else if(isBlackListTag(strCheck))
	{
		return (false);
	}
	else
	{
		return (true);
    }
}
function isNumber(strCheck)
{
	if(strCheck == '')
	{
		return false;	
	}
	return !isNaN(strCheck);
}
function checkEmail(stringIn) 
{
		
	var re = /^([A-Za-z0-9\_\-]+\.)*[A-Za-z0-9\_\-]+@[A-Za-z0-9\_\-]+(\.[A-Za-z0-9\_\-]+)+$/;
    var sEMail = stringIn;
    if (sEMail=="")
	{
		return (false);
	}
	else if (sEMail.search(re) == -1)
	{
		return (false);
	}
	else
	{
		return (true);
    }
}

function addCommas(nStr)
{
	nStr += '';
	
	x = nStr.split('.');
	x1 = x[0];
	
	x2 = x.length > 1 ? '.' + x[1] : '';
	
	var rgx = /(\d+)(\d{3})/;
	
	while (rgx.test(x1))
	{
		x1 = x1.replace(rgx, '$1' + '.' + '$2');
	}
	
	return x1 + x2;
}
function removeCommas(theString)
{
	var rgx = /(\.)/g;
	
	return theString.replace(rgx, "");
}
//cat bo khoang trang 2 dau
function trim(val)
{ 
	return val.replace(/^\s+|\s+$/g,"");
}