var PageBlock = new Class({
							   
	initialize:function(e)
	{
		
		this.e = e;
		
		var coordinates = this.e.getCoordinates();
		this.w = coordinates.width;
		this.h = coordinates.height;
		this.left = coordinates.left;
		this.top = coordinates.top;
		this.right = coordinates.right;
		this.bottom = coordinates.bottom;
				
		this.close = $('closeLightBox');
		this.setLightBoxEvents();
		
		this.pageInfoBlock = $('pageInfoBlock');
		
		window.addEvents
		({
			'mousewheel': this.handleWindowMousewheel.bind(this)
		}); 
		
		this.pageInfoBlock.addEvents
		({	
			'mousewheel': this.handleMousewheelLightBox.bind(this)
		}); 
	},
		
	handleLightBoxKeyDown: function(event)
	{
		if(event.key =='esc')
		{	
			window.removeEvents('mousewheel');
			LB.doClose();
		};
		this.handleKeyScroll(event);
		event.stop();
	},
	
	handleLightBoxClick: function(event)
	{
		window.removeEvents('mousewheel');
		this.pageInfoBlock.removeEvents('mousewheel');
		LB.doClose();
	},
	
	handleMousewheelLightBox: function(event)
	{
		this.pageInfoBlock.scrollTo(0, (this.pageInfoBlock.getScroll().y + (-15*event.wheel)));
	},
	
	setLightBoxEvents: function()
	{
		this.removeListeners();
		
		window.addEvents
		({
			'keydown': this.handleLightBoxKeyDown.bind(this),
			'mousewheel': this.handleWindowMousewheel.bind(this)
		}); 
		
		LB.bg.addEvents
		({
			'click': this.handleLightBoxClick.bind(this)
		}); 
		
		this.close.addEvents
		({
			'click': this.handleLightBoxClick.bind(this)
		}); 
		
	},
	
	handleWindowMousewheel: function()
	{
		event.stop();
	},
	
	removeListeners:function()
	{
		window.removeEvents('keydown');
		LB.bg.removeEvents('click');
		this.close.removeEvents('click');	
	},
	
	handleKeyScroll : function(event)
	{
		if(event.key =='up')
		{
			this.pageInfoBlock.scrollTo(0, (this.pageInfoBlock.getScroll().y - 15));
		};
		if(event.key =='down')
		{
			this.pageInfoBlock.scrollTo(0, (this.pageInfoBlock.getScroll().y + 15));
		};
	}
	

})
