//<!--
//***************************************************************************//
// Copyright (C) 1997 by Steve G. White, All rights reserved.                //
// Duplication or reverse engineering of this software is strictly forbidden.//
// All copies of this software must include this Copyright notice.           //
//***************************************************************************//
NumPoints=new Array();
nm = new Array();
ob  = new Array();
NumPoints = new Array();
FillType = new Array();
Len = new Array();
Plen = new Array();
pRate  = new Array();
Ptype = new Array();
Path = new Array();
cpox = new Array();
cpoy = new Array();
spox = new Array();
spoy = new Array();
epox = new Array();
epoy = new Array();
dpox = new Array();
dpoy = new Array();
atDis  = new Array();
DisPt  = new Array();
disStep = new Array();
PXL  = new Array();
PYL  = new Array();
PathCount = new Array();
LastPt  = new Array();
spritec = new Array();
spritef = new Array();
spriter = new Array();
spritei = new Array();
Xsize  = new Array();
Ysize  = new Array();
Value  = new Array();
lstVal = new Array();
TimeLeft = new Array();
Active = new Array();
AEvent = new Array();
WAEvent = new Array();
AValue = new Array();
ATime = new Array();
AEnter = new Array();
ALeave = new Array();
AKey = new Array();
IKey = new Array();
DEvent = new Array();
WDEvent = new Array();
DValue = new Array();
DTime = new Array();
DEnter = new Array();
DLeave = new Array();
DKey = new Array();
SetNewPath = new Array();
EndPath = new Array();
ActType = new Array();

OpValue = new Array();
WAAObj = new Array();
WADObj = new Array();
WAValue = new Array();
WASVal = new Array();
WAGVal = new Array();
WASPath = new Array();
WAGPath = new Array();

WDAObj = new Array();
WDDObj = new Array();
WDValue = new Array();
WDSVal = new Array();
WDGVal = new Array();
WDSPath = new Array();
WDGPath = new Array();

eDELAY = (1);
eDELAY_TIME = (2);
eMOUSE = (4);
eMOUSE_OVER = (8);
eLMOUSE = (16);
eRMOUSE = (32);
eKEY = (64);
eOBJECT_ENTER = (128);
eOBJECT_ENTER_LIST = (256);
eOBJECT_LEAVE = (512);
eOBJECT_LEAVE_LIST = (1024);
eLT_VALUE =	(2048);
eEQ_VALUE = (4096);
eGT_VALUE =	(8192);
eVALUE = (16384);
eENDPATH = (32768);
eACTIVATE_1 = (65536);
eACTIVATE_2	= (131072);
eANDtest = (1<<30);
var Cobj;
var Cpath;
var cmx = 0;
var cmy = 0;
var smx = -9999;
var smy = -9999;
var slm = 0;
var llm = -9999;
var sky = " ";

var lmx = -9999;
var lmy = -9999;
var lky = 0;
var totObj;
var mS;
var mW;
var waitTime;
/**************************************************************************/
var isNav4, isIE4;
if (navigator.appVersion.charAt(0) >= "4") {
	if (navigator.appName == "Netscape") {
		isNav4 = true;
		window.captureEvents(Event.MOUSEMOVE|Event.MOUSEDOWN|Event.KEYPRESS);
		window.onmousemove=NNmouseMove;
		window.onkeypress=NNkeyPress;
		window.onmousedown=NNmouseDown;
//		window.onmouseup=NNmouseUp;
	}
	else if (navigator.appVersion.indexOf("MSIE") != -1) {
		window.document.onmousemove = IEmouseMove;
		window.document.onkeypress = IEkeyPress;
		window.document.onmousedown = IEmouseDown;
		window.document.onmouseup = IEmouseUp;
		window.document.onkeydown = IEkeyPress;
		window.document.ondragstart = IECancelEvent;
		isIE4 = true;
	}
}
/**************************************************************************/
function NNmouseMove(e) {
	cmx = e.pageX;
	cmy = e.pageY;
}
function NNmouseDown(e) {
	slm = slm | 1;
	window.releaseEvents(Event.MOUSEMOVE);
	document.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
	document.onmousemove=drag;
	document.onmouseup=enddrag;
	smx=e.pageX;
	smy=e.pageY;
	return false;
}
function enddrag(e) {
	slm = slm | 2;
	smx = e.pageX;
	smy = e.pageY;
	document.onmousemove=0;
	document.releaseEvents(Event.MOUSEMOVE);
	document.releaseEvents(Event.MOUSEUP);
	window.captureEvents(Event.MOUSEMOVE|Event.MOUSEDOWN|Event.KEYPRESS);
	return false;
}
function drag(e) {
	cmx = e.pageX;
	cmy = e.pageY;
}

function NNmouseUp(e) {
	slm = slm | 2;
	smx = e.pageX;
	smy = e.pageY;
}

function NNkeyPress(e) {
	sky = String.fromCharCode(e.which);
}

