function trimString (str) 
{
	str = this != window? this : str;
	return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}

function emptyText(str)
{
	if (trimString(str).length == 0)
		return true
	else
		return false
}

function getRadioValue(inObj)
{

	var value = new String
	value = null;
	var tmpLen = inObj.length
	if (tmpLen != null)
	{
		for (var i=0;i<inObj.length;i++)
			{	// alert('value:' + inObj(i).value)
				if (inObj[i].checked)
					{	value=inObj[i].value
						break
					}
			}
	}
	else
	{
		value = inObj.value
	}

	return value
}



function setRadioValue(inObj, inVal)
{
	for (var i=0;i<inObj.length;i++)
	{
		if (inObj[i].value == inVal)
		{	inObj[i].checked = true;
		}
		else
		{
			inObj[i].checked = false;
		}
	}
}

function validateIntInput(inField)
{
	var iString = inField.value
	
    if (!emptyText(iString))
	{
		if (("" + parseInt(iString)) == iString)
		{	inField.value = iString;		
			return true;
		}
		else
		{	alert('Value must be a numeric integer.');
			inField.value="";
			inField.focus();
			return false;
		}
	}
}

function validateInt(iString) 
{
    // no leading 0s allowed
    if (!emptyText(iString))
    {
		if (("" + parseInt(iString)) == iString)
		{		return iString;	    }
		else
		{	alert('Value must be a numeric integer.');
			return '';
		}
	}
	else
	{	return '';		}
}

function validateEmail(inVal)
{
	var tmpEMail = new String(inVal);
	
	//	empty value
	if (emptyText(inVal)) 
    {		return 1;       }
    
    //	Minimum of 7 characters
    if (tmpEMail.length <7)
    {		return 2;		}
    
    //	no @ sign
    var tmpPos1 = tmpEMail.indexOf ('@',0)
	if (tmpPos1 == -1)
    {		return 3;		}
    
    //	No .
    var tmpPos2 = tmpEMail.indexOf ('.',0)  
	if (tmpPos1 == -1)
	{		return 4;		}
	
	//	Check 3rd, 4th, 5th from last char 
	var tmpLength = tmpEMail.length;

	var tmpChar = tmpEMail.substring(tmpLength-3,tmpLength-2);
	if (tmpChar ==".")
	{	return 0		}

	var tmpChar = tmpEMail.substring(tmpLength-4,tmpLength-3);
	if (tmpChar ==".")
	{	return 0		}


	var tmpChar = tmpEMail.substring(tmpLength-5,tmpLength-4);
	if (tmpChar ==".")
	{	return 0		}

	return 5;
}

function resetSel(inCtl)
{
	inCtl.selectedIndex = 0;
}
function clearText(inCtl)
{
	inCtl.value = "";
}

function getCheckboxValues(inObj)
{
	var value = new String
	value = null;
	var tmpLen = inObj.length
	if (tmpLen != null)
	{
		for (var i=0;i<inObj.length;i++)
			{
				if (inObj(i).checked)
					{	
						value = value + "," + inObj(i).value
					}
			}
	}
	else
	{
		if (inObj.checked)
		{
			value = inObj.value
		}
	}

	return value
}

function changeTextAreaHeight(inSize, inCtl)
{
	if (parseInt(inSize)>0)
	{	inCtl.rows = parseInt(inSize)	}
	else
	{
		if (inSize=='LL')
		{	inCtl.rows = 30		}
		else
		{	
			if (inSize=='L')
			{	inCtl.rows = 20		}
			else
			{	inCtl.rows = 5		}
		}	
	}
}

function changeTextAreaWidth(inSize, inCtl)
{
	if (inSize=='W2')
	{	inCtl.cols = 120		}
	else
	{	
		if (inSize=='W1')
		{	inCtl.cols = 100	}
		else
		{	inCtl.cols = 80		}
	}	
}

function clearTextArea(inCtl)
{
	inCtl.value="";
}

function setCheckboxAll(inObj, inChecked)
{
	var tmpLen = inObj.length
	if (tmpLen != null)
	{
		for (var i=0;i<inObj.length;i++)
			{
				inObj(i).checked = inChecked
			}
	}
	else
	{
		inObj.checked = inChecked
	}

}


