        jQuery.jQueryRandom = 0;
        jQuery.extend(jQuery.expr[":"], {
            random: function(a, i, m, r) {
                if (i == 0) {
                    jQuery.jQueryRandom = Math.floor(Math.random() * r.length);
                };
                return i == jQuery.jQueryRandom;
            }
        });
        $(document).ready(function() { 
            $('ul.sf-menu').superfish();
            $("#category_navigation h2").hoverIntent(
              function(el){
                $('#category_navigation ul li').effect("highlight", {color: "#9fc4f1"}, 1000);
              }, 
              function(){
                // $('#category_navigation').removeClass( "buy-now", 500 )
            }).tooltip({ effect: "fade", position: "center left"});
            $("#category_navigation h2")
            $('#videos a').colorbox({innerWidth:425, innerHeight:344, iframe:true});
            
            var galleryOptions = {
                width:347,
                height:347,
                autoplay: 4000, // will move forward every 5 seconds
                showImagenav: false,
                thumbnails: false,
                transition: 'fade',
                transitionSpeed: 1000,
                preload: 'all',
                imageCrop: true,
                dataSource: "#source",
                keepSource: true,
                imagePan: false,
                maxScaleRatio: 1
            };

            var images = $(".image_rotator");
            if(images.length != 0){
              $('#fallback_image').hide();
            }
            $("#source").append(images);
            $('#gallery').galleria(galleryOptions);
            
            $(".accordion_wrapper").accordion({
              autoHeight: false,
              changestart: function(event, ui) {
                var filter = ui.newHeader.attr("id");
                filter = (filter ? "." + filter : "img");
                var gallery = Galleria.get()[0];
                var source = $('#source '+ filter);
                var wrapper = $("<div></div>").append(source.clone());
                gallery.load(wrapper); 
              }
            });
            var productGallery = $('<div id="product_gallery" class="modal"></div>');
 
            $("body").append(productGallery);
            $('#product_gallery').hide();

            $("#product_gallery_show").colorbox({
              width: 600,
              height: 600,
              inline: true,
              href: $('#product_gallery'),
              onCleanup:function(){
                $('#product_gallery').hide('fast', function(){
                  $(this).html(''); // clear contents.
                })
              },
              onComplete:function(){

                $('#product_gallery').show('fast', function(){
                  $('#product_gallery').append($('.product_gallery_link').clone().map(function(){
                     $(this).find('img').attr('src', $(this).find('img').attr('src').replace('m_', 'l_'));
                     return this
                  }));
                  $('#product_gallery').galleria({
                      width:'600',
                      height:'600',
                      dataSelector: '.product_gallery_link img',
                      dataConfig: function(a) {
                          return {
                              image: $(a).attr('src').replace('m_', 'l_'),
                              original: $(a).attr('src').replace('m_', 'l_'), // tell Galleria that the href is the main image,
                              title: $(a).attr('alt') // use the anchor text for title
                          };
                      },
                      autoplay: 4000, // will move forward every 5 seconds
                      showImagenav: true,
                      thumbnails: true,
                      transition: 'fade',
                      transitionSpeed: 1000,
                      preload: 'all',
                      imageCrop: false
                  })
                });
              }
            })
          }); 
