function findObject (ObjectName)
{
	var o;
	if (document.getElementById)
		o=document.getElementById(ObjectName);
	else if (document.all)
		o=document.all[ObjectName];
	else
		eval ("o=document."+ObjectName);
	return o;
}
function objectSize(oLayer)
{
        var s=new Object();

        s.width=oLayer.offsetWidth;
        if (!s.width)
                s.width=oLayer.clip.width;
        if (!s.width)
                s.width=oLayer.style.width;
        s.height=oLayer.offsetHeight;
        if (!s.height)
                s.height=oLayer.clip.height;
        if (!s.height)
                s.height=oLayer.style.height;

        return s;
}
function objectPosition(oLayer)
{
        var s=new Object();
	var done=0;
	s.x=0;
	s.y=0;
	do
	{
	    done+=1;
	    s.x+=oLayer.offsetLeft;
	    s.y+=oLayer.offsetTop;
	    oLayer=oLayer.offsetParent;
	}while (oLayer.offsetParent);
	if (done>1 || (s.x && s.y))
	  return s;

	s.x=oLayer.style.left;
	if (!s.x)
        	s.x=oLayer.pageX;
	s.y=oLayer.style.top;
	if (!s.y)
        	s.y=oLayer.pageY;

	return s;
}
function setObjectPositionX(oLayer,newX)
{
	oLayer.style.left=newX;
	oLayer.pageX=newX;
}
function setObjectPositionY(oLayer,newY)
{
	oLayer.style.top=newY;
	oLayer.pageY=newY;
}

function centerObjects(Object1,Object2)
{
	o1=findObject(Object1);
	o1s=objectSize(o1);
	o1p=objectPosition(o1);

	o2=findObject(Object2);
	o2s=objectSize(o2);
	o2p=objectPosition(o2);
	if (o1s.width>o2s.width)
	{
		setObjectPositionX(o2,o1p.x+(o1s.width-o2s.width)/2);
	}	
	else if (o1s.width<o2s.width)
	{
		setObjectPositionX(o2,o1p.x-(o2s.width-o1s.width)/2);
	}	

}

