function Page()
{
	this.max_width = 1170;
	this.main_object = $('#main');
	this.works_table = $('#works table');
	this.black_bg = $('#black_bg');
	this.shadow_bg = $('#shadow_bg');
	this.fixed_obj = $('#fixed_obj');
	this.head_object = $('#head_object');
	this.bottom_object = $('#bottom_object');
	this.mini_ie_fix = $('#mini_ie_fix');

	this.info_window = $('#info_window');
	this.info_window_name = $('#info_window_name');
	this.info_window_content = $('#info_window_content');
	
	this.popup = $("#popup");
		
	this.ie6 = ($.browser.msie && ($.browser.version == '6.0'));
	this.ie7 = ($.browser.msie && ($.browser.version == '7.0'));
	this.ie8 = ($.browser.msie && ($.browser.version == '8.0'));

	this.WorksWidth = function()
	{
		var client_width = $.getClientWidth();
		return (this.works_table.width() > client_width) ? this.works_table.width() : client_width;
	}
	
	this.SetSize = function()
	{	
		var td1 = $('#main td:first');
		var td2 = $('#main td:eq(1)');
		var td3 = $('#main td:eq(2)');
		var td4 = $('#main td:eq(3)');
		
		this.main_object.css('height', $.getClientHeight() - 1);
		var client_width = $.getClientWidth();
		
		var max_width_objects = this.MaxWidthObject();
		for(i in max_width_objects)
		{
			var obj = max_width_objects[i];
			if( client_width > this.max_width)
			{
				obj.css('width', this.max_width);
			}
			else
			{
				obj.css('width', client_width - 1);
			}
		}
		
		this.RefreshPage();
		
		var plus = 175;
		
		if(this.ie6)
		{
			this.fixed_obj.css('left', $.leftScroll());
			this.head_object.css('left', $.leftScroll());
			
			this.bottom_object.css('left', client_width / 2 - (this.bottom_object.width() / 2) + $.leftScroll());
			this.bottom_object.css('top', td1.height() + td2.height() + 355);
			
			this.mini_ie_fix.text($.getClientHeight());
			this.mini_ie_fix.text('');
		}
		else if(this.ie8)
		{
			this.fixed_obj.css('top', td1.height() + td2.height() - $.topScroll() + 4 + plus);
		}
		else
		{
			this.fixed_obj.css('top', td1.height() + td2.height() - $.topScroll() + plus);
		}
		
		if(!this.ie6)
		{
			this.head_object.css('top', td1.height() + td2.height() - $.topScroll() - this.head_object.height());
			this.bottom_object.css('top', td1.height() + td2.height() + 355 - $.topScroll());
			this.head_object.css('left', client_width / 2 - (this.head_object.width() / 2) );
			this.bottom_object.css('left', client_width / 2 - (this.head_object.width() / 2) );
		}
		else
		{
			if(this.info_window.css('visibility') == 'visible')
			{
				if(typeof(this.info_window_name.get(0).anker) != 'undefined')
				{
					a = this.info_window_name.get(0).anker;
					this.info_window.css('left', a.offset().left + a.width() - this.info_window.width() + 34);
					this.info_window.css('top', a.offset().top + a.height() - this.info_window.height() + 51);
				}
			}
		}
		
		if(this.ie6 || this.ie7)
		{
			var height = ($.getClientHeight() - 515) / 2;
			td1.css('height', height);
		}
	}
	
	this.MaxWidthObject = function()
	{
		var max_width_objects = new Array();
		$('.max_width').each(function(){
			max_width_objects[max_width_objects.length] = $(this);
		});
		
		return max_width_objects;
	}
		
	this.PreparePage = function()
	{
		if(this.ie6)
		{
			this.fixed_obj.css('position', 'relative');
			this.head_object.css('position', 'relative');
			this.bottom_object.css('position', 'absolute');
			this.info_window.css('position', 'absolute');
		}
		else
		{
			this.head_object.css('position', 'fixed');
			this.bottom_object.css('position', 'fixed');
			this.info_window.css('position', 'fixed');
		}
		
		this.SetSize();
		
		// scrolling
		function PreventDefault(e)
		{
			e=e||window.event;
			if (e.preventDefault) e.preventDefault();
			else e.returnValue = false;
		}
		
		function wheel(e)
		{
			e=e||window.event;
			var delta = 0;
			
			if (e.wheelDelta) delta = e.wheelDelta/2;
			else if (e.detail) delta = -e.detail*40;
			
			$.leftScroll( $.leftScroll() - delta );
			
			PreventDefault(e);
		}
		
		var body = $('body:first').get(0);
		if (body.addEventListener) body.addEventListener('DOMMouseScroll', wheel, false);
		body.onmousewheel = wheel;
	}
	
	this.RefreshPage = function()
	{
		this.black_bg.css('width', this.WorksWidth() + "px");
		this.shadow_bg.css('width', this.WorksWidth() + "px");
		return true;
	}
	
	this.SetPopupPosition = function()
	{
		var client_height = $.getClientHeight();
		var popup_height = this.popup.height();
		var popup_position_top = (client_height - popup_height) / 2;
		
		if (popup_position_top < 0) popup_position_top = 10;		
		this.popup.css("top", popup_position_top+"px");
		this.popup.css('left', ($(window).width() / 2 - 368) + "px");
	}
}


