if (typeof Popup == 'undefined') {
    var Popup = {};
}

Popup = Class.create();

Popup.prototype = {
	initialize: function (image) {	
		this.viewportWidth = document.viewport.getWidth();
		
		$$('.popup').each(function (e) {
			this.offset = e.cumulativeOffset()['left'] + e.getWidth();
			$(e).hide();
			if (this.offset > this.viewportWidth) {
				e.setStyle({
					left: '-200px'
				});
			}
		}.bind(this));
		
		$$(image).each(function (e) {
			var el = e.siblings()[0],
			li = el.up('li');
			Event.observe(e, 'mouseover', function () {
				li.setStyle({
					zIndex: 5000
				});
				el.show();
			});
			Event.observe(e, 'mouseout', function () {
				li.setStyle({
					zIndex: 10
				});
				el.hide();
			});
		});
	}
};
