function selectHighlightByValue( select, value )
{
	a = gEBI( select );
	for( var i = 0; i < a.options.length; i++)
	{
		if( a.options[ i ].value == value )
			a.selectedIndex = i
	}
}
function selectHighlightByTextByElement( a, text )
{
	for( var i = 0; i < a.options.length; i++)
	{
		if( a.options[ i ].text == text )
			a.selectedIndex = i
	}
}
function selectHighlightByText( select, text )
{
	a = gEBI( select );
	selectHighlightByTextByElement( a, text );
}
function selectRemoveAll( select )
{
	a = gEBI( select );
	while( a.options.length > 0 )
	{
		a.remove( 0 );
	}
}
function selectGetValue( select, textOrValue )
{
	//0 for value, 1 for text
	var value = "";
	
	if( select.options[ select.selectedIndex ].value == "x-DO-NOT-USE-x" )
		value = "";
	else
	{
		if( textOrValue == 0 )
			value = select.options[ select.selectedIndex ].value;
		if( textOrValue == 1 )
			value = select.options[ select.selectedIndex ].text;
	}
	if( value != "" )
		return value;
	else
		return null;
}
function selectToJSONString( select )
{
	a = gEBI( select );
	var myJSONString = "[";
	for( var i = 0; i < a.options.length; i++ )
	{
		myJSONString = myJSONString + "{\"name\":\"" + a.options[ i ].value.replace(/"/g,'\\"') +
			"\",\"value\":\"" + a.options[ i ].text.replace(/"/g,'\\"') + "\"}";
		if( i < a.options.length - 1 )
			myJSONString = myJSONString + ",";
	}
	myJSONString = myJSONString + "]";
	return myJSONString;
}
function selectSelectedToJSONString( select )
{
	a = gEBI( select );
	var myJSONString = "[";
	for( var i = 0; i < a.options.length; i++ )
	{
		if( a.options[ i ].selected )
		{
			myJSONString = myJSONString + "{\"name\":\"" + a.options[ i ].value.replace(/"/g,'\\"') +
				"\",\"value\":\"" + a.options[ i ].text.replace(/"/g,'\\"') + "\"},";
		}
	}
	if( myJSONString.length > 1 )
		myJSONString = myJSONString.substring( 0, myJSONString.length - 1 );
	myJSONString += "]";
	return myJSONString;
}
function attachIncrementalSearch( text, select )
{
	gEBI( text ).onkeyup = function() { incrementalSearch( text, select ); };
}
function incrementalSearch( text, select )
{
	var found = false;
	var a = gEBI( text ).value;
	var b = gEBI( select );
	for( var i = 0; i < b.options.length; i++ )
	{
		if( b.options[ i ].text.toUpperCase().indexOf( a.toUpperCase() ) == 0 )
		{
			found = true;
			break;
		}
	}
	if( found )
	{
		b.selectedIndex = i;
	}
}
function isInteger( a )
{
	if( parseInt( a ) != ( a - 0 ) )
		return false;
	else
		return true;
}
function getElementsByTagNameAndClassName( tagName, className )
{
	var all = document.getElementsByTagName( tagName );
	var elements = new Array();
	for( var i = 0; i < all.length; i++ )
	{
		if( all[ i ].className.toUpperCase().indexOf( className.toUpperCase() ) >= 0 )
			elements[ elements.length ] = all[ i ];
	}
	return elements;
}
function updateAll( a, b )
{
	inputs = getElementsByTagNameAndClassName( "input", b );
	for( var i = 0; i < inputs.length; i++ )
	{
		inputs[ i ].value = a.value;
	}
}
function textAreaEnlarge( id, hOrV, increaseSize, cap )
{
	a = gEBI( id );
	if( hOrV == "h" )
	{
		if( a.cols < cap )
			a.cols = a.cols + increaseSize;
	}
	else if( hOrV == "v" )
	{
		if( a.rows < cap )
			a.rows = a.rows + increaseSize;
	}
	else
		alert( "pass 'h' or 'v' " );
}
function textAreaShrink( id, hOrV, size )
{
	a = gEBI( id );
	if( hOrV == "h" )
		a.cols = size;
	else if( hOrV == "v" )
		a.rows = size;
	else
		alert( "pass 'h' or 'v' " );
}