var workwidth = 990, realx = 0, offset;

function getClientWidth()
{
	return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}

function gallery(e)
{
	last_realx = realx;
//	if (e.pageX || e.pageY)
//	{
		cursorx = e.pageX;
		cursory = e.pageY;
//	}
//	else if (e.clientX || e.clientY)
//	{
//		cursorx = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
//		cursory = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
//	}
	clientwidth = getClientWidth();
	offset = (clientwidth - workwidth) / 2;
	realx = cursorx - offset;
	if(realx <= 150) realx = 150;
	if(realx >= 840) realx = 840;

	if(last_realx != realx)
	{
		left = Math.round(max_width * (realx - 150) / 690);
		aspeed = Math.round(Math.abs(last_realx - realx) / 3);
		$('#gallery').stop().animate({ left: -left+'px' }, aspeed);
	}

	if(left < 1) $('#gal_left').css({'opacity':0.3}); else $('#gal_left').css({'opacity':1});
	if(left > max_width - 1 || left == 0) $('#gal_right').css({'opacity':0.3}); else $('#gal_right').css({'opacity':1});
}
