function Fader(el, fadeIn) { var me = this; this.el = (typeof(el) == "object")?el:(typeof(el) == "string")?document.getElementById(el):null; this.fadeIn = fadeIn; this.doFade = doFade; this.setOpacity = setOpacity; this.showElement = showElement; this.opacity = 0; this.doFade(); function setOpacity() { if (typeof(this.el.style.opacity) != null) this.el.style.opacity = this.opacity / 100; if (typeof(this.el.style.filter) != null) this.el.style.filter = "alpha(opacity=" + this.opacity + ")"; this.opacity += (this.fadeIn)?1:-1; } function showElement(show) { if (this.el && this.el.style) this.el.style.display = (show)?"block":(this.fadeIn)?"block":"none"; } function doFade() { this.showElement(true); if (this.fadeIn) { this.opacity = 0; this.setOpacity(); for (var i=0; i<=100; i++) { var newFunc = function() { me.setOpacity(); }; setTimeout(newFunc, 8*i); } } else { this.opacity = 100; this.setOpacity(); for (var i=0; i<=100; i++) { var newFunc = function() { me.setOpacity(); }; setTimeout(newFunc, 8*i); } } var newFunc = function () { me.showElement(); }; setTimeout(newFunc, 810); } } function fade(obj, fadeIn) { if (obj) new Fader(obj, fadeIn); } function fadeIn(objID) { fade(objID, true); } function fadeOut(objID) { fade(objID, false); }