
/* ***********************************************************************
 *
 * Date			Initials		Description
 * -----			--------		-----------
 * 30Jun2008	S.Kwong		Add audio parameter to doSubmit as required to
 *  								  to detect session expiration and yet be able to
 *									  display the session expiration message and audio
 * 								  in the appropriate language.
 *
 * ***********************************************************************
 */

function isan(_str)
{
	var success = false;
	if (isNaN(_str) == false) {
		success = true;
	}
	return success;
}

function isPositiveNumber(_str)
{
	var success = false;
	_str = globalReplace(_str,",", "");
	_str = globalReplace(_str," ", "");
	if ( (parseInt(_str) >= 0) || (_str == "") )
	{
		if (isan(_str))
		{
			success = true;
		}
	}
	return success;	
}

function globalReplace(_str, findThis, replaceThis)
{
	while (_str.indexOf(findThis) > -1) {
		_str = _str.replace(findThis, replaceThis);
	}
	return _str
}

function ltrim(_str)
{
	var outString = _str;

	while(''+outString.charAt(0)==' '){
		outString=outString.substring(1,outString.length);
	}
	return outString;
}

function rtrim(_str)
{
	var outString = _str;

	while(''+outString.charAt(outString.length-1)==' '){
		outString=outString.substring(0,outString.length-1);
	}
	return outString;
}

function trim(_str)
{
	var outString = _str;

	outString = ltrim(outString);
	outString = rtrim(outString);
	return outString;
}

function doSubmit(_action, _lang, _audio)
{
	var _act = _action;
	if (!_lang) _lang = "";
	
	if (!_audio) _audio = "";
	
	if (_lang != "")
	{
		_act = _action + "?lang=" + _lang;
	}
	if (_audio != "")
	{
		_act = _act + "&aud=" + _audio;
	}
	document.frmWO.action = _act;
	document.frmWO.submit();
}

function doPopupSubmit(_action, lang, aud)
{
	document.frmWO.action = _action + '?lang=' + lang + '&aud=' + aud;
	document.frmWO.target = 'windowName';
	document.frmWO.onSubmit = openWindow();
	document.frmWO.submit();
}

function doPopupPrint()
{
	document.Print.target = 'windowName';
	document.Print.onSubmit = openWindow();
	document.frmWO.submit();
}

function closeBrowser()
{
	if(navigator.appName=="Microsoft Internet Explorer") {
		this.focus();
		self.opener = this;
		self.close();
	}else {
	window.open('','_self','');
	window.close();
	}
}

function IdentifyBrowser()
{
	if(navigator.appName=="Lynx") {
		return true;
	}else {
		return false;
	}
}

function CheckPrint()
{
	if (window.print)
	{
		window.print();
		self.close();
	} 
}