var NS4 = (document.layers) ? 1 : 0;
var IE4 = (document.all) ? 1 : 0;

function display(text)
{
  if (IE4) event.srcElement.style.cursor = "hand";
  window.status = text;
  return true;
}


function init_anim()
{
  anim_playing = false;
  setTimeout("onresize = redo", 1000);
}

function redo()
{
  location.reload();
}

function animation(id)
{
  this.element = (NS4) ? document[id] : document.all[id].style;
  this.active = 0;
  this.timer = null;
  this.name = id + "Var";
  eval(this.name + " = this");
  this.show = show;
  this.hide = hide;
  this.left = left;
  this.top = top;
  this.moveTo = moveTo;
  this.slideBy = slideBy;
  this.lineSlide = lineSlide;
  this.slideTo = slideTo;
}

function show()
{
  this.element.visibility = (NS4) ? "show" : "visible";
}

function hide()
{
  this.element.visibility = (NS4) ? "hide" : "hidden";
}

function left()
{
  return parseInt(this.element.left);
}

function top()
{
  return parseInt(this.element.top);
}

function moveTo(x, y)
{
  this.element.left = x;
  this.element.top = y;
}

function shift(ar)
{
  var first = ar[0];
  for (var i = 1; i < ar.length; i++)
  {
    ar[i - 1] = ar[i];
  }
  ar.length--;
  return first;
}

function slideBy(dx, dy, increment, interval, statement)
{
  var fx = this.left();
  var fy = this.top();
  var tx = fx + dx;
  var ty = fy + dy;
  this.slideTo(tx, ty, increment, interval, statement);
}

function slideTo(tx, ty, increment, interval, statement)
{
  var fx = this.left();
  var fy = this.top();
  var dx = tx - fx;
  var dy = ty - fy;
  var steps = Math.round(Math.sqrt(dx * dx + dy * dy) / increment);
  var sx = dx / steps;
  var sy = dy / steps;
  if (this.active)
  	return;
  this.active = 1;
  this.statement = statement;
  this.lineSlide(0, fx, fy, tx, ty, sx, sy, interval);
}

function lineSlide(num, fx, fy, tx, ty, sx, sy, interval)
{
  num++;
  this.moveTo(fx + sx * num, fy + sy * num);
  if (this.left() == tx)
  {
    this.active = 0;
	if (this.statement)
	{
      var ar = eval(this.statement);
	  if (ar.length > 0)
        eval(shift(ar));
	}
	return;
  }
  this.timer = setTimeout(this.name + ".lineSlide(" + num + ", " + fx + ", " + fy + ", " + tx + ", " + ty + ", " + sx + ", " + sy + ", " + interval + ")", interval);
}

function getAngle(angle)
{
  var small = angle % 360;
  if (small < 0) small += 360;
  return small;
}
function go_to_main()
{
	location.href="default.htm";
}

function start_anim()
{
  if (!anim_playing)
  {
  	  anim_playing = true;
	  anim1 = new animation("avatar");
	  myArray = new Array();
	  anim1.slideBy(50, -300, 5, 50, "myArray");
	  setTimeout("go_to_main()", 5000);
  }
}