

  // General dhtml functions  
  var browsername=navigator.appName;
  var isIE=(browsername.indexOf("Internet Explorer") != -1);     // IE or NS


  // set style of a div object, regardless if IE or NS.
  // example: setStyle('css1', 'top', 20);
  function setStyle(divobjectname, propertyname, value) {
    
    if (isIE)
      divobjectname += '.style';
    else
      divobjectname = 'document.'+divobjectname;
    //if (propertyname.indexOf('filter') != -1 || isIE)
      eval(divobjectname+'.'+propertyname+' = value');
  }








  // Fish script by Marcus Hoverby
  var tick = 0;
  
  var fish_default;
  var fish_angry;
  var fish_fury;
  var fish_blush;
  var fish_blind;
  var fish_tail;

  var bubble;
  var ready = false;

  var fish_default_count = 0;
  var fish_fury_count = 3;
  var bubble_count = -100;
  var tail_count = 0;
  
    

  function init() {
      
    fish_default = new Image();
    fish_blind = new Image();
    fish_tail = new Image();
    fish_blush = new Image();
    fish_angry = new Image();
    fish_fury = new Image();
    bubble = new Image();
    
    fish_default.src = 'fish/fish.gif';
    fish_blind.src = 'fish/fish_blind.gif';
    fish_tail.src = 'fish/fish_tail.gif';
    fish_blush.src = 'fish/fish_blush.gif';
    fish_angry.src = 'fish/fish_angry.gif';
    fish_fury.src = 'fish/fish_fury.gif';
    bubble.src = 'fish/bubble.gif';
  
    setInterval("animation()", 100);
  }		
	


	
  function animation() {

    ready = true;    
    if (bubble_count > -20) {
      bubble_count = bubble_count - 2;
      setStyle('cssbubble', 'top', bubble_count);
        
    } else 
      setStyle('cssbubble', 'filter', 'alpha(opacity=0)');
      

    if (tail_count == 4) 
      document.thefish.src = fish_default.src;
    if (tail_count == 2) 
      document.thefish.src = fish_tail.src;
    if (tail_count == 0) 
      document.thefish.src = fish_default.src;
    tail_count--;

    if (fish_default_count == 1) {
      if (document.thefish.src == fish_fury.src) {
        document.thefish.src = fish_angry.src;
        fish_default_count++;
      } else {
        document.thefish.src = fish_default.src;
      }
    }
    if (fish_default_count >= 1) {
      fish_default_count--;
      return;
    }

    tick++;    
    if (tick % 50 == 0) blindFish();
    
    if ((Math.round(Math.random()*70) == 1) && (bubble_count <= -20)) {
      bubble_count = 50;
      setStyle('cssbubble', 'top', bubble_count);
      setStyle('cssbubble', 'filter', 'alpha(opacity=60)');
    }
    
    if (Math.round(Math.random()*50) == 2) {
      tail_count = 5;
      document.thefish.src = fish_tail.src;
    }
  }
  
  
  function blindFish() {
    fish_default_count = 1;
    document.thefish.src = fish_blind.src;
  }
  
  
  function blushFish() {

    if (!ready)
      return null;
    return fish_blush.src;
  }

  
  function angryFish(src) {
    
    if (!ready)
      return null;
    fish_default_count=12
    if (fish_fury_count <= 0 && Math.round(Math.random()*2) != 1)
      return fish_fury.src;
    fish_fury_count--; 
    return fish_angry.src; 
  }
  
  



