/*
-------------------------------------------------------------------------------
Purpose: left trim javascript function
---------------------------------------------------------------------------------
*/
function leftTrim(str)
{
	var strTemp = str;
	while(strTemp.length>0)
	{
		if(strTemp.charAt(0)==" ")
		{
			if(strTemp.length>1)
				strTemp = strTemp.substring(1,strTemp.length);
			else
				strTemp = "";
		}
		else break;
	}
	return strTemp;
}
/*
-------------------------------------------------------------------------------
Purpose: right trim javascript function
---------------------------------------------------------------------------------
*/
function rightTrim(str)
{
	var strTemp = str;
	while(strTemp.length>0)
	{
		if(strTemp.charAt(strTemp.length-1)==" ")
		{
			if(strTemp.length>1)
				strTemp = strTemp.substring(0,strTemp.length-1);
			else
				strTemp = "";
		}
		else break;
	}
	return strTemp;
}
/*
---------------------------------------------------------------------------------
Purpose: trim javascript function
---------------------------------------------------------------------------------
*/
function trim(str)
{
	return(leftTrim(rightTrim(str)));
}
/*
---------------------------------------------------------------------------------
Purpose: check if keyCode in Chrs or not
---------------------------------------------------------------------------------
*/
function CheckChr(keyCode, Chrs)
{
	if(keyCode==13)return true;
	var strKeyCode=String.fromCharCode(keyCode)
	if(Chrs.indexOf(strKeyCode)!=-1)return true;
}
/*
---------------------------------------------------------------------------------
Purpose: Open popup window
---------------------------------------------------------------------------------
*/
function openWin(URL, wdh, hgt, scrollbrs, resize) {
	tb = "no"   //toolbars
	mb = "no"   //menubars
	st = "no"   //status

	if(resize != 'yes' && resize != 'no') 
		re =  "yes";
	else
		re = resize;

	if(scrollbrs != 'yes' && scrollbrs != 'no') 
		sb =  "yes";
	else
		sb = scrollbrs;

	if (hgt >= screen.availHeight)
	{
		hgt = screen.availHeight - 100;
	}
		  
	var h = hgt
	var w = wdh
	var winl = (screen.width - w)/2;
	var wint = (screen.availHeight - h)/2;
	  
	strWindow = "width="+w+",height="+h+",top="+wint+",left="+winl;
	strWindow = strWindow+",toolbar="+tb+",menubar="+mb+",scrollbars="+sb;
	strWindow = strWindow+",status="+st+",resizable="+re;
	  
	window.open(URL,"_popup",strWindow);
}