/*
  ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Copyright © 2003 by Gary Johnson
Copyright (&copy;) 2003 by Gary Johnson

COPYRIGHT

The information contained on this site is protected by Canadian, United States of America and international copyright laws.

All website materials, including, without limitation, design, text, graphics, photos, files, the Fast Track! logo, and 
the selection and arrangement thereof are © 2004 Gary Johnson ALL RIGHTS RESERVED.
 
Permission is granted to electronically copy and print to hard copy portions of this website for the sole purpose of 
using materials it contains for informational and non-commercial personal use only.
 
Any other use of materials in this website, including any commercial use, reproduction for purposes other than those noted above, 
modification, distribution or republication, without the prior written consent of Gary Johnson is strictly prohibited.


The Full Copyright statement is

	http://mywebpages.comcast.net/adgj/XXSoftwareTools/Copyright.html

  ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

  see gjmove.txt for doc

*/


//might not need the effects flags
// up to 2147483647



if (!window.F) 
{
var F =
	{
		HorizontalVertical: 0x0001,
		VerticalHorizontal:	0x0002,
		myWipeLeft:			0x0004,
		myWipeRight:		0x0008,
		myWipeTop:			0x0010,
		myWipeBottom:		0x0020,
		Fade:				0x0040,
		Plot:				0x0080,
		Init:				0x0100,
		DoneH:				0x0200,
		DoneV:				0x0400,
		DoneE:				0x0800,
		myClip:				0x1000,
		Diagonal:			0x2000,
		Keep:				0x4000,
		mySWipe:			0x8000, 
		sixfive536:			0x10000, 
		onethreeone07:		0x20000, 
		twosixtwo144:		0x40000, 
		fivetwofour288:		0x80000, 
		aaa:				0x100000, 
		bbb:				0x200000, 
		cccc:				0x400000, 
		dddd:				0x800000, 
		eeee:				0x1000000,
		ffff:				0x2000000,
		gggg:				0x4000000,
		hhhh:				0x8000000,
		iiii:				0x10000000,
		jjjj:				0x20000000,
		kkkk:				0x40000000
	}
}

if (!window.NO) 
{
    var NO = 
	{      
		NUMBEROBJECTS:		0 
    }
} 

if (!window.objSGS) 
{
    var objSGS = 
	{      
		objectNumber:		1, 
		theId:				2,
		ointervalSpeed:		3,
		ointervalObj:		4,
		MIV:				5,    
		MIH:				6,    
		moveFromTop:		7,		
		moveFromLeft:		8,
		moveToTop:			9,
		moveToLeft:			10,	
		nextFunc:			11,	
		theIdType:			12,		
		theIdOrigTop:		13,
		theIdOrigLeft:		14,
		theIdOrigWidth:		15,	
		theIdOrigHeight:	16,
		theIdOrigStyle:		17,
		theIdCurrTop:		18,
		theIdCurrLeft:		19,
		theIdCurrWidth:		20,		
		theIdCurrHeight:	21,	
		theIdClipCounter:	22,	
		moveType:			23,
		MIE:				24							
	}
} 

if (!window.scrSGS) 
{
    var scrSGS = 
	{      
		reserved:				1,	
		clientWidth:			2,
		clientHeight:			3,
		screenWidth:			4,
		screenHeight:			5,
		screenColorDepth:		6
    }
} 

if (!window.gI) 
{
    var gI= 
	{      
		INTERVALOBJ:	0,
		INTERVALSPEED:	1
	}
}

//I need to add the unload function
//see hideit showit.  adding another CGGS with the same ID fakes out the 
//get number from ID 
//need to return the number or something so that it can handle this situtation


function cleanUp()
{

// called from window.unload
	// add an array
	// add things in it to delete
	// and code other actions to perform

	delete myGCSGS;
	myGCSGS = -1;
//	alert('in cleanUp');

}



function GCSGS()
{

	if(myGCSGS == -1)
	{
		myGCSGS = new CSGS()
	}
	

	if(typeof(myGCSGS.constructor) == 'CSGS')
	{
		alert('constructor');
	}

	if(typeof(myGCSGS) == 'object')
	{

		if(myGCSGS == 'CSGS')
		{
			alert('== CSGS');
		}

		if(window.onunload && (typeof(window.onunload) == 'function') && (window.onunload != cleanUp) )
		{
			alert('we have an onunload already');
		}

		window.onunload=cleanUp;

//		

		return myGCSGS;
	}
	else
	{
		alert('we are hosed in GCSGS')
		return -1;
	}
}

//call in this order
//
//if addMove is not just before doit, the MI is not set correctly
//
//addElement('theheader');
//addEffect('theheader','myWipe')
//setIntervalSpeed('theheader', 60);
//addMove('theheader', 0,0, 0,400);
//addElement('newheader');
//addMove('newheader', 'll','ll', 0, 0);
//doIt();
//don't call this from 'internal API'

// this is the easeist way to avoid conflicts
// use the number instead of the id, and let it clean itself up instead of calling delete
// call the global one see hideIt and showIt
//			var popItUp = GCSGS();
			
//			var myNum = popItUp.addElement(idin);
//			popItUp.setIntervalSpeed(60);
//			popItUp.setMI(myNum, 25);
//			popItUp.addMove(myNum, 'tl','tl', leftVal, topVal);


function CSGS(idin)
{
	this.objASGS = new Array();
	this.objASGS[NO.NUMBEROBJECTS] = 0;

	this.scrASGS = new Array(6);
	this.Agi = new Array(2);

	//if I set this global, and use it to reference all object.methods that I store in arrays
	//and execute with new
	//it looks like it works in Mozilla 1.5 and IE 6.0 
	myself=this;

	this.scrASGS[scrSGS.clientWidth]	=	getCW();
	this.scrASGS[scrSGS.clientHeight]	=	getCH();

	this.scrASGS[scrSGS.screenWidth]	=	screen.width;
	this.scrASGS[scrSGS.screenHeight]	=	screen.height;
	//  JavaScript strict warning:
  //  gjmove.js line 239: reference to undefined property scrSGS.colorDepth
	this.scrASGS[scrSGS.screencolorDepth]		=	screen.colorDepth;

	if(!idin)
	{
		return;
	}
	else
	{
		this.addElement(idin);
	}

}

