// Beware: JSCRIPT specific code !

var KEY_ENTER  = 13;
var KEY_ESCAPE = 27;


// tegenhanger staat in guivbs.inc
//var GLOBAL_DEVELOPMENT_MODE = "DevelopmentMode"
//var GLOBAL_SCREEN_RESOLTION = "ScreenResolution"
//var GLOBAL_ROEPNAAM_GEBRUIKER = "RoepnaamGebruiker"


/*
' Function		: BrowserVersion
' Description	: 
' Arguments		: 
' Returns		: string with browsertype
*/
function BrowserVersion()
{
	// not yet andere versies zoals ie6
	var IE4=(document.all&&!document.getElementById)?1:0;
	var IE5=(document.all&&document.getElementById)?1:0;
}



/*
' Function		: GetCurrentPage
' Description	: 
' Arguments		: 
' Returns		: current page
*/
function GetCurrentPage()
{
	// de slash tussen host en pathname is eigenlijk overbodig maar
  // toch nodig als een soort 'prevent caching code' !!
	return location.protocol + '//' + location.host + '/' + location.pathname;
}



/*
' Function		: UpdateLocationString
' Description	: Substitute parts of a location string (URL or querystring)
' Arguments		: sLocationString - query/URL string containing elements <identiefier>=<value>  
'               sQueryStringMember - specifies a part of the query string. 
'                 The format must be <identiefier>=<value>
'                 If the identifier is already used in the query string it will be replaced
'                 otherwise it will be appended
' Returns		  : adjusted location string
*/
function UpdateLocationString(sLocationString, sQueryStringMember)
{
  var sNewLocation = sLocationString;
  var iPositionEqualSign = sQueryStringMember.indexOf('=');
  if (iPositionEqualSign >= 0)
  {
    var sIdentifier = sQueryStringMember.substring(0, iPositionEqualSign); // part before =

    // search the identifier in the current location
    var iPosition = sLocationString.indexOf('&' + sIdentifier + '=');

    if (iPosition < 0)
      iPosition = sLocationString.indexOf('?' + sIdentifier + '=');  
    if (iPosition >= 0) // let's substitute
    {
      sNewLocation = sLocationString.substring(0, iPosition + 1) + sQueryStringMember;
      var iEndPosition = sLocationString.indexOf('&', iPosition + 1);
      if (iEndPosition >= 0)
        sNewLocation += sLocationString.substring(iEndPosition);   
    }
    else // let's append
    {
        sNewLocation = sLocationString + ((sLocationString.indexOf('?') < 0) ? '?' : '&');
        sNewLocation += sQueryStringMember;
    }
  }
  return sNewLocation;
}


/*
' Function		: UpdateLocation
' Description	: Update the location of a window.
' Arguments		: wWindow - the window (or frame) to be updated
'               sQueryStringMember - 0 or more optional arguments that specifies a part of the query string. 
                  The format must be <identiefier>=<value>
                  If the identifier is already used in the query string it will be replaced
                  otherwise it will be appended
' Returns		  : nothing
*/
function UpdateLocation(wWindow, sQueryStringMembers)
{
/*
wWindow.location.reload();
return;
*/
  if (!wWindow) return;
  var sLocation;
  try
  {
    sLocation = wWindow.location.toString();
    var sNewLocation = sLocation;
    for (var i = 1; i < arguments.length; i++)
      sNewLocation = UpdateLocationString(sNewLocation, arguments[i]);
    wWindow.location.replace(sNewLocation);
  }
  catch(e)
  {
    return;
  }
}  


/*
' Function		: RefreshWindow
' Description	: Rerender the content of a window/frame
' Arguments		: wWindow - the window (or frame) to be updated
' Returns		  : nothing
*/
function RefreshWindow(wWindow)
{
	if (wWindow.RefreshPageWithPosting)
  {
  	wWindow.RefreshPageWithPosting();
  }  
  else
  {  
  	UpdateLocation (wWindow, "")
  }  
}

/*
' Functions		: onbekend
' Description	: 
' Arguments		: 
' Returns		  : 
*/

