﻿function colorFade(n,o,p,q,c,j){var d,e,m,l,k,s,i,h,f,s,a=document.getElementById(n);c=c||20;j=j||20;clearInterval(a.timer);e=colorConv(q);m=e[0];l=e[1];k=e[2];if(!a.r){d=colorConv(p);r=d[0];g=d[1];b=d[2];a.r=r;a.g=g;a.b=b}i=Math.round(Math.abs(a.r-m)/c);h=Math.round(Math.abs(a.g-l)/c);f=Math.round(Math.abs(a.b-k)/c);if(i==0)i=1;if(h==0)h=1;if(f==0)f=1;a.step=1;a.timer=setInterval(function(){animateColor(n,o,c,m,l,k,i,h,f)},j)}function animateColor(n,f,m,l,k,j,i,h,g){var a=document.getElementById(n),b;if(a.step<=m){var e=a.r,d=a.g,c=a.b;if(e>=l)e=e-i;else e=parseInt(e)+parseInt(i);if(d>=k)d=d-h;else d=parseInt(d)+parseInt(h);if(c>=j)c=c-g;else c=parseInt(c)+parseInt(g);b="rgb("+e+","+d+","+c+")";if(f=="background")a.style.backgroundColor=b;else if(f=="border")a.style.borderColor=b;else a.style.color=b;a.r=e;a.g=d;a.b=c;a.step=a.step+1}else{clearInterval(a.timer);b="rgb("+l+","+k+","+j+")";if(f=="background")a.style.backgroundColor=b;else if(f=="border")a.style.borderColor=b;else a.style.color=b}}function colorConv(a){var b=[parseInt(a.substring(0,2),16),parseInt(a.substring(2,4),16),parseInt(a.substring(4,6),16)];return b}
