function showMsg(msg, waitForClick, ignoreMousePosition, showShadow)
{
	msgWidth = 600; 
	// Add messenger if not exists
	if ($('messenger') == null)
	{
		var messenger = document.createElement('div');
		messenger.setAttribute('id', 'messenger');
		document.body.appendChild(messenger);
	}
	
	// Set position relative to mouse if defined (need to include mouse_position.js)
	if ((ignoreMousePosition == null || !ignoreMousePosition) && typeof(_currentSafeX) != "undefined" && typeof(_currentSafeY) != "undefined")
	{
		$('messenger').style.width = msgWidth + 'px';
		$('messenger').style.left = document.body.offsetWidth/2 - msgWidth/2 +'px';
		$('messenger').style.top = jQuery(window).scrollTop() + 10 + 'px';
	}

	if (waitForClick == null || !waitForClick)
	{
		$('messenger').innerHTML = '<a class="messengerClose" type="button" onclick="hideMsg()" >x</a><p>' + msg + '</p>';

		// Fade the text in and out
		new Effect.Appear('messenger', { queue: 'front' });
		new Effect.Fade('messenger', { delay: 2.0, queue: 'end' });
	}
	else
	{
		var hideShadow = false;
		if (showShadow != null && showShadow === true)
		{
			// Show curtain
			showCurtain('hideMsg(true)');
			hideShadow = true;
		}
			
		// Add close button
		
		$('messenger').innerHTML = '<a class="messengerClose" type="button" onclick="hideMsg('+ hideShadow +')" >x</a><p>' + msg + '</p><input class="messengerButton" type="button" onclick="hideMsg('+ hideShadow +')" value="Lukk" />';
		$('messenger').show();
	}
}

function showMsgWithShadow(msg)
{
	showMsg(msg, true, true, true);
}

function showMsgWithImage(img)
{
	// Add imageMesseger if not exists
	if ($('imageMessenger') == null)
	{
		var messenger = document.createElement('div');
		messenger.setAttribute('id', 'imageMessenger');
		messenger.setAttribute('onclick', 'hideImgMsg()');
		document.body.appendChild(messenger);
	}
	
	$('imageMessenger').innerHTML = img + '<p><input type="button" class="buttonBgSmall" onclick="hideImgMsg()" value="Lukk" /></p>';

	showCurtain();
	$('imageMessenger').show();
}

function showMsgFromElement(elementId, waitForClick, ignoreMousePosition)
{
	// Add messenger if not exists
	if ($('messenger') == null)
	{
		var messenger = document.createElement('div');
		messenger.setAttribute('id', 'messenger');
		document.body.appendChild(messenger);
	}
	
	// Set position relative to mouse if defined (need to include mouse_position.js)
	/*if ((ignoreMousePosition == null || !ignoreMousePosition) && typeof(_currentSafeX) != "undefined" && typeof(_currentSafeY) != "undefined")
	{
		$('messenger').style.left = _currentSafeX +'px';
		$('messenger').style.top = _currentSafeY +'px';
	}*/

	if (waitForClick == null || !waitForClick)
	{
		$('messenger').innerHTML = $(elementId).value;

		// Fade the text in and out
		new Effect.Appear('messenger', { queue: 'front' });
		new Effect.Fade('messenger', { delay: 1.0, queue: 'end' });
	}
	else
	{
		// Add close button
		$('messenger').innerHTML = $(elementId).innerHTML + '<input type="button" onclick="hideMsg()" value="Lukk" />';

		// Fade the text in
		new Effect.Appear('messenger');
	}
}

function hideMsg(hideShadow)
{
	$('messenger').hide();
	
	if (hideShadow != null && hideShadow)
		removeCurtain();
}

function hideImgMsg()
{
	$('imageMessenger').hide();
	removeCurtain();
}

