var div_g = null;
var width_g = 500;
var height_g = 200;
var top_g = -height_g;
var max_g = 0;
var coeff_g = (document.all) ? 1 : 3;

function start_anim()
{
  div_g = (document.getElementById) ? document.getElementById("anim")
        : (document.all) ? document.all.anim
        : document.anim;
  sw = (document.body.clientWidth) ? document.body.clientWidth : document.body.innerWidth;
  sh = (document.body.clientHeight) ? document.body.clientHeight : document.body.innerHeight;
  if (document.all)
  {
    div_g.style.pixelLeft = (sw-width_g)/2;
    div_g.style.pixelTop = top_g;
  }
  else
  {
    div_g.style.left = (sw-width_g)/2;
    div_g.style.top = top_g
  }
  div_g.style.visibility = "visible";
  max_g = (sh-height_g)/2;
  run_anim_1();
}

function run_anim_1()
{
  top_g += 10*coeff_g;
  if (top_g < max_g)
  {
    if (document.all)
    {
      div_g.style.pixelTop = top_g;
    }
    else
    {
      div_g.style.top = top_g;
    }
    setTimeout("run_anim_1()", 10);
  }
  else
  {
    setTimeout("run_anim_2("+(height_g/10)+",-1)", 10);
  }
}

function run_anim_2(value_p, sign_p)
{
  top_g += value_p*sign_p;
  value_p -= 1*coeff_g;
  sign_p = -sign_p;
  if (value_p >= 0)
  {
    if (document.all)
    {
      div_g.style.pixelTop = top_g;
    }
    else
    {
      div_g.style.top = top_g;
    }
    setTimeout("run_anim_2("+value_p+","+sign_p+")", 10);
  }
  else
  {
    setTimeout("run_anim_3(0)", 10000);
  }
}

function run_anim_3(height_p)
{
  height_p += 5*coeff_g;
  if (height_p < height_g/2)
  {
    div_g.style.clip = "rect(" + height_p + " " + width_g + " " + (height_g-height_p) + " 0)";
    setTimeout("run_anim_3("+height_p+")", 10);
  }
  else
  {
    div_g.style.visibility = "hidden";
  }
}