CSGS.prototype.addElement = function(idin)
{
var newObjNum	= 0;

	this.objASGS[NO.NUMBEROBJECTS]		+=	1;
	newObjNum = this.objASGS[NO.NUMBEROBJECTS];

	this.objASGS[newObjNum] = new Array(24);

	this.objASGS[newObjNum][objSGS.objectNumber]			= newObjNum;
	this.objASGS[newObjNum][objSGS.theId]					= idin;
	this.objASGS[newObjNum][objSGS.theIdType]				= 1;
	this.objASGS[newObjNum][objSGS.theIdOrigTop]			= mygetTop(idin);
	this.objASGS[newObjNum][objSGS.theIdOrigLeft]			= mygetLeft(idin);
	this.objASGS[newObjNum][objSGS.theIdOrigWidth]			= mygetWidth(idin);
	this.objASGS[newObjNum][objSGS.theIdOrigHeight]			= mygetHeight(idin);

//still getting NAN for height
//	if(!this.objASGS[newObjNum][objSGS.theIdOrigHeight])
//	{
//		this.objASGS[newObjNum][objSGS.theIdOrigHeight] = getCompStyle(idin, 'height');
//		alert( 'no height ' + this.objASGS[newObjNum][objSGS.theIdOrigHeight] );
//
//	}

	this.objASGS[newObjNum][objSGS.theIdCurrTop]			= mygetTop(idin);
	this.objASGS[newObjNum][objSGS.theIdCurrLeft]			= mygetLeft(idin);
	this.objASGS[newObjNum][objSGS.theIdCurrWidth]			= mygetWidth(idin);
	this.objASGS[newObjNum][objSGS.theIdCurrHeight]			= mygetHeight(idin);
	this.objASGS[newObjNum][objSGS.theIdClipCounter]		= 0;
	this.objASGS[newObjNum][objSGS.moveType]				= 0;
//hack to prevent myself from calling addMove before setMI
	this.objASGS[newObjNum][objSGS.moveToTop]				= -1;
	this.setMI(newObjNum,0);
	this.setMIE(newObjNum,0);
//	this.setIntervalSpeed(newObjNum,0);
	this.setIntervalSpeed(0);
	this.addEffect(newObjNum,0);

//	this.dump(newObjNum);
return newObjNum;
}

CSGS.prototype.setMI = function(idORbojNum, newMI)
{
	//is there an over ride ?
	//check machine
	//check browser

var newObjNum;

	newObjNum = this.getNumberFromIDorNum(idORbojNum);
	if(newObjNum == -1)
	{
		return;
	}

	if(this.objASGS[newObjNum][objSGS.moveToTop] != -1)
	{
		alert('call to setMI after call to addMove');
	}


	if(!newMI) //0 uses the default
	{
		if(isIE())
		{
			this.objASGS[newObjNum][objSGS.MIV] = 25;
			this.objASGS[newObjNum][objSGS.MIH] = 25;
		}
		else
		{
			this.objASGS[newObjNum][objSGS.MIV] = 25;
			this.objASGS[newObjNum][objSGS.MIH] = 25;
		}
	}
	else
	{
			this.objASGS[newObjNum][objSGS.MIV] = newMI;
			this.objASGS[newObjNum][objSGS.MIH] = newMI;
	}

}

CSGS.prototype.setMIE = function(idORbojNum, newMIE)
{
	// 2 for clip 5 for wipe
	//check machine
	//check browser

var newObjNum;

	newObjNum = this.getNumberFromIDorNum(idORbojNum);
	if(newObjNum == -1)
	{
		return;
	}


	if(!newMIE) //0 uses the default
	{
		if(isIE())
		{
			this.objASGS[newObjNum][objSGS.MIE] = 5;
		}
		else
		{
			this.objASGS[newObjNum][objSGS.MIE] = 5;
		}
	}
	else
	{
			this.objASGS[newObjNum][objSGS.MIE] = newMIE;
	}

}

//CSGS.prototype.setIntervalSpeed = function(idORbojNum, newIS)
CSGS.prototype.setIntervalSpeed = function(newIS)
{
//check machine
//check browser
//	100 is slow 	1 is snappy try 60 

	if(!newIS) //0 uses the default
	{
		if(isIE())
		{
			this.Agi[gI.INTERVALSPEED] = 60;
		}
		else
		{
			this.Agi[gI.INTERVALSPEED] = 60;
		}
	}
	else
	{
			this.Agi[gI.INTERVALSPEED] = newIS;
	}
}



