﻿function getOpacity(obj) {
    if (obj) {
        if (obj.style.getAttribute)
            return obj.style.getAttribute('opacity') * 100;
        return obj.style.opacity * 100;
    }
    return 0;
}

function setOpacity(o, obj) {
    if (obj) {
        if (obj.style.getAttribute) {
            obj.style.setAttribute('filter', 'alpha(opacity=' + o + ')');
            obj.style.setAttribute('opacity', o / 100);
        }
        else {
            obj.style.opacity = o / 100;
        }
    }
}


function fadeIn(objname, start, end, step, rate, timeoutname, nextAnimation) {
    var params = "'" + objname + "'," + start + "," + end + "," + step + "," + rate + ",'" + timeoutname + "','" + nextAnimation + "'";
    var timeout = eval(timeoutname);
    var obj = eval(objname);
    var op = getOpacity(obj);
    if (isNaN(op)) {
        op = start - step;
    }
    if (op < end) {
        op = op + step;
        setOpacity(op, obj);
        timeout = setTimeout("fadeIn(" + params + ")", rate);
    }
    else {
        clearTimeout(timeout);
        setOpacity(end, obj);
        eval(nextAnimation);
    }
}

