/*
return element object by Id
@param string, object Id
@return element object
*/
function elId(id){return document.getElementById(id);}

/*
return element object by name
@param string, object name
@return element object
*/
function elName(name){return document.getElementByName(name);}

/**
 * trim value
 * @param string strToTrim. value to be trim.
 * @return string
 */
function trim(strToTrim)
{
	return strToTrim.replace(/^\s+|\s+$/g,"");
}

/**
 * set object visibility
 * @param string strObjName. object name.
 * @param boolean blnShow. true=visible | false=collapse
 */
function setObjVisibility(strObjName, blnShow)
{	
	var obj = elId(strObjName);
	if(obj == null) return;

	var strVisibleValue ;
//	if(blnShow == 'true') strVisibleValue = 'visible';
//	else strVisibleValue = 'collapse';
//	obj.style.visibility = strVisibleValue;
	
	if(blnShow == 'true')
	{
		obj.style.display = '';
		obj.style.visibility = 'visible';		
	}
	else obj.style.display = 'none';
}

/**
 * set object Div msg
 * @param string strObjName. regex.
 * @param string strMsg. msg
 * @param string strClassName. css class name
 */
function setDivMsg(strObjName, strMsg, strClassName)
{
	var obj = elId(strObjName);
	if(obj == null) return;
	if(typeof(strClassName) != 'undefined' && strClassName.length > 0) 
	{
		strMsg = "<span class='" + strClassName +"'>" + strMsg + "</span>";
	}
	obj.innerHTML  = strMsg;
}

/*
* Do submit
*/
function doSubmit(objCtrl)
{
	objCtrl.form.submit();
}

/*
* Do Client site language translation
*/
function lang(strKey)
{
	var translation = eval(strKey);
	if(translation == '') return strKey;
	return translation;
}

/*
* Include a js file in a js file. same as includeJs2 
*/
function includeJs(strUrl)
{
	var str = '<script type="text/javascript" src="' + strUrl + '"></script>';
	document.write(str); 
}

/*
* Include a js file in a js file. same as includeJs 
*/
function includeJs2(strUrl)
{
	var body = document.getElementsByTagName('body').item(0);
	script = document.createElement('script');
	script.src = strUrl;
	script.type = 'text/javascript';
	body.appendChild(script);
}

function popWin(url, h, w) 
{
	if(typeof(h) == 'undefined') h = 600;
	if(typeof(w) == 'undefined') w = 700;
	
	var winW = GetWidth();
	var winH = GetHeight();
	var intTop = Math.round((winH-h)/2);;
	var intLeft = Math.round((winW-w)/2);

	mywin =window.open(url, "mywin", "left="+intLeft+",top="+intTop+",menubar=no,height="+h+",width="+w+",scrollbars=yes,resizable=no");
	mywin.focus();
} 


function GetWidth()
{

        var x = 0;
        if (self.innerWidth)
        {
                x = self.innerWidth;
        }
        else if (document.documentElement && document.documentElement.clientWidth)
        {
                x = document.documentElement.clientWidth;
        }
        else if (document.body)
        {
               x = document.body.clientWidth;
        }
        return x;

}

function GetHeight()
{

        var x = 0;
        if (self.innerHeight)
        {
                x = self.innerHeight;
        }
        else if (document.documentElement && document.documentElement.clientHeight)
        {
                x = document.documentElement.clientHeight;
        }
        else if (document.body)
        {
               x = document.body.clientHeight;
        }
        return x;

}


function popup_win( loc, wd, hg ) {
var remote = null;
remote = window.open('','','width=' + wd + ',height=' + hg + ',resizable=0,scrollbars=1,top=0,left=0');
if (remote != null) {
if (remote.opener == null) {
remote.opener = self;
}
remote.location.href = loc;
} 
else { self.close(); }
}

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) 
        {
			return false;
		}
	}
	return IsNumber;
   
}


