// JavaScript Document

function opacityFadeInOut(id, opacityStart, opacityEnd, milliseconds) {
    //speed for each frame
    var speed = Math.round(milliseconds / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacityStart > opacityEnd) {
        for(i = opacityStart; i >= opacityEnd; i--) {
            setTimeout("changeOpacity(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacityStart < opacityEnd) {
        for(i = opacityStart; i <= opacityEnd; i++)
            {
            setTimeout("changeOpacity(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

//change the opacity for different browsers
function changeOpacity(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
} 