function ReturnScriptsArray(oSource)
{
	// oSource bv document

	var aScripts = new Array();
  var nScript = 0;
	
  if (oSource.scripts)
  	return oSource.scripts; // bv IE	document.scripts

  if (oSource.all)
  {
  	for (var i = 0; i < oSource.all.length; i++) {

    	if (oSource.all[i].tagName == 'SCRIPT')
      {
      	aScripts[nScript] = oSource.all[i];
        nScript = nScript + 1;
      }  
    }
  }
  // else empty array
  
	return aScripts; //bv Mozilla
}

function FindTopFrame(sFrameName)
{
  var TopFrame = null;
  for (var i = 0; i < top.frames.length; i++)
  {		
  	// hoe test ik in vredesnaam de security
    // maw wanneer mag ik wel en niet top.frames[i].name 'lezen'
    // top.frames[i] mag ik alert()...
  
		var bSecure = true;  
		try {
    	var s = top.frames[i].name;
    }
    catch(e) {			
    	bSecure = false;
    }	  
  
  	if (bSecure)	// ja het is 'veilig'
    {
    	if (top.frames[i].name == sFrameName)
      {
      	TopFrame = top.frames[i];
  	    break; // gevonden = gevonden
      }
    }  
  }
  return TopFrame;
}
function IsFunctionInFrame(Frame, sFunction)
{
	var bInFrame = false;
	if (Frame)
  {  
  	var oScriptCollection = ReturnScriptsArray(Frame.document);
    var sText;
    for (var i = 0; i < oScriptCollection.length; i++)
    {
	    sText = oScriptCollection[i].text;
      if (sText.indexOf(sFunction) > -1) 
      {
      	bInFrame = true;
      }
    }
  }        
  return bInFrame;
}
function GetQuickSelectSelectieType()
{  
	var iSelectieType = 0;
	var QuickSelectFrame = FindTopFrame('QuickSelect'); 
  if (QuickSelectFrame)
  	if (IsFunctionInFrame(QuickSelectFrame, 'GetSelectieTypeID')) 
			iSelectieType = QuickSelectFrame.GetSelectieTypeID();
  
  return iSelectieType;  
}
function GetQuickSelectSelectie()
{  
	var iSelectie = 0;
	var QuickSelectFrame = FindTopFrame('QuickSelect'); 
  if (QuickSelectFrame)
  	if (IsFunctionInFrame(QuickSelectFrame, 'GetSelectieID')) 
			iSelectie = QuickSelectFrame.GetSelectieID();
  
  return iSelectie;  
}
function GetQuickSelectSnelSelectieNaam()
{  
	var sSnelSelectieNaam = '';
	var QuickSelectFrame = FindTopFrame('QuickSelect'); 
  if (QuickSelectFrame)
  	if (IsFunctionInFrame(QuickSelectFrame, 'GetSnelSelectieNaam')) 
			sSnelSelectieNaam = QuickSelectFrame.GetSnelSelectieNaam();
  
  return sSnelSelectieNaam;  
}
function RefreshQuickSelectPage(iOnlyThisTypeID)
{  
	/* controleer eerst of 'QuickSelect' er is
     en of de OnLoad al is uitgevoerd, dit is te controleren
     door te kijken of RefreshPage te vinden is
    
     als RefreshPage er niet is hoef ik ook niet te refreshen
  */
	var QuickSelectFrame = FindTopFrame('QuickSelect'); 
  if (QuickSelectFrame)
  	if (IsFunctionInFrame(QuickSelectFrame, 'RefreshPage'))
    	QuickSelectFrame.RefreshPage(iOnlyThisTypeID);
}
function SelectOrMakeSnelSelectieForType(iSelectieTypeID, bDirectRefresh)
{
	var iNewSelectieTypeID = 0;
	var QuickSelectFrame = FindTopFrame('QuickSelect'); 
  if (QuickSelectFrame)
  	if (IsFunctionInFrame(QuickSelectFrame, 'SelectOrMakeSnelSelectieForType'))
    	iNewSelectieTypeID = QuickSelectFrame.SelectOrMakeSnelSelectieForType(iSelectieTypeID, bDirectRefresh);  
  
  return iNewSelectieTypeID;  
}
function SelectSelectieByID(iSelectieID, bDirectRefresh)
{
	var iNewSelectieID = 0;
	var QuickSelectFrame = FindTopFrame('QuickSelect'); 
  if (QuickSelectFrame)
  	if (IsFunctionInFrame(QuickSelectFrame, 'SelectSelectieByID'))
    	iNewSelectieID = QuickSelectFrame.SelectSelectieByID(iSelectieID, bDirectRefresh);  
  
  return iNewSelectieID;  
}
function GetQuickSelectSelectieOpen()
{  
	var sSelectieOpen = 'false';
	var QuickSelectFrame = FindTopFrame('QuickSelect'); 
  if (QuickSelectFrame)
  	if (IsFunctionInFrame(QuickSelectFrame, 'GetSelectieOpen')) 
			sSelectieOpen = QuickSelectFrame.GetSelectieOpen();
  
  return sSelectieOpen;  
}


