// Opacity and Fade in script. // Script copyright (C) 2008 http://www.cryer.co.uk/. // Script is free to use provided this copyright header is included. function SetOpacity(object,opacityPct) { // IE. object.style.filter = 'alpha(opacity=' + opacityPct + ')'; // Old mozilla and firefox object.style.MozOpacity = opacityPct/100; // Everything else. object.style.opacity = opacityPct/100; } function ChangeOpacity(id,msDuration,msStart,fromO,toO) { var element=document.getElementById(id); var opacity = element.style.opacity * 100; var msNow = (new Date()).getTime(); opacity = fromO + (toO - fromO) * (msNow - msStart) / msDuration; if (opacity<0) SetOpacity(element,0) else if (opacity>100) SetOpacity(element,100) else { SetOpacity(element,opacity); element.timer = window.setTimeout("ChangeOpacity('" + id + "'," + msDuration + "," + msStart + "," + fromO + "," + toO + ")",1); } } function FadeIn(id) { var element=document.getElementById(id); if (element.timer) window.clearTimeout(element.timer); var startMS = (new Date()).getTime(); element.timer = window.setTimeout("ChangeOpacity('" + id + "',2000," + startMS + ",0,100)",1); } function FadeOut(id) { var element=document.getElementById(id); if (element.timer) window.clearTimeout(element.timer); var startMS = (new Date()).getTime(); element.timer = window.setTimeout("ChangeOpacity('" + id + "',2000," + startMS + ",100,0)",1); } // COPYRIGHT outatex GmbH below function fullOpacity(fadeID) { var fade=document.getElementById(fadeID); SetOpacity(fade,100); } function LoadFades(fades) { this.images=[]; for(var i=0, len=fades.length; i < len; i++) { this.images[i]=new Image(); this.images[i].src=fades[i]; } } function FadeCycle(fades, lastFade, currentFade, fadeFG, fadeBG, timeout) { LoadFades(fades); if(currentFade < lastFade) { setTimeout(function() { FadeOutFG(fades, lastFade, currentFade, fadeFG, fadeBG, timeout); }, timeout/2); } } function FadeOutFG(fades, lastFade, currentFade, fadeFG, fadeBG, timeout) { if(currentFade == lastFade) { currentFade = 0; } else { currentFade++; } document.getElementById(fadeBG).style.backgroundImage = "url('" + fades[currentFade] + "')"; FadeOut(fadeFG); setTimeout(function() { FadeInFG(fades, lastFade, currentFade, fadeFG, fadeBG, timeout); }, timeout); } function FadeInFG(fades, lastFade, currentFade, fadeFG, fadeBG, timeout) { if(currentFade == lastFade) { currentFade = 0; } else { currentFade++; } document.getElementById(fadeFG).style.backgroundImage = "url('" + fades[currentFade] + "')"; FadeIn(fadeFG); setTimeout(function() { FadeOutFG(fades, lastFade, currentFade, fadeFG, fadeBG, timeout); }, timeout); }