//global this hold the string of the variable name so that it can be called dynamically function MooRotate(class_name_of_targets, global_this) { //the line right below will NOT work without Prototype this.targets = document.getElementsByClassName(class_name_of_targets); this.numTarget = this.targets.length; this.currentKey = 1; this.prevKey = 0; this.delay = 5000; this.myGlobalVarName = global_this; //keep this variable name (for setTimeout calls) this.fxArray = new Array(); this.duration = 500; //build all the effects this.buildEffects = function() { for(i=0; i0)?duration:500; //(re)build effects this.buildEffects(); //fall back to default delay as necessary this.delay = (delay>0)?delay:this.delay; //since "this" does not retain its scope when setTimeout triggers in the future, we need to use this variable name (held in this.myGlobalVarName) cmd = this.myGlobalVarName + ".rotate()"; setTimeout(cmd, this.delay); } }