function GetLoginGebruiker()
{
	iGebruikerID = 0;
	var LoginStatusFrame = FindTopFrame('LoginStatus'); 
  if (LoginStatusFrame)
  	iGebruikerID = LoginStatusFrame.window.document.forms['frm'].elements['fldGebruikerID'].value
  return iGebruikerID;
}



/*
' Function		: FormValuesToQueryString
' Description	: 
' Arguments		: in: object of form
' Returns		: querystring
*/
function FormValuesToQueryString(objForm)
{
	var sRetval = '';
	for (var i = 0; i < objForm.elements.length; i++)
	{
		var sName = objForm.elements[i].name.substring(3);
		switch (objForm.elements[i].type)
		{
			case 'checkbox' : sRetval = sRetval + sName + '=' + escape(objForm.elements[i].checked?'1':'0') + '&';
  											break;
			case 'radio'		:	if (objForm.elements[i].checked)
												sRetval = sRetval + sName + '=' + escape(objForm.elements[i].value) + '&';
												break;
			case 'button'		: break;
			default:					sRetval = sRetval + sName + '=' + escape(objForm.elements[i].value) + '&';
												break;
		}
	}

	if (sRetval != '')
		sRetval = '?' + sRetval.substring(0, sRetval.length - 1);
	return sRetval;
}



/*
' Function		: FormValuesToFormString
' Description	: a form string is a string containing the values of the controls (except for the buttons) in the form
'               the values are separated by a ~. The values have the layout: <controlname>=<value>
'               To distinguish the field separator ~ from the ~ in a value this tilde will be replaces by \~ (escaped)
'               To distinguish the escape character (\) from the character (\) it will be escaped to (replaced by \\)
'               In VBS the original value can be determined by using the function GetValueFromFormString()
' Arguments		: in: object of form
' Returns		  : form-string
*/
function FormValuesToFormString(objForm)
{
	var sRetval = '';
  var lNumberOfElements = objForm.elements.length
	for (var i = 0; i < lNumberOfElements; i++)
	{
    var objElement = objForm.elements[i]; // Het blijkt dat dit in een aparte variabele stoppen de functie ruim sneller maakt (ipv overal objForm.elements[i] te benaderen)
		switch (objElement.type)
		{
			case 'checkbox' : //sRetval = sRetval + '~' + objForm.elements[i].name + '=' + CADAN_escape(objForm.elements[i].checked?'1':'0');
                        // in principe moet de waarde 1 of 0 ge-CADAN_escaped worden. Uit de code van deze functie blijkt dat dit overbodig is.
                        // Omdat deze regel in bepaalde gevallen ontzettend vaak wordt aangeroepen, en dit onacceptabel traag is is er hier
                        // voor gekozen om deze aanroep dan maar weg te laten. Nu maar hopen dat dit commentaar niet bij iedere aanroep geinterpreteerd wordt! 
                        sRetval = sRetval + '~' + objElement.name + '=' + (objElement.checked?'1':'0');
  											break;
			case 'radio'		:	if (objElement.checked)
												  sRetval = sRetval + '~' + objElement.name + '=' + CADAN_escape(objElement.value);
												break;
			case 'button'		: break;
			default:					sRetval = sRetval + '~' + objElement.name + '=' + CADAN_escape(objElement.value);
												break;
		}
	}
	return sRetval;
}

