function getstyle(obj,attr){ return obj.currentstyle ? obj.currentstyle[attr] : window.getcomputedstyle(obj,null)[attr]; } function animate(obj,json,fn){ clearinterval(obj.timer); obj.timer=setinterval(function(){ var bool=true; for(var k in json){ var leader; if (k=='opacity') { if (getstyle(obj,k)==undefined) { leader=100; }else { leader=parseint(getstyle(obj,k)*100); } }else { leader=parseint(getstyle(obj,k)) || 0; } var step=(json[k]-leader)/10; step=step>0?math.ceil(step):math.floor(step); leader=leader+step; if(k=='zindex'){ obj.style[k]=json[k]; }else if(k=='opacity'){ obj.style[k]=leader/100; obj.style.filter='alpha(opacity='+leader+')'; }else { obj.style[k]=leader+'px'; } if(json[k]!=leader){ bool=false; } } if(bool){ clearinterval(obj.timer); if (fn) { fn(); } } },10); }