function trim_blah( thestring ) {
	return thestring.replace(/^\s*/,"").replace(/\s*$/,"");
}

function trim( theText ) {
	return theText.replace(/^\s{1,}/, "").replace(/\s{1,}$/, "")
}


function deComma( thestring ) {
	return thestring.replace(/[,]/,"");
}

function getFieldValue ( theField, vType ) { 

//this function will return the field value (or value list) based on the element type 
//FROM NOTES.NET - WRITTEN BY KAREN HOBART

theValue = ""; 
sep = ""; 
hits = 0; 

//text is the user-entered value as a string
if ( vType == "text" ) return ( trim( theField.value ) ) ; 

if ( vType == "number" ) return ( trim( theField.value ) ) ;
if ( vType == "time" ) return ( theField.value ) ;
if ( vType == "date" ) return ( theField.value ) ;

//select is an array of selection pointers to an array of strings representing the choices
if ( vType == "select" ) { 

	for ( i = 0; i < theField.options.length; i++ ) {
		if ( theField.options[i].selected ) theValue += theField.options[i].text 
	}

	if (theValue == "- Select -") {
		return("");
	} else {
		return ( theValue );
	}
}

//textarea is the user-entered value as a string array of one element
if ( vType == "textarea" ) return ( trim( theField.value ) );

//checkboxes & radio buttons are not so simple
if ( vType == "checkbox" || vType == "radio" ) { 

if ( theField.value == null ) { 

//if we're here, we are validating a radio button or a nn multi-element checkbox 

for ( i = 0; i < theField.length; i++ ) { 
if ( theField[i].checked ) { 
hits++; 
if ( hits > 1 ) {
sep = "; ";
} 
theValue += sep + theField[i].value; 
} 
}
} 
return ( theValue );

} else { 

//if we are here, must be an ie checkbox, or nn with a one-element checkbox") 

if ( navigator.appName == "Microsoft Internet Explorer" ) { 

//ie. return some data so we can validate on the server; 
return ("can't validate on client")
} 

//nn one-element checkbox, see if its checked ...
if (theField.checked ) { 
return ( theField.value ); 

} else {
return ( "" ); 
} 
} 
}

function getRadioValue ( theField ) 
{ 
theValue = ""; 

if ( theField.value == null ) 
{ 
	//if we're here, we are validating a radio button or a nn multi-element checkbox 
	for ( i = 0; i < theField.length; i++ ) 
	{ 
		if ( theField[i].checked ) 
		{ 
			theValue = theField[i].value; 
		} 
	}
} 
return ( theValue );

}

function GetSelectedText( theField )
{
theValue = ""; 

for ( i = 0; i < theField.options.length; i++ ) 
  {
  if ( theField.options[i].selected ) 
    {
      if ( theField.options[i].value == "" ) 
      {
        theValue += theField.options[i].text ;
      }
      else
      {
        theValue += theField.options[i].value ;
      }
    }
  }

return ( theValue );
}

