<!--

// Copyright © 1997-1999 Butz Yung. All rights reserved.
// Do NOT copy or modify any part of the script without permission.
// All comments and notice must be left as is.
// Homepage: http://animetheme.vill.edu/

var w
if (dhtml)
  w = screen.width
else {
  w = 0
  event = null
}

// Default values
if (!self.Y)
  var Y = 150
if (!self.width)
  var width = 150
width += 30
if (!self.pathNum)
  var pathNum = 0
if (!self.reiYes)
  var reiYes = "Ok"
if (!self.reiNo)
  var reiNo = "......"
if (!self.asukaYes)
  var asukaYes = "It's show time!"
if (!self.asukaNo)
  var asukaNo = "Oh no!"
if (!self.reiTable) {
  var reiTable = new Array()
  reiTable[0] = "Hello."
  reiTable[1] = "I like Anime Theme."
}
if (!self.asukaTable) {
  var asukaTable = new Array()
  asukaTable[0] = "Hey!"
  asukaTable[1] = "Anime Theme rocks!"
}

// Choose path
if (pathNum == 0) {
  var d = w * 0.25
  var reiHome = new Array(0, Y, 2*d, Y, d, Y, d, Y-40, d, Y-72, d, Y-96, d, Y-112, d, Y-120)
  w -= width
  var asukaHome = new Array(w, Y, w-2*d, Y, w-d, Y, w-d, Y-40, w-d, Y-72, w-d, Y-96, w-d, Y-112, w-d, Y-120)
  var time = new Array(1,1,0.5,0.5,0.5,0.5,0.5)
}
else if (pathNum == 1) {
  w -= width
  var d = parseInt(w / 8)
  var reiHome = new Array()
  var asukaHome = new Array()
  for (i = 0; i < 10; i++) {
    var rad = i / 9 * Math.PI
    var x1 = -(Math.round(Math.cos(rad) * d) - d)
    var x2 = -(Math.round(Math.cos(rad) * d) - d)
    var y = -Math.round(Math.sin(rad) * 50) + Y
    reiHome[2 * i] = x1
    reiHome[2 * i + 1] = y
    reiHome[20 + 2 * i] = x1 + 2 * d
    reiHome[21 + 2 * i] = y
    reiHome[40 + 2 * i] = x1 + 4 * d
    reiHome[41 + 2 * i] = y
    reiHome[60 + 2 * i] = x1 + 6 * d
    reiHome[61 + 2 * i] = y
    asukaHome[2 * i] = w - x2
    asukaHome[2 * i + 1] = y
    asukaHome[20 + 2 * i] = w - x2 - 2 * d
    asukaHome[21 + 2 * i] = y
    asukaHome[40 + 2 * i] = w - x2 - 4 * d
    asukaHome[41 + 2 * i] = y
    asukaHome[60 + 2 * i] = w - x2 - 6 * d
    asukaHome[61 + 2 * i] = y
  }
  var time = new Array()
  for (var i = 0; i < 80; i++)
    time[i] = 0.1
}
else {
  w -= width
  var reiHome = new Array()
  var asukaHome = new Array()
  var d = w / 2
  reiHome[0] = 0
  reiHome[1] = Y
  reiHome[2] = d
  reiHome[3] = Y
  asukaHome[0] = w
  asukaHome[1] = Y
  asukaHome[2] = d
  asukaHome[3] = Y
  var time = new Array()
  time[0] = 1
  for (i = 1; i < 21; i++) {
    var rad = i / 20 * Math.PI
    var x = -(Math.round(Math.cos(rad) * d / 2) - d / 2)
    var y = -Math.round(Math.sin(rad) * 50) + Y
    reiHome[2 + 2 * i] = x + d
    reiHome[2 + 2 * i + 1] = y
    asukaHome[2 + 2 * i] = d - x
    asukaHome[2 + 2 * i + 1] = y  
    time[i] = 0.1
  }
  var dum = 0
  for (i = 22; i < 27; i++) {
    reiHome[2 * i] = w
    dum += 40 - 8 * (i - 22)
    reiHome[2 * i + 1] = Y - dum
    asukaHome[2 * i] = 0
    asukaHome[2 * i + 1] = Y - dum
    time[i - 1] = 0.5
  }
}

var Rei = new pilot("Rei", 0, reiHome,reiTable)
var Asuka = new pilot("Asuka", w, asukaHome,asukaTable)
var characters = new Array(Rei, Asuka)
var loaded = false

