/* script.js */



function setAncherFish(id){
  location.href = './?fish=' + id;
}

function setFishEvent(){
  var a = document.getElementById('fish-list').getElementsByTagName('a');
  for(var i=0;i<a.length;i++){
    if(!a[i].getAttribute('href')) continue;
    a[i].onmouseover = function(){
      this.style.top = '-5px';
//      setFishMoveTimer(this.getAttribute('id').split('-')[2]);
    }
    a[i].onmouseout = function(){
//      clearInterval(timer);
      this.style.top = '0';
//      move = -1;
    }
  }
}

var timer, move = -1;
function setFishMoveTimer(id){
  clearInterval(timer);
  var obj = document.getElementById('fish-icon-'+id).style;
  var y = Number(obj.top.split(/[^\-\d]+/)[0]);
  timer = setInterval(setFishMove,50);
  function setFishMove(){
    y += move;
    if(y <= -3) move = 1;
    else if(y > 0) move = -1;
    obj.top = y + 'px';
  }
}

function setOnLoad(func){
  (window.addEventListener)? window.addEventListener('load',func,false):
  (window.attachEvent)? window.attachEvent('onload',func):
  window.onload = func;
}


setOnLoad(setFishEvent);

