var loadChain = new Array(); function onLoad() { for (var i=0;ithis.lim) n = 1; return n; }; Rotator.prototype.flip = function(item,state) { for (var i = 0; i < this.pfx.length; i++) { var id=this.pfx[i]+item; var elm=document.getElementById(id); if (elm!=null) elm.style.display = state? 'block' : 'none'; } }; Rotator.prototype.hook = function(sfx) { var rotator = this; var id=this.lnk+sfx; var elm=document.getElementById(id); if (elm!=null) elm.onclick=function(e) {return rotator.nav(rotator,sfx);}; }; Rotator.prototype.init = function() { if (this.lnk!='') for(key in this.hooks) this.hook(key); if (this.typ=='R') this.flip(1,0); this.flip(this.seq[1],1); this.toggle(); if (this.run!=0) this.step(0,1); }; Rotator.prototype.nav = function(r,s) { if (r.hooks[s]==3) r.auto(); else if (this.run!=0) ; else { var delta; var next; switch(delta=r.hooks[s]) { case -2: next=1; break; case +2: next=this.lim; break; default: next=r.cur+delta; } r.step(r.cur,r.bnd(next)); } return false; }; Rotator.prototype.rotate = function(cur) { this.step(cur,this.bnd(cur+1)); }; Rotator.prototype.shuffle = function(v) { for(var j, x, i = v.length; i; j = parseInt(Math.random() * i), x = v[--i], v[i] = v[j], v[j] = x); return v; }; Rotator.prototype.step = function(cur,next) { if (cur) this.flip(this.seq[cur],0); this.flip(this.seq[next],1); this.cur = next; if (this.run!=0 && this.inv>0) { var rotator = this; this.tic = setTimeout(function() {rotator.timeout(rotator,next);},this.inv); } }; Rotator.prototype.timeout = function(rotator,cur) { rotator.rotate(cur); }; Rotator.prototype.toggle = function() { for(key in this.hooks) { var id = this.lnk+key; var elm = document.getElementById(id); var tgl = key=='run'? this.sld : this.nvg; if (tgl==undefined) continue; var action = tgl.split(':'); var value = action[this.run!=0? 1 : 2]; if (elm!=null) switch(action[0]) { case 'class': elm.className=value; break; case 'disabled': elm.disabled=value; break; case 'display': elm.style.display=value; break; default: return; } } }; Rotator.prototype.toString = function() { var dump = ''; for(var item in this) { if (item=='hooks') ; else if (typeof this[item]=='function') ; else dump += item+': '+this[item]+"\n"; } return dump; }; var rotator_args = {"interval":5, "link":"p_", "nav":"display:none:block", "prefix":['p'], "run":0, "count":10}; var rotator = new Rotator(rotator_args); onLoadAdd(function(){rotator.init();});