CSGS.prototype.addEffect = function(idORbojNum, funcToCall, option)
{
var newObjNum;

	newObjNum = this.getNumberFromIDorNum(idORbojNum);
	if(newObjNum == -1)
	{
		return;
	}

	//defaults to top in the effects code
	if(option)
	{
		switch (option)
		{
		case 'myKeep':
			this.objASGS[newObjNum][objSGS.moveType] |= F.Keep;
			break;
		case 'WLR':
			this.objASGS[newObjNum][objSGS.moveType] |= F.myWipeLeft;
			break;
		case 'WRL':
			this.objASGS[newObjNum][objSGS.moveType] |= F.myWipeRight;
			this.objASGS[newObjNum][objSGS.theIdClipCounter] = this.objASGS[newObjNum][objSGS.theIdOrigLeft];
			break;
		case 'WTB':
			this.objASGS[newObjNum][objSGS.moveType] |= F.myWipeTop;
			break;
		case 'WBT':
			this.objASGS[newObjNum][objSGS.moveType] |= F.myWipeBottom;
			this.objASGS[newObjNum][objSGS.theIdClipCounter] = this.objASGS[newObjNum][objSGS.theIdOrigHeight];
			break;
		default:
			break;
		}
	}

	if(!funcToCall) //0 uses the default
	{
			myself.ptrEffect					= '';
	}
	else
	{
//mywipe dead
		switch (funcToCall)
		{
		case 'mySWipe':
			myself.ptrEffect					= myself.mySWipe;
			this.objASGS[newObjNum][objSGS.moveType] |= F.mySWipe;
			break;
		case 'myClip':
			myself.ptrEffect					= myself.myClip;
			this.objASGS[newObjNum][objSGS.moveType] |= F.myClip;
			break;
		default : myself.ptrEffect				= '';
		}
	}

	this.objASGS[newObjNum][objSGS.nextFunc]	=   myself.ptrEffect;
}

CSGS.prototype.toggleEffect = function(objNum)
{
//this is dead
		switch ( this.objASGS[objNum][objSGS.nextFunc])
		{
		case myself.mySWipe:
			this.objASGS[objNum][objSGS.moveType] |= F.myWipeBottom;
			break;
		case myself.myClip:
			this.objASGS[objNum][objSGS.moveType] |= F.myClip;
			break;
		default : 
			break;
		}
}

/*

	This has to be called last, just before doit to get the right MI set

	have to figure out which direction we are going in so that you can set MI correctly (*-1 if going down)
	you might have different MI for x and Y, but I doubt it

	if its hidden, I want it to appear from somewhere and end up somewhere
	fromx, fromy can be numbers (no quotes) or 'll', 'lr', 'tr', 'tl' 'cl'
	example ll lower left cl current location

	diag over rides defualt assingment of HV or VH

*/

//                                            LEFT   TOP    LEFT TOP 
CSGS.prototype.addMove = function(idORbojNum, fromx, fromy, tox, toy, diag)
{

var newObjNum;

	newObjNum = this.getNumberFromIDorNum(idORbojNum);
	if(newObjNum == -1)
	{
		return;
	}

/*
	b	bottom of object to bottom of screen
	l   left of object to left of screen
	r	right of object to right of screen
	t	top of object to top of screen

    c   center either one
*/
	
	if(tox == 'l')   
	{
		this.objASGS[newObjNum][objSGS.moveToLeft]		= getXoffset() + 2;//0 cuts off borders. to uch to do to to compute at the moment
	}
	else if(tox == 'r')
	{
		this.objASGS[newObjNum][objSGS.moveToLeft]		= getXoffset() + (this.scrASGS[scrSGS.clientWidth] - this.objASGS[newObjNum][objSGS.theIdOrigWidth]);
	}
	else if(tox == 'c')
	{
		this.objASGS[newObjNum][objSGS.moveToLeft]		= getXoffset() + ((this.scrASGS[scrSGS.clientWidth] - this.objASGS[newObjNum][objSGS.theIdOrigWidth]) / 2);
	}
	else if(typeof(tox) == 'number')
	{
		this.objASGS[newObjNum][objSGS.moveToLeft]		= tox;
	}
	else
	{
		alert('we are hosed in addMove tox');
	}

	if(toy == 'b')
	{
		this.objASGS[newObjNum][objSGS.moveToTop]		= getYoffset() + (this.scrASGS[scrSGS.clientHeight] - this.objASGS[newObjNum][objSGS.theIdOrigHeight]);
	}
	else if(toy == 't')
	{
		this.objASGS[newObjNum][objSGS.moveToTop]		= getYoffset() + 2;  //0 cuts off borders. to uch to do to to compute at the moment
	}	
	else if(toy == 'c')
	{
		this.objASGS[newObjNum][objSGS.moveToTop]		= getYoffset() + ((this.scrASGS[scrSGS.clientHeight] - this.objASGS[newObjNum][objSGS.theIdOrigHeight]) / 2);
	}
	else if(typeof(toy) == 'number')
	{
		this.objASGS[newObjNum][objSGS.moveToTop]		= toy;
	}
	else
	{
		alert('we are hosed in addMove toy');
	}

/*
	the ll and lr should move Vertically then Horizontal	(?if top is 0)
	the tr and tl should move Horizontal then Vertical		(?if top is not 0)

	I am ignoring moveFromTop and setting theIdCurrTop instead
	if using mnemonics I will only check one
*/

	if(fromx == 'll') // this sets both x and y 
	{
		this.objASGS[newObjNum][objSGS.theIdCurrLeft]	=	getXoffset() + 0;	
		this.objASGS[newObjNum][objSGS.theIdCurrTop]	=	getYoffset() + this.scrASGS[scrSGS.clientHeight]; 
		this.objASGS[newObjNum][objSGS.moveType]		|=	F.VerticalHorizontal;
	}
	else if(fromx == 'lr') 
	{
		this.objASGS[newObjNum][objSGS.theIdCurrLeft]	=	getXoffset() + (this.scrASGS[scrSGS.clientWidth] - this.objASGS[newObjNum][objSGS.theIdOrigWidth]);	
		this.objASGS[newObjNum][objSGS.theIdCurrTop]	=	getYoffset() + this.scrASGS[scrSGS.clientHeight]; 
		this.objASGS[newObjNum][objSGS.moveType]		|=	F.VerticalHorizontal;
	}
	else if(fromx == 'tr') 
	{
		this.objASGS[newObjNum][objSGS.theIdCurrLeft]	=	getXoffset() + this.scrASGS[scrSGS.clientWidth];	
		this.objASGS[newObjNum][objSGS.theIdCurrTop]	=	0; 
		this.objASGS[newObjNum][objSGS.moveType]		|=	F.HorizontalVertical;
	}
	else if(fromx == 'tl') 
	{
		this.objASGS[newObjNum][objSGS.theIdCurrLeft]	=	getXoffset() + 0;	
		this.objASGS[newObjNum][objSGS.theIdCurrTop]	=	getYoffset() + 0; 
		this.objASGS[newObjNum][objSGS.moveType]		|=	F.HorizontalVertical;
	}
	else if(fromx == 'cl') 
	{
		this.objASGS[newObjNum][objSGS.moveType]		|=	F.HorizontalVertical;
	}
	else
	{
		this.objASGS[newObjNum][objSGS.theIdCurrLeft]	=	(fromx - 0);	
		this.objASGS[newObjNum][objSGS.theIdCurrTop]	=	(fromy - 0); 
		this.objASGS[newObjNum][objSGS.moveType]		|=	F.HorizontalVertical;
	}




	if(this.objASGS[newObjNum][objSGS.moveToLeft] < this.objASGS[newObjNum][objSGS.theIdCurrLeft])
	{
		this.objASGS[newObjNum][objSGS.MIH] *= -1;
	}

	
	//adjust the moveTo's so that we don't move past where we want to 

	if((Math.abs(this.objASGS[newObjNum][objSGS.moveToLeft] - this.objASGS[newObjNum][objSGS.theIdCurrLeft]) % Math.abs(this.objASGS[newObjNum][objSGS.MIH])) !=0)
	{
			this.objASGS[newObjNum][objSGS.moveToLeft] -= this.objASGS[newObjNum][objSGS.MIH];
	}



	if(this.objASGS[newObjNum][objSGS.moveToTop] < this.objASGS[newObjNum][objSGS.theIdCurrTop])
	{
		this.objASGS[newObjNum][objSGS.MIV] *= -1;
	}
		//adjust the moveTo's so that we don't move past where we want to 

	if((Math.abs(this.objASGS[newObjNum][objSGS.theIdCurrTop] - this.objASGS[newObjNum][objSGS.moveToTop]) % Math.abs(this.objASGS[newObjNum][objSGS.MIV])) !=0)
	{
		this.objASGS[newObjNum][objSGS.moveToTop] -= this.objASGS[newObjNum][objSGS.MIV];
	}

	if(diag)
	{
		if(this.objASGS[newObjNum][objSGS.moveType]		&	F.HorizontalVertical)
		{
			this.objASGS[newObjNum][objSGS.moveType]	|=	F.HorizontalVertical;
		}

		if(this.objASGS[newObjNum][objSGS.moveType]		&	F.VerticalHorizontal)
		{
			this.objASGS[newObjNum][objSGS.moveType]	|=	F.VerticalHorizontal;
		}

		this.objASGS[newObjNum][objSGS.moveType]		|=	F.Diagonal;
	}

//	if(checkDebug())
//	{
//		this.dump(newObjNum,'addMove');
//	}
}


