var fpUIC = [];

fpUIC =
	{
	mouseXpos	: 0,
	mouseYpos	: 0,
	mouseDown	: 0,
	mouseOver	: false,
	windowCount	: 0,
	zindexArray	: [],
	screenWidth	: 0,
	screenHeight: 0,
	dragYdiffer	: 0,
	dragXdiffer	: 0,

	init: function()
		{
		if(document.body == null)
			{
			setTimeout("fpUIC.init()", 300);
			return false;
			}
		if (self.innerWidth)
			{
			fpUIC.screenWidth = document.body.clientWidth;
			fpUIC.screenHeight = self.innerHeight;
			}
		else	{
			fpUIC.screenWidth = document.documentElement.clientWidth;
			fpUIC.screenHeight = document.documentElement.clientHeight;
			}
		if(!this.windowInit)
			{
	 		document.onmousemove = this.mousemove;
 			document.onmousedown = this.mousedown;
 			document.onmouseup	= this.mouseup;
			document.onclick	=  this.mouseClick;
 			window.onresize = function()
	 			{
 				fpUIC.init();
 				}
 			}
 		this.windowInit = true;
		},
	
	mousemove: function(evt)
		{
		if(!evt) var evt = window.event;

		fpUIC.mouseXpos = document.all ? window.event.clientX : evt.pageX;
		fpUIC.mouseYpos = document.all ? window.event.clientY : evt.pageY;
		},

	mousedown: function(evt)
		{
		fpUIC.mouseDown = true;
		if (!evt) var evt = window.event;
		if (evt.target) fpUIC.mouseOver = evt.target;
		else if (evt.srcElement) fpUIC.mouseOver = evt.srcElement;
		},

	mouseup: function()
		{
		fpUIC.mouseDown = false;
		fpUIC.mouseOver = false;
		},
	
	attachEvent: function(controller, evtType, func)
		{
		if(controller.addEventListener)
			{
			controller.addEventListener(evtType, func, false);
			}
		else if(controller.attachEvent)
			{
			if(evtType.indexOf('mouse') != -1) evtType = 'on'+evtType;
			
			controller.attachEvent(evtType, func);
			}

		},

	removeEvent: function(controller, evtType, func)
		{
		if(controller.removeEventListener)
			{
			controller.removeEventListener(evtType, func ,false);
			}
		else if(controller.detachEvent)
			{
			controller.detachEvent(evtType, func);
			}
		},
	
	mouseClick: function(e)
		{
		if(!e) var e = window.event;
		var rightclick = false;
		if (e.which) rightclick = (e.which == 3);
		else if (e.button) rightclick = (e.button == 1);
		if (rightclick)
			{
			var clickTarget = (e.target) ? e.target : e.srcElement;
			if(clickTarget.rightClick)
				{
				setTimeout(clickTarget.rightClick, 0);
				e.cancelBubble = true;
				if (e.stopPropagation) e.stopPropagation();
				return false;
				}
			}
		}
	}

fpUIC.init();
