var ui = {
	initialize: function(){
		if ($('vacature')) 
			Event.observe($('vacature'), 'click', this.showPopup.bindAsEventListener(this));
			
		this.externallinks();
	},
	
	showPopup: function(){
		var overlay = document.createElement("div");
		var dimensions = document.viewport.getDimensions();
		var offsets = document.viewport.getScrollOffsets();
		Element.extend(overlay);
		
		overlay.id = "overlay";
		overlay.setStyle({
			position: 'absolute',
			left: offsets.left + 'px',
			top: offsets.top + 'px',
			width: (dimensions.width - 50) + 'px',
			height: (dimensions.height - 50) + 'px',
			zIndex: 100
		});
		
		Event.observe(overlay, 'click', this.hidePopup.bindAsEventListener(this));
		
		document.body.appendChild(overlay);
		
		$('popup').setStyle({
			display: 'block'
		});
	},
	
	hidePopup: function(){
		$('popup').setStyle({
			display: 'none'
		});
		document.body.removeChild($('overlay'));
	},
	
	externallinks: function(){
		var ls = $$('a');
		ls.each(function(a) {
			if (a.getAttribute('rel') == 'external') {
				a.className += a.className ? ' extlink' : 'extlink';
				a.title += '(opens in new window)';
				a.onclick = function(){
					window.open(this.href);
					return false
				}
			}
		}.bind(this));
	}
}
