function getBrowserWinWidth()
{
	var availableWindowWidth=0;
	if (typeof(window.innerWidth) == 'number')
	{
		availableWindowWidth=window.innerWidth;
	}
	else
	{
		if (document.documentElement && document.documentElement.clientWidth)
		{
			availableWindowWidth = document.documentElement.clientWidth;
		}
		else
		{
			if (document.body && document.body.clientWidth)
			{
				availableWindowWidth=document.body.clientWidth;
			}
		}
	}

	return(availableWindowWidth);
}

function setVariables(objectid, owidth)
{
	y1=-50;
	ob=1;
	max=20; // this max sets the distance from the top of the page
	objwidth=owidth;

	if (navigator.appName == "Netscape")
	{
		v=".top=";
		h=".left=";
		dS="document.";
		sD="";
		y="window.pageYOffset";
		x="window.pageXOffset";
		iW="window.innerWidth";
		iH="window.innerHeight";
	}
	else
	{
		h=".pixelLeft=";
		v=".pixelTop=";
		dS="";
		sD=".style";
		y="document.body.scrollTop";
		x="document.body.scrollLeft";
		iW="document.body.clientWidth";
		iH="document.body.clientHeight";
	}


	object=objectid;
}

movex=0,movey=0,xdiff=0,ydiff=0,ystart=0,xstart=0;


function checkLocation(objectid)
{
	innerX=getBrowserWinWidth()-objwidth+20; // controls the horizontal from the left side of the page
	innerY=-10; // controls the verticle from the top of the page

	if (document.layers){innerY-=10;innerX-=10}

	yy=eval(y);
	xx=eval(x);
	ydiff=ystart-yy;
	xdiff=xstart-xx;
/*	if ((ydiff<(-0.01))||(ydiff>(0.01))) movey=Math.round(ydiff/10),ystart-=movey;
	if ((xdiff<(-0.01))||(xdiff>(0.01))) movex=Math.round(xdiff/10),xstart-=movex;*/
	if ((ydiff<(-0.01))||(ydiff>(0.01))) movey=ydiff,ystart-=movey;
	if ((xdiff<(-0.01))||(xdiff>(0.01))) movex=xdiff,xstart-=movex;

	N=(document.layers)?1:0;
	V=(N) ? 4:5;
	if (V==4)
	{
		object=objectid;
		eval(dS+object+sD+v+(ystart+innerY+10));
		eval(dS+object+sD+h+(xstart+innerX+10));
	}
	else
	{
		object=document.getElementById(objectid);
		object.style.top=ystart+innerY;
		object.style.left=xstart+innerX;
	}

	setTimeout("checkLocation('"+objectid+"')",10);
}
