﻿//--- Indien ajax
//--- prototype.js moet geladen zijn
var ua = navigator.userAgent
var cssFilters = ((ua.indexOf("MSIE 5.5") >= 0 || ua.indexOf("MSIE 6") >= 0 || ua.indexOf("MSIE 7") >= 0) && ua.indexOf("Opera") < 0)? 1:0
var blnFiltersEnabled = 0
var tbody
var intMouseX = 0;
var intMouseY = 0;
var blnIE = (document.all)? 1:0
var blnDom = (document.getElementById)? 1:0
//var popupwindow = document.getElementById('popupwindow');
var grabx = 0;
var graby = 0;
var orix = 0;
var oriy = 0;
var elex = 0;
var eley = 0;
var dragobj = null;
var intWindowWidth = 0;
var intWindowHeight = 0;
var intScrollTop = 0;
var intScrollLeft = 0;

//document.onmousemove = getMousePosition;

var strResult = '';
strResult += '<div id="popupwindow" style="position: absolute; top: -1000px; visibility: hidden; left: -1000px; z-index: 1000; width: 10px; height: 10px" onmousedown="grab(this);hideContent()" onmouseup="showContent()" onselectstart="return false">';
strResult += '	<table id="popupwindow_table" border="0" cellpadding="0" cellspacing="0" width="100%" height="100%">';
strResult += '		<tr>';
strResult += '			<td id="popupwindow_header">';
strResult += '				<table border="0" cellpadding="0" cellspacing="0" width="100%">';
strResult += '					<tr>';
strResult += '						<td id="popupwindow_header_text">&nbsp;</td>';
strResult += '						<td id="popupwindow_header_close" onClick="hidePopup()"><img src="/mba/images/popup_close.gif" border="0" alt="Sluiten"/></td>';
strResult += '					</tr>';
strResult += '				</table>';
strResult += '			</td>';
strResult += '		</tr>';
strResult += '		<tr>';
strResult += '			<td valign="top" id="popupwindow_content" style="width: 100%; height: 100%">&nbsp;</td>';
strResult += '		</tr>';
strResult += '	</table>';
strResult += '	</div>';

document.write(strResult)


function hideContent()
{
	document.getElementById('popupwindow_content').style.visibility = 'hidden'
}

function showContent()
{
	document.getElementById('popupwindow_content').style.visibility = 'visible'
}



function showPopup(p_strHeader,p_strText,p_strURL,p_intWidth,p_intHeight)
{
	var intOffsetX = 6;
	var intOffsetY = 6;
	var intLeft = 0;
	var intTop = 0;
	var popupwindow = document.getElementById('popupwindow');

	getMousePosition();
	getWindowSize();
	getScrollOffset();

	intMouseX = parseFloat(intMouseX);
	intMouseY = parseFloat(intMouseY);
	p_intWidth = parseFloat(p_intWidth);
	p_intHeight = parseFloat(p_intHeight);
	intOffsetX = parseFloat(intOffsetX);
	intOffsetY = parseFloat(intOffsetY);
	intWindowWidth = parseFloat(intWindowWidth);
	intWindowHeight = parseFloat(intWindowHeight);
	intScrollLeft = parseFloat(intScrollLeft);
	intScrollTop = parseFloat(intScrollTop);

	if((intMouseX + p_intWidth + intOffsetX) >= (intWindowWidth - intScrollLeft))
	{
		intLeft = (intMouseX - p_intWidth - intOffsetX);
	}
	else
	{
		intLeft = (intMouseX + intOffsetX);
	}

	if(intLeft < 0)
	{
		intLeft = intScrollLeft;
	}

	if((intMouseY + p_intHeight + intOffsetY) >= (intWindowHeight - intScrollTop))
	{
		intTop = (intMouseY - p_intHeight - intOffsetY);
	}
	else
	{
		intTop = (intMouseY + intOffsetY);
	}

	if(intTop < 0)
	{
		intTop = intScrollTop;
	}

	if(blnDom == false)
	{
		window.open(p_strURL,p_strHeader,'width=' + p_intWidth + 'px,height=' + p_intHeight + 'px,left=' + intLeft + ',top=' + intTop + ',scrollbars=1');
	}
	else
	{
		if(p_strHeader == '')
		{
			p_strHeader = '&nbsp;';
		}

		getLoadingAnimation();

		document.getElementById('popupwindow_header_text').innerHTML = p_strHeader;

		popupwindow.style.width = p_intWidth + 'px';
		popupwindow.style.height = p_intHeight + 'px';
		popupwindow.style.left = intLeft + 'px';
		popupwindow.style.top = intTop + 'px';

		if(p_strText != '')
		{
			document.getElementById('popupwindow_content').innerHTML = p_strText;
		}

		if(p_strURL != '')
		{
			document.getElementById('popupwindow_content').innerHTML = "<iframe name='iframe_popupwindow' id='iframe_popupwindow' scrolling='auto' style='width: 100%; height: " + (p_intHeight - 25) + "px' frameborder='0' src='" + p_strURL + "'></iframe>";
		}

		popupwindow.style.visibility = 'visible';
	}
}


