function updateStyle(className, element, value)
{
	var cssRules;
	if (document.all)
		cssRules = 'rules';
	else if (document.getElementById)
		cssRules = 'cssRules';

	for (var S = 0; S < document.styleSheets.length; S++)
		for (var R = 0; R < document.styleSheets[S][cssRules].length; R++)
			if (document.styleSheets[S][cssRules][R][cssRules])
			{
				for (var M = 0; M < document.styleSheets[S][cssRules][R][cssRules].length; M++)
					if (document.styleSheets[S][cssRules][R][cssRules][M].selectorText == className)
					{
						document.styleSheets[S][cssRules][R][cssRules][M].style[element] = value;
						return;
					}
			}
			else if (document.styleSheets[S][cssRules][R].selectorText == className)
			{
				document.styleSheets[S][cssRules][R].style[element] = value;
				return;
			}
}

function showingBlock(objectID)
{
  if (document.getElementById) return (document.getElementById(objectID).style.display != 'none');
}

function showBlock(objectID)
{
  if (document.getElementById) document.getElementById(objectID).style.display = '';
}

function hideBlock(objectID)
{
  if (document.getElementById) document.getElementById(objectID).style.display = 'none';
}

function swapAbstract(abstractID, documentID)
{
  if (showingBlock('abstract' + abstractID + '_row'))
  {
    hideBlock('abstract' + abstractID + '_row');
  }
  else
  {
    showBlock('abstract' + abstractID + '_row');

	var request = new ServerRequest('abstract.php', 'id=' + escape(documentID) + '&<?php echo $GLOBALS["SID"]; ?>', 'abstract' + abstractID);
	if (request.failed)
	  alert('Your current browser configuration does not allow for displaying abstracts.  Please contact support for assistance.');
  }
}

function clearAbstracts()
{
  if (!document.getElementById)
    return;
  for (i = 0; i >= 0; i++)
    if (document.getElementById('abstract' + i))
	  hideBlock('abstract' + i + '_row')
	else
	  return;
}

function setClass(objectID, className)
{
  if (document.getElementById) document.getElementById(objectID).className = className;
}

function switchTab(tab)
{
  for (var i = 1; i <= 4; i++)
    if (i != tab)
    {
      hideBlock('pane' + i);
      setClass('tab' + i, '');
    }

  showBlock('pane' + tab);
  setClass('tab' + tab, 'activetab');
  document.cookie = 'tab=' + tab;
}

var currentHit = -1;
function jumpHit(change)
{
  if (currentHit == -1)
    for (var i = 0; i < document.anchors.length; i++)
      if (document.anchors[i].name == 'hit1')
          currentHit = i;

  if (change == 1)
  {
    for (i = currentHit + 1; i < document.anchors.length; i++)
      if (document.anchors[i].name.substring(0, 3) == 'hit')
      {
        currentHit = i;
        window.location.hash = document.anchors[currentHit].name;
        return;
      }

    if (document.getElementById('nextdoc'))
    {
      window.location.href = document.getElementById('nextdoc').href + '&flash=true#hit1';
      return;
    }
    else
      alert('There are no additional hits available.');
  }
  else if (change == -1)
  {
    for (i = currentHit - 1; i >= 0; i--)
      if (document.anchors[i].name.substring(0, 3) == 'hit')
      {
        currentHit = i;
        window.location.hash = document.anchors[currentHit].name;
        return;
      }

    if (document.getElementById('prevdoc'))
    {
      window.location.href = document.getElementById('prevdoc').href + '&flash=true#hit1';
      return;
    }
    else
      alert('There are no previous hits available.');
  }
}