function getUrl(url) {
	return urlBase + '/' + url;
}

function removeDialog() {
	window.parent.$$('div.dialog').pop().remove();
}

function createDialog(url, width, height, title) {

	var viewportHeight = window.innerHeight;
	var viewportWidth = window.innerWidth;

	if(width > viewportWidth - 40) {
		width = viewportWidth - 45;
	}
	if(height > viewportHeight - 40) {
		height = viewportHeight - 45;
	}

	var marginLeft = (viewportWidth - width) / 2;
	var marginTop = (viewportHeight - height) / 2;

	var dialog = new Element('div', {
		className : 'dialog'
	});
	var dialogBackground = new Element('div', {
		className : 'dialogBackground'
	});
	dialog.insert(dialogBackground);

	var dialogContainer = new Element('div', {
		className	: 'dialogContainer',
		style		: 'width: ' + width + 'px; height: ' + height+ 'px; margin-left: ' + marginLeft + 'px; margin-top: ' + marginTop + 'px;'
	});

	var divTitleContainer = new Element('div', {
		className	: 'titleContainer'
	});
	var divTitle = new Element('div', {
		className	: 'title'
	}).insert(title);
	var divButtonContainer = new Element('div', {
		className	: 'button'
	});
	var button = new Element('a', {
		href	: '#'
	});
	button.observe('click', function(event) {
		dialog.remove();
	});

	var image = new Element('img', {
		src : getUrl('img/navigate_cross16.png')
	});

	divButtonContainer.insert(button.insert(image));
	divTitleContainer.insert(divTitle).insert(divButtonContainer);
	dialogContainer.insert(divTitleContainer);

	var iframeContainer = new Element('div', {
		className	: 'iframeContainer',
		style		: 'width: ' + (width) + 'px; height: ' + (height - 21) + 'px;'
	});
	var frame = new Element('iframe', {
		src		: url
	});
	iframeContainer.insert(frame);
	dialogContainer.insert(iframeContainer);

	dialog.insert(dialogContainer);

	var body = $$('body').pop();
	body.insert(dialog);
}

function createNotice(type, message) {

	var noticeDiv = new Element('div', {
		'id' : 'notice-' + type
	}).update( new Element('div', { 'class' : 'notice-image'})).insert(message);

	var noticeContainer = new Element('div', {
		'id' : 'notice-container'
	}).update(noticeDiv);

//	<div id="notice-success"> <div class="notice-image"></div>De pagina is succesvol bewerkt</div>

	if($('notice-container')) {
		$('notice-container').replace(noticeContainer);
	} else {
		$('middle-status').insert(noticeContainer);
	}
}
