	ns4 = (document.layers) ? true:false;
	ie4 = (document.all) ? true:false;
	ng5 = (document.getElementById) ? true:false;
	ie6 = (parseInt(window.navigator.appVersion.charAt(0), 10) <= 6 && window.navigator.userAgent.indexOf("MSIE") > -1);


	var mousex = 0;
	var mousey = 0;

	//addListener(document,"load",watchMouse);
	var mouse_onload_old = window.onload;
	window.onload = watchMouse;
	
	function watchMouse()
	{
		if (typeof(mouse_onload_old) == "function")
		{
			try
			{
				mouse_onload_old();
			}
			catch(e) {}
		}

		addListener(document,"mousemove",getMousePos);
	}

	function getMousePos(e)
	{
		if(ie4)
		{
			mousex = event.clientX + document.body.scrollLeft;
			mousey = event.clientY + document.body.scrollTop;

		}
		else
		{
			mousex = e.pageX;
			mousey = e.pageY;
		}

		if (mousex <= 0) {mousex = 0};
		if (mousey <= 0) {mousey = 0} ;  

		return true;
	}

	function objectVisible(object, visible)
	{
		if (visible == null)
		{
			visible = true;
		}
		if (visible)
		{
			if (ng5) document.getElementById(object).style.visibility = "visible";
			else if (ns4) document[object].visibility = "show";
			else if (ie4) eval(object + ".style.visibility = 'visible'");
		}
		else
		{
			if (ng5) document.getElementById(object).style.visibility = "hidden";
			else if (ns4) document[object].visibility = "hide";
			else if (ie4) eval(object + ".style.visibility = 'hidden'");
		}
	}

	function objectDisplayStyle(object, state)
	{
		if (ng5) document.getElementById(object).style.display = state;
		else if (ie4) eval(object + ".style.display = '" + state + "';");
	}
	
	function centerItem(idItem)
	{
		var item = getItemFromId(idItem);
		var browseWidth;
		var browseHeight;
		var docleft = getScrollLeft();
		var doctop = getScrollTop();
		var itemWidth = item.offsetWidth;
		var itemHeight = item.offsetHeight;
		if (ie4)
		{
			browseWidth=document.body.clientWidth;
			browseHeight=document.body.clientHeight;
		}
		else
		{
			browseWidth = window.innerWidth;
			browseHeight = window.innerHeight;
		}
		var left_pos = docleft + ((browseWidth/2) - (itemWidth/2));
		var top_pos = doctop + ((browseHeight/2) - (itemHeight/2));
		if (left_pos < docleft)
			left_pos = docleft;
		if (top_pos < doctop)
			top_pos = doctop;
		setItemPos(idItem, left_pos, top_pos);
	}

	function calculateSumOffset(idItem, offsetName)
	{
		var totalOffset = 0;
		var item = getItemFromId(idItem);
		do
		{
			totalOffset += eval('item.'+offsetName);
			item = eval('item.offsetParent');
		} while (item != null);
		return totalOffset;
	}

	function getItemX(idItem)
	{
		var obj = getItemFromId(idItem);
		var curleft = 0;
		if (obj.offsetParent)
		{
			while (obj.offsetParent)
			{
				curleft += obj.offsetLeft;
				obj = obj.offsetParent;
			}
		}
		else if (obj.x)
			curleft += obj.x;
		return curleft;
	}
	
	function getItemY(idItem)
	{
		var obj = getItemFromId(idItem);
		var curtop = 0;
		if (obj.offsetParent)
		{
			while (obj.offsetParent)
			{
				curtop += obj.offsetTop;
				obj = obj.offsetParent;
			}
		}
		else if (obj.y)
			curtop += obj.y;
		return curtop;
	}

	function getItemHeight(idItem)
	{
		var obj = getItemFromId(idItem);
		return obj.offsetHeight;
	}

	function getItemWidth(idItem)
	{
		var obj = getItemFromId(idItem);
		return obj.offsetWidth;
	}

	function setItemHeight(idItem,height)
	{
		var obj = getItemFromId(idItem);
		obj.style.height = height + "px";
	}
	
	function setItemWidth(idItem,width)
	{
		var obj = getItemFromId(idItem);
		obj.style.width = width + "px";
	}

	function setItemPos(idItem, x, y)
	{
		var item;
		if (ie4)
		{
			eval ("document.all." + idItem + ".style.pixelTop = y ;");
			eval ("document.all." + idItem + ".style.pixelLeft = x ;");
		}
		else if (ng5)
		{
			item = document.getElementById(idItem);
			item.style.top = y + "px";
			item.style.left = x + "px";
		}
		else if (ns4)
		{
			item = document[idItem];
			item.top = y;
			item.left = x;
		}
	}

	function getItemFromId(idItem)
	{
		if (typeof(idItem) == "object")
			return idItem;
		var item;
		if (ie4)
		{
			eval ("item = document.all." + idItem + " ;");
		}
		else if (ng5)
		{
			item = document.getElementById(idItem);
		}
		else if (ns4)
		{
			item = document[idItem];
		}
		return item;
	}
	
	function positionByMouse(idItem)
	{
		var item = getItemFromId(idItem);
		var docleft = document.body.scrollLeft;
		var doctop = document.body.scrollTop;
		var docright = docleft + document.body.clientWidth;
		var docbottom = doctop + document.body.clientHeight;
		var itemwidth = item.offsetWidth;
		var itemheight = item.offsetHeight;
		var newx;
		var newy;

		if (mousex + itemwidth > docright)
		{
			if (docright - itemwidth < docleft)
			{
				newx = docleft;
			}
			else
			{
				newx = docright - itemwidth;
			}
		}
		else
		{
			newx = mousex;
		}

		if (mousey + itemheight > docbottom)
		{
			if (docbottom - itemheight < doctop)
			{
				newy = doctop;
			}
			else
			{
				newy = docbottom - itemheight;
			}
		}
		else
		{
			newy = mousey;
		}

		setItemPos(idItem,newx,newy);
	}

	function addListener(item,method,func)
	{
		//var item = getItemFromId(id);
		if (item.addEventListener)
			item.addEventListener(method,func,true);
		else if (item.attachEvent)
		{
			var r = item.attachEvent('on' + method,func);
		}
	}
	
	function removeListener(item,method,func)
	{
		//var item = getItemFromId(id);
		if (item.removeEventListener)
			item.removeEventListener(method,func,true);
		else if (item.detachEvent)
		{
			var r = item.detachEvent('on' + method,func);
		}
	}

	function getPageSize()
	{
		var xScroll, yScroll;
		
		if (window.innerHeight && window.scrollMaxY)
		{
			xScroll = document.body.scrollWidth;
			yScroll = window.innerHeight + window.scrollMaxY;
		}
		else if (document.body.scrollHeight > document.body.offsetHeight)
		{
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		}
		else
		{
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		
		var windowWidth, windowHeight;
		if (self.innerHeight)
		{
			windowWidth = self.innerWidth;
			windowHeight = self.innerHeight;
		}
		else if (document.documentElement && document.documentElement.clientHeight)
		{
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		}
		else if (document.body)
		{
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
		
		if(yScroll < windowHeight)
		{
			pageHeight = windowHeight;
		}
		else
		{ 
			pageHeight = yScroll;
		}

		if(xScroll < windowWidth)
		{
			pageWidth = windowWidth;
		}
		else
		{
			pageWidth = xScroll;
		}

		arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
		return arrayPageSize;
	}
	
	function getPageWidth()
	{
		var xScroll;
		
		if (window.innerHeight && window.scrollMaxY)
		{
			xScroll = document.body.scrollWidth;
		}
		else if (document.body.scrollHeight > document.body.offsetHeight)
		{
			xScroll = document.body.scrollWidth;
		}
		else
		{
			xScroll = document.body.offsetWidth;
		}
		
		var windowWidth;
		if (self.innerHeight)
		{
			windowWidth = self.innerWidth;
		}
		else if (document.documentElement && document.documentElement.clientHeight)
		{
			windowWidth = document.documentElement.clientWidth;
		}
		else if (document.body)
		{
			windowWidth = document.body.clientWidth;
		}	

		if(xScroll < windowWidth)
		{
			pageWidth = windowWidth;
		}
		else
		{
			pageWidth = xScroll;
		}

		return pageWidth;
	}

	function getPageHeight()
	{
		var yScroll;
		
		if (window.innerHeight && window.scrollMaxY)
		{
			yScroll = window.innerHeight + window.scrollMaxY;
		}
		else if (document.body.scrollHeight > document.body.offsetHeight)
		{
			yScroll = document.body.scrollHeight;
		}
		else
		{
			yScroll = document.body.offsetHeight;
		}
		
		var windowHeight;
		if (self.innerHeight)
		{
			windowHeight = self.innerHeight;
		}
		else if (document.documentElement && document.documentElement.clientHeight)
		{ 
			windowHeight = document.documentElement.clientHeight;
		}
		else if (document.body)
		{ 
			windowHeight = document.body.clientHeight;
		}	
		
		if(yScroll < windowHeight)
		{
			pageHeight = windowHeight;
		}
		else
		{ 
			pageHeight = yScroll;
		}
		
		return pageHeight;
	}
	
	function getScrollTop()
	{
		if (self.pageYOffset)
		{
			return self.pageYOffset;
		}
		else if (document.documentElement && document.documentElement.scrollTop)
		{
			return document.documentElement.scrollTop;
		}
		else if (document.body)
		{
			return document.body.scrollTop;
		}
	}
	
	function getScrollLeft()
	{
		if (self.pageXOffset)
		{
			return self.pageXOffset;
		}
		else if (document.documentElement && document.documentElement.scrollLeft)
		{
			return document.documentElement.scrollLeft;
		}
		else if (document.body)
		{
			return document.body.scrollLeft;
		}
	}