/*
' Function		: CADAN_escape
*/
function CADAN_escape(s)
{
  var t = "";
  for (var i=0; i<s.length; i++)
  {
    var c = s.charAt(i);
    switch (c)
    {
      case '\\' : t += '\\\\'; break;
      case '~'  : t += '\\s'; break;
      default   : t += c;
    }
  }
  return t;
}

function CADAN_unescape(s)
{
  var t = "";
  for (var i=0; i<s.length; i++)
  {
    var c = s.charAt(i);
    if (c=='\\') // escape 
    {
      i++;
      c = s.charAt(i);
      switch(c)
      {
        case 's' : c = '~';
      }
    }
    t += c;
  }
  return t;
}



/*
' Function		: UpdateFrameset
' Description	: 
' Arguments		: window that has to be resized (or in fact the frameset in which it lives)
' Remarks			: Werkt als w een frame is die ligt binnen een framset die bestaat uit 2 bovenelkaar liggende frames ???????? 
' Remarks			: JScript specific 
*/
function UpdateFrameset(w)
{
	try
	{
		w.document.body.bottomMargin = 0;
		w.parent.document.childNodes[0].children[1].rows = (w.document.body.scrollHeight).toString() + ',*'; 
	}
	catch(e)
	{
		// object not found; just do nothing
	}					
}

/*
' Function		: ClickOnElement
' Description	: Search an element in the current document with the specified name and click on it (simulate the mouse) 
' Arguments		: sElementName - the element to be pressed
'               wWindow - optional (default=current window) - the window in which the specified element must be searched
' Returns		: nothing
*/
function ClickOnElement(sElementName, wWindow)
{
  if (!wWindow)
    wWindow = window
	var objElement = wWindow.document.getElementById(sElementName);
	if (objElement)	objElement.click();
}