CSGS.prototype.doIt = function(idORbojNum)
{
	//this way does not allow me to set different interval speeds
	//I could setup one interval and compute in here when to do some of the moves
	//sort of like how I did the timers

	try
	{

		if(idORbojNum)
		{
			var newObjNum;

			newObjNum = this.getNumberFromIDorNum(idORbojNum);
			if(newObjNum == -1)
			{
				return;
			}
		}
	//as soon as I get the below fixed, I coulds fix the above; however, for most of what I anticpate doing, its not necessary


		for (i = 1; i <= this.objASGS[NO.NUMBEROBJECTS]; i++)
		{

			if(!(this.objASGS[i][objSGS.moveType] & F.Init))
			{
				this.objASGS[i][objSGS.moveType] |= F.Init; 
				setLeft(this.objASGS[i][objSGS.theId]	, this.objASGS[i][objSGS.theIdCurrLeft]); 
				setTop(this.objASGS[i][objSGS.theId]	, this.objASGS[i][objSGS.theIdCurrTop]); 
				//could check to see if its already visible
				setVisible(this.objASGS[i][objSGS.theId]);
			}
			//the next two get excuted each pass (if diagonal) 
			//rather than one at a time for the HorizontalVertical VerticalHorizontal			
			if((this.objASGS[i][objSGS.moveType] & F.Diagonal) && (!(this.objASGS[i][objSGS.moveType] & F.DoneH)))
			{
				this.moveHorizontal(i);		
			}

			if((this.objASGS[i][objSGS.moveType] & F.Diagonal) && (!(this.objASGS[i][objSGS.moveType] & F.DoneV)))
			{
			
				this.moveVertical(i);		
			}

			if((this.objASGS[i][objSGS.moveType] & F.HorizontalVertical) && (!(this.objASGS[i][objSGS.moveType] & F.DoneH)))
			{
				this.moveHorizontal(i);		
			}

			if((this.objASGS[i][objSGS.moveType] & F.HorizontalVertical) && (this.objASGS[i][objSGS.moveType] & F.DoneH) && (!(this.objASGS[i][objSGS.moveType] & F.DoneV)))
			{
			
				this.moveVertical(i);		
			}

			if((this.objASGS[i][objSGS.moveType] & F.VerticalHorizontal) && (!(this.objASGS[i][objSGS.moveType] & F.DoneV)))
			{
			
				this.moveVertical(i);		
			}
			
			if((this.objASGS[i][objSGS.moveType] & F.VerticalHorizontal) && (this.objASGS[i][objSGS.moveType] & F.DoneV) && (!(this.objASGS[i][objSGS.moveType] & F.DoneH)))
			{
			
				this.moveHorizontal(i);		
			}

			//if this one is done moving, call the next func
			if( (this.objASGS[i][objSGS.moveType] & F.DoneH) && (this.objASGS[i][objSGS.moveType] & F.DoneV) && (!(this.objASGS[i][objSGS.moveType] & F.DoneE)) )
			{
				if(this.objASGS[i][objSGS.nextFunc] != '')
				{
					//this.toggleEffect(i);
					if((this.objASGS[i][objSGS.nextFunc]) == myself.mySWipe)
					{
						this.mySWipe(i);
					}
					else 
					if((this.objASGS[i][objSGS.nextFunc]) == myself.myClip)
					{
						this.myClip(i);
					}
				}
			}
		}

		for (i = 1; i <= this.objASGS[NO.NUMBEROBJECTS]; i++)
		{
			//if any are not done, call this again
			if( (!(this.objASGS[i][objSGS.moveType] & F.DoneH)) || (!(this.objASGS[i][objSGS.moveType] & F.DoneV)) || (!(this.objASGS[i][objSGS.moveType] & F.DoneE)) )
			{
					setTimeout(function() { myself.doIt()},this.Agi[gI.INTERVALSPEED]);
					return;
			}
		}
	}
	catch (ex)
	{

	}
	//done
//	window.clearInterval(this.Agi[gI.INTERVALOBJ]);
return;
}


