/*
Roaming Cursor script (By Kurt at kurt.grigg@virgin.net)
Modified and permission granted to Dynamic Drive to feature script in archive
For full source, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
*/

count=-1;
move=1;

function Curve(){
  abc=new Array(0,1,1,1,2,3,4,0,6,-1,-1,-1,-2,-3,-4,0,-6)
  for (i=0; i < abc.length; i++)
    {var C=Math.round(Math.random()*[i])}
  howbend=abc[C];
  setTimeout('Curve()',1900);
  return howbend;
}
var wanderObj;
var wanderBox;
var wanderBox_l;
var wanderBox_r;
var wanderBox_t;
var wanderBox_b;
var xpos;
var ypos;
degree = 60;

function MoveRandom(){
  PathBend=degree+=howbend;
  y = 0.3*4*Math.sin(PathBend*Math.PI/180);
  x = 0.3*6*Math.cos(PathBend*Math.PI/180);
  ypos+=y;
  xpos+=x;
  wanderObj.css('top', ypos+'px');
  wanderObj.css('left', xpos+'px');
  //log(xpos+' '+ypos);
  Twander=setTimeout('MoveRandom()',20);
}

function edges(){
  if (xpos >= wanderBox_r)
   degree=Math.round(Math.random()*45+157.5);
  if (ypos >= wanderBox_b)
   degree=Math.round(Math.random()*45-112.5);
  if (ypos <= wanderBox_t)
   degree = Math.round(Math.random()*45+67.5);
  if (xpos <= wanderBox_l)
   degree = Math.round(Math.random()*45-22.5);
  setTimeout('edges()',100);
}

function startWander(wo, wo_l, wo_t, wo_w, wo_h, wb_l, wb_t, wb_w, wb_h){
  wanderObj = wo;
  xpos = wo_l;
  ypos = wo_t;
  wanderBox_l = wb_l;
  wanderBox_t = wb_t;
  wanderBox_r = wb_l+wb_w-wo_w;
  wanderBox_b = wb_t+wb_h-wo_h;
  Curve();
  MoveRandom();// onUnload="opener.gO()"
  edges();
}