/*
' Function		: OpenReportWindow
' Description	: Creates a modal dialog box that displays the specified RPT (IE only)
' Arguments		: in: string, arguments-object
' 020723: vArguments will be ignored. In all cases window (caller) will be passed by vArguments (==dialogArguments in modaldialog)
' Returns		: the return value set in new page (window.returnValue) 
*/
function OpenReportWindow(sURL, vArguments)
{
	// .rpt is een filter voor Crystal rapporten als dit voorkomt in de url
	// dan wordt de web-server altijd naar Crystal getriggerd dus dit is een geldig
	// URL filter
//  if (sURL.indexOf('correspondentie') < 0)  
//  	alert('Voor jac:    ' + sURL);

	OpenModalDialog('/xu/reports/log_report_querystring.asp?' + sURL, vArguments)
    
  if (sURL.indexOf('.rpt') >= 0)
  {
		var d = new Date();
		sURL += (sURL.indexOf('?') < 0) ? '?' : '&';
		sURL += "CADANPreventCachingCode=" + d.valueOf().toString();

    
	  // Crystal in een vast formaat
	  return showModalDialog (sURL, vArguments, "dialogwidth:800px;dialogheight:600px;center:yes;status:no;help:no;resizable:yes;");
  } 

  if (sURL.indexOf('XyliaWebtier.dll') >= 0) // schijnt hoofdletter gevoelig te zijn; ieps...
  {
//		var d = new Date();
//		sURL += (sURL.indexOf('?') < 0) ? '?' : '&';
//		sURL += "CADANPreventCachingCode=" + d.valueOf().toString();
    
	  // Reportbuilder in een vast formaat
	  return showModalDialog (sURL, vArguments, "dialogwidth:800px;dialogheight:600px;center:yes;status:no;help:no;resizable:yes;");
  } 
  
  
  if ((sURL.indexOf('.dot') >= 0) || (sURL.indexOf('.doc') >= 0)) 
  {
		var d = new Date();
		sURL += (sURL.indexOf('?') < 0) ? '?' : '&';
		sURL += "CADANPreventCachingCode=" + d.valueOf().toString();

	  // Word in een vast formaat
	  return showModalDialog (sURL, vArguments, "dialogwidth:668px;dialogheight:530px;center:yes;status:no;help:no;resizable:yes;");
  } 
  
 	// default naar Word
  // return OpenReportWizard(sURL, vArguments);
  
  if (sURL.indexOf('report_excel_href.asp') >= 0)	// !!!!!!!!!
  {
		var d = new Date();
		sURL += (sURL.indexOf('?') < 0) ? '?' : '&';
		sURL += "CADANPreventCachingCode=" + d.valueOf().toString();

		// op mijn (rolf) systeem proefondervindelijk omdat ik resize e.d. niet in de lucht krijg 
		window.open(sURL, '_blank', 'titlebar=no,directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,height=130px,width=280px,resizable=no,top=300,left=300');
		return;
  } 
  if (sURL.indexOf('report_exact_href.asp') >= 0)	// !!!!!!!!!
  {
		var d = new Date();
		sURL += (sURL.indexOf('?') < 0) ? '?' : '&';
		sURL += "CADANPreventCachingCode=" + d.valueOf().toString();

		// op mijn (rolf) systeem proefondervindelijk omdat ik resize e.d. niet in de lucht krijg 
		window.open(sURL, '_blank', 'titlebar=no,directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,height=130px,width=280px,resizable=no,top=300,left=300');
		return;
  } 

//  alert(sURL);
  if (sURL.indexOf('report_excel.asp') >= 0)	// !!!!!!!!!
  {
		var d = new Date();
		sURL += (sURL.indexOf('?') < 0) ? '?' : '&';
		sURL += "CADANPreventCachingCode=" + d.valueOf().toString();

//	  alert('xxx');
    
	  // Word in een vast formaat
	  return showModalDialog (sURL, vArguments, "dialogwidth:668px;dialogheight:530px;center:yes;status:no;help:no;resizable:yes;");
  } 
  
 	return OpenModalDialog(sURL, vArguments);
  
}
/*
' Function		: OpenReportWizard
' Description	: Creates a modal dialog box that displays the specified URL (IE only)
' Arguments		: in: string, arguments-object
' Returns		: the return value set in new page (window.returnValue) 
*/
function OpenReportWizard(sURL, vArguments)
{
	var d = new Date();
	sURL += (sURL.indexOf('?') < 0) ? '?' : '&';
	sURL += "CADANPreventCachingCode=" + d.valueOf().toString();
	
 // width en heigth worden bepaald vanuit de asp zelf door een span
 // deze waarden in tbl_configuratie aanpasbaar, maar kies de initiele waarde
 // een beetje in de buurt (maar niet groter) dan is er minder flikkering door 
 // resizen (span maakt 'm wel groter maar niet kleiner) ! 
 return showModalDialog (sURL, window, "dialogwidth:400px;dialogheight:350px;center:yes;status:no;help:no;resizable:no;");
}

/*
' Function		: OpenListModifierWindow
' Description	: Creates a modal dialog box that displays the specified URL (IE only)
' Arguments		: in: string, arguments-object
' Returns		: the return value set in new page (window.returnValue) 
*/
function OpenListModifierWindow(sURL, vArguments, iWidth, iHeight)
{
	var d = new Date();
	sURL += (sURL.indexOf('?') < 0) ? '?' : '&';
	sURL += "CADANPreventCachingCode=" + d.valueOf().toString();
	
  if (!iWidth) iWidth = 700;
  if (!iHeight) iHeight = 440;
  
  return showModalDialog (sURL, vArguments, "dialogwidth:" + iWidth.toString() + "px;dialogheight:" + iHeight.toString() + "px;center:yes;status:no;help:no;resizable:yes");
}


