//---------------------------------------------------------------------
// ianime.js extension 
//   by Satoshi Nakajima (copyright 2007)
//   version 0.22 (Nov. 26nd, 2007)
//---------------------------------------------------------------------

iAnime.effects.fadeout = function(element, r, x, y) {
    iAnime.drawElement(element, r, x, y);
    iBrowse.setOpacity(element, 1-r);
};

iAnime.effects.fadein = function(element, r, x, y) {
    iAnime.drawElement(element, r, x, y);
    iBrowse.setOpacity(element, r);
};

iAnime.effects.blink = function(element, r, x, y) {
    iAnime.drawElement(element, r, x, y);
    var index = Math.floor(r * ((this.repeat-1)*2+1)) % 2;
    element.style.visibility = iAnime.effects.blink.visibility[index];
};

iAnime.effects.blink.visibility = ['hidden', 'visible'];

iAnime.effects.bounce = function(e,r,x,y) {
    e.style.left = x + "px";
    e.style.top = y + "px";
};

iAnime.effects.bounce.ratio = function(r) {
    return (r<0.6) ? ((r*r)/0.6) : (0.90+2.5*(r-0.8)*(r-0.8)); 
};

iAnime.effects.easein = function(e,r,x,y) {
    e.style.left = x + "px";
    e.style.top = y + "px";
};

iAnime.effects.easein.ratio = function(r) {
    return r*r;
};

iAnime.effects.easeout = function(e,r,x,y) {
    e.style.left = x + "px";
    e.style.top = y + "px";
};

iAnime.effects.easeout.ratio = function(r) {
    return 1-(1-r)*(1-r);
};

iAnime.effects.jump = function(e,r,x,y) {
    var h = (1-4*(r-0.5)*(r-0.5));
    e.style.left = x + this.j_x * h + "px";
    e.style.top = y + this.j_y * h + "px";
};

iAnime.effects.jump.init = function(item) {
    var dist = Math.sqrt(item.dx*item.dx + item.dy*item.dy);
    item.j_x = -item.dy * item.height / dist;
    item.j_y = item.dx * item.height / dist;
};

iAnime.effects.settext = function(element, r, x, y) {
    var text = this.text;
    iBrowse.setText(element, text.substr(0, Math.floor(text.length*r)));
    iAnime.drawElement(element, r, x, y);
};
