var anim_g = 0;

function startIndexAnim()
{
  var img = document.getElementById("index");
  if (img != null)
  {
    anim_g += 1;
    var opacity = 50 + anim_g;
    img.style.marginLeft = (-675+anim_g) + "px";
    img.style.opacity = opacity/100;
    img.style.filter = "alpha(opacity=" + opacity + ")";
    if (anim_g < 50)
    {
      window.setTimeout("startIndexAnim()", 50);
    }
  }
}

function getWindowHeight()
{
  var height = 0;
  if ((window.innerHeight != null) && (window.innerHeight > 0)) { height = window.innerHeight; }
  else if ((document.body != null) && (document.body.clientHeight != null) && (document.body.clientHeight > 0)) { height = document.body.clientHeight; }
  else if ((document.documentElement != null) && (document.documentElement.clientHeight != null) && (document.documentElement.clientHeight > 0)) { height = document.documentElement.clientHeight; }
  return height;
}

var scrollTimer_g = null;

function nextProperties()
{
  if (scrollTimer_g != null)
  {
    clearTimeout(scrollTimer_g);
  }
  var elem = document.getElementById("body");
  var height = Math.round(getWindowHeight()*0.85);
  if ((elem != null) && (height > 0))
  {
    if ((elem.scrollTop % height) < (height - 10))
    {
      scrollDown(elem.scrollTop - (elem.scrollTop % height) + height);
    }
    else
    {
      scrollDown(elem.scrollTop - (elem.scrollTop % height) + 2*height);
    }
  }
}

function prevProperties()
{
  if (scrollTimer_g != null)
  {
    clearTimeout(scrollTimer_g);
  }
  var elem = document.getElementById("body");
  var height = Math.round(getWindowHeight()*0.85);
  if ((elem != null) && (height > 0))
  {
    if ((elem.scrollTop % height) < 10)
    {
      if (elem.scrollTop > 0)
      {
        scrollUp(elem.scrollTop - (elem.scrollTop % height) - height);
      }
    }
    else
    {
      scrollUp(elem.scrollTop - (elem.scrollTop % height));
    }
  }
}

function scrollDown(scrollTop_p)
{
  var elem = document.getElementById("body");
  if ((elem != null) && (elem.scrollTop < scrollTop_p))
  {
    var scrollTop = elem.scrollTop + 20;
    if (scrollTop > scrollTop_p)
    {
      scrollTop = scrollTop_p;
    }
    elem.scrollTop = scrollTop;
    if ((elem.scrollTop == scrollTop) && (scrollTop < scrollTop_p))
    {
      scrollTimer_g = setTimeout("scrollDown("+scrollTop_p+")", 50);
    }
  }
}

function scrollUp(scrollTop_p)
{
  var elem = document.getElementById("body");
  if ((elem != null) && (elem.scrollTop > scrollTop_p))
  {
    var scrollTop = elem.scrollTop - 20;
    if (scrollTop < scrollTop_p)
    {
      scrollTop = scrollTop_p;
    }
    elem.scrollTop = scrollTop;
    if (scrollTop > scrollTop_p)
    {
      scrollTimer_g = setTimeout("scrollUp("+scrollTop_p+")", 50);
    }
  }
}

function zoomPhoto(normal_p, large_p)
{
  if ((document.images != null) && (document.images['photo'] != null) && (document.images['photo'].src != null))
  {
    document.images['photo'].src = normal_p;
  }
  if ((document.links != null) && (document.links['aphoto'] != null) && (document.links['aphoto'].href != null))
  {
    document.links['aphoto'].href = large_p;
  }
  else if ((window.aphoto != null) && (window.aphoto.href != null))
  {
    window.aphoto.href = large_p;
  }
}
