function iNumberOfCheckedCheckboxes(objCheckboxGroup)
{
  var iAantalChecked = 0;

  if (typeof objCheckboxGroup == 'undefined')
  {
    alert('Updater: onbekend checkbox group object');
    iAantalChecked = 0;
  }
  else  
  {
    // als de checkboxgroup uit 1 radiobutton bestaat dan is de checkboxgroup helemaal
    // geen checkbox group maar 1 checkbox en dient dus als zodanig te worden behandeld. 
    if (typeof objCheckboxGroup.length == 'undefined')
    {
      iAantalChecked = objCheckboxGroup.checked?1:0;
    }
    else
    {
      var iNumberOfCheckboxes;
      iNumberOfCheckboxes = objCheckboxGroup.length;
    
      for (var i = 0; i < iNumberOfCheckboxes; i++)
      {
        if (objCheckboxGroup[i].checked)
        {
          iAantalChecked++;
        }
      }
    }
  }
  
  return iAantalChecked;
}


/*
function    : isLegalDate
description : checks if the given year, month, day form a legal date
arguments   : [in] iYear, the year (4 digits)
              [in] iMonth, the month (0=januari, 1=februari ... 11=december)
              [in] iDay, the day of the month (1=first day)
returns     : true if the given year, month, day form a legal date else false
*/
function isLegalDate(iYear, iMonth, iDay)
{
  // save the given date as a legal date
  var dDate = new Date(iYear, iMonth, iDay);
  // the date will be shifted to a legal date if it is illegal.
  // if the year, month and day are not the same as specified through the arguments
  // of this function then the date was shifted e.g. was illegal. 
  var getYear_dDate = (dDate.getYear()<1900)?dDate.getYear() + 1900:dDate.getYear();
  return ((iYear == getYear_dDate) && (iMonth == dDate.getMonth()) && (iDay == dDate.getDate()));
}

/*
' function    : isValidInteger
' description : returns true if the string is a integer
' arguments   : [in] sNumber
' returns     : true if the string contains a valid integer value and nothing but an integer value
'               else false
*/
function isValidInteger(sNumber)
{
  return ((parseInt(parseFloat(sNumber)) == parseFloat(sNumber)) && (!isNaN(sNumber)));
}

/*
' function  : isValidFilename
' overview  : checks if the filename is valid
' arguments : 
' return    : 
' example   : 
' note      : the filename may contain a path, which will be stripped before checking the filename (i.o.w. the )
*/
function isValidFilename(sFilename) {
  return ((/(^|\\|\/)(\w|:|\/| |\.|-)*\.([a-z]+)$/i).test(sFilename));
}


function TryBodyLoadHistoryBackIE()
{

	var sMessage = '';
  var oErrorMessage = document.getElementById('oFBError');
	if (oErrorMessage)
	{ // IE >= 5.5
    oErrorMessage.load('oXMLMessage');
  	sMessage = oErrorMessage.getAttribute('errorMessage');
	if (sMessage == null)
	  sMessage = '';
	}
  // voor IE < 5.5 
  if (sMessage == '')
  { if (window.navigator)
    { if (window.navigator.errorMessage)
	    { if (window.navigator.errorMessage > '')
			    // 'nav:' +
		      sMessage = window.navigator.errorMessage;
		  }
	  }
  }

	/* als je terug wilt komen op de 'verstuurd-div' dan deze code...
  if (sMessage > '')
  {
    if (arVraagOffBusyOn) // zet 'busy div' aan, 'vraag div' uit
   	{ for (i=0;i<arVraagOffBusyOn.length;i++)
      { try {eval(arVraagOffBusyOn[i])()} catch(e) {};
      }
   	}
    alert(sMessage);
	}	
  */	 
 
  if (oErrorMessage)
  { oErrorMessage.setAttribute('errorMessage','');
      oErrorMessage.save('oXMLMessage');
  }	
  if (window.navigator)
  { if (window.navigator.errorMessage)
	  { if (window.navigator.errorMessage > '')
				 window.navigator.errorMessage = '';
	  }
  }

  if (arVraagOnBusyOff) // zet 'vraag div' aan, 'busy div' uit
	{ for (i=0;i<arVraagOnBusyOff.length;i++)
     { try {eval(arVraagOnBusyOff[i])()} catch(e) {};
     }
	}	 

  if (sMessage > '')
	{
	 	if (window.attachEvent("onload", TryBodyLoadHistoryShowMessageAfterUnload) == true)
 		{
		 	sMessageAfterUnload = sMessage;
 		  sMessage = '';
		}
		else
		{
      alert(sMessage);
		}	
	}		 
 	
}

var sMessageAfterUnload = '';
function TryBodyLoadHistoryShowMessageAfterUnload()
{ 
  if (sMessageAfterUnload > '')
	{
    alert(sMessageAfterUnload);
		sMessageAfterUnload = ''; // for sure
	}
	window.detachEvent("onload", TryBodyLoadHistoryShowMessageAfterUnload);
}


function TryBodyLoadHistoryBackFF()
{
	var sMessage = '';
 	if (sessionStorage) // deze test levert een fout op in IE
 	{ // 'ff:' +
 		var sItem = sessionStorage.getItem('errorMessage');
		if (sItem != null)
 		  sMessage = sItem.toString();
			
 	  sessionStorage.setItem('errorMessage', '');
	}			

	/* als je terug wilt komen op de 'verstuurd-div' dan deze code...
  if (sMessage > '')
  {
    if (arVraagOffBusyOn) // zet 'busy div' aan, 'vraag div' uit
   	{ for (i=0;i<arVraagOffBusyOn.length;i++)
      { try {eval(arVraagOffBusyOn[i])()} catch(e) {};
      }
   	}
    alert(sMessage);
	}	
  */	
		
  if (arVraagOnBusyOff) // zet 'vraag div' aan, 'busy div' uit
	{ for (i=0;i<arVraagOnBusyOff.length;i++)
     { try {eval(arVraagOnBusyOff[i])()} catch(e) {};
     }
	}	 

	// Bij Firefox wordt TryBodyLoadHistoryBack in onshowpage aangeroepen
  if (sMessage > '')
  { // De pagina zal er (grotendeels) staan; nu de melding geven
    alert(sMessage);
	}		 
 	
}


// in arHistoryBack worden per formbuilder formulier de
// history.back code uitgevoerd (vooral voor firefox nodig)
function TryBodyLoadHistoryBack()
{
	var oP = document.body.parentElement; // IE
  var bIE = false;
	var bFF = true;
  if (oP)
  { bIE = true;
	  bFF = false; // zeer arbitrair
  }	
	
	if (bIE == true)
		TryBodyLoadHistoryBackIE();
		 
	if (bFF == true)
		TryBodyLoadHistoryBackFF();

}

var arScript = new Array();
function LoadScript(sUrl)
{
  for (var i=0; i<arScript.length;i++)
	{
	  if (sUrl == arScript[i]) return;
	}
	
	arScript[arScript.length] = sUrl;		

  var script = document.createElement('script');
  script.type = 'text/javascript';
  document.getElementsByTagName('head')[0].appendChild(script);
  script.src = sUrl; 
}
