var Fader = function(el){ // Set defaults this.fadeMax = 100 ; this.fadeMin = 00 ; this.fadeGap = Math.abs( this.fadeMax-this.fadeMin ) ; this.currFade = this.fadeMax ; this.time = 500; this.fps = 25 ; this.frames = parseInt( this.time / this.fps ) ; this.increment = this.fadeGap / this.fps ; this.fadeType = 1 ; // 0 -> fade id , 1->fade out this.elem = el ; this.status = "ready"; this.oncomplete = false ; var self = this ; this.play = function( ) { if(this.elem) { var stop = false ; // new Fade value with limits handling if( this.fadeType==1 ) { this.currFade -= this.increment ; if( this.currFade < this.fadeMin ) // BASE CASE { stop = true ; this.currFade = this.fadeMin ; } } else { this.currFade += this.increment ; if( this.currFade > this.fadeMax ) { stop = true; this.currFade = this.fadeMax ; } } // apply new fade value to the needed elements if( isArray(this.elem) ) { for ( var i=0 ; i