
if( window.jQuery )  // Avoid more errors in IE 5.0
{
  // Directly set flag for CSS to indicate JavaScript is enabled.
  // At this point "HTML" is the only accessable element.
  $(document.documentElement).addClass("jsEnabled");

  $(document).ready( function() {


    // ---------------------------
    // Flash
    // Embed as soon as possible


    if( window.swfobject != null )
    {
      var objectAttr = { align: 'center' };
      var params = { allowscriptaccess: 'samedomain'
                   , allowfullScreen:   'false'
                   , quality:           'high'
                   , scale:             '100%'
                   //, salign:            't'            // must be below scale
                   , wmode:             'transparent'  // not supported in Linux
                   , bgcolor:           '#ffffff'
                   };

	  	// Flash at home page.
			var homevideo = document.getElementById('branding');
			if( homevideo != null )
			{
				swfobject.embedSWF( "/resources/swf/logo.swf", 'branding', '100%', '100%', '6.0.0'
													, '/resources/swf/logo.swf', objectAttr, params
													);
			}
    }


    // -------------------------------
    // Fix links

    // Geef links met rel="external" een target="_blank" attribuut.
    $(document.links).filter('[href][rel=external]').attr("target", "_blank");


    // --------------------------------
    // Form input label flip

    // Activeer 'overlabels' over compacte formulieren zoals het zoekscherm
    $('label.overlabel')
      .each( function()
      {
        // Get field
        var label = $(this);
        var id    = this.htmlFor || this.getAttribute('for');
        var field = null;
        if( ! id || ! (field = document.getElementById( id ) ) ) return;

        // Implement show/hide effect
        $(field).addClass("overlabel-js")                 // for setTimeout() below
                .focus( function() { label.hide(); } )
                .blur ( function() { this.value === '' && label.show(); } );

        // Also for mouse click
        label.mousedown( function() { setTimeout( function() { field.focus(); }, 20 ); } );
      }
    );

    // Hide overlabels after the form is auto-filled in by the browser.
    setTimeout( function()
    {
      var fields = $("input.overlabel-js");
      var labels = $("label.overlabel");
      fields.each( function() { this.value !== '' && labels.filter("[for=" + this.id + "]").hide(); } );
    }, 50 );


  } );
}



