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)
	{ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	}
	else if (document.documentElement && document.documentElement.scrollHeight > document.documentElement.offsetHeight)
	{ // Explorer 6 strict mode
		xScroll = document.documentElement.scrollWidth;
		yScroll = document.documentElement.scrollHeight;
	}
	else
	{ // Explorer Mac...would also work in Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	var windowWidth, windowHeight;
	if (self.innerHeight)
	{ // all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
	{ // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	}
	else if (document.body)
	{ // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}

	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight)
	{
		pageHeight = windowHeight;
	}
	else
	{
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth)
	{
		pageWidth = windowWidth;
	}
	else
	{
		pageWidth = xScroll;
	}

	return [pageWidth,pageHeight,windowWidth,windowHeight];
}

$(document).ready
(
	function()
	{
		var resize = function()
		{
			var koef = 1414/883;
			var bodyWidth = $('body').width();
			var bodyHeight = $('body').height();
			var realBodyHeight = bodyHeight;
			var realBodyWidth = bodyWidth;
			
			if ( bodyHeight < 624 || bodyWidth < 1000 )
			{
				bodyHeight = 624;
				bodyWidth = 1000;
				$('body').css('overflow', 'auto');
				$('html').css('overflow', 'auto');
			}
			else
			{
				$('body').css('overflow', 'hidden');
				$('html').css('overflow', 'hidden');
			}
			var width = ( bodyWidth/bodyHeight > koef ) ? bodyHeight*koef : bodyWidth;
			koef = 1414/width;
			width = Math.round(width);
			var height = Math.round(width/(1414/883));
			height = ( bodyHeight > height ) ? height : bodyHeight;
			if ( realBodyHeight > 624 )
			{
				$('div#pageConteiner').css({'height':height, 'margin-top':Math.round((realBodyHeight-height)/2)});
			}
			else
			{
				$('div#pageConteiner').css({'height':height, 'margin-top':0});
			}

			$('body').css('fontSize', Math.round(10000/koef)/100+'%');
			$('div.pageBg').css({'width':width, 'display':'block'});
			$('div#page').css({'width':width, 'display':'block'});
			var bottomWidth = $('div#btn div.bottomMenu > img').width();
			var pageOffset = $('div.pageBg').offset();
			var bottomOffset = $('div#btn div.pageBottom').offset();
			$('form#searchFrom input').width( Math.round( bottomWidth/(1329/216) ) );
			bottomWidth = Math.round(width - bottomWidth - 16*2.875/koef + bottomWidth/(1329/262));

			$('form#searchForm').width(bottomWidth);
			
			if ( $.browser.msie )
			{
				$('img#background').css({'right':0, 'bottom':0, 'left':width-$('img#background').outerWidth(), 'top':bodyHeight-$('img#background').outerHeight()});
			}
		};

		resize();
		$('img#background').css('visibility', 'visible');

		$(window).bind('resize', function(){ resize(); });
	}
);
