/*############################################################################*/
/*# Initialize */

function Main_Initialize()
{
  //Add search form default text
  var oForm = WHITE_GetElementFlex('searchform');
  if ('object' == typeof oForm)
  {
    WHITE_InitFieldExplanation('searchfield', 'zoek in deze site');
    WHITE_AddEvent(oForm, 'submit', WHITE_FormRemoveEplanationsEvent);
  }

  AddPrintButton();
  OpenCloseIntroPageInit();
  if (WHITE_GetElementFlex('map'))
  {
    GoogleLoadMap();
  }
  WHITE_InitAddBookmarkLinks();
}

if ('function' == typeof WHITE_AddBodyLoadFunction)
{
  WHITE_AddBodyLoadFunction(Main_Initialize);
}

/*# /Initialize
/*############################################################################*/
/*# Create printbutton */

function AddPrintButton()
{
  //if printbutton found
  var oPrintButton = WHITE_GetElementFlex('printbutton');
  if ('object' == typeof oPrintButton)
  {
    //add print event
    WHITE_AddEvent(oPrintButton, 'click', PrintWindowEvent);
  }
}

function PrintWindowEvent()
{
  window.print();
}

/*# /Create printbutton */
/*############################################################################*/
/*# Create open/close div's intro */

function OpenCloseIntroPageInit()
{
  var aIntroContentDivs = WHITE_GetElementsByClass(document, 'introcontentitems');
  for (var iNr1=0; iNr1 < aIntroContentDivs.length; iNr1++)
  {
    var oIntroContentDiv = aIntroContentDivs[iNr1];
    var aOpenCloseIntroDivs = WHITE_GetElementsByClass(oIntroContentDiv, 'menuitem_btn');
    for (var iNr2=0; iNr2 < aOpenCloseIntroDivs.length; iNr2++)
    {
      var oOpenCloseIntroDiv = aOpenCloseIntroDivs[iNr2];
      oOpenCloseIntroDiv['holder'] = oIntroContentDiv;
      WHITE_AddEvent(oOpenCloseIntroDiv, 'mouseover', MouseOverIntroPageEvent);
    }
  }
}

function MouseOverIntroPageEvent() {
  var oIntroContentDiv = this.holder;
  //# First close all contentdivs
  var aOpenCloseIntroTitleDivs = WHITE_GetElementsByClass(oIntroContentDiv, 'menuitem_content');
  for (var iNr=0; iNr < aOpenCloseIntroTitleDivs.length; iNr++)
  {
    var oOpenCloseIntroTitleDiv = aOpenCloseIntroTitleDivs[iNr];
    WHITE_AddClassName(oOpenCloseIntroTitleDiv, 'hidden');
  }

  //# Then remove highlight on titles
  var aOpenCloseIntroContentDivs = WHITE_GetElementsByClass(oIntroContentDiv, 'menuitem_btn');
  for (var iNr=0; iNr < aOpenCloseIntroContentDivs.length; iNr++)
  {
    var oOpenCloseIntroContentDiv = aOpenCloseIntroContentDivs[iNr];
    WHITE_RemoveClassName(oOpenCloseIntroContentDiv, 'menuitem_btn_open');
  }

  //# Highlight own item
  WHITE_AddClassName(this, 'menuitem_btn_open');

  //# Open contentdiv
  var oIntroContentDiv = WHITE_GetElementFlex(this.id + 'content');
  if ('object' == typeof oIntroContentDiv)
  {
    WHITE_RemoveClassName(oIntroContentDiv, 'hidden');
  }
}

/*# /Create open/close div's intro */
/*############################################################################*/
/*# Google maps function */

function GoogleLoadMap() {
  var oGoogleMapDiv = WHITE_GetElementFlex('map');
  if ('object' == typeof oGoogleMapDiv)
  {
    if (GBrowserIsCompatible()) 
    {
      var map = new GMap2(document.getElementById("map"));
      var point = new GLatLng(51.3405159, 5.4648763);

      map.setCenter(point, 13);
      map.addControl(new GSmallMapControl());
      map.addControl(new GMapTypeControl());
      map.setMapType(G_NORMAL_MAP);

      var marker = new GMarker(point);
      var html = "DFD De Financi&euml;le Dienstverleners B.V.<br \/>Dragonder 3<br \/>5554 GM Valkenswaard";
      GEvent.addListener(marker, 'click', function() { marker.openInfoWindowHtml(html); });

      map.addOverlay(marker);
      
      marker.openInfoWindowHtml(html);
    }
  }
}

/*# /Google maps function */
/*############################################################################*/
