// 20090203:mdd
function hide_fup(arg_fup_id, arg_click_text)
{
	$(arg_fup_id).style.display = 'none';
	
	// Clear all errors on the entire page.
	// 20090205:ehf
	error_collection = document.getElementsByClassName ('error');
	for ( var i=0; i < error_collection.length; i++ )
	{
		error_collection[i].style.display = 'none';
	}
	

	// Clear the fup.
	// 20090209:ehf
	var o_fup = document.getElementById(arg_fup_id);
	
	// Clear all textboxes and checkboxes in the form.
	var clear_form_collection = $(arg_fup_id).descendants();
	for ( i=0; i < clear_form_collection.length; i++ )
	{
		if ( clear_form_collection[i].tagName == 'INPUT' && clear_form_collection[i].type == 'text' )
		{
			clear_form_collection[i].value = '';
		}

		if ( clear_form_collection[i].tagName == 'INPUT' && clear_form_collection[i].type == 'checkbox' )
		{
			clear_form_collection[i].checked = false;
		}
	}  // end for loop through all descendants ( elements ) in the form itself.
	
	// Manipulate the elements inside the 'autocompleter' div id, which should only contain autocompleter elements.
	// var autocompleter_collection = $('autocompleter').descendants();
	var autocompleter_class = document.getElementById(arg_fup_id).getElementsByClassName('autocompleter');
	
	
	
	// Loop through each autocompleter class in the form.  It's possible we'll have multiple
	// autocompletes in one form.
	for ( var i=0; i < autocompleter_class.length; i++ )
	{
		//alert(autocompleter_class[i].id);
	
		var autocompleter_collection = autocompleter_class[i].descendants();
		
		if ( typeof autocompleter_collection != 'undefined' )
		{
			for ( var x=0; x < autocompleter_collection.length; x++ )
			{
				// alert('tagName: ' + autocompleter_collection[x].tagName + '  id: ' + autocompleter_collection[x].id) + '   type: ' +  autocompleter_collection[x].type;
				if ( autocompleter_collection[x].tagName == 'INPUT' && ( autocompleter_collection[x].type == 'text' || autocompleter_collection[x].type == 'button' ) )
				{
					if ( arg_click_text != '' )
					{
						autocompleter_collection[x].style.display = 'none';
					}
					else
					{
						autocompleter_collection[x].style.display = 'block';
					}
				}
				
				// Hide the autocompleter loading indicator.
				if ( autocompleter_collection[x].tagName == 'SPAN' )
				{
					autocompleter_collection[x].style.display = 'none';
				}
								
				// Replace 'click to edit'.
				if ( autocompleter_collection[x].tagName == 'DIV' && 
				   ( autocompleter_collection[x].className != 'value' &&
					 autocompleter_collection[x].className != 'row' &&
					 autocompleter_collection[x].className != 'autocomplete' &&
					 autocompleter_collection[x].className != 'error' &&
					 autocompleter_collection[x].className != 'label' &&
					 autocompleter_collection[x].className != 'processing') )
				{
					autocompleter_collection[x].style.display = 'block';
					autocompleter_collection[x].innerHTML = arg_click_text;
				}		
			} // end loop through autocomplete collection.
		}  // end autocompleter_collection.length != undefined.
	}
	
}  // end function hide_fup.


