       function _logStatus(text) {
         if ('undefined' != typeof console)
           if ('function' == typeof console.log)
             if ('object' == typeof text)
               console.log(text);
             else
               console.log('debug javascript: ' + text);
       };

       // for the curious visitor here: the server script checks for referer.
       // This is why you will find it returns false when you try to abuse it.
       var _mailFieldOk = {
         'srf_naam': 0,
         'srf_telefoon': 0,
         'srf_email': 0,
         'srf_reactie': 0
       };
       
       function setFormError(_field) {
         jQuery('#' + _field).css('background-color', '#c80039');
       }

       function removeFormError(_field) {
         jQuery('#' + _field).css('background-color', 'white');
       }

       function sendEmail() {
         _mailArgs = {
           'naam':     jQuery('#srf_naam').val(),
           'telefoon': jQuery('#srf_telefoon').val(),
           'email':    jQuery('#srf_email').val(),
           'reactie':  jQuery('#srf_reactie').val()
         };

         // validate fields (every value should be 1)
         _errorFound = false;
         jQuery.each(_mailFieldOk, function(_i, _value) {
           _logStatus('checking ' + _i + ', has value ' + _value);
           if (0 == _value) {
             setFormError(_i);
             _errorFound = true;
           }
         });
         if (_errorFound) {
           return false;
         }

         jQuery.get(
           _templateDir + 'sendmail.php',
           _mailArgs,
           function(data) {
             // alert(data);
             if ('OK' == data) {
               jQuery('#sendreactionform').html('<h2>Reactie verzonden</h2><p>Uw reactie is verzonden; wij nemen contact met u op.</p>');
             } else {
               jQuery('#sendreactionform').html('<h2>Oeps!</h2><p>Er is iets fout gegaan bij het verzenden. U kunt ons via <a href="mailto:info@kondar.nl">info@kondar.nl</a> een e-mail sturen.</p>');
             }
           }
         )
       }

       var _slidenr = 0;

       // callback function, called when next slide has been displayed
       function afterSlideDisplay(_currSlideElement, _nextSlideElement, _options, _forwardFlag) {
         jQuery("#slideshowcaption_" + _slidenr).animate({ 
           top: "201px"
         }, 800);
         setTimeout("nextSlide()", 8000);
       }

       function nextSlide() {
         jQuery("#slideshowcaption_" + _slidenr).animate({ 
           top: "400px"
         }, 800);
         _slidenr+=1;
         if (0 == jQuery("#slideshowcaption_" + _slidenr).length) {
           _slidenr = 0;
         }
         jQuery('.slideshow').cycle('next');
       }

       jQuery(window).ready( function() {

         // add superfish to menu
        jQuery('ul.sf-menu').superfish({ 
          delay:       500,                             // one second delay on mouseout 
          // animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation 
          animation:   {height: 'show'},
          speed:       300,                             // faster animation speed 
          autoArrows:  false,                           // disable generation of arrow mark-up 
          dropShadows: false                            // disable drop shadows 
        });
        
        // slider menu in content (on kahw-page e.g.)
        if (jQuery('#slides').length > 0) {
          // first, position the prev and next buttons for the slider
          var _slidesPos   = jQuery('#slides').offset();
          var _slidesRight = _slidesPos.left + parseInt(jQuery('#slides').css('width')) + 36;
          // alert(_slidesRight);
          jQuery('#sliderprev').css('top', _slidesPos.top).css('left', 0).show();
          jQuery('#slidernext').css('top', _slidesPos.top).css('left', _slidesRight).show();

          // let cycle plugin handle the scrolling
          jQuery('#slides').cycle({
            fx:      'scrollLeft',
            easing:  'easeInOutBack',
            timeout: 0,
            prev:    '#sliderprev',
            next:    '#slidernext'
          });
        }

        // make first level of menu non-clickable
        // jQuery('ul.sf-menu > li > a').click( function(e) { e.preventDefault(); });
        jQuery('ul.sf-menu > li > a').each( function() {
          jQuery(this).replaceWith(jQuery(this).text());
        });
        
        // jQuery('div#footermenu > ul > li > a').click( function(e) { e.preventDefault(); });
        jQuery('div#footermenu > ul > li > a').each( function() {
          jQuery(this).replaceWith(jQuery(this).text());
        });

        // event handler for form submit
        jQuery('#srf_submit').click(
          function() {
            sendEmail();
          }
        );

        // event handler to show inlog fields
        if (jQuery('#form_login')) {
          jQuery('#button_login').click(
            function() {
              jQuery('#form_login').toggle();
            }
          );
        } else {
          // TODO JNS
          // jQuery('#button_login').click(
          //   function() {
          //     jQuery("#logoutclick").click();
          //   }
          // );
        }

        // create slideshow in sub-upper right (subupper?)
        jQuery('.slideshow img.first').fadeIn(1000, function() {
          jQuery('.slideshow').cycle({
            fx:      'scrollLeft',
            easing:  'easeInOutBack',
            timeout: 0,
            after:   afterSlideDisplay
          })
        });

        // test email adres
        function validEmail(_email) {
          var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
          return pattern.test(_email);
        }

        function validTelephoneNr(_number) {
          var pattern = new RegExp(/^[0-9]{10}$/);
          return pattern.test(_number);
        }

        // default values of input fields
        _inputStrings = {
          "f_search_s":   "zoek",
          "srf_naam":     "Mijn naam",
          "srf_telefoon": "Mijn telefoonnummer",
          "srf_email":    "Mijn email adres",
          "srf_reactie":  "Mijn reactie"
        };

        // set event handler to remove values from input fields
        jQuery.each(_inputStrings, function(_index, _value) {
          jQuery('#' + _index).focus(
            function() {
              if (_value == jQuery('#' + _index).val()) {
                jQuery('#' + _index).val('');
                _mailFieldOk[_index] = 0;
              }
            }
          ).blur(
            function() {
              if ('' == jQuery('#' + _index).val()) {
                jQuery('#' + _index).val(_value);
                _mailFieldOk[_index] = 0;
              }
            }
          ).keyup(
            function() {
              _result = 1;
              _val    = jQuery('#' + _index).val();
              // something *in* the field?
              if ('' == _val) { _result = 0; }

              // email
              if (_index == "srf_email" && !validEmail(_val)) { _result = 0; }

              // telephone number
              if (_index == "srf_telefoon" && !validTelephoneNr(_val)) { _result = 0; }

              _mailFieldOk[_index] = _result;
              if (1 == _result) {
                // don't set the error style here, only remove it when it has been set in sendEmail()
                removeFormError(_index);
              }
            }
          );
        });
        
        // make nice table on employee overwiew page
        jQuery("#tableEmployees").tablesorter();

        // display promo text
        jQuery('#subheader img').fadeIn('slow'); // .css('display', 'block');
        jQuery('#subheader_promo_transp').fadeTo('slow', 0.75);
        jQuery('#subheader_promo_text').fadeIn('slow');

        // jQuery('#subheader img').fadeIn(
        //   'slow',
        //   function() {
        //     jQuery('#subheader_promo_transp').fadeIn(
        //       'slow',
        //       function() {
        //         jQuery('#subheader_promo_text').fadeIn('slow');
        //       }
        //     );
        //   }
        // );
      });