//this is to be called by setInterval
CSGS.prototype.moveVertical = function(newObjNum)
{
//	http://www.permadi.com/tutorial/jsFunc/
//	http://w3future.com/html/stories/callbacks.xml
//	http://www.zonageek.com/articulos/web/javascript_for_geeks_part_iii/index.php

		this.objASGS[newObjNum][objSGS.theIdCurrTop] += this.objASGS[newObjNum][objSGS.MIV];
	
		setTop(this.objASGS[newObjNum][objSGS.theId], this.objASGS[newObjNum][objSGS.theIdCurrTop]);

		if(this.objASGS[newObjNum][objSGS.MIV] < 0)
		{
			if(this.objASGS[newObjNum][objSGS.theIdCurrTop] <= this.objASGS[newObjNum][objSGS.moveToTop])
			{
				this.objASGS[newObjNum][objSGS.moveType] |= F.DoneV;
			}
		}
		else
		{
			if(this.objASGS[newObjNum][objSGS.theIdCurrTop] >= this.objASGS[newObjNum][objSGS.moveToTop])
			{
				this.objASGS[newObjNum][objSGS.moveType] |= F.DoneV;
			}
		}
}

CSGS.prototype.moveHorizontal = function(newObjNum)
{

	this.objASGS[newObjNum][objSGS.theIdCurrLeft] += this.objASGS[newObjNum][objSGS.MIH];
	
		setLeft(this.objASGS[newObjNum][objSGS.theId], this.objASGS[newObjNum][objSGS.theIdCurrLeft]);

//		this.dump(newObjNum);

		if(this.objASGS[newObjNum][objSGS.MIH] < 0)
		{
			if(this.objASGS[newObjNum][objSGS.theIdCurrLeft] <= this.objASGS[newObjNum][objSGS.moveToLeft])
			{
				this.objASGS[newObjNum][objSGS.moveType] |= F.DoneH;
			}
		}
		else
		{
			if(this.objASGS[newObjNum][objSGS.theIdCurrLeft] >= this.objASGS[newObjNum][objSGS.moveToLeft])
			{
				this.objASGS[newObjNum][objSGS.moveType] |= F.DoneH;
			}
		}
}


CSGS.prototype.getNumberFromIDorNum = function(idORbojNum)
{

var newObjNum;

	if(!testInteger(idORbojNum))
	{
		//if its not an integer 
		newObjNum = this.getNumberFromId(idORbojNum); 
	    if(newObjNum == -1)
		{
			doMessage('Object ID invalid in CSGS ' + idORbojNum);
			return -1;
		}
	}
	else
	{
		if(idORbojNum >	this.objASGS[NO.NUMBEROBJECTS])
		{
			doMessage('Object ID invalid in CSGS ' + idORbojNum);
			return -1;
		}
		else
		{
			newObjNum = idORbojNum;
		}
	}
return newObjNum;
}



CSGS.prototype.getNumberFromId = function(idin)
{
var icounter = 0;

    for (i = 1; i <= this.objASGS[NO.NUMBEROBJECTS]; i++)
	{
		if(this.objASGS[i][objSGS.theId] == idin)
		{
			return this.objASGS[i][objSGS.objectNumber];
		}
	}
return -1;
};



