var w3c=document.getElementById;
var ie45=document.all;
var y,p,q,f,b,m,o,x=1e6;
var z=new Array();

function cm(r,s){document.getElementById("pos"+r).style.color=s}

function tightl(fg,bg) {
 if (!w3c) return false;
 var t,u,i,s;
 p=f=(fg)?fg:"#ff00ff";
 b=(bg)?bg:"#ffeaff";
 q=hx(b,f,0.5);
 t=document.getElementById("tightl");
 s=t.firstChild.nodeValue;
 m=s.length;
 t.removeChild(t.firstChild);
 for (i=0; i<m; i++) {
  z[i]=i;
  u=document.createElement("span");
  u.setAttribute("id","pos"+i);
  u.appendChild(document.createTextNode(s.charAt(i)));
  t.appendChild(u);
 }
 setInterval("rw()",66);
 linkify_ww();
}

function linkify_ww() { // add 'ww' to page links
 var ww=468;
 if (document.documentElement && document.documentElement.clientWidth) ww=document.documentElement.clientWidth;
 else if (typeof(self.innerHeight)=="number") ww=self.innerWidth;
 else if (document.body.clientWidth) ww=document.body.clientWidth;
 if (ww>468) {
   var a=document.getElementsByTagName("a");
   for (var z=0; z<a.length; z++) {
	  if (a[z].href.indexOf('mf2fm')!=-1) a[z].href=a[z].href+(a[z].href.indexOf('?')==-1?'?':'&')+'ww='+ww;
   }
 }
}

function rw() {
 if (++x<2*m+((p==f)?100:2)) eval("w"+y+"();");
 else {
  x=-1;
  p=(p==f)?b:f;
  var o=y;
  while (y==o) y=1+Math.floor(Math.random()*6);
 }
}

function w1() {
 if (x<Math.floor(m/2)) {
  cm(x,q);
  cm(m-x-1,q);
 }
 else if (x<m) {
  cm(x,p);
  cm(m-x-1,p);
 }
}

function w2() {
 var i,r,t;
 if (x==0) {
  for (i=0; i<m; i++) {
   r=Math.floor(Math.random()*m);
   t=z[i];
   z[i]=z[r];
   z[r]=t;
  }
 }
 if (x<m) cm(z[x],q);
 if (x&&x<m+1) cm(z[x-1],p);
}

function w3() {
 if (x<m) cm(x,q);
 if (x&&x<m+1) cm(x-1,p);
}

function w4() {
 if (x<m) cm(x,q);
 if (x&&x<m+1) cm(x-1,p);
 if (x>1&&x<m+2) cm(x-2,q);
 if (x>2&&x<m+3) cm(x-3,(p==f)?b:f);
 if (x==m+3) p=(p==f)?b:f;
}

function w5(){if(x<m+3)for(var i=0;i<m;i++)cm(i,hx((p==f)?b:f,p,x/(m+2)))}

function w6(){if(x<2*m)for(var i=0;i<m;i++)cm(i,hx((p==f)?b:f,p,Math.min(1,Math.max(0,(i+x-m)/m))))}

function hx(h1,h2,ix) {
 var i,d1,d2,o="rgb(";
 for (i=1; i<6; i+=2) {
  d1=parseInt(h1.substring(i,i+2),16);
  d2=parseInt(h2.substring(i,i+2),16);
  o+=Math.floor(d1+(d2-d1)*ix)+((i==5)?")":",");
 }
 return o;
}

var rtt=false;
function rate(n) {
 if (!w3c) return false;
 for (var i=0; i<(n+1); i++) document.getElementById("rate"+i).style.backgroundColor="#f9c";
 for (; i<6; i++) document.getElementById("rate"+i).style.backgroundColor="transparent";
 if (rtt) clearTimeout(rtt);
 rtt=setTimeout('rate(-1)',15000);
}

function popUp(r,n,w,h) {
 r+=(r.indexOf("?")==-1)?"?t=":"&t=";
 r+=escape(self.location.pathname);
 if (self.location.search) r+=escape(self.location.search);
 var m=window.open(r,n,'width='+w+',height='+h+',scrollbars=0,toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0');
 if (m&&(!m.opener||m.opener!=self)) m.opener=self;
 if (m&&m.opener==self) {
  m.focus();
  return false;
 }
 else return true;
}
