/*	File		:	mousewords.js
**	Author		:	Dr. Clue	( A.K.A. Ian A. Storms )
**	Description	:	a text string is broken up into individual
**		characters that chase the mouse cursor arround.
*/

DCmw={fontFamily:"sans-serif",fontSize:"20pt",color:"#996600",textDecoration:"none",bInRipple:false}
//User Parameters
DCmw.szMsg		="1-866-978-4841"
DCmw.backgroundImage	="Foo Bar"
DCmw.iSpeed		=.4		; //Speed 0.1-1.0
DCmw.iXmouse=-100;DCmw.iYmouse=-100;DCmw.iPageOffsetY=0;


ay=new Array();ax=new Array();
aY=new Array();aX=new Array();
oW=null;

function USRmouse(pL,Evt){DCmw.iXmouse=Evt.pageX;DCmw.iYmouse=Evt.pageY}
function MouseWords(szTrail)
	{
	if(szTrail			)DCmw.szMsg=szTrail
	if(typeof oDC=="undefined"	)return
	if(!oDC.READY			)return
	clearInterval(DCmw.idInterval);DCmw.idInterval=null;
	DCa2o(DCo2a(DCgetCSSclass(document,"DCmousewords")),DCmw,true)
	aMsgChars	=DCmw.szMsg.split('');
	aMsg		=new Array();
	iChars		=aMsgChars.length;
	iAw		=parseInt(DCmw.fontSize)*2 //10;
	DCmw.bInRipple	=false;
	szFstart	='<span style="font-family:'+DCmw.fontFamily+';font-size:'+DCmw.fontSize+';color:'+DCmw.color+';text-align:center;text-decoration:'+DCmw.textDecoration+'">'
	szFend	="</span>"

	for(i=0;i<iChars;i++)
		{
		aMsg[i]=DCcreate("self.document.all.nsmsg"+i,i*iAw,-50,iAw,iAw,"clear")
		DCsetContent(aMsg[i],szFstart+aMsgChars[i]+szFend);
		DCshow(aMsg[i],true);
		ay[i]=0;ax[i]=0;aY[i]=0;aX[i]=0;
		}
	DCsetTrigger(aMsg[0],"onmousemove","USRmouse")
	oW=DCgetParentWindow(aMsg[0].navPath.szPath)
	setInterval("ripple()",60)
	}
function ripple()
	{
	if(DCmw.bInRipple)return	;
	DCmw.bInRipple		=true	;
	DCmw.iPageOffsetY	=0	;
	ay[0]=Math.round(aY[0]+=((DCmw.iYmouse)-aY[0])*DCmw.iSpeed);
	ax[0]=Math.round(aX[0]+=((DCmw.iXmouse)-aX[0])*DCmw.iSpeed);
	for(i=1;i<iChars;i++)
		{
		ay[i]=Math.round(aY[i]+=(ay[i-1]-aY[i])*DCmw.iSpeed);
		ax[i]=Math.round(aX[i]+=(ax[i-1]-aX[i])*DCmw.iSpeed);
		}
	for(i=0;i<iChars;i++)
		{
		var d	=self.document.all['nsmsg'+i].style;
		iY=ay[i]+DCmw.iPageOffsetY;
		iX=ax[i]+(i*(iAw/2))+10;
		d.top	=iY+"px";//ay[i]+DCmw.iPageOffsetY;
		d.left	=iX+"px";//ax[i]+(i*(iAw/2))+10;
		}
	DCmw.bInRipple=false;
	}
DCmw.idInterval=setInterval("MouseWords()",500)