function getLoadingAnimation()
{
	document.getElementById('popupwindow_content').innerHTML = "<table border='0' width='100%' height='100%'><tr><td valign='middle' align='center'><img src='../images/loader.gif' border='0' width='32' height='32' alt=''/></td></tr></table>";
}


function hidePopup()
{
	var popupwindow = document.getElementById('popupwindow');

	popupwindow.style.left = '-1000px';
	popupwindow.style.top = '-1000px';
	popupwindow.style.visibility = 'hidden';

	getLoadingAnimation();
}



function getMousePosition(e)
{ 
  if (!e) e = window.event;

  if (e)
  { 
    if (e.pageX || e.pageY)
    {
      intMouseX = e.pageX;
      intMouseY = e.pageY;
    }
    else if (e.clientX || e.clientY)
    {
      intMouseX = e.clientX + document.body.scrollLeft;
      intMouseY = e.clientY + document.body.scrollTop;
    }  
  }
}



function getWindowSize()
{
	if(blnIE == 1)
	{
    intWindowWidth = document.body.clientWidth;
    intWindowHeight = document.body.clientHeight;
	}
	else
	{
    intWindowWidth = window.innerWidth;
    intWindowHeight = window.innerHeight;
	}
}


function getScrollOffset()
{
  if(typeof(window.pageYOffset) == 'number')
   {
    //Netscape compliant
    intScrollTop = window.pageYOffset;
    intScrollLeft = window.pageXOffset;
  }
  else if( document.body && (document.body.scrollLeft || document.body.scrollTop))
  {
    //DOM compliant
    intScrollTop = document.body.scrollTop;
    intScrollLeft = document.body.scrollLeft;
  }
  else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) )
   {
    //IE6 standards compliant mode
    intScrollTop = document.documentElement.scrollTop;
    intScrollLeft = document.documentElement.scrollLeft;
  }
}


//Drag & Drop

var grabx = 0;
var graby = 0;
var orix = 0;
var oriy = 0;
var elex = 0;
var eley = 0;

var dragobj = null;

function falsefunc()
{
	return false;
}

function grab(context)
{
	getMousePosition()

  document.onmousedown = falsefunc;
  dragobj = context;
  dragobj.style.zIndex = 10;
  dragobj.style.cursor = 'move';
  document.onmousemove = drag;
  document.onmouseup = drop;
  grabx = intMouseX;
  graby = intMouseY;
  elex = orix = dragobj.offsetLeft;
  eley = oriy = dragobj.offsetTop;
  
}

function drag(e)
{
  if (dragobj)
  {
		getMousePosition()

    elex = orix + (intMouseX-grabx);
    eley = oriy + (intMouseY-graby);

    dragobj.style.position = "absolute";
    dragobj.style.left = (elex).toString(10) + 'px';
    dragobj.style.top  = (eley).toString(10) + 'px';
  }

  return false;
}

function drop()
{
  if(dragobj)
  {
		dragobj.style.cursor = '';
    dragobj.style.zIndex = 0;
    dragobj = null;
  }

  document.onmouseup = null;
  document.onmousedown = null;
}