CSGS.prototype.dump = function(newObjNum,msg)
{

	var mymsg = '';
	mymsg  +=	msg + '<br>'
	mymsg  +=	this.scrASGS[scrSGS.clientWidth] + '  clientWidth' + '<br>';	
	mymsg  += 	this.scrASGS[scrSGS.clientHeight] + '  clientHeight' + '<br>';	
	mymsg  +=	this.scrASGS[scrSGS.screenWidth] + '  screenWidth' + '<br>';	
	mymsg  +=	this.scrASGS[scrSGS.screenHeight] + '  screen Height' + '<br>';	
	mymsg  +=	this.scrASGS[scrSGS.colorDepth] + '  colorDepth' + '<br>';		

	mymsg  += this.objASGS[newObjNum][objSGS.ointervalObj] + '  ointervalobj' + '<br>';	
	mymsg  += this.objASGS[newObjNum][objSGS.theId] + ' theId' + '<br>';			   
	mymsg  += this.objASGS[newObjNum][objSGS.MIV] + ' MIV' + '<br>';			 
	mymsg  += this.objASGS[newObjNum][objSGS.MIH] + ' MIH' + '<br>';			 
	mymsg  += this.objASGS[newObjNum][objSGS.ointervalSpeed] + ' ointervalSpeed' + '<br>';	
	mymsg  += this.objASGS[newObjNum][objSGS.moveFromTop] + ' MFT' + '<br>';		
	mymsg  += this.objASGS[newObjNum][objSGS.moveFromLeft] + ' MFL' + '<br>';	
	mymsg  += this.objASGS[newObjNum][objSGS.moveToTop] + ' MTT' + '<br>';		
	mymsg  += this.objASGS[newObjNum][objSGS.moveToLeft] + ' MTL' + '<br>';			
	mymsg  += this.objASGS[newObjNum][objSGS.theIdType] + ' theIdtType' + '<br>';			
	mymsg  += this.objASGS[newObjNum][objSGS.theIdOrigTop] + ' theIdOrigTop' + '<br>';	
	mymsg  += this.objASGS[newObjNum][objSGS.theIdOrigLeft] + ' theIdOrigLeft' + '<br>';	
	mymsg  += this.objASGS[newObjNum][objSGS.theIdOrigWidth] + ' theIdOrigWidth' + '<br>';	
	mymsg  += this.objASGS[newObjNum][objSGS.theIdOrigHeight] + ' theIdOrigHeight' + '<br>';
	mymsg  += this.objASGS[newObjNum][objSGS.theIdOrigStyle] + ' theIdOrigStyle' + '<br>';	
	mymsg  += this.objASGS[newObjNum][objSGS.theIdCurrTop] + ' theIdCurrTop' + '<br>';	
	mymsg  += this.objASGS[newObjNum][objSGS.theIdCurrLeft] + ' theIdCurrLeft' + '<br>';	
	mymsg  += this.objASGS[newObjNum][objSGS.theIdCurrWidth] + ' theIdCurrWidth' + '<br>';	
	mymsg  += this.objASGS[newObjNum][objSGS.theIdCurrHeight] + ' theIdCurrHeight' + '<br>';	

	mymsg  += this.objASGS[newObjNum][objSGS.theIdClipCounter] + ' theIdClipCounter' + '<br>';	

	doMessage(mymsg);

	this.dump2(newObjNum,msg); 
}

CSGS.prototype.dump2 = function(newObjNum,msg)
{
	var mymsg = '';
	mymsg  +=	msg + '<br>'


	mymsg  += this.objASGS[newObjNum][objSGS.moveType] + ' moveType' + '<br>';	

	if(this.objASGS[newObjNum][objSGS.moveType] & F.HorizontalVertical)
		mymsg  += this.objASGS[newObjNum][objSGS.moveType] + ' HorizontalVertical' + '<br>';	

	if(this.objASGS[newObjNum][objSGS.moveType] & F.VerticalHorizontal)
		mymsg  += this.objASGS[newObjNum][objSGS.moveType] + ' VerticalHorizontal' + '<br>';	

	if(this.objASGS[newObjNum][objSGS.moveType] & F.myWipeLeft)
		mymsg  += this.objASGS[newObjNum][objSGS.moveType] + ' myWipeLeft' + '<br>';	

	if(this.objASGS[newObjNum][objSGS.moveType] & F.myWipeRight)
		mymsg  += this.objASGS[newObjNum][objSGS.moveType] + ' myWipeRight' + '<br>';	
	
	if(this.objASGS[newObjNum][objSGS.moveType] & F.myWipeTop)
		mymsg  += this.objASGS[newObjNum][objSGS.moveType] + ' myWipeTop' + '<br>';	

	if(this.objASGS[newObjNum][objSGS.moveType] & F.myWipeBottom)
		mymsg  += this.objASGS[newObjNum][objSGS.moveType] + ' myWipeBottom' + '<br>';	

	if(this.objASGS[newObjNum][objSGS.moveType] & F.Fade)
		mymsg  += this.objASGS[newObjNum][objSGS.moveType] + ' Fade' + '<br>';	

	if(this.objASGS[newObjNum][objSGS.moveType] & F.Plot)
		mymsg  += this.objASGS[newObjNum][objSGS.moveType] + ' Plot' + '<br>';	

	if(this.objASGS[newObjNum][objSGS.moveType] & F.Init)
		mymsg  += this.objASGS[newObjNum][objSGS.moveType] + ' Init' + '<br>';	

	if(this.objASGS[newObjNum][objSGS.moveType] & F.DoneH)
		mymsg  += this.objASGS[newObjNum][objSGS.moveType] + ' DoneH' + '<br>';	

	if(this.objASGS[newObjNum][objSGS.moveType] & F.DoneV)
		mymsg  += this.objASGS[newObjNum][objSGS.moveType] + ' DoneV' + '<br>';	

	if(this.objASGS[newObjNum][objSGS.moveType] & F.DoneE)
		mymsg  += this.objASGS[newObjNum][objSGS.moveType] + ' DoneE' + '<br>';	

	if(this.objASGS[newObjNum][objSGS.moveType] & F.myClip)
		mymsg  += this.objASGS[newObjNum][objSGS.moveType] + ' myClip' + '<br>';	

	if(this.objASGS[newObjNum][objSGS.moveType] & F.Diagonal)
		mymsg  += this.objASGS[newObjNum][objSGS.moveType] + ' Diagonal' + '<br>';	

	if(this.objASGS[newObjNum][objSGS.moveType] & F.Keep)
		mymsg  += this.objASGS[newObjNum][objSGS.moveType] + ' Keep' + '<br>';	

	if(this.objASGS[newObjNum][objSGS.moveType] & F.mySWipe)
		mymsg  += this.objASGS[newObjNum][objSGS.moveType] + ' mySWipe' + '<br>';	

	doMessage(mymsg);
		
}

