//javascript opacity functions
/***************************************************************************************************************/
function blendimage(divid, imageid, imagefile, millisec) {
    var speed = Math.round(millisec / 100);
    var i, timer = 0;

    document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";		 //set the current image as background
    changeOpac(0, imageid);					//make the front image transparent, the background image which is the same image, still shows
    document.getElementById(imageid).src = imagefile;    //put the name image in (front) image, since it is transparent, it does not show yet
    for(var i = 0; i <= 100; i++) {													// fade in the front picture (the back has the old, but will be discarded in the next stage
        setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
        timer++;
    }
} 
/************************************************************************shift opacity*********************************/
function shiftOpacity(id, millisec) {
    //if an element is invisible, make it visible, else make it ivisible
    if(document.getElementById(id).style.opacity == 0) {
        opacity(id, 0, 100, millisec);
    } else {
        opacity(id, 100, 0, millisec);
    }
} 
/************************************************************************changeOpac(opacity, id)*********************************/
function changeOpac(opacity, id) {					//change the opacity for different browsers
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}
/************************************************************************opacity*********************************/
function opacity(id, opacStart, opacEnd, millisec) {
    var timeStep = 50;										// Time steps, in milli seconds 
	var NoOfSteps = Math.round(millisec / timeStep);		// number of stemps needed
	var opacInc = Math.round((opacEnd -opacStart)/NoOfSteps)
    var i, opac= opacStart;
	changeOpac(opacStart, id)
	for (i=0; i<=NoOfSteps && opac!=opacEnd; i++){
		opac += opacInc;
		if ( (opacStart > opacEnd && opac < opacEnd) || (opacStart < opacEnd && opac > opacEnd) )
			opac=opacEnd;
		timeOuts["changeOpac"] = setTimeout("changeOpac(" + opac + ",'" + id + "')",(timeStep * i));
	}
}
/******************************************************************************************************************************************/