function fadeswap(id,fadestart,fadeduration,finalopacity) {
  var object = document.getElementById(id)
  changeOpac(0,id);
  eventArray[eventArray.length]="setTimeout(\"opacity('"+id+"', 0, "+finalopacity+", "+fadeduration+")\","+fadestart+")";
  eventArray[eventArray.length]="setTimeout(\"document.getElementById('"+id+"').className='ping'\","+(fadestart+fadeduration)+")";
  eventArray[eventArray.length]="setTimeout(\"document.getElementById('"+id+"').src='images/fade/"+id+".png'\","+(fadestart+fadeduration+500)+")";
}
function fade(id,fadestart,fadeduration,finalopacity) {
  var object = document.getElementById(id)
  changeOpac(0,id);
  eventArray[eventArray.length]="setTimeout(\"opacity('"+id+"', 0, "+finalopacity+", "+fadeduration+")\","+fadestart+")";
}
function opacity(id, opacStart, opacEnd, duration) {
    //speed for each frame
    var speed = Math.round(duration / 100);
    var timer = 0;
    var increment=2;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i-=increment) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i+=increment)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
  var object= new getObj(id);
  object.style.visibility="visible";
  object.obj.style.visibility="visible";
    object.style.opacity = (opacity / 100);
    object.style.MozOpacity = (opacity / 100);
    object.style.KhtmlOpacity = (opacity / 100);
    object.style.filter = "alpha(opacity=" + opacity + ")";
}