function start() {
  loaded = true
  if (ie4) {
    Rei.path = new Path("rei", "pathStop(Rei)")
    Rei.target = rei.style
    Rei.msg = Lrei_msg
    Asuka.path = new Path("asuka", "pathStop(Asuka)")
    Asuka.target = asuka.style
    Asuka.msg = Lasuka_msg
    Rei.hello()
    Asuka.hello()
  }
  else {
    Rei.path = new Path("document.rei", "pathStop(Rei)")
    Rei.target = document.rei
    Rei.msg = document.Lrei_msg
    Asuka.path = new Path("document.asuka", "pathStop(Asuka)")
    Asuka.target = document.asuka
    Asuka.msg = document.Lasuka_msg
    setInterval("runPath()", 100)
  }
  home(Rei)
  home(Asuka)
  setTimeout('scrollTo(0,0)', 0)
}

function distance(who, x, y) {
  return Math.sqrt(Math.pow(Math.abs(who.x - x), 2) + Math.pow(Math.abs(who.y - y), 2))
}

function move(who, x, y) {
  if (!loaded || who.running)
    return
  if ((who.x == x) && (who.y == y))
    return
  var dis = distance(who, x, y) / 500
  var obj = who.path
  var xy = new Array(who.x, who.y, x, y)
  obj.Stop()
  obj.Duration = dis
  obj.Bounce = 0
  obj.Repeat = 1
  obj.PolyLine(2,xy)
  who.x = x
  who.y = y
  who.running = true
  obj.Play()
}

function wander(who) {
  var obj = who.path
  obj.Repeat = -1
  obj.Duration = 5
  obj.Oval(who.x, who.y, 50, 20)
  obj.Play()
}

function home(who) {
  var obj = who.path
  obj.Repeat = -1
  obj.Bounce = 1
  obj.KeyFrame(who.points, who.home, time)
  obj.Play()
}

function pilot(name, x, whoHome,events) {
  this.name = name
  this.x = x
  this.y = Y
  this.hide_count = 0
  this.event_count = 0
  this.home = whoHome
  this.events = events
  this.running = false
  this.points = whoHome.length / 2
  this.hello = hello
}

function come(who, e) {
  if (!loaded || who.running || !isFollow)
    return
  var x = (ie5) ? e.clientX + document.body.scrollLeft : e.x
  var y = (ie5) ? e.clientY + document.body.scrollTop : e.y
  if (x > w - 100)
    x -= (screen.width - w + 50)
  else
    x += 20
  move(who, x, y - 50)
}

function hello(msg) {
  if (!loaded || !ie4)
    return
  if (!msg)
    msg = this.events[Math.round(Math.random() * this.events.length - 0.5)]
  var m = this.msg
  m.innerText = msg
  m.style.posTop = this.target.posTop
  m.style.posLeft = this.target.posLeft
  m.style.visibility = "visible"
  this.hide_count = 15
  if (isSpeak)
    this.event_count = Math.round(Math.random() * 50 + 0.5) + 30
}

function runPath2() {
  runPath()
  for (var i = 0; i < 2; i++) {
    var c = characters[i]
    if (--c.hide_count == 0)
      c.msg.style.visibility = "hidden"
    if (--c.event_count == 0)
      c.hello()
  }
  if (!document.all.title)
    return
  document.all.item("title",0).Rotate(0,9,1,1)
  var t = document.all.item("title")
  for (var i = 1; i < t.length; i++)
    t[i].Rotate(0,9,1,1)
}

function command(isChangeSpeak) {
  if (!loaded || !ie4)
    return
  var mode
  if (isChangeSpeak) {
    isSpeak = Math.abs(isSpeak - 1)
    mode = isSpeak
  }
  else {
    isFollow = Math.abs(isFollow - 1)
    mode = isFollow
  }
  Lcommand.innerHTML = speak[isSpeak] + "  " + follow[isFollow]
  if (mode == 0) {
    Rei.hello(reiNo)
    Asuka.hello(asukaNo)
  }
  else {
    Rei.hello(reiYes)
    Asuka.hello(asukaYes)
  }
}

function pathStop(who) {
  if (!who.running)
    return
  who.running = false
  if (who.y == Y)
    home(who)
  else
    wander(who)
}

var speak = new Array()
speak[0] = '<font size=4><a href="javascript:Let\'s talk!" onClick="command(true); return false">Let\'s talk!</a></font>'
speak[1] = '<font size=4><a href="javascript:Keep quiet!" onClick="command(true); return false">Keep quiet!</a></font>'
var follow = new Array()
follow[0] = '<font size=4><a href="javascript:Show me the way!" onClick="command(false); return false">Show me the way!</a></font>'
follow[1] = '<font size=4><a href="javascript:Don\'t follow!" onClick="command(false); return false">Don\'t follow me!</a></font>'

var isSpeak = 1
var isFollow = 1

if (ie4)
  window.onload = start

var nn_guides = 0

function nn_check_guides() {
  if (!nc4)
    return
  if (++nn_guides == 2)
    start()
}

//-->
