//*焦点切换 (function(){ if(!Function.prototype.bind){ Function.prototype.bind = function(obj){ var owner = this,args = Array.prototype.slice.call(arguments),callobj = Array.prototype.shift.call(args); return function(e){e=e||top.window.event||window.event;owner.apply(callobj,args.concat([e]));}; }; } })(); var player = function(id){ this.ctn = document.getElementById(id); this.adLis = null; this.btns = null; this.animStep = 0.2;//动画速度0.1~0.9 this.switchSpeed = 3;//自动播放间隔(s) this.defOpacity = 1; this.tmpOpacity = 1; this.crtIndex = 0; this.crtLi = null; this.adLength = 0; this.timerAnim = null; this.timerSwitch = null; this.init(); }; player.prototype = { fnAnim:function(toIndex){ if(this.timerAnim){window.clearTimeout(this.timerAnim);} if(this.tmpOpacity <= 0){ this.crtLi.style.opacity = this.tmpOpacity = this.defOpacity; this.crtLi.style.filter = 'Alpha(Opacity=' + this.defOpacity*100 + ')'; this.crtLi.style.zIndex = 0; this.crtIndex = toIndex; return; } this.crtLi.style.opacity = this.tmpOpacity = this.tmpOpacity - this.animStep; this.crtLi.style.filter = 'Alpha(Opacity=' + this.tmpOpacity*100 + ')'; this.timerAnim = window.setTimeout(this.fnAnim.bind(this,toIndex),50); }, fnNextIndex:function(){ return (this.crtIndex >= this.adLength-1)?0:this.crtIndex+1; }, fnSwitch:function(toIndex){ if(this.crtIndex==toIndex){return;} this.crtLi = this.adLis[this.crtIndex]; for(var i=0;i