//	Capture mouse coordinates outside flash file
var browser	= -1;
var mouseX	= 0;
var mouseY	= 0;
var flashMovies	= new Array("flashObject");

function checkBrowser()
{
	var userAgent	= navigator.userAgent;
	if(userAgent.indexOf("MSIE") > -1)			browser		= 0;
	if(userAgent.indexOf("Netscape6/") > -1)	browser		= 1;
	if(userAgent.indexOf("Gecko") > -1)			browser		= 1;
	
	startUpdate();
}

function startUpdate()
{
	if(browser == 0)
	{
		document.attachEvent("onmousemove", updateMouseEvent);
	}
	
	if(browser == 1)
	{
		document.addEventListener("mousemove", updateMouseEvent, true);
		event.preventDefault();
	}
}

function updateMouseEvent(e)
{
	if(browser == 0)
	{
		mouseY		= window.event.clientY + document.documentElement.scrollTop + document.body.scrollTop;
		mouseX		= window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft;
	}
	
	if(browser == 1)
	{
		mouseY		= e.clientY + window.scrollY;
		mouseX		= e.clientX + window.scrollX;
	}
	
	sendMousePosition();
}

function sendMousePosition()
{
	var containerOffset	= getContainerOffset();
	var l				= flashMovies.length;
	for(i=0; i<l; i++)
	{
		var object		= getMovie(flashMovies[i]);
		var point		= findPosition(object);
		var x			= mouseX - point.x;
		var y			= mouseY - point.y;
		
		if(browser == 0 && 1 == 2)
		{
			x	-= containerOffset.x;
			y	-= containerOffset.y;
		}
		
		object.updateMousePosition(x, y);
	}
}

function getMovie(objectID)
{
	if (navigator.appName.indexOf("Microsoft") != -1)	return window[objectID];
	else												return document[objectID];
}

function findPosition(target)
{
	var curLeft	= 0;
	var curTop	= 0;
	
	if(target.offsetParent)
	{
		curLeft		= target.offsetLeft;
		curTop		= target.offsetTop;
		
		while(target = target.offsetParent)
		{
			curLeft		+= target.offsetLeft;
			curTop		+= target.offsetTop;
		}
	}
	
	return {x:curLeft, y:curTop};
}

function getContainerOffset()
{
	var object	= document.getElementById("maincontainer");
	var object2	= document.getElementById("container");
	
	var width	= objectWidth(object);
	var height	= objectHeight(object);
	
	var width2	= objectWidth(object2);
	var height2	= objectHeight(object2);
	
	var x		= (width - width2) / 2;
	var y		= (height - height2) / 2;
	
	return {x:x, y:y};
}

function objectHeight(object)
{
	if(object.offsetHeight)	return object.offsetHeight;
	if(object.clip)			return object.clip.height;
	return 0;
}

function objectWidth(object)
{
	if(object.offsetWidth)	return object.offsetWidth;
	if(object.clip)			return object.clip.width;
	return 0;
}
/*

// Object Functions
// copyright Stephen Chapman, 4th Jan 2005
//  you may copy these functions but please keep the copyright notice as well
function objWidth(objectID)
{
	var obj = xDOM(objectID,0);
	
	if(obj.offsetWidth)	return  obj.offsetWidth;
	if (obj.clip)		return obj.clip.width;
	return 0;
}

function objHeight(objectID)
{
	var obj = xDOM(objectID,0);
	
	if(obj.offsetHeight) return  obj.offsetHeight;
	if (obj.clip) return obj.clip.height;
	return 0;
}

function objLeft(objectID)
{
	var obj = xDOM(objectID,0);
	var objs = xDOM(objectID,1);
	if(objs.left) return objs.left;
	if (objs.pixelLeft) return objs.pixelLeft;
	if (obj.offsetLeft) return obj.offsetLeft;
	return 0;
}

function objTop(objectID)
{
	var obj = xDOM(objectID,0);
	var objs = xDOM(objectID,1);
	
	if(objs.top) return objs.top;
	if (objs.pixelTop) return objs.pixelTop;
	if (obj.offsetTop) return obj.offsetTop;
	return 0;
}

function objRight(objectID)
{
	return objLeft(objectID)+objWidth(objectID);
}

function objBottom(objectID)
{
	return objTop(objectID)+objHeight(objectID);
}
function objLayer(objectID)
{
	var objs = xDOM(objectID,1);
	if(objs.zIndex) return objs.zIndex;
	return 0;
}

function objVisible(objectID)
{
	var objs = xDOM(objectID,1);
	if(objs.visibility == 'hide' || objs.visibility == 'hidden') return 'hidden'; return 'visible';
}
*/
