

function GetScrollPosX()
{
  if (self.pageYOffset)
    return self.pageXOffset;
  if (document.documentElement && document.documentElement.scrollTop)
    return document.documentElement.scrollLeft;
  if (document.body)
    return document.body.scrollLeft;
  return 0;
}

function GetScrollPosY()
{
  if (self.pageYOffset)
    return self.pageYOffset;
  if (document.documentElement && document.documentElement.scrollTop)
    return document.documentElement.scrollTop;
  if (document.body)
    return document.body.scrollTop;
  return 0;
}

function SetScrollPos(x,y)
{
  window.scrollTo(x, y);
}

// display help panel
function ShowHelp(event, divId)
{
  var element = document.getElementById(divId);
  var width = element.offsetWidth + 10;
  var cX = 0; var cY = 0; var rX = 0; var rY = 0; var innerWidth = 0;
  
  // for all browsers supporting "documentElement.clientWidth"
  if (typeof document.documentElement != 'undefined'
      && typeof document.documentElement.clientWidth != 'undefined' 
      && document.documentElement.clientWidth != 0)
      innerWidth = document.documentElement.clientWidth; 
  else
      innerWidth = document.body.clientWidth; 
              
  if ((event.clientX + width) > innerWidth)
      cX = innerWidth - width ;
  else 
      cX = event.clientX ;

  if (cX < 0)
      cX = 0;

      cY = event.clientY;

  rX = GetScrollPosX();
  rY = GetScrollPosY();
 
  cX += rX + 10;
  cY += rY + 10;

  element.style.left = cX + 'px';
  element.style.top = cY + 'px';
  element.style.visibility='visible';
}
 
// hide help panel
function HideHelp(divId)
{
  document.getElementById(divId).style.visibility='hidden';
}


// expand block
function expand(id,display)
{
  var item = document.getElementById(id);
  var imageId = id + '_img';
  var image = document.getElementById(imageId);
 
  if (item.style.display=='block'||display=='none')
  {
    item.style.display='none';
    image.src='images/dashplus.gif';
  } else {
    item.style.display='block';
    image.src='images/dashminus.gif';
  }
}
      
// change cursor on mouse over 
function cursor(id)
{
  var imageId = id + '_img';
  var hId = id + '_h2';
  document.getElementById(hId).style.cursor='hand';
  document.getElementById(imageId).style.cursor='hand';
}

// change text of label on event
function updateLabel(id, text)
{
  var tableRow = (document.getElementById("TR_" + id));
  
  // if there is a text to display, show it
  if (text!='')
  {
    if (tableRow)
      document.getElementById("TR_" + id).style.display = "block";
    else
      document.getElementById(id).style.display = "block";
    
    document.getElementById(id).innerHTML = text;
  } 
  else
  {
    // hide table row
    if (tableRow)
     document.getElementById("TR_" + id).style.display = "none";
    // hide label by default 
    else
     document.getElementById(id).style.display = "none";
  }
}

// enables the element with the corresponding id
function Enable(id)
{
  document.getElementById(id).disabled = false;
}

// disables the element with the corresponding id
function Disable(id)
{
  document.getElementById(id).disabled = true;
}

// adds actual scroll position and moves to new link
function AddScrollPos(link)
{
  if (!link || !link.href)
    return true;

  if (link.href.indexOf('?') == -1) link.href = link.href + '?';
  
  // add scroll positions
  link.href = link.href + '&scrollposx=' + GetScrollPosX() + '&scrollposy=' + GetScrollPosY();
  
  return true;
}

