document.observe('dom:loaded', function() {
	$dialog = $('geoip-notification-dialog');
	
	if ($dialog == null) {
		return;
	}
	
	var seenDialog = false;
	if (Mage.Cookies.get('geoip-notification-dialog')) {
		seenDialog = true;
	}
	
	if (!seenDialog) {
		Modalbox.show($dialog, {
			title: $dialog.readAttribute('title'),
			transitions: false,
			beforeHide: function() {
				var cookieDate = null;
				
				if ($('MB_dontshow') && $$('#MB_dontshow input')[0].checked) {
					cookieDate = new Date(2038, 11, 31, 23, 59, 59);
				}

				// set cookie
				Mage.Cookies.set('geoip-notification-dialog', true, cookieDate, '/');
			
				return true;
			},
			overlayOpacity: 0.65,
			overlayDuration: 0,
			beforeLoad: function() {
				$('MB_close').insert({
					'before': '<span id="MB_dontshow">' +
							  '<label><input type="checkbox" /> Don\'t show this again' + 
							  '</span>'
				})
			},
			afterLoad: function() {
				// fix for Prototype 1.6 setOpacity()
				if (/MSIE 9/.test(navigator.appVersion)) {
					$('MB_overlay').style.opacity = 0.65;
				}

				// fix for centering
				$('MB_window').setStyle({ height: '' });
				$('MB_windowwrapper').setStyle({
					marginTop: (-0.5 * $('MB_windowwrapper').getHeight()) + 'px'
				});
			}
		});
	}
});