/*
' Function		: OpenModalDialog
' Description	: Creates a modal dialog box that displays the specified URL (IE only)
' Arguments		: in: string, arguments-object
' Returns		: the return value set in new page (window.returnValue) 
*/
function OpenModalDialog(sURL, vArguments, iWidth, iHeight)
{
	var d = new Date();
	sURL += (sURL.indexOf('?') < 0) ? '?' : '&';
	sURL += "CADANPreventCachingCode=" + d.valueOf().toString();
	
  if (!iWidth) iWidth = 100;
  if (!iHeight) iHeight = 100;
  
  return showModalDialog (sURL, vArguments, "dialogwidth:" + iWidth.toString() + "px;dialogheight:" + iHeight.toString() + "px;center:yes;status:no;help:no;resizable:yes");
}



/*
' Function		: IsModalDialog
' Description	: Is window opened in modal mode (with showModalDialog()) (IE only)
' Arguments		: wWindow - window object
' Returns		: boolean
*/
function IsModalDialog(wWindow)
{
	return (typeof(wWindow.dialogArguments) != "undefined");
}



/*
' Function		: LoadURLInModalDialog
' Description	: Replace the URL of an existing modal dialog (IE only)
' Arguments		: wWindow - window object
' Returns		: nothing
' Remarks		: does not work for IE6
*/
function LoadURLInModalDialog(wWindow, sNewURL)
{
	wWindow.open(sNewURL, "_self");	
	//wWindow.location.replace(sNewURL); werkt niet
}

function FindEventHandleOnClickTablePageDescrToShowCheckInput()
{
		var oFormElement = document.all;
    var bFirst = false;
    
		for (var j = 0; j < oFormElement.length; j++)
    {
      if ((oFormElement[j].tagName == 'TD') && (oFormElement[j].className == 'td_page_title'))
      {
      		if (bFirst == false)
		      	oFormElement[j].onclick = OnClickTablePageDescrToShowCheckInput;
          bFirst = true;  
      }
		}
}

function OnClickTablePageDescrToShowCheckInput()
{
	var oScriptCollection = ReturnScriptsArray(window.document);
  for (var i = 0; i < oScriptCollection.length; i++) {
		var sText = oScriptCollection[i].text;
    // om de zoek te misleiden
    var sTextToSearch = 'function' + ' CheckInput';
	 	if (sText.indexOf(sTextToSearch) > -1)
    {
    	// dit is het hele scriptgedeelte   
    	var iStart = sText.indexOf(sTextToSearch);
      var sTextVanaf = sText.substr(iStart);
      var sTextNextFunction = sText.substr(iStart + 9);
    	var iNext = sTextNextFunction.indexOf('function');
      var sTextVerder = sTextVanaf.substr(iNext);
			
      // nu houden we alleen de functie over      
      var sTextFunction = sText.substr(iStart, iNext + 9);
      alert(sTextFunction);
    }  
  }  
}


function XX_InDevelopmentMode()
{
	var bMode = false;
  var oScriptCollection = ReturnScriptsArray(window.document);
  var sSrc;
	for (var i = 0; i < oScriptCollection.length; i++) {
  	sSrc = oScriptCollection[i].src;
    if (sSrc.indexOf('programma_status.js') > -1) { // ja deze file
    	// dan kan ik de mode bepalen, zonder foutmelding
      // wil ik dus debugmode in JScript, dan zal ik programma_status.js
      // moeten opnemen !
      var sMode;
      sMode = RetrieveStringProgramStatus(GLOBAL_DEVELOPMENT_MODE)
      if (sMode == 'true') 
      	bMode = true;
      return bMode;
    }  
  }
  return bMode;
}

//function YY_StoreClientScreenGlobal()
// verhuist naar gebruiker_tree.asp ?
//{
//	// Scherm resolutie	
//  var iScreenHeight = screen.height;
//  var iScreenWidth = screen.width;
//  StoreStringProgramStatus(GLOBAL_SCREEN_RESOLTION, iScreenWidth.toString() + '*' + iScreenHeight.toString());
//}

