
 /**
  * Function to show popup with info how to enlarge the page
  */

 function showHowtoEnlarge()
 {
 	$('popup_window_content').update('U kunt de lettergrootte van de pagina vergroten en verkleinen door de Ctrl toets ingedrukt te houden, terwijl u met het scrollwiel van de muis schuift om in of uit te zoomen. Daarnaast kunt u ook met behulp van het toetsenbord de lettergrootte van de pagina bewerken door gelijktijdig de Ctrl toets en de &#45; of &#43; toets ingedrukt te houden');
 	$('popup_window_content').style.fontWeight = 'bold';
 	$('popup_window_content').style.fontSize = '16px';
 	$('popup_okButton').style.display = 'block';
 	showPopup();
 }


/**
 * Show popup
 */
 function showPopup(bHideClose)
 {
	if(bHideClose)
	{
		$('closePopupButton').style.display = 'none';
	}	
	else
	{
		$('closePopupButton').style.display = 'block';
	}	
	 
 	window.setTimeout("adjustPosition()", 300);
 }

function hidePopup()
{
	new Effect.Fade('popup_window',{duration: '0.2'});
	setTimeout("Effect.Fade('popup_overlay',{duration: '0.4'})",400);
}

function setPopupContent( sHtml )
{
	for( i = 0; i < $('popup_window').childNodes.length; i++ )
	{
		if( $('popup_window').childNodes[i].className == 'popup_window_content' )
		{
			$('popup_window').childNodes[i].innerHTML = sHtml;
		}
	}
}

function showOkPopup( message, okFunction )
{
	//Create the ok button
	var okButton = document.createElement( 'input' );
	okButton.setAttribute( 'type', 'button' );
	okButton.className = 'ok';
	okButton.name = 'okButton';
	okButton.id = 'popup_okButton';
	okButton.value = 'Ok';
	
	//Create a text element and add text and buttons
	var pMessage = document.createElement( 'p' ); 
	pMessage.innerHTML = message;
	
	var htmlContent = document.createElement( 'p' );
	htmlContent.appendChild( pMessage );
	htmlContent.appendChild( okButton );
	
	setPopupContent( htmlContent.innerHTML );
	
	//Set onclick events for buttons
	$( 'popup_okButton' ).onclick = new Function( okFunction + '()' );

	showPopup(true);
	
	return;
}

function showYesNoPopup( message, yesFunction, noFunction )
{
	//Create two buttons
	var yesButton = document.createElement( 'input' );
	yesButton.setAttribute( 'type', 'button' );
	yesButton.className = 'yes';
	yesButton.name = 'yesButton';
	yesButton.id = 'popup_yesButton';
	yesButton.value = 'Ja';
	
	var noButton = document.createElement( 'input' );
	noButton.setAttribute( 'type', 'button' );
	noButton.className = 'no';
	noButton.name = 'noButton';
	noButton.id = 'popup_noButton';
	noButton.value = 'Nee';
	
	//Create a text element and add text and buttons
	var pMessage = document.createElement( 'p' ); 
	pMessage.innerHTML = message;
	
	var htmlContent = document.createElement( 'p' );
	htmlContent.appendChild( pMessage );
	htmlContent.appendChild( yesButton );
	htmlContent.appendChild( noButton );
	setPopupContent( htmlContent.innerHTML );
	
	//Set onclick events for buttons
	$( 'popup_yesButton' ).onclick = new Function( yesFunction + '()' );
	$( 'popup_noButton' ).onclick = new Function( noFunction + '()' );

	showPopup();
	
	return;
}

var iMarginTop;

function adjustPosition()
{
	$('popup').style.display ='block';

	var iHeight = $('popup_window').getHeight();
	var iWidth = $('popup_window').getWidth();

	$('popup_window').style.marginLeft = '-'+ iWidth / 2 + 'px';

	if(!iMarginTop && iMarginTop != 0)
	{	
		iMarginTop = parseInt($('popup_window').getStyle('margin-top').replace('px',''));
	}
	aScroll = getScrollSize();

	$('popup_window').style.marginTop = iMarginTop + aScroll[1] + 'px';
	
	$('popup').style.display ='none';

	$('popup').style.display = 'block';
	new Effect.Appear('popup_overlay',{	duration: '0.4', from: 0.0, to: 0.8});
	setTimeout("Effect.Appear('popup_window',{duration: '0.2'})",400);
}

function getScrollSize() 
{
	
	  var iScrollX = 0, iScrollY = 0;
	  if( typeof( window.pageYOffset ) == 'number' ) 
	  {
		  iScrollY = window.pageYOffset;
		  iScrollX = window.pageXOffset;
	  } 
	  else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) 
	  {
		  iScrollY = document.body.scrollTop;
		  iScrollX = document.body.scrollLeft;
	  } 
	  else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) 
	  {
		  iScrollY = document.documentElement.scrollTop;
		  iScrollX = document.documentElement.scrollLeft;
	  }
	  
	  return [ iScrollX, iScrollY ];
}

