var mooExitpopup = new Class({
	Implements: [Options],
	area : {},
	trigger: 0,
	mousey: 99,
	options: {
		popup: function(){
			alert('test');
		},
		message: 'Please specify { message: <value>}'
	},
	
	initialize: function(options){
		this.setOptions(options);
		
		// init MODAL
		this.area = new Element('div', {
			'styles': {
				width: window.getSize().x,
				height: '15px',
				position: 'absolute',
				margin: '0px',
				padding: '0px',
				top: '0px',
				left: '0px',
				backgroundColor: '',
				zIndex: 9999
			},
			events:{
				mousemove: function(event){
					
					this.trigger = 0;
					var offset = this.area.getCoordinates().top;
					if (event.page.y < this.mousey && event.page.y <= (5+offset) )
						this.show();
						
					this.mousey = event.page.y;
					
				}.bind(this)
				
			}
		})
		.injectInside(document.body);
		
		var repos = this.reposition.bind(this);
		window.addEvents({
			scroll: repos,
			resize: repos,
			beforeunload: function(e){
				/*
				return true;
				this.show();
				//return confirm(this.options.message);
				return false;
				*/
			}.bind(this)
		});
		
	},

	reposition: function() {
		var max = document.getCoordinates(), scroll = document.getScroll(), margin = this.options.margin;
		max.left += scroll.x;
		max.right += scroll.x;
		max.top += scroll.y;
		max.bottom += scroll.y;
		var rel = ($type(this.container) == 'element') ? this.container.getCoordinates() : max;
		this.area.setStyles({
			top: max.top
		});
	},
	
	show: function(){
		this.options.popup();
		this.shown = true;
	}
	
});