/*
' Function		: ResizeModalDialogToFitControls 
' Description	: (IE only)
' Arguments		: 
' Returns		: 
*/
function ResizeModalDialogToFitControls(wWindow)
{

//	var sMode = GetConfigurationValue('development_mode');
  
	// Voor debug doeleinden, omdat deze functie bijna overal in de Onload staat !
  //if (InDevelopmentMode())
  //		FindEventHandleOnClickTablePageDescrToShowCheckInput();

	var iMinimumDialogWidth = 100;
	var iMinimumDialogHeight = 100;
	var iMaximumDialogWidth = 800;
	var iMaximumDialogHeight = 500; // iets minder dan 600 ivm knoppenbalk
  
  // wat voor resolutie heb ik ?
	// 800*600
  // 1024*768
  // 1152*864
	if ((screen.height >= 768) && (screen.width >= 1024))
  {
  	iMaximumDialogWidth = 1000;
  	iMaximumDialogHeight = 600;
  }  
  
	var iNewDialogWidth = wWindow.document.body.scrollWidth + 13; // verhoogd naar 13 ivm windows xp en extra groot font (was 8)
	if (iNewDialogWidth < iMinimumDialogWidth) iNewDialogWidth = iMinimumDialogWidth;
	if (iNewDialogWidth > iMaximumDialogWidth) iNewDialogWidth = iMaximumDialogWidth;

	var iNewDialogHeight = wWindow.document.body.scrollHeight + 44; // verhoogd naar 44 ivm windows xp en extra groot font (was 27)
	if (iNewDialogHeight < iMinimumDialogHeight) iNewDialogHeight = iMinimumDialogHeight;
	if (iNewDialogHeight > iMaximumDialogHeight) iNewDialogHeight = iMaximumDialogHeight;

	var iDeltaWidth = parseInt(wWindow.dialogWidth) - iNewDialogWidth;
	var iDeltaHeight = parseInt(wWindow.dialogHeight) - iNewDialogHeight;

	var iScreenX = parseInt(wWindow.dialogLeft);
	var iScreenY = parseInt(wWindow.dialogTop);
	
	// resize
	wWindow.dialogWidth = (iNewDialogWidth).toString() + "px";
	wWindow.dialogHeight = (iNewDialogHeight).toString() + "px";

//  alert(wWindow.dialogWidth);
//  alert(wWindow.dialogHeight);
  
	// center
	wWindow.dialogLeft = (iScreenX + Math.round(iDeltaWidth/2)).toString() + "px";
	wWindow.dialogTop = (iScreenY + Math.round(iDeltaHeight/2)).toString() + "px";

//  alert(wWindow.dialogLeft);
//	alert(wWindow.dialogTop);
  
	// als er een verticale scrollbar ontstaat, ontstaat daardoor ook een horizontale scrollbar
	// laat ons nog een beetje bij sizen om deze horizontale scrollbar weer kwijt te raken
  if (wWindow.document.body.scrollHeight > wWindow.document.body.offsetHeight) // hopelijk is dit 1 op 1 met er is een verticale scrollbar 
	{
  	iNewDialogWidth += 16;
  
  	// resize
  	wWindow.dialogWidth = (iNewDialogWidth).toString() + "px";
  	//wWindow.dialogHeight = (iNewDialogHeight).toString() + "px";
  
  	// center
  	//wWindow.dialogLeft = (iScreenX + Math.round(iDeltaWidth/2)).toString() + "px";
  	//wWindow.dialogTop = (iScreenY + Math.round(iDeltaHeight/2)).toString() + "px";
  	}
}


/*
' Function		: ShowURL 
' Description	: Open a new browser window with location = specified URL
' Arguments		: URL; if '://' not specified then it will be http://URL 
' Returns		: window ID
*/
function ShowURL(sURL)
{
  if (sURL == null) return null;
  if (sURL == '') return null;
  
  if (sURL.indexOf('://') < 0 )
    sURL = "http://" + sURL;
  return window.open(sURL);
}
