function getWindowSize(getWhidth)
{
	var myWidth = 0, myHeight = 0;
	if (typeof(window.innerWidth) == 'number' )
	{
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	}
	else if (document.documentElement && (document.documentElement.clientWidth ||
			document.documentElement.clientHeight))
	{
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	}
	else if(document.body && (document.body.clientWidth || document.body.clientHeight))
	{
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	if (getWhidth)
	{
		return myWidth;
	}
	else
	{
		return myHeight;
	}
}

function getWindowWidth()
{
	return getWindowSize(true);
}

function getWindowHeight()
{
	return getWindowSize(false);
}

function getScrollXY(getX)
{
	var scrOfX = 0, scrOfY = 0;
	if (typeof(window.pageYOffset) == 'number')
	{
		//Netscape compliant
		scrOfY = window.pageYOffset;
		scrOfX = window.pageXOffset;
	}
	else if (document.body && (document.body.scrollLeft || document.body.scrollTop))
	{
		//DOM compliant
		scrOfY = document.body.scrollTop;
		scrOfX = document.body.scrollLeft;
	}
	else if (document.documentElement && (document.documentElement.scrollLeft ||
			document.documentElement.scrollTop))
	{
		//IE6 standards compliant mode
		scrOfY = document.documentElement.scrollTop;
		scrOfX = document.documentElement.scrollLeft;
	}
	if (getX)
	{
		return scrOfX;
	}
	else
	{
		return scrOfY;
	}
}

function getScrollX()
{
	return getScrollXY(true);
}

function getScrollY()
{
	return getScrollXY(false);
}


function centerDiv()
{
	var div_outer = document.getElementById('modalpopup_outer');
	var WindowWidth = getWindowWidth();
	var WindowHeight = getWindowHeight();
	var WindowX = getScrollX();
	var WindowY = getScrollY();
	if (div_outer && (div_outer.style.display == 'block'))
	{
		var div_inner = document.getElementById('modalpopup_inner');
		var hid_correction = document.getElementById('__modal_top_correction');
		var WindowCenterX = WindowX+(WindowWidth / 2);
		var WindowCenterY = WindowY+(WindowHeight / 2);
		var DivMidWidth = div_inner.clientWidth / 2;
		var DivMidHeight = div_inner.clientHeight / 2;
		var DivNewTop = Math.round(WindowCenterY-DivMidHeight)-hid_correction.value;
		var DivNewLeft = Math.round(WindowCenterX-DivMidWidth);
		div_inner.style.top = DivNewTop+'px';
		div_inner.style.left = DivNewLeft+'px';
	}
	var cart_right_side = document.getElementById('float_cart');
	var right_cart_top = document.getElementById('right_cart_top');
	if (cart_right_side && right_cart_top)
	{
		var min_top = right_cart_top.value+'px';
		if (WindowY > 342)
		{
			cart_right_side.style.top = WindowY+'px';
		}
		else
		{
			cart_right_side.style.top = min_top;
		}
	}
}
