
//
// Popup Window
//
function popwin(url, name, width, height, location, menubar, status, toolbar)
{
	if (name == null)
	{
		name = "stdWin";
	}
	if (width == null)
	{
		width = 550;
	}
	if (height == null)
	{
		height = 500;
	}
	if (location == null)
	{
		location = "no"
	}
	if (menubar == null)
	{
		menubar = "yes"
	}
	if (status == null)
	{
		status = "yes"
	}
	if (toolbar == null)
	{
		toolbar = "yes"
	}

	popup = window.open(url, name, 'width=' + width + ',height=' + height + ',location=' + location + ',menubar=' + menubar + ',status=' + status + ',toolbar=' + toolbar +',scrollbars=yes,resizable=yes,screenx=0,screeny=0,left=0,top=0');
	if (window.focus) setTimeout("popup.focus()",100);
}


//
// Removing spaces from the beginning of a string
//
function ltrim(strText)
{
	while (strText.charAt(0)==" ")
	{
		strText = strText.substring(1);
	}
	return strText;
}

//
// Removing spaces from the end of a string
//
function rtrim(strText)
{
	while (strText.charAt( strText.length-1 )==" ")
	{
		strText = strText.substring(0, strText.length-1);
	}
	return strText;
}

//
// Removes spaces from both ends using above functions
//
function trim(strText)
{
	strText = ltrim(strText);
	strText = rtrim(strText);
	return strText;
}

//
// Validation for to check a string includes @ and looks like it takes the form of an email address
//
function isEmailAddr(email)
{
	var result = false;
	var theStr = new String(email)
	var index = theStr.indexOf("@");
	if (index > 0)
	{
		var pindex = theStr.indexOf(".",index);
		if ((pindex > index+1) && (theStr.length > pindex+1))
		result = true;
	}
	return result;
}
