// params:
//      id: optional, if not null, identifies a specific error box is needed
//      display_data: data that will be displayed to the user in the error box body
//	      if display_data is an array, each element will be in individual error_body_item div tags.
//	      if display_data is not an array, all its contents will be displayed in a single error_body_item div.
//      header_text: optional, if not null, will change the header text
//      show_hide_action: optional, null = no change, true = show, false = hide
//      class_name_prefix: if not null, class_name_prefix and an underscore will prefix the css.
//	      specifically, the body_box_item
function ShowErrorBox(id, display_data, header_text, show_hide_action, class_name_prefix)
{
	var main_box_id = 'error_box';
	var heading_box_id = 'error_box_heading';
	var body_box_id = 'error_box_body';
	var hide_action_box_id = 'error_box_hide_action_wrapper';
	var body_item_box_css_class_name = 'error_box_body_item';
	// add id if needed
	if(id != null)
	{
		main_box_id = id + '_' + main_box_id;
		heading_box_id = id + '_' + heading_box_id;
		body_box_id = id + '_' + body_box_id;
		hide_action_box_id = id + '_' + hide_action_box_id;
	}
	
	if(class_name_prefix)
	{
		body_item_box_css_class_name = class_name_prefix + '_' + body_item_box_css_class_name;
	}
	
	var main_box_obj = document.getElementById(main_box_id);
	var heading_box_obj = document.getElementById(heading_box_id);
	var body_box_obj = document.getElementById(body_box_id);
	var hide_action_box_obj = document.getElementById(hide_action_box_id);

	if(header_text != null && heading_box_obj)
	{
		heading_box_obj.innerHTML = display_data;
	}
	
	if(hide_action_box_obj && show_hide_action != null)
	{
		if(show_hide_action == true)
			hide_action_box_obj.style.display = 'block';
		else
			hide_action_box_obj.style.display = 'none';
	}

	if(body_box_obj)
	{
		// *** determine if the variable is an array and build the appropriate
		//      display.
		if(display_data.constructor.toString().indexOf("Array") == -1)
		{
			body_box_obj.innerHTML = '<div class="'+body_item_box_css_class_name+'">'+display_data+'</div>';
		}
		else
		{
			var tmp_output = '';

			for(var key=0; key<display_data.length;key++)
			{
				tmp_output += '<div class="'+body_item_box_css_class_name+'">'+display_data[key]+'</div>';
	   		}
			body_box_obj.innerHTML = tmp_output;
		}
	}
	
	if(main_box_obj)
		main_box_obj.style.display = 'block';
}

function HideErrorBox(id)
{
	var main_box_id = 'error_box';
	if(id != null)
	{
		main_box_id = id + '_' + main_box_id;
	}
	
	var main_box_obj = document.getElementById(main_box_id);
	if(main_box_obj)
		main_box_obj.style.display = 'none';
	
}