function PopUpWindow(Wurl,Wname,Wtoolbar,Wlocation,Wdirectories,Wstatus,Wmenubar,Wscrollbars,Wresizable,Wcopyhistory,_width,_height)
{
  Wtop  = (document.body.clientHeight-_height)/2;
  Wleft = (document.body.clientWidth-_width)/2
  nw = window.open(Wurl,Wname,"height="+_height+",width="+_width+",top="+Wtop+",left="+Wleft+",resizable="+Wresizable+",scrollbars="+Wscrollbars+",toolbar="+Wtoolbar+",menubar="+Wmenubar+",location="+Wlocation+",status="+Wstatus+",directories="+Wdirectories);
}

function addLoadEvent(func)
{
  var oldonload = window.onload;
  if (typeof window.onload != 'function')
  {
    window.onload = func;
  }
  else
  {
    window.onload = function()
    {
      if (oldonload)
      {
        oldonload();
      }
      func();
    }
  }
}

/*############################################################################*/
/*# Initialize */

function Sunglass_Initialize()
{
  //# Defined sizes for popupdiv types
  var aPopupDivSizes = new Array;
  aPopupDivSizes['popup'] = new Array;
  aPopupDivSizes['popup']['width'] = 752;
  aPopupDivSizes['popup']['height'] = 410;
  document['aPopupDivSizes'] = aPopupDivSizes;

  //# Create sunglassdiv and add onclick events
  if ('function' == typeof SUNGLASS_CreateSunglassPopup)
  {
    SUNGLASS_CreateSunglassPopup();
  }
  //# Create close popup links
  if ('function' == typeof SUNGLASS_InitClosePopupWindow)
  {
    SUNGLASS_InitClosePopupWindow();
  }
}



function HomePopupShow()
{
  //Sunglass_Initialize();
  //SUNGLASS_SunglassPopupShowType('http://www.starline.nl/popup.html','popup');
  //setTimeout('SUNGLASS_SunglassPopupHide();',5000);
}

/*# /Initialize */
/*############################################################################*/

if ('function' == typeof GoogleLoadMap)
{
  WHITE_AddLoadEvent(GoogleLoadMap);
}

/*# /Googlemaps */
/*############################################################################*/
var sToLocation = "Albert Quintinlaan, 3900 Overpelt";

function GoogleLoadMap() {
  var oGoogleMapDiv = WHITE_GetElementFlex('googleMaps');
  if ('object' == typeof oGoogleMapDiv)
  {
    if (GBrowserIsCompatible()) {
      var map = new GMap2(oGoogleMapDiv);
      var point = new GLatLng(51.2247101, 5.3825732);

      map.setCenter(point, 13);
      map.addControl(new GSmallMapControl());
      map.addControl(new GMapTypeControl());
      map.setMapType(G_NORMAL_MAP);

      /* Part for the directions */
      gdir = new GDirections(map, document.getElementById("googleMapsDirections"));
      GEvent.addListener(gdir, "error", handleErrors);
      /* End directions */

      var marker = new GMarker(point);
      var html = "<b>TVSFiber<\/b><br \/>Albert Quintinlaan 1605<br \/>3900 Overpelt ";
      GEvent.addListener(marker, 'click', function() { marker.openInfoWindowHtml(html); });

      map.addOverlay(marker);

      marker.openInfoWindowHtml(html);
    }
  }
}

function handleErrors(){
  if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
	 alert("Google heeft uw locatie niet kunnen vaststellen. De beste manier om de route te zoeken, is door het volgende formaat aan te houden: straatnaam nummer, plaats.");
	else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
	 alert("Er heeft zich een fout voor gedaan op de server van Google. Probeert u het nog een keer.\n Fout code code: " + gdir.getStatus().code);

else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
	 alert("De HTTP q parameter mist of heeft geen waarde.\n Fout code: " + gdir.getStatus().code);

	else if (gdir.getStatus().code == G_GEO_BAD_KEY)
  	alert("De opgegeven sleutel is niet geldig. \n Fout code: " + gdir.getStatus().code);

	else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
    alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);

	else alert("U heeft het veld 'Vertrekpunt' leeg gelaten. Deze is vereist om een route te plannen");
}

function setDirections(sFromAddress, locale) {
  gdir.load("from: " + sFromAddress +" to: "+sToLocation,{ "locale": locale });
}
