function getWindowWidth()
{
  // REFERENCE: http://www.quirksmode.org/viewport/compatibility.html

  if (self.innerWidth)
  {
    // all except Explorer
    return self.innerWidth;
  }
  else if (document.documentElement && document.documentElement.clientWidth)
  {
    // Explorer 6 Strict Mode
    return document.documentElement.clientWidth;
  }
  else if (document.body)
  {
    // other Explorers
    return document.body.clientWidth;
  }
}

function getWindowHeight()
{
  if (self.innerHeight)
  {
    // all except Explorer
    return self.innerHeight;
  }
  else if (document.documentElement && document.documentElement.clientHeight)
  {
    // Explorer 6 Strict Mode
    return document.documentElement.clientHeight;
  }
  else if (document.body)
  {
    // other Explorers
    return document.body.clientHeight;
  }
}

function getWindowColorDepth()
{
  return window.screen.colorDepth;
}

function getComponentComputedStyle(object, cssPropertyName, iePropertyName)
{
  // REFERENCE: http://www.javascriptkit.com/dhtmltutors/dhtmlcascade4.shtml and
  //            http://www.quirksmode.org/dom/w3c_css.html

  if (object.currentStyle)
    return object.currentStyle.getAttribute(iePropertyName);
  else if (window.getComputedStyle)
  {
    var style = window.getComputedStyle(object, '');
    return style.getPropertyValue(cssPropertyName);
  }
  else
  {
    alert('getComputedStyle() failed');
    return 0;
  }
}

function onFocus(tag)
{
  bodyMarginTop = getComponentComputedStyle(document.body, 'margin-top', 'marginTop');
  bodyMarginTop = parseInt(bodyMarginTop);

  bodyMarginBottom = getComponentComputedStyle(document.body, 'margin-bottom', 'marginBottom');
  bodyMarginBottom = parseInt(bodyMarginBottom);

  bodyMarginLeft = getComponentComputedStyle(document.body, 'margin-left', 'marginLeft');
  bodyMarginLeft = parseInt(bodyMarginLeft);

  bodyMarginRight = getComponentComputedStyle(document.body, 'margin-right', 'marginRight');
  bodyMarginRight = parseInt(bodyMarginRight);

  semicolon = tag.href.indexOf(";");
  if (semicolon==-1)
    semicolon = tag.href.length;
  tag.href = tag.href.substring(0, semicolon) +
  '/width/' + (getWindowWidth() - bodyMarginLeft - bodyMarginRight) +
  '/height/' + (getWindowHeight() - bodyMarginTop - bodyMarginBottom) +
  '/colorDepth/' + getWindowColorDepth() + tag.href.substring(semicolon);
  tag.onfocus=null;
}