var current_z_index = 3;

function get_cell(starting_element)
{
  	// first of all find the td element
  	var td = starting_element;
  	while (td && td.tagName != 'td' && td.tagName != 'TD')
  	{
  		td = td.parentNode;
  	}
	if (td)
	{
		// ok, now find a div(or DIV) that has class cell or cell_sticky : 
		var tag = td.tagName == 'TD' ? 'DIV' : 'div';
		var divs = td.getElementsByTagName(tag);
		for (var n = 0; n < divs.length; ++n)
		{
		   if (divs[n].className == 'cell' || divs[n].className == 'cell_sticky')
		   {
		      return divs[n];
		   }
		}
	}
	return null
}
    
function redisplay(event)
{
    if (!event) event = window.event;
    var target = event.target ? event.target : event.srcElement;
    var cell = get_cell(target);
    if (cell)
    {
        if (target.title == 'Close')
        {
            event.cancelBubble = true;  // stop this event from bubbling up to the redisplay event
            event.returnValue = false;
            event.cancel = true;
            cell.className = 'cell';
            cell.style.zIndex = 10000;
        }
        else if ((target.tagName == 'a' || target.tagName == 'A') && target.onclick == null)
        {
            // follow links UNLESS the link is the non JS link
            return true;
        }
        else
        {
            cell.className = 'cell_sticky';
            cell.style.zIndex = current_z_index++;
        }
    }
    return false;   // stop the a href being followed
}