function IEmouseMove() {
	cmx = window.event.x;
	cmy = window.event.y;
}

function IEmouseDown() {
	slm = slm | 1;
	smx = window.event.x;
	smy = window.event.y;
}

function IEmouseUp() {
	slm = slm | 2;
	smx = window.event.x;
	smy = window.event.y;
}

function IEkeyPress() {
	sky = window.event.keyCode;
}
function IECancelEvent() {
	window.event.returnValue=false;
}
/**************************************************************************/
function doObjectList() {
//	window.norefresh;
	if(lmx == smx) smx = -99999;
	if(lmy == smy) smy = -99999;
	if(lky == sky) sky = " ";
	llt = 0;
	if((llm & 2) == (slm & 2)) slm = (slm  & ~2);
	if((llm & 1) == (slm & 1)) slm = (slm  & ~1);
	lmx = smx;
	lmy = smy;
	lky = sky;
	llm = slm;
	for(Cobj=1; Cobj<= totObj; Cobj++) {
		if(Xsize[Cobj]) {
			Cpath = Path[Cobj];
			Evtest();
		}
	}
//   window.refresh;
}
/***************************************************************************/
function spritea(hflip) {
	if(spritec[Cobj] == 0) return;
	var flip = spritef[Cobj];
	if(!hflip) flip = -spritef[Cobj];
	if(ob[Cobj].src != spritei[Cobj][flip].src) ob[Cobj].src = spritei[Cobj][flip].src;
	spritef[Cobj] ++;
	if(spritef[Cobj] > spritec[Cobj]) {
		spritef[Cobj] = 1;
	}
}
function UpdStr() {
	if(lstVal[Cobj] == Value[Cobj]) return;
	lstVal[Cobj] = Value[Cobj];
	if(isIE4)
		ob[Cobj].innerText = Value[Cobj];
//	else
//		ob[Cobj].innerHTML = Value[Cobj];
	return;
}
function ticktime() {
	doObjectList();
	window.setTimeout("ticktime();", waitTime, "JavaScript");
}
/*************************************************************************/
function UpdPos() {
if(Plen[Cobj] > 0 && atDis[Cobj] >= Plen[Cobj]) {
	atDis[Cobj] -= Plen[Cobj];
	DisPt[Cobj] = 0;
	LastPt[Cobj] = 0;
	cpox[Cobj] = spox[Cobj];
	cpoy[Cobj] = spoy[Cobj];
}

if(((ActType[Cobj] & 0xf000) >> 12) == 4) {
	cpox[Cobj] = cpox[Cpath];
	cpoy[Cobj] = cpoy[Cpath];
}
else if(ActType[Cobj] & 0xf000) {
if(Ptype[Cpath] == 1)
	GetRectLoc();
else if(Ptype[Cpath] == 2) {
	GetArcLoc();
}
else if(Ptype[Cpath] == 3)
	GetPathLoc();
cpox[Cobj] += cpox[Cpath];
cpoy[Cobj] += cpoy[Cpath];
}
else if(ActType[Cobj] & 0x00ff) {
if( (ActType[Cobj] & 0x000f) == 8)
	cpox[Cobj] = cmx;
else
	cpox[Cobj] += dpox[Cobj];

if( (ActType[Cobj] & 0x00f0)>>4 == 8)
	cpoy[Cobj] = cmy;
else
	cpoy[Cobj] += dpoy[Cobj];
}
nm[Cobj].left=cpox[Cobj] - Xsize[Cobj] * 0.5;
nm[Cobj].top =cpoy[Cobj] - Ysize[Cobj] * 0.5;
if(Plen[Cobj] != 0) atDis[Cobj] += disStep[Cobj];
if(Plen[Cobj] > 0 && atDis[Cobj] >= Plen[Cobj]) {
	if(PathCount[Cobj] > 0) PathCount[Cobj] --;
	if(PathCount[Cobj] == 0) EndPath[Cobj] = 1;
}
return;
}
/************************************************************************/
function GetRectLoc() {
var dis = 0.0;

 while (0==0) {
	if(LastPt[Cobj] == 0) {
		dis = (PXL[Cpath][1] - PXL[Cpath][0]);
		if((DisPt[Cobj] + dis) > atDis[Cobj]) {
			cpox[Cobj] = PXL[Cpath][0] + atDis[Cobj];
			cpoy[Cobj] = PYL[Cpath][0];
			break; }
		LastPt[Cobj] = 1;
		DisPt[Cobj] += dis; }
	if(LastPt[Cobj] == 1) {
		dis = (PYL[Cpath][1] - PYL[Cpath][0]);
		if((DisPt[Cobj] + dis) > atDis[Cobj]) {
			cpox[Cobj] = PXL[Cpath][1];
			cpoy[Cobj] = PYL[Cpath][0] + (atDis[Cobj]-DisPt[Cobj]);
			break; }
		DisPt[Cobj] += dis;
		LastPt[Cobj] = 2; }
	if(LastPt[Cobj] == 2) {
		dis = (PXL[Cpath][1] - PXL[Cpath][0]);
		if((DisPt[Cobj] + dis) > atDis[Cobj]) {
			cpox[Cobj] = PXL[Cpath][1] - (atDis[Cobj]-DisPt[Cobj]);
			cpoy[Cobj] = PYL[Cpath][1];
			break; }
		DisPt[Cobj] += dis;
		LastPt[Cobj] = 3; }
	if(LastPt[Cobj] == 3) {
		dis = (PXL[Cpath][1] - PXL[Cpath][0]);
		if((DisPt[Cobj] + dis) > atDis[Cobj]) {
			cpox[Cobj] = PXL[Cpath][0];
			cpoy[Cobj] = PYL[Cpath][1] - (atDis[Cobj]-DisPt[Cobj]);
			break;
	 }
	}
}
return;
}
/**************************************************************************/
function GetArcLoc() {
cpox[Cobj] = Math.sin(0.017453292*(atDis[Cobj]-90)) * (PXL[Cpath][1] * 0.5);
cpoy[Cobj] = Math.cos(0.017453292*(atDis[Cobj]-90)) * (PYL[Cpath][1] * 0.5);
return;
}
/*************************************************************************/
function GetPathLoc() {
var cPt, nPt, x, y, dis=0.0, ratio=0.0;

while(0 == 0) {
	if(LastPt[Cobj]+1 < NumPoints[Cpath]) {
		cPt = LastPt[Cobj];
		nPt = cPt + 1; }
	else {
		if(FillType[Cpath] & 1) {
			LastPt[Cobj]  = NumPoints[Cpath]-1;
			cPt = LastPt[Cobj];
			nPt = 0; }
		else {
			LastPt[Cobj]  = 0;
			cPt = 0;
			nPt = 1; }
	}
	x  = PXL[Cpath][nPt] - PXL[Cpath][cPt];
	y  = PYL[Cpath][nPt] - PYL[Cpath][cPt];
	dis = Math.sqrt(x*x + y*y);
	if(atDis[Cobj] < (dis + DisPt[Cobj])) break;
	DisPt[Cobj] += dis;
	LastPt[Cobj]++;
	if(LastPt[Cobj] >= NumPoints[Cpath]) {
		cPt = 0;
		nPt = 1;
}
}
ratio = (atDis[Cobj] - DisPt[Cobj]) / dis;
cpox[Cobj] = PXL[Cpath][cPt] + x * ratio;
cpoy[Cobj] = PYL[Cpath][cPt] + y * ratio;
return;
}
/****************************************************************************/
function Evtest() {
if(Active[Cobj] <= 0) {
if(AEvent[Cobj] & eANDtest)
	ActANDTest();
else
	ActORTest();
}
else if(Active[Cobj] == 1) {
if(DEvent[Cobj] & eANDtest)
	DeactANDTest();
else
	DeactORTest();
}
if     (Active[Cobj] == 4) whenActive();
else if(Active[Cobj] == 2) whenDeactive();
if(SetNewPath[Cobj]) SetPath(Cobj);
if     (Active[Cobj] == -1) isInitial();
else if(Active[Cobj] == 1) isActive();
else if(Active[Cobj] == 0) isDeactive();
return;
}
/***************************************************************************/
function ActORTest()
{
if(((AEvent[Cobj] & eDELAY) 			&& TimeCount() <= 0  ) ||
  ( (AEvent[Cobj] & eOBJECT_ENTER)	&& ObjectEnter(AEnter[Cobj])  ) ||
  ( (AEvent[Cobj] & eOBJECT_LEAVE) 	&& ObjectLeave(ALeave[Cobj])  ) ||
  ( (AEvent[Cobj] & eMOUSE)			&& MouseSelect() > 0 ) ||
  ( (AEvent[Cobj] & eMOUSE_OVER)		&& MouseOver()   ) ||
  ( (AEvent[Cobj] & eLMOUSE)			&& IsMouseLClick()   ) ||
  ( (AEvent[Cobj] & eRMOUSE)			&& IsMouseRClick()   ) ||
  ( (AEvent[Cobj] & eKEY)				&&  KeyChar()   ) ||
  ( (AEvent[Cobj] & eLT_VALUE)		&&  Value[Cobj] <  AValue[Cobj]) ||
  ( (AEvent[Cobj] & eEQ_VALUE)		&&  Value[Cobj] == AValue[Cobj]) ||
  ( (AEvent[Cobj] & eGT_VALUE)		&&  Value[Cobj] >  AValue[Cobj]) ||
  ( (AEvent[Cobj] & eENDPATH)			&&  EndPath[Cobj]     )   )
Active[Cobj] = 4;
}
/***************************************************************************/
function ActANDTest()
{
if(((AEvent[Cobj] & eDELAY) 			&& !(TimeCount() <= 0)  ) ||
  ( (AEvent[Cobj] & eOBJECT_ENTER)	&& !ObjectEnter(AEnter[Cobj])  ) ||
  ( (AEvent[Cobj] & eOBJECT_LEAVE) 	&& !ObjectLeave(ALeave[Cobj])  ) ||
  ( (AEvent[Cobj] & eMOUSE)			&& !(MouseSelect() > 0) ) ||
  ( (AEvent[Cobj] & eMOUSE_OVER)		&& !MouseOver()   ) ||
  ( (AEvent[Cobj] & eLMOUSE)			&& !IsMouseLClick()   ) ||
  ( (AEvent[Cobj] & eRMOUSE)			&& !IsMouseRClick()   ) ||
  ( (AEvent[Cobj] & eKEY)				&& !KeyChar()   ) ||
  ( (AEvent[Cobj] & eLT_VALUE)		&& !(Value[Cobj] <  AValue[Cobj])) ||
  ( (AEvent[Cobj] & eEQ_VALUE)		&& !(Value[Cobj] == AValue[Cobj])) ||
  ( (AEvent[Cobj] & eGT_VALUE)		&& !(Value[Cobj] >  AValue[Cobj])) ||
  ( (AEvent[Cobj] & eENDPATH)			&& !EndPath[Cobj]     )   )
  {} else Active[Cobj] = 4;
}
/***************************************************************************/
function DeactORTest()
{

if(((DEvent[Cobj] & eDELAY) 			&& TimeCount() <= 0  ) ||
  ( (DEvent[Cobj] & eOBJECT_ENTER)	&& ObjectEnter(DEnter[Cobj])  ) ||
  ( (DEvent[Cobj] & eOBJECT_LEAVE) 	&& ObjectLeave(DLeave[Cobj])  ) ||
  ( (DEvent[Cobj] & eMOUSE)			&& MouseSelect() > 0 ) ||
  ( (DEvent[Cobj] & eMOUSE_OVER)		&& MouseOver()   ) ||
  ( (DEvent[Cobj] & eLMOUSE)			&& IsMouseLClick()   ) ||
  ( (DEvent[Cobj] & eRMOUSE)			&& IsMouseRClick()   ) ||
  ( (DEvent[Cobj] & eKEY)				&&  KeyChar()   ) ||
  ( (DEvent[Cobj] & eLT_VALUE)		&&  Value[Cobj] <  DValue[Cobj]) ||
  ( (DEvent[Cobj] & eEQ_VALUE)		&&  Value[Cobj] == DValue[Cobj]) ||
  ( (DEvent[Cobj] & eGT_VALUE)		&&  Value[Cobj] >  DValue[Cobj]) ||
  ( (DEvent[Cobj] & eENDPATH)		   &&  EndPath[Cobj]     )   )
	Active[Cobj] = 2;
}
/***************************************************************************/
function DeactANDTest()
{
if(((DEvent[Cobj] & eDELAY) 			&& !(TimeCount() <= 0)  ) ||
  ( (DEvent[Cobj] & eOBJECT_ENTER)	&& !ObjectEnter(DEnter[Cobj])  ) ||
  ( (DEvent[Cobj] & eOBJECT_LEAVE) 	&& !ObjectLeave(DLeave[Cobj])  ) ||
  ( (DEvent[Cobj] & eMOUSE)			&& !(MouseSelect() > 0) ) ||
  ( (DEvent[Cobj] & eMOUSE_OVER)		&& !MouseOver()   ) ||
  ( (DEvent[Cobj] & eLMOUSE)			&& !IsMouseLClick()   ) ||
  ( (DEvent[Cobj] & eRMOUSE)			&& !IsMouseRClick()   ) ||
  ( (DEvent[Cobj] & eKEY)				&& !KeyChar()   ) ||
  ( (DEvent[Cobj] & eLT_VALUE)		&& !(Value[Cobj] <  DValue[Cobj])) ||
  ( (DEvent[Cobj] & eEQ_VALUE)		&& !(Value[Cobj] == DValue[Cobj])) ||
  ( (DEvent[Cobj] & eGT_VALUE)		&& !(Value[Cobj] >  DValue[Cobj])) ||
  ( (DEvent[Cobj] & eENDPATH)		   && !EndPath[Cobj]     )   )
  {} else Active[Cobj] = 2;
}
/**************************************************************************/
function TimeCount() {
if(TimeLeft[Cobj] > 0)  {
	if(isNav4) TimeLeft[Cobj] -= 2;
	else       TimeLeft[Cobj] -= 1;
}
return (TimeLeft[Cobj]);
}
function ObjectEnter(eobj) {
x = Xsize[Cobj] * 0.5;
y = Ysize[Cobj] * 0.5;
if ( cpox[eobj] >= cpox[Cobj] - x && cpox[eobj] <= cpox[Cobj] + x &&
	  cpoy[eobj] >= cpoy[Cobj] - y && cpoy[eobj] <= cpoy[Cobj] + y )
	return 1;
return 0;
}
function ObjectLeave(eobj) {
x = Xsize[Cobj] * 0.5;
y = Ysize[Cobj] * 0.5;
if ( cpox[eobj] >= cpox[Cobj] - x && cpox[eobj] <= cpox[Cobj] + x &&
	  cpoy[eobj] >= cpoy[Cobj] - y && cpoy[eobj] <= cpoy[Cobj] + y )
	return 0;
return 1;
}
function MouseSelect() {
var val = 0;
if(smx == -99999) return val;
x = Xsize[Cobj] * 0.5;
y = Ysize[Cobj] * 0.5;
if ( smx >= cpox[Cobj] - x && smx <= cpox[Cobj] + x &&
	  smy >= cpoy[Cobj] - y && smy <= cpoy[Cobj] + y )
	return val = 1;
return val;
}
function MouseOver() {
x = Xsize[Cobj] * 0.5;
y = Ysize[Cobj] * 0.5;
if ( smx >= cpox[Cobj] - x && smx <= cpox[Cobj] + x &&
	  smy >= cpoy[Cobj] - y && smy <= cpoy[Cobj] + y )
	return 1;
return 0;
}
function IsMouseLClick() {
return (slm && 1);
}
function IsMouseRClick() {
return (slm && 2);
}
function KeyChar() {
if(!sky) return 0;
if(isNav4 && (AKey[Cobj] == sky)) return 1;
if(isIE4  && (IKey[Cobj] == sky)) return 1;
return 0;
}
/***************************************************************************/
function isInitial() {
	var cx = cpox[Cobj];
	var cy = cpoy[Cobj];
	var hflip = 1;
	if(AEvent[Cobj] & (1<<28)) UpdStr();
	if(PathCount[Cobj] != 0) UpdPos();
	if(WAEvent[Cobj] & (1<<28)) {
		if		 (cx < cpox[Cobj]) hflip= !(FillType[Cobj] & 2);
		else if(cx > cpox[Cobj]) hflip= (FillType[Cobj] & 2);
//		if		 (cx < cpox[Cobj]) ob[Cobj].filters.fliph.enabled=!(FillType[Cobj] & 2);
//		else if(cx > cpox[Cobj]) ob[Cobj].filters.fliph.enabled=(FillType[Cobj] & 2);
	}
	if(WAEvent[Cobj] & (1<<27)) {
//		if		 (cy < cpoy[Cobj]) ob[Cobj].filters.flipv.enabled=!(FillType[Cobj] & 4);
//		else if(cy > cpoy[Cobj]) ob[Cobj].filters.flipv.enabled=(FillType[Cobj] & 4);
	}
	spritea(hflip);
return;
}
/***************************************************************************/
function isActive() {
	var cx = cpox[Cobj];
	var cy = cpoy[Cobj];
	var hflip = 1;
	if(AEvent[Cobj] & (1<<28)) UpdStr();
	if(PathCount[Cobj] != 0) UpdPos();
	if(WAEvent[Cobj] & (1<<28)) {
		if		 (cx < cpox[Cobj]) hflip=!(FillType[Cobj] & 2);
		else if(cx > cpox[Cobj]) hflip= (FillType[Cobj] & 2);
//		if		 (cx < cpox[Cobj]) ob[Cobj].filters.fliph.enabled=!(FillType[Cobj] & 2);
//		else if(cx > cpox[Cobj]) ob[Cobj].filters.fliph.enabled=(FillType[Cobj] & 2);
	}
	if(WAEvent[Cobj] & (1<<27)) {
//		if		 (cy < cpoy[Cobj]) ob[Cobj].filters.flipv.enabled=!(FillType[Cobj] & 4);
//		else if(cy > cpoy[Cobj]) ob[Cobj].filters.flipv.enabled=(FillType[Cobj] & 4);
	}
	if(WAEvent[Cobj] & 2) spritea(hflip);
return;
}
function isDeactive() {
	var cx = cpox[Cobj];
	var cy = cpoy[Cobj];
	var hflip = 1;
	if(DEvent[Cobj] & (1<<28)) UpdStr();
	if(PathCount[Cobj] != 0) UpdPos();
	if(WDEvent[Cobj] & (1<<28)) {
		if		 (cx < cpox[Cobj]) hflip= !(FillType[Cobj] & 2);
		else if(cx > cpox[Cobj]) hflip= (FillType[Cobj] & 2);
//		if		 (cx < cpox[Cobj]) ob[Cobj].filters.fliph.enabled=!(FillType[Cobj] & 2);
//		else if(cx > cpox[Cobj]) ob[Cobj].filters.fliph.enabled=(FillType[Cobj] & 2);
	}
	if(WDEvent[Cobj] & (1<<27)) {
//		if		 (cy < cpoy[Cobj]) ob[Cobj].filters.flipv.enabled=!(FillType[Cobj] & 2);
//		else if(cy > cpoy[Cobj]) ob[Cobj].filters.flipv.enabled=(FillType[Cobj] & 2);
	}
	if(WDEvent[Cobj] & 2) spritea(hflip);
return;
}
/***************************************************************************/
function ApplyPath(fromobj,toobj) {
		Path[toobj] = Path[fromobj];
		ActType[toobj]= ActType[fromobj];
		SetPath(Cobj);
//		SetNewPath[toobj] = 1;
}
/***************************************************************************/
function ApplyXYZ(fromobj,toobj) {
		if(fromobj==toobj) {
			var cx = cpox[fromobj];
			var cy = cpoy[fromobj];
			UpdPos();
			dpox[fromobj] = cpox[fromobj] - cx;
			dpoy[fromobj] = cpoy[fromobj] - cy;
			ActType[Cobj] = 0x00ff;
			Plen[Cobj] = -1;
			atDis[Cobj]= 0;
		}
		else {
			ActType[toobj] = (4<<12 & 0xf000)
			Path[toobj] = fromobj;
			cpox[toobj] = cpox[fromobj];
			cpoy[toobj] = cpoy[fromobj];
			SetPath(Cobj)
//			SetNewPath[toobj] = 1;
			nm[toobj].left=cpox[fromobj] - Xsize[toobj] * 0.5;
			nm[toobj].top =cpoy[fromobj] - Ysize[toobj] * 0.5;
		}
}
function initialOpts() {
	Active[Cobj] = -1;
	PathCount[Cobj] = 1;
	TimeLeft[Cobj] = ATime[Cobj];
	nm[Cobj].visibility = "visible";
}
function activeOpts() {
	Active[Cobj] = 1;
	PathCount[Cobj] = 0;
	TimeLeft[Cobj] = DTime[Cobj];
// 	motion
	if(WAEvent[Cobj] & 4) {
		if(WAEvent[Cobj] & 32768)
			PathCount[Cobj] = -1;
		else
			PathCount[Cobj] = 1;
	}
//	else {
//		PathCount[Cobj] = 0;
//	}
// 	visibility
	if(WAEvent[Cobj] & 8) nm[Cobj].visibility = "visible";
	else                  nm[Cobj].visibility = "hidden";
// 	sound
	if(WAEvent[Cobj] & 16) {	}
}
function deactiveOpts() {
	Active[Cobj] = 0;
	PathCount[Cobj] = 0;
	TimeLeft[Cobj] = ATime[Cobj];
// set motion
	if(WDEvent[Cobj] & 4) {
	if(WDEvent[Cobj] & 32768)
		PathCount[Cobj] = -1;
	else
		PathCount[Cobj] = 1;
	}
//	else {
//		PathCount[Cobj] = 0;
//	}

	if(WDEvent[Cobj] & 8) nm[Cobj].visibility = "visible";
	else                  nm[Cobj].visibility = "hidden";
// set sound
	if(WDEvent[Cobj] & 16) {	}
}
/***************************************************************************/
function whenActive()
{
	activeOpts();
	EndPath[Cobj] = 0;

	if(WAEvent[Cobj] &  32) Active[WAAObj[Cobj]] = 4;
	if(WAEvent[Cobj] & 128) Active[WADObj[Cobj]] = 2;
	if(WAEvent[Cobj] & 512) {
		if		 ((OpValue[Cobj] & 0x000f) == 0)
			Value[WASVal[Cobj]]  = WAValue[Cobj];
		else if((OpValue[Cobj] & 0x000f) == 2)
			Value[WASVal[Cobj]] += WAValue[Cobj];
		else if((OpValue[Cobj] & 0x000f) == 3)
			Value[WASVal[Cobj]] -= WAValue[Cobj];
		else if((OpValue[Cobj] & 0x000f) == 4)
			Value[WASVal[Cobj]] *= WAValue[Cobj];
		else if((OpValue[Cobj] & 0x000f) == 5)
			if(WAValue[Cobj] != 0) Value[WASVal[Cobj]] /= WAValue[Cobj];
	}
	if(WAEvent[Cobj] & 2048) {
		if		 ((OpValue[Cobj] & 0x000f) == 0)
			Value[Cobj]  = WAValue[WAGVal[Cobj]];
		else if((OpValue[Cobj] & 0x000f) == 2)
			Value[Cobj] += WAValue[WAGVal[Cobj]];
		else if((OpValue[Cobj] & 0x000f) == 3)
			Value[Cobj] -= WAValue[WAGVal[Cobj]];
		else if((OpValue[Cobj] & 0x000f) == 4)
			Value[Cobj] *= WAValue[WAGVal[Cobj]];
		else if((OpValue[Cobj] & 0x000f) == 5)
			if(AValue[Cobj] != 0) Value[Cobj] /= WAValue[WAGVal[Cobj]];
	}
	if(WAEvent[Cobj] & 8192) {
		if		 ((OpValue[Cobj] & 0x000f) == 0)
			Value[Cobj]  = WAValue[Cobj];
		else if((OpValue[Cobj] & 0x000f) == 2)
			Value[Cobj] += WAValue[Cobj];
		else if((OpValue[Cobj] & 0x000f) == 3)
			Value[Cobj] -= WAValue[Cobj];
		else if((OpValue[Cobj] & 0x000f) == 4)
			Value[Cobj] *= WAValue[Cobj];
		else if((OpValue[Cobj] & 0x000f) == 5)
			if(AValue[Cobj] != 0) Value[Cobj] /= WAValue[Cobj];
	}
	if(WAEvent[Cobj] & 16384) {
	}
	if(WAEvent[Cobj] & (1<<24)) {
		ApplyPath(WAGPath[Cobj],Cobj);
		Cpath = WAGPath[Cobj];
	}
	if(WAEvent[Cobj] & (1<<25)) {
		ApplyXYZ(WAGPath[Cobj],Cobj);
		Cpath = WAGPath[Cobj];
	}
	if(WAEvent[Cobj] & (1<<21)) {                    // get path
		ApplyPath(Cobj,WASPath[Cobj]);
	}
	if(WAEvent[Cobj] & (1<<22)) {                    // get xyz
		ApplyXYZ(Cobj,WASPath[Cobj]);
	}
// link to the referenced page
	if(WAEvent[Cobj] & 16384) {	}
// reset the object
	if(WAEvent[Cobj] & 65536) {
		reset(Cobj);
	}
// terminate the program
	if(WAEvent[Cobj] & 131072) {	}

}
/***************************************************************************/
function whenDeactive()
{
	deactiveOpts();
	EndPath[Cobj] = 0;

	if(WDEvent[Cobj] & 32) Active[WDAObj[Cobj]] = 4;
	if(WDEvent[Cobj] & 128) Active[WDDObj[Cobj]] = 2;
	if(WDEvent[Cobj] & 512) {
		if		 ((OpValue[Cobj] & 0x000f)>>4 == 0)
			Value[WDSVal[Cobj]]  = WDValue[Cobj];
		else if((OpValue[Cobj] & 0x000f)>>4 == 2)
			Value[WDSVal[Cobj]] += WDValue[Cobj];
		else if((OpValue[Cobj] & 0x000f)>>4 == 3)
			Value[WDSVal[Cobj]] -= WDValue[Cobj];
		else if((OpValue[Cobj] & 0x000f)>>4 == 4)
			Value[WDSVal[Cobj]] *= WDValue[Cobj];
		else if((OpValue[Cobj] & 0x000f)>>4 == 5)
			if(WDValue[Cobj] != 0) Value[WDSVal[Cobj]] /= WDValue[Cobj];
	}
	if(WDEvent[Cobj] & 2048) {
		if		 ((OpValue[Cobj] & 0x000f)>>4 == 0)
			Value[Cobj]  = WDValue[WDGVal[Cobj]];
		else if((OpValue[Cobj] & 0x000f)>>4 == 2)
			Value[Cobj] += WDValue[WDGVal[Cobj]];
		else if((OpValue[Cobj] & 0x000f)>>4 == 3)
			Value[Cobj] -= WDValue[WDGVal[Cobj]];
		else if((OpValue[Cobj] & 0x000f)>>4 == 4)
			Value[Cobj] *= WDValue[WDGVal[Cobj]];
		else if((OpValue[Cobj] & 0x000f)>>4 == 5)
			if(AValue[Cobj] != 0) Value[Cobj] /= WDValue[WDGVal[Cobj]];
	}
	if(WDEvent[Cobj] & 8192) {
		if		 ((OpValue[Cobj] & 0x000f)>>4 == 0)
			Value[Cobj]  = WDValue[Cobj];
		else if((OpValue[Cobj] & 0x000f)>>4 == 2)
			Value[Cobj] += WDValue[Cobj];
		else if((OpValue[Cobj] & 0x000f)>>4 == 3)
			Value[Cobj] -= WDValue[Cobj];
		else if((OpValue[Cobj] & 0x000f)>>4 == 4)
			Value[Cobj] *= WDValue[Cobj];
		else if((OpValue[Cobj] & 0x000f)>>4 == 5)
			if(AValue[Cobj] != 0) Value[Cobj] /= WDValue[Cobj];
	}
	if(WDEvent[Cobj] & 16384) {
	}
	if(WDEvent[Cobj] & (1<<24)) {
		ApplyPath(WDGPath[Cobj],Cobj);
		Cpath = WDGPath[Cobj];
	}
	if(WDEvent[Cobj] & (1<<25)) {
		ApplyXYZ(WDGPath[Cobj],Cobj);
		Cpath = WDGPath[Cobj];
	}
	if(WDEvent[Cobj] & (1<<21)) {
		ApplyPath(Cobj,WDSPath[Cobj]);
	}
	if(WDEvent[Cobj] & (1<<22)) {
		ApplyXYZ(Cobj,WDSPath[Cobj]);
	}
// link to the referenced page
	if(WDEvent[Cobj] & 16384) {	}
// reset the object
	if(WDEvent[Cobj] & 65536) {
		reset(Cobj);
	}
	if(WDEvent[Cobj] & 131072) {	}
}
/**************************************************************************/
function reset(cobj) {

	Cobj = cobj;
   Cpath = Path[cobj];

	if     (AEvent[cobj] & (1<<31)) activeOpts();
	else if(DEvent[cobj] & (1<<31)) deactiveOpts();
	else                    		  initialOpts();
	cpox[cobj] = spox[cobj];
	cpoy[cobj] = spoy[cobj];
	LastPt[cobj] = 0;
	atDis[cobj] = 0;
	DisPt[cobj] = 0;
	EndPath[cobj] = 0;
	TimeLeft[cobj] = DTime[cobj];
return;
}
/*************************************************************************/
function SetPath(cobj) {

var cpath = Path[cobj];
SetNewPath[cobj] = 0;

if(((ActType[cobj] & 0xf000) >> 12) == 4) {
	Plen[cobj] = 1;
	noStep = 1;
	disStep[cobj] = 1;
	dpox[cobj] = 0;
	dpoy[cobj] = 0;
	spox[cobj] = cpox[cobj];
	spoy[cobj] = cpoy[cobj];
}
else if(ActType[cobj] & 0xf000) {
	spox[cobj] = cpox[cpath];
	spoy[cobj] = cpoy[cpath];
	objPath(cobj,cpath);
}
else
{
	linPath(cobj);
}

cpox[cobj] = spox[cobj];
cpoy[cobj] = spoy[cobj];
LastPt[cobj] = 0;
atDis[cobj] = 0;
DisPt[cobj] = 0;
EndPath[cobj] = 0;
nm[cobj].left=cpox[cobj] - Xsize[cobj] * 0.5;
nm[cobj].top =cpoy[cobj] - Ysize[cobj] * 0.5;
return;
}
function objPath(cobj,cpath) {
if(Ptype[cpath] == 1) {
	spox[cobj] = PXL[cpath][0] + cpox[cpath];
	spoy[cobj] = PYL[cpath][0] + cpoy[cpath];
}
else if(Ptype[cpath] == 2) {
	spox[cobj] = PXL[cpath][0] - PXL[cpath][1] + cpox[cpath];
	spoy[cobj] = PYL[cpath][0] - PYL[cpath][1] + cpoy[cpath];
}
else if(Ptype[cpath] == 3) {
	spox[cobj] = PXL[cpath][0] + cpox[cpath];
	spoy[cobj] = PYL[cpath][0] + cpoy[cpath];
}

Plen[cobj] = Len[cpath];
noStep  = Plen[cobj] / pRate[cobj];
if(noStep < 1) noStep = 1;
disStep[cobj] = Plen[cobj] / noStep;
return;
}
function linPath(cobj) {

epox[cobj] = spox[cobj] = cpox[cobj];
epoy[cobj] = spoy[cobj] = cpoy[cobj];
switch( (ActType[cobj] & 0x00f0) >> 4)
{
case 2:
	spoy[cobj] 	+= mH;
	epoy[cobj]  -= H;
	break;
case 3:
	spoy[cobj] 	+= mH;
	break;
case 4:
	epoy[cobj]  -= mH;
	break;
case 5:
	epoy[cobj]  += mH;
	break;
case 6:
	spoy[cobj] 	-= mH;
	break;
case 7:
	spoy[cobj] 	-= mH;
	epoy[cobj]  += mH;
	break;
case 8:
	break;
default:
	break;
}
switch( ActType[cobj] & 0x000f )
{
case 2:
	spox[cobj] 	+= mW;
	epox[cobj]  -= mW;
	break;
case 3:
	spox[cobj] 	+= mW;
	break;
case 4:
	epox[cobj]  -= mW;
	break;
case 5:
	epox[cobj]  += mW;
	break;
case 6:
	spox[cobj] 	-= mW;
	break;
case 7:
	spox[cobj] 	-= mW;
	epox[cobj]  += mW;
	break;
case 8:
	break;
default:
	break;
}
var x = epox[cobj] - spox[cobj];
var y = epoy[cobj] - spoy[cobj];
if(x+y)
{
	Plen[cobj] = Math.sqrt(x*x + y*y);
	noStep  = Plen[cobj] / pRate[cobj];
	if(noStep < 1) noStep = 1;
	disStep[cobj] = Plen[cobj] / noStep;
	dpox[cobj] = x / noStep;
	dpoy[cobj] = y / noStep;
}
else
{
	Plen[cobj] = 0;
	dpox[cobj] = 0;
	dpoy[cobj] = 0;
	disStep[cobj] = 0;
}
return
}
//if(Cobj==1) window.status = " Cobj=" + Cobj + " dpox=" + dpox[Cobj] + " dpoy=" + dpoy[Cobj];
//window.status = " mousex=" + smx + " mousey=" + smy;
//-->