CSGS.prototype.mySWipe = function(newObjNum)
{
/*
superseded by myclip  

	need to update the references to the obj at the end
	MIE used to be 5
	
*/
		if(myself.objASGS[newObjNum][objSGS.moveType] & F.mySWipe)
		{

//			var width =	myself.objASGS[newObjNum][objSGS.theIdCurrWidth];
//			var height=	myself.objASGS[newObjNum][objSGS.theIdCurrHeight];
			var left =	myself.objASGS[newObjNum][objSGS.theIdCurrLeft];

			var wipeMIE = myself.objASGS[newObjNum][objSGS.MIE];

			if (left < getCW()) 
			{
		//		if((width % 100) == 0)
		//		{
		//			setLeft(myself.objASGS[objSGS.theId], (left + 5));
		//			myself.objASGS[objSGS.theIdCurrLeft] +=5;
		//
		//			setWidth(myself.objASGS[objSGS.theId], (width - 5));
		//			myself.objASGS[objSGS.theIdOrigWidth] -=5;
		//			
		//			setTimeout(function() { myself.wipe()},20);
		//		}
		//		else
		//		{
					setLeft(myself.objASGS[newObjNum][objSGS.theId], (left + wipeMIE));
					myself.objASGS[newObjNum][objSGS.theIdCurrLeft] +=wipeMIE;

				//	setHeight(myself.objASGS[newObjNum][objSGS.theId], (height  - wipeMIE));
				//	myself.objASGS[newObjNum][objSGS.theIdCurrHeight] -=wipeMIE;

				//	setWidth(myself.objASGS[newObjNum][objSGS.theId], (width - wipeMIE));
				//	myself.objASGS[newObjNum][objSGS.theIdCurrWidth] -=wipeMIE;

//					setTimeout(function() { myself.myWipe()},20);
		//		}
			}
			else
			{

 // looks like I need to fix this for Mozilla 
//  div id="ht2" class='dynDom' style='position:absolute;top:0px;left:10px; min-height:100px;max-height:300px; width:296px;visibility:hidden;clip:rect(0 320 320 0);z-index:100;' 	
//  I am getting truncation of the left and bottom 
//  in popCSGSDiv(event,'ht2' ..
//  also might be wahcking the effect


				if(myself.objASGS[newObjNum][objSGS.moveType] & F.Keep) 
				{
					setHidden(myself.objASGS[newObjNum][objSGS.theId]);
					myself.objASGS[newObjNum][objSGS.theIdCurrWidth]	= myself.objASGS[newObjNum][objSGS.theIdOrigWidth];
					myself.objASGS[newObjNum][objSGS.theIdCurrHeight]	= myself.objASGS[newObjNum][objSGS.theIdOrigHeight];
					myself.objASGS[newObjNum][objSGS.theIdCurrLeft]		= myself.objASGS[newObjNum][objSGS.theIdOrigLeft];

					setLeft(myself.objASGS[newObjNum][objSGS.theId],	myself.objASGS[newObjNum][objSGS.theIdOrigLeft]);

					setHeight(myself.objASGS[newObjNum][objSGS.theId],	myself.objASGS[newObjNum][objSGS.theIdOrigHeight]);

					setWidth(myself.objASGS[newObjNum][objSGS.theId],	myself.objASGS[newObjNum][objSGS.theIdOrigWidth]);
				}
				else
				{
					//I could set this off screen here
					setGone(myself.objASGS[newObjNum][objSGS.theId]);
	//				myself.objASGS[newObjNum][objSGS.moveType] |= F.myWipeBottom;
				}
				
				myself.objASGS[newObjNum][objSGS.moveType] |= F.Keep;
				myself.toggleEffect(newObjNum);
				myself.objASGS[newObjNum][objSGS.moveType] |= F.DoneE;
			}
		}

return; 
}
/*
	need to update the references to the obj at the end

	setClip(id, t,r,b,l)

    on clip full size to small 
				vary T from 0 to height
    on clip not visiible to full size
				vary T from height to 0
	  
	style.clip = "rect(0,width,height,0)";		is full size
	style.clip = "rect(height,width,height,0)"; is fully clipped

	1 is to fast
		setTimeout(function() { myself.myClip()},20);

MIE used to be 2

*/

