/*======================================================================
FUNCTION: 	Trim(VALUE)
======================================================================
FUNCTION: 	RTrim(VALUE)
======================================================================
FUNCTION: 	LTrim(VALUE)
======================================================================
*/

function Trim(VALUE) {
	var strTemp = "";
	
	strTemp = LTrim(RTrim(VALUE));
	
	return strTemp;
}

function RTrim(VALUE)
{
	var w_space = String.fromCharCode(32);	
	var v_length = VALUE.length;
	var strTemp = "";
	
	if(v_length < 0)
	{
		return"";
	}
	var iTemp = v_length -1;
	
	while(iTemp > -1)
	{
		if(VALUE.charAt(iTemp) == w_space)
		{
			
		}
		else
		{
			strTemp = VALUE.substring(0,iTemp +1);
			break;
		}
		iTemp = iTemp-1;
	} //End While
	
	return strTemp;
} //End Function

function LTrim(VALUE)
{
	var w_space = String.fromCharCode(32);
	
	if(v_length < 1)
	{
		return"";
	}
	
	var v_length = VALUE.length;
	var strTemp = "";
	var iTemp = 0;
	
	while(iTemp < v_length)
	{
		if(VALUE.charAt(iTemp) == w_space)
		{
		
		}
		else
		{
			strTemp = VALUE.substring(iTemp,v_length);
			break;
		}
		iTemp = iTemp + 1;
	} //End While
	
	return strTemp;
} //End Function


// -------------------------------------------------------------------
// TabNext()
// Function to auto-tab phone field
// Arguments:
//   obj :  The input object (this)
//   event: Either 'up' or 'down' depending on the keypress event
//   len  : Max length of field - tab when input reaches this length
//   next_field: input object to get focus after this one
// -------------------------------------------------------------------
var phone_field_length=0;
function TabNext(obj,event,len,next_field) {
	if (event == "down") {
		phone_field_length=obj.value.length;
		}
	else if (event == "up") {
		if (obj.value.length != phone_field_length) {
			phone_field_length=obj.value.length;
			if (phone_field_length == len) {
				next_field.focus();
				}
			}
		}
	}
