/*!
	\brief Expands/collapses an element
	\param id - id of the element to expand/collapse (<XXX id="[id here]" ...>...</XXX>)
	\param retractor (optional) - reference to an html element that is triggering the toggle event - when passed, its inner html is changed to reflect the current expanded/retracted status
	\param contracted (optional) - text that retractor.innerHTML should show when controlled object is in its contracted state
	\param expanded (optional) - text that retractor.innerHTML should show when controlled object is in its expanded state
	\returns nothing
*/
function toggle_div(id, retractor, contracted, expanded)
{
	var element = get_element(id);
	var status=null;
	
	if(document.getElementById)
	{
		element.style.display = (element.style.display == 'none') ? 'block' : 'none';
		status = element.style.display;
	}
	else if(document.layers)
	{
		element.display = (element.display == 'none') ? 'block' : 'none';
		status = element.display;
	}
	/*else
	{
		eval("document.all." + id + ".style.display") = (eval("document.all." + id + ".style.display")=='none') ? 'block' : 'none';
		status = eval("document.all." + id + ".style.display");
	}*/
	
	if(arguments.length > 1)
		retractor.innerHTML = (status == "block") ? expanded : contracted;
}

/*!
	\brief Highlights an HTML element by changing its background color (HTMLElement.style.backgroundColor
	\param element - id of the element to highlight
	\returns nothing
	
	This is usually called as part of a mouseover event
*/
function Highlight(element_id)
{
	var element = get_element(element_id);
	
	if(element.marked == null || element.marked == false)
	{
		element.style.backgroundColor = highlight_bg;
	}
}

/*!
	\brief Un-highlights an HTML element by changing its background color (HTMLElement.style.backgroundColor
	\param element - id of the element to un-highlight
	\returns nothing
	
	This is usually called on a mouseout event
*/
function Restore(element_id)
{
	var element = get_element(element_id);

	if(element.marked == null || element.marked == false)
	{
		element.style.backgroundColor = default_bg;
	}
}

var mark_bg = "#EEEEFF";		// The color to mark cells with
var default_bg = "#FFFFFF";		// The color to un-highlight cells with*/
var last_marked = null;		// Reference to an HTML element, the last element that was marked

var highlight_bg = "#70AAD8";	// The color to highlight cells with
var mark_bg = "#BDCADA";		// The color to mark cells with
var default_bg = "#FFFFFF";		// The color to un-highlight cells with


/*!
	\brief cross-browser(?) element fetcher - fetches an HTML element
	\param id - the ID of the element to fetch
	\returns HTMLElement object
*/
function get_element(id)
{
	if(document.getElementById)
		return document.getElementById(id);
	return document.layers[id];
}