CSGS.prototype.myClip = function(newObjNum)
{
		if(myself.objASGS[newObjNum][objSGS.moveType] & F.myClip)
		{
			var top		=   myself.objASGS[newObjNum][objSGS.theIdOrigHeight];
			var bottom	=   myself.objASGS[newObjNum][objSGS.theIdOrigHeight];
			var width	=	myself.objASGS[newObjNum][objSGS.theIdOrigWidth];
			var height	=	myself.objASGS[newObjNum][objSGS.theIdOrigHeight];
			var left	=	myself.objASGS[newObjNum][objSGS.theIdOrigLeft];

			if(myself.objASGS[newObjNum][objSGS.moveType] & F.myWipeBottom)
			{
				bottom		=   myself.objASGS[newObjNum][objSGS.theIdClipCounter];

				if(bottom > 0)
				{
					bottom			-=	this.objASGS[newObjNum][objSGS.MIE];
					myself.objASGS[newObjNum][objSGS.theIdClipCounter]	=	bottom;

					setClip(myself.objASGS[newObjNum][objSGS.theId], 0 ,width,bottom,0);
					return;
				}
			}
			else if(myself.objASGS[newObjNum][objSGS.moveType] & F.myWipeLeft)
			{
				left		=   myself.objASGS[newObjNum][objSGS.theIdClipCounter];

				if(myself.objASGS[newObjNum][objSGS.theIdOrigLeft] > left)
				{
					left			+=	this.objASGS[newObjNum][objSGS.MIE];
					myself.objASGS[newObjNum][objSGS.theIdClipCounter]	=	left;

					setClip(myself.objASGS[newObjNum][objSGS.theId], 0 ,width,bottom,left);
					return;
				}
			} 
			else if(myself.objASGS[newObjNum][objSGS.moveType] & F.myWipeRight)
			{
				right		=   myself.objASGS[newObjNum][objSGS.theIdClipCounter];

				if(right > 0)
				{
					right			-=	this.objASGS[newObjNum][objSGS.MIE];
					myself.objASGS[newObjNum][objSGS.theIdClipCounter]	=	right;

					setClip(myself.objASGS[newObjNum][objSGS.theId], 0 ,right,bottom,0);
					return;
				}
			}
			else 	// the default if(myself.objASGS[newObjNum][objSGS.moveType] & F.myWipeTop)
			{
				top		=   myself.objASGS[newObjNum][objSGS.theIdClipCounter];

				if(myself.objASGS[newObjNum][objSGS.theIdOrigHeight] > top)
				{
					top			+=	this.objASGS[newObjNum][objSGS.MIE];
					myself.objASGS[newObjNum][objSGS.theIdClipCounter]	=	top;

					setClip(myself.objASGS[newObjNum][objSGS.theId], top ,width,height,0);
	//				setTimeout(function() { myself.myClip()},20);
					return;
				}
			}

//done stage 1
			
			if(myself.objASGS[newObjNum][objSGS.moveType] & F.Keep)
			{
				setHidden(myself.objASGS[newObjNum][objSGS.theId]);

				myself.objASGS[newObjNum][objSGS.theIdCurrWidth]	= myself.objASGS[newObjNum][objSGS.theIdOrigWidth];
				myself.objASGS[newObjNum][objSGS.theIdCurrHeight]	= myself.objASGS[newObjNum][objSGS.theIdOrigHeight];
				myself.objASGS[newObjNum][objSGS.theIdCurrLeft]		= myself.objASGS[newObjNum][objSGS.theIdOrigLeft];
				myself.objASGS[newObjNum][objSGS.theIdCurrTop]		= myself.objASGS[newObjNum][objSGS.theIdOrigTop];

				setTop(myself.objASGS[newObjNum][objSGS.theId],		myself.objASGS[newObjNum][objSGS.theIdOrigTop]);

				setLeft(myself.objASGS[newObjNum][objSGS.theId],	myself.objASGS[newObjNum][objSGS.theIdOrigLeft]);

				setHeight(myself.objASGS[newObjNum][objSGS.theId],	myself.objASGS[newObjNum][objSGS.theIdOrigHeight]);

				setWidth(myself.objASGS[newObjNum][objSGS.theId],	myself.objASGS[newObjNum][objSGS.theIdOrigWidth]);
				//will make it hidden for now			
				setClip(myself.objASGS[newObjNum][objSGS.theId], 0, width, height,0);
// this did not stopborder from being whacked		setClip(myself.objASGS[newObjNum][objSGS.theId], 0, width + 12 , height + 12,0);
				myself.objASGS[newObjNum][objSGS.moveType] |= F.Keep;
//				if(checkDebug())
//				{
//					this.dump(newObjNum,'myClip');
//				}
			}
			else
			{
			//I could set this off screen here
				setGone(myself.objASGS[newObjNum][objSGS.theId]);
			}
			//at last we leave
			myself.toggleEffect(newObjNum);
			this.objASGS[newObjNum][objSGS.moveType] |= F.DoneE;

		}
}




/*


function fade() 
{
  // insert fader color into message
  // texts should be defined in user script, e.g.: var texts = new Array("<font color='{COLOR}' sized='+3' face='Arial'>howdy</font>");

  var text_out = texts[text].replace("{COLOR}", colors[color]); 

  // actually write message to document
  switch(g_fBrowser) 
  {
    case 1:  document.layers.fader.document.layers.Content.document.write(text_out); document.layers.fader.document.layers.Content.document.close();
		     break;

	case 2:
	case 3:  document.all.faderContent.innerHTML = text_out;
             break;
  }  

  // select next fader color
  color += step; 

  // completely faded in?
  if (color >= colors.length-1) 
  {
    step = -1; // traverse colors array backward to fade out
    // stop at last message if loop=false
    if (!loop && text >= texts.length-1) return; // loop should be defined in user script, e.g.: var loop=true;
  }

  // completely faded out?
  if (color == 0) 
  {
    step = 1; // traverse colors array forward to fade in again
    // select next message
    text += 1;
    if (text == texts.length) text = 0; // loop back to first message
  }

  // subtle timing logic...
  setTimeout("fade()", (color == colors.length-2 && step == -1) ? show : ((color == 1 && step == 1) ? sleep : 50)); // sleep and show should be defined in user script, e.g.: var sleep=30; var show=500;
}

// getFadeColors: fills Colors (predefined Array)
// with color hex strings fading from ColorA to ColorB
// note: Colors.length equals the number of steps to fade
function getFadeColors(ColorA, ColorB, Colors) 
{
  len = Colors.length; 

  // strip '#' signs if present 
  if (ColorA.charAt(0)=='#') ColorA = ColorA.substring(1);
  if (ColorB.charAt(0)=='#') ColorB = ColorB.substring(1);

  // substract rgb compents from hex string 
  var r = hexToInt(ColorA.substring(0,2));
  var g = hexToInt(ColorA.substring(2,4));
  var b = hexToInt(ColorA.substring(4,6));
  var r2 = hexToInt(ColorB.substring(0,2));
  var g2 = hexToInt(ColorB.substring(2,4));
  var b2 = hexToInt(ColorB.substring(4,6));

  // calculate size of step for each color component
  var rStep = Math.round((r2 - r) / len);
  var gStep = Math.round((g2 - g) / len);
  var bStep = Math.round((b2 - b) / len);

  // fill Colors array with fader colors
  for (i = 0; i < len-1; i++) 
  {
    Colors[i] = "#" + intToHex(r) + intToHex(g) + intToHex(b);
    r += rStep;
    g += gStep;
    b += bStep;
  }
  Colors[len-1] = ColorB; // make sure we finish exactly at ColorB
}

rgb(245,245,245)


*/

