﻿String.prototype.trim = function () { return this.replace(/^\s+|\s+$/, ''); };

$(document).ready(function () {


    //$(function () { $('#wijklijst').jScrollPane(); });


    //$("ul.sf-menu").supersubs({
    $(".sf-menu li ul").supersubs({
        minWidth: 12,   // minimum width of sub-menus in em units 
        maxWidth: 27,   // maximum width of sub-menus in em units 
        extraWidth: 1     // extra width can ensure lines don't sometimes turn over 
        // due to slight rounding differences and font-family 
    });

    //$("ul.sf-menu").supersubs({
    // minWidth:    12,   // minimum width of sub-menus in em units             
    // maxWidth:    27,   // maximum width of sub-menus in em units             
    // extraWidth:  1     // extra width can ensure lines don't sometimes turn over                                
    // // due to slight rounding differences and font-family         
    // }).superfish();  // call supersubs first, then superfish, so that subs are                          
    // // not display:none when measuring. Call before initialising                          // containing tabs for same reason. 

    $("ul.sf-menu").superfish({
        hoverClass: 'sfHover',          // the class applied to hovered list items 
        pathClass: 'ActiveMenuPath',       // the class you have applied to list items that lead to the current page 
        pathLevels: 1,                  // the number of levels of submenus that remain open or are restored using pathClass 
        delay: 600,                // the delay in milliseconds that the mouse can remain outside a submenu without it closing 
        animation: { opacity: 'show' },   // an object equivalent to first parameter of jQuery’s .animate() method 
        speed: 'fast',           // speed of the animation. Equivalent to second parameter of jQuery’s .animate() method 
        autoArrows: true,               // if true, arrow mark-up generated automatically = cleaner source code at expense of initialisation performance 
        dropShadows: true,               // completely disable drop shadows by setting this to false 
        disableHI: false,              // set to true to disable hoverIntent detection 
        // onInit:        function(){},       // callback function fires once Superfish is initialised – 'this' is the containing ul 
        // onBeforeShow:  function(){},       // callback function fires just before reveal animation begins – 'this' is the ul about to open 
        onShow: function () {
            // $('.sf-navbar > li > a.sf-with-ul').css("color", "red"); /* toegevoegd door rw, nadat de muis van het menu gaat worden deze kleuren gezet */
            // $('.ActiveMenuPathRoot').css("color", "blue");
            // $(this).parent().parent().css("color", "green");
            // $('.ActiveMenuPathRoot').css("background-image", "url(/images/tabgroenclosed.gif)");
            $('.sfHover > a').css("color", "black");
        },       // callback function fires once reveal animation completed – 'this' is the opened ul 
        onHide: function () {
            //$('.ActiveMenuPathRoot').css("background-image", "url(/images/taboranje.gif)");
        }        // callback function fires after a sub-menu has closed – 'this' is the ul that just closed 
    });


    //$('.sf-navbar > li > a.sf-with-ul').css("color", "Blue");

    /* om een flick in het menu op te lossen moet hier inderdaad 2x black, in superfish.js worden ook nog kleuren gezet */
    $(".sf-navbar > li > a.sf-with-ul").hover(
      function () {
          $(this).css("color", "black");
          $('.ActiveMenuPathRoot').css("background-image", "url(/images/tabgroenclosed.gif)");
          // $(".sf-navbar > .sfHover > a").css("color", "green");
      },
      function () {
          $(this).not('.ActiveMenuPathRoot').css("color", "black");
          // $(".sf-navbar > .sfHover > a").css("color", "black");
      }
    );



    $('.ActiveMenuPathRoot').hover(
      function () {
          $(this).css("background-image", "url(/images/tabgroenhi.gif)");
          $(this).css("color", "black");
      },
      function () {
          $(this).css("color", "black");
      }
     );

    $('.sfHover').css("color", "gray");

});




/* start de slideshow binnen de meegegeven container id  */
function StartSlideshow(containerId) {
    //alert(containerId);
    //bepaal de omvattende div
    var container = $("#" + containerId)[0];

    //bepaal aantal afbeeldingen
    var nslideshowimg = $("img", container).length;

    var pnlSlideShow = $(".slideshowElement", container);

    if (nslideshowimg > 1) {
        pnlSlideShow.cycle({
            fx: 'fade',
            timeout: 4000,
            speed: 750,
            before: onBefore
        });
    }
    else {
        $('.nav', container).hide();
    }

    $('.playpause', container).click(function () {
        $(this).toggleClass('play');
        $(slideshowid).cycle('toggle');

    });


    $('.next', container).click(
        function () {
           
            pnlSlideShow.cycle('next');
        }
    );

    $('.prev', container).click(
        function () {
            pnlSlideShow.cycle('prev');
        }
    );

        function onBefore() {
            //alert(this.src);
            if (this.alt != "") {
                $('.homebijschrift').show();
                $('.homebijschrift').html(this.alt);
            } else {
                $('.homebijschrift').hide();
            }
        }

       // function onAfter() { $('.homebijschrift').html("Scroll complete for:<br>" + this.src).append('<h3>' + this.alt + '</h3>'); }


    //    $('.playpause', container).hover(
    //        function () {
    //            $(this).addClass('hover');
    //        },
    //        function () {
    //            $(this).removeClass('hover');
    //        }
    //    )

}
