/** Opacity Manager **/
function Opacity(id)
{
this.opacity = 0;
this.style = id.style;
this.timer = null;
}
Opacity.prototype.setOpacity = function(value)
{
if(value == 0) {
this.style.display = 'none';
} else {
this.style.display = 'block';
}
this.style.opacity = (value / 100);
this.style.MozOpacity = (value / 100);
this.style.KhtmlOpacity = (value / 100);
this.style.filter = "alpha(opacity=" + value + ")";
}
Opacity.prototype.Stop = function()
{
clearInterval(this.timer);
if(this.opacity> 0) {
this.setOpacity(100);
}
}
Opacity.prototype.FadeIn = function()
{
var _this = this;
this.timer = window.setInterval(function() { _this.FadeInTimer(); }, 10);
}
Opacity.prototype.FadeInTimer = function()
{
if(this.opacity <100) {
this.opacity = this.opacity + 25;
this.setOpacity(this.opacity);
return false;
} else {
clearInterval(this.timer);
if ( this.FadeDone ) { this.FadeDone(); }
return true;
}
}
Opacity.prototype.FadeOut = function()
{
var _this = this;
this.timer = window.setInterval(function() { _this.FadeOutTimer(); }, 10);
}
Opacity.prototype.FadeOutTimer = function()
{
if(this.opacity> 0) {
this.opacity = this.opacity-25;
this.setOpacity(this.opacity);
return false;
} else {
clearInterval(this.timer);
return true;
}
}
Element.FadeIn = function(element){
if ( !element.opacity ) element.opacity = new Opacity( element );
element.opacity.FadeIn()
}
Element.FadeOut = function(element){
if ( !element.opacity ) element.opacity = new Opacity( element );
element.opacity.FadeOut()
}