
function PopupArgument()
{
	this.nReturnValue	= 0; 
	this.sReturnValue	= ""; 
	this.bReturnValue	= false; 
	this.bLoggedOff		= false;
	
	

	
	this.IsSessionValid = function()	
	{
		if(this.bLoggedOff)
		{
			__doPostBack('SessionInvalid', '');
		}
	}
}


function PopupWindow(pUrl, pWidth, pHeight)
{
	
	var features = "dialogWidth="+pWidth+"px;dialogHeight="+pHeight+"px;center=yes;help=no;status=yes;scroll=no;";
	var popupArgs = new PopupArgument();
	window.showModalDialog(pUrl, popupArgs, features);
	popupArgs.IsSessionValid();
	
	return popupArgs;
}


function ltrim(str)
{

	var result = "";
	for(i=0;i<str.length;i++)
	{
		if(str.substr(i,1) != " ")
		{
			result = str.substr(i, str.length);
			break;
		}
	}
	return result;
}
function rtrim(str)
{

	var result = "";
	for(i=str.length-1;i>=0;i--)
	{
	
		if(str.substr(i,1) != " ")
		{
			result = str.substr(0, i+1);
			break;
		}
	}
	return result;
}
	
function trim(str)
{
	return rtrim(ltrim(str));
}

function padr(str, pad, cnt)
{
	for(i=str.length;i<cnt;i++)
	{
		str += pad;
	}
	return str;
}
function padl(str, pad, cnt)
{
	var result = str;
	for(i=str.length;i<cnt;i++)
	{
		result = pad+result;
	}
	return result;
}		

function isAlien(a) {
   return isObject(a) && typeof a.constructor != 'function';
}
function isArray(a) {
    return isObject(a) && a.constructor == Array;
}
function isBoolean(a) {
    return typeof a == 'boolean';
}
function isEmpty(o) {
    var i, v;
    if (isObject(o)) {
        for (i in o) {
            v = o[i];
            if (isUndefined(v) && isFunction(v)) {
                return false;
            }
        }
    }
    return true;
}
function isFunction(a) {
    return typeof a == 'function';
}
function isNull(a) {
    return typeof a == 'object' && !a;
}
function isNumber(a) {
    return typeof a == 'number' && isFinite(a);
}
function isObject(a) {
    return (a && typeof a == 'object') || isFunction(a);
}
function isString(a) {
    return typeof a == 'string';
}
function isUndefined(a) {
    return typeof a == 'undefined';
} 


function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop;
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}


function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft;
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}	

function getAvailW()
{
    var w = 0;
    if (document.all)
        w = document.body.offsetWidth;
    else if (document.layers)
        w = window.innerWidth;
    return w;
}
function getAvailH()
{
    var h = 0;
    if (document.all)
        h = document.body.offsetHeight;
    else if (document.layers)
        h = window.innerHeight;
    return h;
}
