  MeerShopsCollapsed = 0;
  MandjeCollapsed    = 0;
  MaxProductsPerCart = 10;
  MeerShopsLast      = 7;
  MeerShopsActive    = 0;
  CurrentCarouselAt  = -1;
  CarouselTimeOut    = null;
  myVote             = -1;
  numVotes           = -1;
  fading             = 0;
  fW                 = 900;
  fH                 = 600;
  shopId             = 0;
  revertPGOA         = null;
  orgh               = 0;
  prod               = '';
  version            = '2.3.29';
  perrorbarstatus    = 0;
  max_use_voorraad   = -1;
  jquery_loaded      = 0;
  lastWhereGreater   = -1;
  theMinAantal       = 1;
  
  function InitMeerShops(){
    if($("div#container-shopbrowser a.shop").size() > 8){
      $("div#container-shopbrowser a.links").show().click(function(){SwapMeerShops('links');});
      $("div#container-shopbrowser a.rechts").show().click(function(){SwapMeerShops('rechts');});
    }
    $("div#container-shopbrowser a.shop").each(function(a){
      if(a < 8){
        $(this).show();
      }
    });
  }
  
  function phpjs_urlencode (str) {
      str = (str + '').toString();
      return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').
      replace(/\)/g, '%29').replace(/\*/g, '%2A').replace(/%20/g, '+');
  }
  
  function SwapMeerShops(richting){
    $("#shopblocks").stop().animate({'opacity' : '0', 'top' : '100px'}, 300, function(){
      //$("#shopblocks").css({'top' : '-100px'});
      MeerShopsActive = 0;
      if(richting == 'links'){
        if(MeerShopsLast-7 > 0){
          $("div#container-shopbrowser a.shop").each(function(a){
            $(this).hide();
            if(a < MeerShopsLast-7 && a > (MeerShopsLast-16)){
              $(this).show();
              MeerShopsActive--;
              lastShop = a;
            }
          });
          MeerShopsLast = lastShop;
        }else{
          $("div#container-shopbrowser a.shop").each(function(a){
            if(! $(this).is(":hidden")){
              $(this).hide();
            }          
          });
        }
        if(MeerShopsActive+8 < 1){
          // Er is nog meer, dus OK!
        }else{
          // Geen 8, begin van de array
          shopRemainder = (MeerShopsActive+8);
          $("div#container-shopbrowser a.shop").each(function(a){
            if(a >= ($("div#container-shopbrowser a.shop").size()-shopRemainder)){
              $(this).show();
              lastShop = a;
            }
          });
          MeerShopsLast = lastShop+(8-shopRemainder);
        }
        $("#shopblocks").animate({'opacity' : '1', 'top' : '0px'}, 300);
      }else{
        $("div#container-shopbrowser a.shop").each(function(a){
          if(! $(this).is(":hidden")){
            $(this).hide();
          }          
          if(a > MeerShopsLast && a <= (MeerShopsLast+8)){
            $(this).show();
            MeerShopsActive++;
            lastShop = a;
          }
        });
        MeerShopsLast = lastShop;
        if(lastShop + 1 < $("div#container-shopbrowser a.shop").size()){
          // Er is nog meer, dus OK!
        }else{
          // Geen 8, einde van de array
          shopRemainder = 8-MeerShopsActive;
          $("div#container-shopbrowser a.shop").each(function(a){
            if(a < shopRemainder){
              $(this).show();
              lastShop = a;
            }
          });
          MeerShopsLast = lastShop;
        }
        $("#shopblocks").animate({'opacity' : '1', 'top' : '0px'}, 300);
      }
    });
  }

  function CartInit(){
    if($("div#productenlijst ul").size() > 0){
      UpdateCartLabel();
      $("#winkelmandje").css({'background-position' : '-468px 0px'});
      $("#winkelmandje a").attr('href', 'javascript:niets();');

      $("#winkelmandje").css({'cursor' : 'pointer'});
      $("div#productenlijst ul li.col3 a").unbind('click');
      $("div#productenlijst ul li.col3 a").click(function(){
        DeleteFromCart($(this).parent());
      });
      
      if($("div#productenlijst ul").size() > MaxProductsPerCart){
        $("#meerproducten").show();
        $("div#productenlijst ul").each(function(a,b){
          if(a >= MaxProductsPerCart){
            $(this).hide();
          }
        });
      }
    }
  }

  function CollapseMandje(rm){    
    if(MandjeCollapsed < 1){
      $("div#wkw-striptop").show();
      $("#overlay").css({'z-index' : '20', 'opacity' : '0', 'filter' : 'alpha(opacity=0)'}).show();
      MandjeCollapsed = 1;
      $("#winkelmandje-fix").show().animate({'top' : '0px'}, 400, function(){
        if(rm < 1){
          $("#winkelmandje").css({'background-position' : '-234px 0px'});
        }
      });
      $("#overlay, div#wkw-striptop").click(function(){
        MandjeCollapsed = 1;
        CollapseMandje(0);
        $("#overlay, div#wkw-striptop").unbind('click');
      });
    }else{
      $("#overlay").css({'z-index' : '980', 'opacity' : '.6', 'filter' : 'alpha(opacity=60)'}).hide();
      MandjeCollapsed = 0;
      if($("div#productenlijst ul").size() > 0){
        $("#winkelmandje-fix").animate({'top' : '-250px'}, 300, function(){
          if(rm < 1)
          {
            $("#winkelmandje").css({'background-position' : '-468px 0px'});
          }
          $("div#wkw-striptop").hide();
        });
      }else{
        $("#winkelmandje-fix").animate({'top' : '-250px'}, 300, function(){
          $("div#wkw-striptop").hide();
        });
      }
    }
  }

  function CollapseMeerShops(){
    if(MeerShopsCollapsed < 1){
      $("#shopbrowser-meer").css({'background-image' : 'url(/images/pijltje-down.png)', 'background-position' : 'center 4px'});
      $("#shopbrowser").animate({bottom: '0px', 'opacity' : '1', 'filter' : 'alpha(opacity=100)'}, 200);
      MeerShopsCollapsed = 1;
    }else{
      $("#shopbrowser-meer").css({'background-image' : 'url(/images/pijltje-up.png)', 'background-position' : 'center 5px'});
      $("#shopbrowser").animate({bottom: '-200px', 'opacity' : '.85', 'filter' : 'alpha(opacity=85)'}, 350);
      MeerShopsCollapsed = 0;
    }
  }
  
  function DeleteFromCart(a){
    var rmprod = 0;
    rmprod = a.parent().parent().find("ul").index(a.parent());
    $.post('/simple_ajax.php', {'rmprod' : rmprod }, function(d){
      // alert(d.r);
    }, "json");
    $(a).parent().remove();
    if($("div#productenlijst ul").size() >= MaxProductsPerCart){
      $("#meerproducten").show();
      $("div#productenlijst ul").each(function(a,b){
        if(a+1 == MaxProductsPerCart){
          $(this).show();
        }
      });
    }else{
      $("#meerproducten").hide();
    }
    if($("div#productenlijst ul").size() < 1){
      CollapseMandje(0);
      LeegMandje();
    }
    $("#winkelmandje-content").hide().show();
    UpdateCartLabel();
    update_spc_korting();
  }
  
  function MandjeClickable(){
    if($("div#productenlijst ul").size() > 0){
      $("#winkelmandje").unbind('click');
      $("#winkelmandje").click(function(){
        CollapseMandje(0);
      });
    }
  }
  
  function LeegMandje(){
    $("#winkelmandje").css({'background-position' : '0px 0px'});
    $("#winkelmandje").unbind('click');
    $("#winkelmandje").css({'cursor' : 'default'});
  }
  
  function UpdateCartLabel(){
    if($("div#productenlijst ul").size() > 0){
      if($("div#productenlijst ul").size() == 1){
        $("#winkelmandje a").html('<b>1 ' + (l('product')) + '</b>');
      }else{
        $("#winkelmandje a").html('<b>' + $("div#productenlijst ul").size() + ' ' + (l('producten')) + '</b>');
      }
      /*
      var totaalprijs = 0;
      
      $("div#productenlijst ul").each(function(a,b){
        var aantal = parseInt($(this).children().eq(0).html());
        var prijs  = parseFloat($(this).children().eq(3).html());
        var staffel = 1;
        if($(this).children().eq(4).length > 0)
        {
          var staffel = parseInt($(this).children().eq(4).val());
        }
        totaalprijs += aantal * prijs * staffel;
      });
      
      totaalprijs = number_format(totaalprijs, 2, ',', '.');
      
      $("#winkelmandje a").append(' <small>(' + l('currencyhtml') + '' + totaalprijs + ')</small>');
      */
      
      $.post('simple_ajax.php', { 'cartTotal' : '1' }, function(d){
        if(d.sum)
        {
          if(d.sum !== '0,00')
          {
            $("#winkelmandje a").append(' <small class="hide">(' + l('currencyhtml') + '' + d.sum + ')</small>');
            $("#winkelmandje a small").removeClass('hide').hide().fadeIn('fast');
          }
        }
      }, 'json');
    }else{
      $("#winkelmandje a").html('<b>' + ucfirst(l('winkelmandje')) + '</b>');
    }
  }
  
  function ucfirst(str) {
    str += '';
    var f = str.charAt(0).toUpperCase();
    return f + str.substr(1);
  }
  
  function l(label){
    if(shoplang[label]){
      return shoplang[label];
    }else{
      return '#lang_err#';
    }
  }
  
  function number_format( number, decimals, dec_point, thousands_sep ) {
    var n = number, prec = decimals;
    n = !isFinite(+n) ? 0 : +n;
    prec = !isFinite(+prec) ? 0 : Math.abs(prec);
    var sep = (typeof thousands_sep == "undefined") ? ',' : thousands_sep;
    var dec = (typeof dec_point == "undefined") ? '.' : dec_point;
    var s = (prec > 0) ? n.toFixed(prec) : Math.round(n).toFixed(prec); //fix for IE parseFloat(0.55).toFixed(0) = 0;
    var abs = Math.abs(n).toFixed(prec);
    var _, i;
    if (abs >= 1000) {
      _ = abs.split(/\D/);
      i = _[0].length % 3 || 3;
      _[0] = s.slice(0,i + (n < 0)) +
        _[0].slice(i).replace(/(\d{3})/g, sep+'$1');
      s = _.join(dec);
    }else{ s = s.replace('.', dec); }
    return s;
  }
  
  $(document).ready(function(){
    jquery_loaded = 1;
    $.ajaxSetup({async:true});
    
    if($("div#bgcontent").length > 0 && $("body#overlaybody").length < 1)
    {
      $.cookie('iPubShop.' + document.domain, 1);
      if($.cookie('iPubShop.' + document.domain) === null && l('cookiesblocked') !== '#lang_err#' && l('cookiesblocked') !== '')
      {
        alert(l('cookiesblocked'));
      }
    }
    
    fW = $(window).width()-100;
    fH = $(window).height()-100;

    CartInit();
    MandjeClickable();
    
    $("#shopbrowser").css({'bottom' : '-200px'});
    $("#shopbrowser-meer").click(function(){
      CollapseMeerShops();
    });
    
    $("div#leegmaken").hover(function(){$("div#leegmaken div.button-bg").addClass('button-bg-hover');},function(){$("div#leegmaken div.button-bg").removeClass('button-bg-hover');});
    $("div#checkout").hover(function(){$("div#checkout div.button-bg").addClass('button-bg-hover');},function(){$("div#checkout div.button-bg").removeClass('button-bg-hover');});
    
    
    $(".activator").each(function(a){      
    /*
      $(this).click(function(){
        $(this).effect('transfer', { to: "#winkelmandje", className: 'ui-effects-transfer' }, 650, function(){
          $("#meerproducten").before('<ul class="product"><li class="col1">100x</li><li class="col2">XXXX</li><li class="col3"><a class="delete" href="#"></a></li><li class="prijs">2</li></ul>');
          CartInit();
          MandjeClickable();
        });
      });
    */
      $(this).mouseover(function(){
        $(this).parent().addClass("product-bg-hover");
      }).mouseout(function(){
        $(this).parent().removeClass("product-bg-hover");
      });
    });
    
    setTimeout(function(){void(0);InitMeerShops();}, 100);
    
    if($("#carousell").size() > 0){
      $("#carousell").jqGalScroll();
      SwapTo();
    }
    
    $("#submenu li .hassub").each(function(){
      $(this).attr('href', 'javascript:menu();');
      addMenuClick($(this));
    });

    $("ul#submenu li ul.submenu-uitklap li.hasinner>a").each(function(){
      $(this).attr('href', 'javascript:menu();');
      addSubMenuClick($(this));
    });
    
    $("img.vlaggetje").each(function(a,b){
      $(this).parent().attr('alt', $(this).parent().attr('title'));
      $(this).parent().removeAttr('title');
      $(this).tooltip({
        track: true,
        delay: 0,
        showURL: false,
        top: -25,
        left: -2,
        positionLeft: true,
        bodyHandler: function() { 
          return '<div class="tt_left"><img src="/images/tooltip_left.png" /></div><div class="tt_main">' + $(b).parent().attr('alt') + '</div><div class="tt_right"><img src="/images/tooltip_right.png" /></div>'; 
        }
      });
    });
    
    $("img.tooltip").each(function(a,b){
      $(this).parent().attr('alt', $(this).parent().attr('title'));
      $(this).parent().removeAttr('title');
      $(this).tooltip({
        track: true,
        delay: 0,
        showURL: false,
        top: -31,
        left: 65,
        positionLeft: true,
        bodyHandler: function() { 
          return '<div class="tt_left"><img src="/images/tooltip_left.png" /></div><div class="tt_main">' + $(b).parent().attr('alt') + '</div><div class="tt_right"><img src="/images/tooltip_right.png" /></div>'; 
        }
      });
    });

    $("img.kleurhover").each(function(a,b){
      var c = $(this).attr('title');
      $(this).tooltip({
        track: true,
        delay: 0,
        showURL: false,
        top: -23,
        left: 2,
        bodyHandler: function() { 
          if($.browser.msie)
          {
            return '<div style="white-space: nowrap; padding: 2px; border: 1px solid #000; background-color: #fff; opacity: .92; filter:alpha(opacity=92); ">' + c + '</div>';  
          }else{
            return '<div class="tt_left"><img src="/images/tooltip_left.png" /></div><div class="tt_main">' + c + '</div><div class="tt_right"><img src="/images/tooltip_right.png" /></div>';
          }
        }
      });
    });


    $("img.vlaggetjeAD").each(function(a,b){
      var c = $(this).attr('title');
      $(this).tooltip({
        track: true,
        delay: 0,
        showURL: false,
        top: -37,
        left: 5,
        bodyHandler: function() { 
          return '<div style="white-space: nowrap; padding: 2px; border: 1px solid #000; background-color: #fff; opacity: .88; filter:alpha(opacity=88); ">' + c + '</div>'; 
        }
      });
    });
    

    $("div.plaatsinwinkelwagen a").live('mouseenter',function(){
      $("div.plaatsinwinkelwagen-bg").addClass('plaatsinwinkelwagen-bg-hover');
     }).live('mouseleave', function(){
      $("div.plaatsinwinkelwagen-bg").removeClass('plaatsinwinkelwagen-bg-hover');
     });
    
    $("div.product-bg a").live('mouseenter',function(){
      $(this).parent().addClass('product-bg-hover');
     }).live('mouseleave', function(){
      $(this).parent().removeClass('product-bg-hover');
     });
    
    if($("#myVote").val() > 0) myVote = $("#myVote").val();
    
    $("#rating a").removeAttr('title').each(function(a,b){
      $(this).hover(function(){
        if(numVotes < 0) numVotes = $("#rating a img.geel").size();
        for(i=0;i<a+1;i++){
          $("#rating a img:eq(" + i + ")").attr('src', '/images/rating-oranje.png');
        }
        for(i=a+1;i<5;i++){
          $("#rating a img:eq(" + i + ")").attr('src', '/images/rating-wit.png');
        }
      }, function(){
        if(myVote < 0){
          for(i=0;i<5;i++){
            vColor = 'wit';
            if(i < numVotes) vColor = 'geel';
            $("#rating a img:eq(" + i + ")").attr('src', '/images/rating-' + vColor + '.png');
          }
        }else{
          for(i=0;i<5;i++){
            vColor = 'wit';
            if(i < myVote) vColor = 'oranje';
            $("#rating a img:eq(" + i + ")").attr('src', '/images/rating-' + vColor + '.png');
          }          
        }
      }).click(function(){
        myVote = a+1;
        // Ajaxcall Rate
        theProduct = $("#productNo").val();
        $.post('/simple_ajax.php', { rating : myVote, product : theProduct }, function(data){
          // alert(data.r);
        }, "json");
      });
    });
    
    big = null;
    
    $("#zoomer").mousemove(function(e){
//      if(fading < 1){
//        $("#pics img.big").show();
//        $("#pics img.normal").hide();
//      }
      pad  = 15;
      var pos = $(this).offset();
      posl = parseInt(pos.left);
      post = parseInt(pos.top);
      x    = e.pageX-posl;
      y    = e.pageY-post;
      w    = $(this).width();
      h    = $(this).height();
      if(x < pad) x = pad;
      if(y < pad) y = pad;
      if(x > w-pad) x = w-pad;
      if(y > h-pad) y = h-pad;
      x    = x-pad;
      y    = y-pad;
      fX = Math.ceil(x / (w-(pad*2)) * 100);
      fY = Math.ceil(y / (h-(pad*2)) * 100);
      $(big).css({'margin-left' : '-' + fX + '%', 'margin-top' : '-' + fY + '%'})
    }).hover(function(){
      big  = $("#pics img.big");
      if(fading < 1){
        $("#pics img.big").show();
        $("#pics img.normal").hide();
      }
    }, function(){
      $("#pics img.normal").show();
      $("#pics img.big").hide();
    });
    
    if($("img.normal").length > 0){
      if($("img.big").length == 1 && $("img.normal").length == 1){
        $("#zoomer").show();
      }else{
        if($("div.pbrowser.show .big").length > 0){
          $("#zoomer").show();
        }
        $("#nav a").removeAttr('href').css({'cursor' : 'pointer'});
        $("#nav a#nav-prev.none").css({'cursor' : 'default'});
        $("#nav a#nav-next.none").css({'cursor' : 'default'});
        
        $("#nav a#nav-next").click(function(){
          if($("div.pbrowser.show").next().length > 0){
            if(fading < 1){
              fading = 1;
              $("div.pbrowser.show").next().show().find(".normal").hide().fadeIn("slow", function(){
                $("div.pbrowser.show").hide();
                $("div.pbrowser.show").removeClass('show').next().addClass('show');
                fading = 0;
                if($("div.pbrowser.show .big").length > 0){
                  $("#zoomer").show();
                }else{
                  $("#zoomer").hide();
                }
              });
              if($("div.pbrowser.show").next().next().length < 1){
                $("#nav-next").addClass("none").css({'cursor' : 'default'});
              }
              if($("div.pbrowser.show").length > 0){
                $("#nav-prev").removeClass("none").css({'cursor' : 'pointer'});
              }
            }
          }
        });
        $("#nav a#nav-prev").click(function(){
          if($("div.pbrowser.show").prev().length > 0){
            if(fading < 1){
              fading = 1;
              $("div.pbrowser.show").prev().show().next().find(".normal").fadeOut("slow", function(){
                $(this).parent().hide().removeClass("show").prev().addClass("show");
                fading = 0;
                if($("div.pbrowser.show .big").length > 0){
                  $("#zoomer").show();
                }else{
                  $("#zoomer").hide();
                }
              });
              if($("div.pbrowser.show").length > 0){
                $("#nav-next").removeClass("none").css({'cursor' : 'pointer'});
              }
              if($("div.pbrowser.show").prev().prev().length < 1){
                $("#nav-prev").addClass("none").css({'cursor' : 'default'});
              }
            }
          }
        });       
      }
    }
    
    $(".zoeken-knop").click(function(){
      $(this).hide();
      gotopos = 193;
      if($("input[name='slpos']").length > 0)
      {
        gotopos = $("input[name='slpos']").val();
      }
      
      $("#searchloader").css({'margin-left' : gotopos + 'px'});
    });
    
    if($("#colorpicker").length > 0)
    {
      var colorpicker = $.farbtastic("#colorpicker");
      $("#colorpicker").css({'opacity' : '0', 'filter' : 'alpha(opacity=0)'}).css({'display' : 'none'});
      $('.colorwell').focus(function(){
        $(this).css({'border-color' : '#000000'});
        $('#colorpicker').stop().css({'display' : 'block'}).animate({'opacity' : '1', 'filter' : 'alpha(opacity=100)'});
        colorpicker.linkTo(this);
      }).blur(function(){
      
      });
  
      $('.colorwell').each(function(){
        colorpicker.linkTo(this);
      });
      
      $("#switchcolors").removeAttr('href').addClass('pointer').click(function(){
        styleswitch(0,($('.colorwell:eq(0)').val()).substr(1),($('.colorwell:eq(1)').val()).substr(1),($('.colorwell:eq(2)').val()).substr(1),($('.colorwell:eq(3)').val()).substr(1));
      });
    }
    
    $("#carslnonjs").hide();
    $("#carsljs").show();
    
    $("div#faq fieldset div.content").hide();
    
    $("div#faq fieldset legend a").removeAttr('href');
    $("div#faq fieldset legend a").click(function(){
      $(this).parent().parent().find("div.content").slideToggle();
    });
    
    $("#bestel-content #sluiten").click(function(){
      $("#overlay-content").fadeOut(function(){
        $("#overlay").fadeOut();
      });
    });
    
    $("a button").click(function(){
      if($(this).parent().attr('href'))
      {
        document.location.href = $(this).parent().attr('href');
      }
    });
    
    $("a.iframe").fancybox({'width' : 625,'height' : 400, 'type' : 'iframe'});
    $("a.cartiframe").fancybox({'width' : 645,'height' : 400, 'type' : 'iframe' });
    
    $(".iframeWindow").fancybox({'width' : fW,'height' : fH, 'type' : 'iframe'});
    
    $("div#leegmaken a").click(function(){
      confirmClearCart();
    });
    
    $(".winkelwagen-content img.collapseimg").click(function(){
      $(this).parent().parent().find(".winkelwagen-beschrijving-extrainfo").slideToggle("fast");
    });

    $(".functies #leegmaken, .incartclearcart").click(function(){
      confirmClearCartS100();
    });
    $(".functies #printen").click(function(){
      printS();
    });
    
    $("div.winkelwagen-footer div#winkelwagen-nav div#volgende a").hover(function(){
      $("div.winkelwagen-footer div#winkelwagen-nav div#volgende div.button-bg.notrans").addClass("button-bg-hover");
    }, function(){
      $("div.winkelwagen-footer div#winkelwagen-nav div#volgende div.button-bg.notrans").removeClass("button-bg-hover");
    });
    $("div.winkelwagen-footer div#winkelwagen-nav div#vorige a").hover(function(){
      $("div.winkelwagen-footer div#winkelwagen-nav div#vorige div.button-bg.notrans").addClass("button-bg-hover");
    }, function(){
      $("div.winkelwagen-footer div#winkelwagen-nav div#vorige div.button-bg.notrans").removeClass("button-bg-hover");
    });
    
    $("#addkcode").click(function(){
      var kc = trim($("#kcode").val());
      $("p.error").hide(100, function(){
        $(this).remove();  
      });
      $.post('/simple_ajax.php', { 'kcode': kc }, function(kdata){
        if(kdata.rcode == 1)
        {
          $(".button-bg-klein").hide();
          $("#kcodeform").slideUp('fast', function(){
            $(".winkelwagen-item-rij-korting").slideDown('fast');
            $("span#thecode").html(trim($("#kcode").val()));
          });
        }else{
          setTimeout(function(){
            $("#kortingscoupon").before('<p class="error hide">' + kdata.rtxt + '</p>').prev().slideDown('fast');
            $("#kcode").focus().select();
          }, 125);
        }
      }, 'json');
    });
    
    $("#kcodegooiweg").click(function(){
      $(".winkelwagen-item-rij-korting").slideUp('fast', function(){
        $("#kcodeform").slideDown('fast', function(){
          $(".button-bg-klein").show();
          $.post('/simple_ajax.php', { 'kcode': 'remove' }, function(kdata){}, 'json');
        });
      });
    });
    
    $(".winkelwagen-aantal span").css({'cursor' : 'pointer'}).click(function(){
      $(this).hide();
      $(this).prev().prev().prev().show().focus().select();
    });
    
    $(".winkelwagen-aantal input").keydown(function(event){
      if(event.keyCode == 13){
        $(this).blur();
        return false;
      }
    });
    
    $(".winkelwagen-aantal input").blur(function(){
      $(this).hide();
      $(this).next().next().next().html('<img src="/images/ajax-loader.gif" id="numloader" alt="" />');
      var hash = $(this).next().next().val();
      var aant = $(this).val();
      var prod = $(this).next().val();
      var stprijs = $(this).next().next().next().next().val();
      $.post('/simple_ajax.php', { 'hash' : hash, 'aantal' : aant, 'prod' : prod, 'stprijs' : stprijs }, function(r){
        holdit = 0;
        if(r.bestelxkrijgy)
        {
          if(r.bestelxkrijgy > 0)
          {
            holdit = 1;
            document.location.href = document.location.href;
          }
        }
        
        if($("div.kassa.btwsplits").length > 0)
        {
          holdit = 1;
          document.location.href = document.location.href;
        }

        if(r.took_minaant > 0)
        {
          alert(sprintf(l('minverkoopaantal'), r.r));
        }
        
        if(holdit < 1)
        {
          kortingsobject = $("#numloader").parent().parent().parent().next().filter(".kortingsnotificatie");
          $("#numloader").parent().html(r.r).parent().parent().find(".winkelwagen-totaal b").html(l('currencyhtml') + ' ' + r.c).parent().prev().html(l('currencyhtml') + ' ' + r.stprijs);
          //.parent().parent().next().find(".winkelwagen-prijs").hide();
          
          if(kortingsobject.length > 0)
          {
            kortingsobject.find(".winkelwagen-totaal").html('<b>- ' + number_format(r.r * parseFloat(kortingsobject.find("input").val()), 2, ',', '') + '</b>');
          }
          
          $(".kassa span.bedrag-dik").html(l('currencyhtml') + ' ' + r.m);
          $(".kassa span.bedrag:eq(0)").html(l('currencyhtml') + ' ' + r.e);
          $(".kassa span.bedrag:eq(1)").html(l('currencyhtml') + ' ' + r.b);
          if($("b.origsum").length > 0)
          {
            $("b.origsum").html(l('currencyhtml') + ' ' + r.k1);
            $("b.kortingsum").html(l('currencyhtml') + ' ' + r.k2);
            $.each($('div.dev.padding.kortingsberekening span table tr:not(.th1px)'), function(a1d,b1d){
              $(this).find("td:last").html('&nbsp;&nbsp;&nbsp;&nbsp;...&nbsp;&nbsp;&nbsp;&nbsp;');
            });
            $.post('/s/100', {}, function(m){
              m2 = $(m).find('div.dev.padding.kortingsberekening span table');
              if(m2.length > 0)
              {
                $('div.dev.padding.kortingsberekening span table').html(m2.html());
              }
            }, 'html');
          }
          
          //$("#winkelmandje a small").html(' (' + l('currencyhtml') + r.k1 + ')');
          $("#winkelmandje a small").fadeOut('200', function(){
            UpdateCartLabel();
          });
          
          var tPrm = r.m;
          tPrm = (tPrm.replace(/,/, ".") * 100);
          if(tPrm > $("#minordercent").val()-1)
          {
            $(".minorderbedrag").hide();
            $(".minorderbedrag2").show();
          }else{
            $(".minorderbedrag").show();
            $(".minorderbedrag2").hide();         
          }
          if(r.voorraadmod)
          {
            if(r.voorraadmod[0] > 0)
            {
              alert(l('artikelmaxvoorraad').replace(/%/, r.voorraadmod[1]));
            }
          }
        }
        update_spc_korting();
      }, 'json');
      $(this).next().next().next().show();
    });
    
    $("#afhb").change(function(){
      $.post('/simple_ajax.php', { 'hybridvmethod' : $(this).val() }, function(r){
        $("#afhb").parent().parent().click();
      });
    });
    
    $("#bestelmethode li").click(function(){
      $("#bestelmethode li").removeClass("hover").addClass("semihidden");
      $(this).addClass("hover").removeClass("semihidden");
      var vmeth = $(this).find("input").val();
      $.post('/simple_ajax.php', { 'vmethod' : vmeth }, function(r){
        vmeth_enable = 1;
        
        if(vmeth == 1)
        {
          // alert('123');
          if($("#afhb").val() < 1)
          {
            vmeth_enable = 0;
          }else{
            //alert('submit');
          }
        }
        
        if(vmeth_enable > 0)
        {
          $(".winkelwagen-footer #volgende .button-bg").next().unbind('click');
          $(".winkelwagen-footer #volgende").removeClass("nocursor").addClass("pointer");
          $(".winkelwagen-footer #volgende .button-bg").removeClass("semitrans").addClass("notrans").next().attr('href','/s/102');
        }else{
          $(".winkelwagen-footer #volgende .button-bg").next().click(function(){
            //alert(l('hybridmnk'));
            if(perrorbarstatus < 1)
            {
              perrorbarstatus = 1;
              $.scrollTo($('h1'), 500, function(){
                $("#progresscontent").before('<p class="error">' + l('hybridmnk') + '</p>');
                $("p.error").hide().slideDown();
                setTimeout(function(){
                  $("p.error").slideUp(function(){
                    perrorbarstatus = 0;
                    $(this).remove();
                  });
                }, 5000);
              });
            }
          });
          $(".winkelwagen-footer #volgende .button-bg").next().removeAttr('href');
          $(".winkelwagen-footer #volgende .button-bg").removeClass("notrans").addClass("semitrans");
          $(".winkelwagen-footer #volgende").removeClass("pointer").addClass("nocursor");
        }
      }, 'json');
    });
    
    $("#bestelmethode li.firstclick").click();
    
    $("#NCOLPP").hide();
  
    animatingaddP = 0;

    if($("#wwrijlsprodcontainer.noslide").length < 1){
      $("#wwrijlmprodcontainer").hover(function(){
        if(animatingaddP < 1){
          animatingaddP = 1;
          $("#wwrijlsprod").slideUp('fast', function(){
            animatingaddM = 0;
          });
          $("#wwrijlmprod").slideDown('fast', function(){
            animatingaddP = 0;
          });
        }
      },function(){
        if(animatingaddP < 1){
          animatingaddP = 1;
          $("#wwrijlmprod").slideUp('fast', function(){
            animatingaddP = 0;
          });
        }
      });
    }
      
    $("#wwrijlmprod").click(function(){
      document.location.href = '/s/100&addlma=true';
    });

    animatingaddM = 0;
    
    if($("#wwrijlsprodcontainer.noslide").length < 1){
      $("#wwrijlsprodcontainer").hover(function(){
        if(animatingaddM < 1){
          animatingaddM = 1;
          $("#wwrijlmprod").slideUp('fast', function(){
            animatingaddP = 0;
          });
          $("#wwrijlsprod").slideDown('fast', function(){
            animatingaddM = 0;
          });
        }
      },function(){
        if(animatingaddM < 1){
          animatingaddM = 1;
          $("#wwrijlsprod").slideUp('fast', function(){
            animatingaddM = 0;
          });
        }
      });
    }
    
    $("#wwrijlsprod .winkelwagen-item-rij:last").addClass('noborder');
    
    $("#wwrijlsprod .winkelwagen-item-rij").click(function(){
      document.location.href = '/s/100&addxprod=' + $(this).find("input").val();
    });
    
    $("#productkleurmaatopties .kleuren img.hoverdeze").hover(function(){
      $(this).attr("src", "/images/prod-lijst-kleur_over.png");
    },function(){
      $(this).attr("src", "/images/prod-lijst-kleur.png");
    });
    
    // $("#productkleurmaatopties").fancybox({"width" : 645,"height" : 400, 'type' : 'iframe'});
    
    var chatDiv    = $("#chat-init");
    var chatTopPos = $(chatDiv).offset().top;

    var topChatSpc = $("#chat-init-above");
    var chatFixed  = $("#chat-fixed");
    
    $(window).scroll(function(){
      if($(window).scrollTop() >= chatTopPos-20)
      {
        $(chatDiv).css({'top' : '20px', 'position' : 'fixed' });
        chatFixed.show();
        topChatSpc.show();
      }else{
        if($(chatDiv).css('position') == 'fixed')
        {
          topChatSpc.hide();
          chatFixed.hide();
          $(chatDiv).css({'top' : '0px', 'position' : 'relative' });
        }
      }  
    });
    
    $("#alv").click(function(){
      window.open('/plugins/pdf-conditions', 'blank');
    });
    
    $(".plaatsinwinkelwagen.geenproductopties a").removeAttr('href').css({'cursor' : 'pointer'});
    
    $(".plaatsinwinkelwagen.geenproductopties").hover(function(){
      clearTimeout(revertPGOA);
      var curh = parseInt($(".no-opts-aantal").css('marginTop').replace(/px/, ''));
      if(orgh < 1) orgh = curh;
      $(".no-opts-aantal").stop().animate({'marginTop' : (orgh + 35) + 'px'}, 200);
    },function(){
      revert_ProductGeenOptiesAantal();
    });
    
    $(".no-opts-aantal").hover(function(){
      clearTimeout(revertPGOA);
    },function(){
      revert_ProductGeenOptiesAantal();
    });
    
	$(".no-opts-aantal .minder").click(function(){
      var newaant = $(".no-opts-aantal input#go-aantal").val();

      if($("input#theMinAantal").length > 0 && $("input#theMinAantal").val() > 0) theMinAantal = parseInt($("input#theMinAantal").val());
      if(newaant <= theMinAantal) newaant = theMinAantal+1;

      newaant = parseInt(newaant);
      if(newaant > 0 && newaant < 99999) {}
      else {
          newaant = 1;
      }
      newaant = newaant-1;
      if(newaant < 1) newaant = 1;
      $(".no-opts-aantal input#go-aantal").val(newaant);
      
      calcStaffelPrijs(newaant);
      
    });
	
	$(".no-opts-aantal .meer").click(function(){
      var newaant = $(".no-opts-aantal input#go-aantal").val();
      newaant = parseInt(newaant);
      if(newaant > 0 && newaant < 99999) {}
      else {
          newaant = 1;
      }
      newaant = newaant+1;
      if(newaant > 99999) newaant = 99999;
      $(".no-opts-aantal input#go-aantal").val(newaant);
      
      calcStaffelPrijs(newaant);
      
	});
    
    $(".no-opts-aantal input#go-aantal").bind('keyup', function(e){
      if(e.keyCode && ( e.keyCode == 40 || e.keyCode == 38 ) )
      {
        if(e.keyCode == 40)
        {
          $(".no-opts-aantal .minder").click();
          return false;
        }else{
          $(".no-opts-aantal .meer").click();
          return false;
        }
      }else{      
        var newaant = $(".no-opts-aantal input#go-aantal").val();
        newaant = parseInt(newaant);
        if(newaant > 0 && newaant < 99999) {}
        else {
          newaant = 0;
        }
        if(newaant > 99999) newaant = 99999;
        $(".no-opts-aantal input#go-aantal").val(newaant == 0 ? '' : newaant);
  
        calcStaffelPrijs(newaant);
      }
    }).blur(function(){
      var newaant = $(this).val();
      if(newaant == '')
      {
        $(".no-opts-aantal .minder").click();
      }      
      theMinAantal = 1;
      if($("input#theMinAantal").length > 0 && $("input#theMinAantal").val() > 0) theMinAantal = parseInt($("input#theMinAantal").val());
      var newaant = $(this).val();
      newaant = parseInt(newaant);
      if(newaant < theMinAantal || isNaN(newaant))
      {
        newaant = theMinAantal ;
        alert(sprintf(l('minverkoopaantal'), theMinAantal));
        $(this).val(theMinAantal);
      }		      
    });
    
    $(".no-opts-aantal a, .plaatsinwinkelwagen.geenproductopties a").click(function(){
      var newaant = $(".no-opts-aantal input#go-aantal").val();
      newaant = parseInt(newaant);
      if(newaant > 0 && newaant < 99999) {}
      else {
        newaant = 1;
      }

      var params = {};
      params.aantal = newaant;
      
      if($(".s-optieveld").length > 0)
      {
        params.optie = $(".s-optieveld").val();
      }
      if($(".s-kleur").length > 0)
      {
        params.kleur = $(".s-kleur").val();
      }
      if(params.aantal && max_use_voorraad > -1 && max_use_voorraad < params.aantal)
      {
        alert(l('artikelmaxvoorraad').replace(/%/, max_use_voorraad));
        $(".no-opts-aantal input#go-aantal").val(max_use_voorraad);
      }else{
        $(".no-opts-aantal").stop().animate({'marginTop' : (orgh) + 'px'}, 150);
        iframeclose(1,newaant,parseFloat($("#prodprijs").val()),$("#productNo").val());
        $.post("/o/cart/" + $("#productNo").val(), params, function(d){}, 'json');
      }
    });

    if($(".bekeken.verwant").length > 0 && $(".bekeken.laatstbekeken").length < 1){
      $(".verwant").fadeIn();
    }

    if($(".bekeken.verwant").length > 0 && $(".bekeken.laatstbekeken").length > 0){
      $(".bekeken.verwant").prev().remove().prev().remove();
      $(".bekeken.laatstbekeken h2").html('<span class="vw">' + $(".bekeken.verwant h2").html() + '</span>' + '<span class="lb">' + $(".bekeken.laatstbekeken h2").html() + '</span>');
      $(".bekeken.verwant h2").remove();
      $(".bekeken.laatstbekeken div.prodcontainer").after($(".bekeken.verwant").html());
      $(".bekeken.verwant").remove();
      $(".bekeken.laatstbekeken h2 span:eq(1)").click(function(){
        $(this).css({ 'color' : '#000' });
        $(".bekeken.laatstbekeken h2 span:eq(0)").css({ 'color' : '#ccc' });
        $(".bekeken.laatstbekeken div.prodcontainer:eq(1)").fadeOut();
        $(".bekeken.laatstbekeken div.prodcontainer:eq(0)").fadeIn();
      });
      $(".bekeken.laatstbekeken h2 span:eq(0)").click(function(){
        $(this).css({ 'color' : '#000' });
        $(".bekeken.laatstbekeken h2 span:eq(1)").css({ 'color' : '#ccc' });
        $(".bekeken.laatstbekeken div.prodcontainer:eq(0)").fadeOut();
        $(".bekeken.laatstbekeken div.prodcontainer:eq(1)").fadeIn();
      });
    }
    
    $("span.inline-order-form input").live('click', function(){
      $(this).select();
    });
        
    $("span.inline-order-form img").live('click', function(){
      newaant = parseInt($(this).parent().find("input").val());
      if(newaant > 0 && newaant < 9999) {}
      else {
        newaant = 1;
      }
      
      var params = {};
      params.aantal = newaant;

      if($(this).parent().find("input[name='kleur']").val().length > 0 && $(this).parent().find("input[name='kleur']").val() !== "")
      {
        params.kleur = $(this).parent().find("input[name='kleur']").val();
      }
      if($(this).parent().find("input[name='optie']").val().length > 0 && $(this).parent().find("input[name='optie']").val() !== "")
      {
        params.optie = $(this).parent().find("input[name='optie']").val();
      }

      $.post("/o/cart/" + $(this).parent().find("input").attr('name'), params, function(d){}, 'json');
      // alert(newaant);
      // alert($(this).parent().parent().find(".prod-lijst-prijs").html().replace(/,/, "."));
      // alert($(this).parent().find("input").attr('name'));
      // alert($(this).parent().parent().find("a").html());
      iframeclose(2,newaant,$(this).parent().parent().find(".prod-lijst-prijs").html().replace(/,/, "."),$(this).parent().find("input").attr('name'), this, $(this).parent().parent().find("a").html());
    });
    
    if($(".voorraadcheck-button").length > 0)
    {
      $.post('simple_ajax.php', { 'VoorraadAanwezig' : $("#artcode").val() }, function(d){
        //alert(d.voorraad);
        if(d.voorraad > 0)
        {
          $(".voorraadcheck-button").fadeOut('fast', function(){
            $(this).remove();
            $(".geenvoorraad-button").remove();
            $(".hidebutton").fadeIn('slow');
          });
        }else{
          $(".voorraadcheck-button").fadeOut('fast', function(){
            $(this).remove();
            $(".geenvoorraad-button").fadeIn('slow');
          });
        }
        max_use_voorraad = d.voorraad;
      }, 'json');
    }
    
    $("div.savedcartlinecontainer").hover(function(){
      $(this).find("a.deletesavedcart").stop(true, true).fadeIn();
    }, function(){
      $(this).find("a.deletesavedcart").stop(true, true).fadeOut();
    });    
    
    $("textarea.orderopmerking").bind('focus', function(){
      if($(this).val() == l('geefopmerkingop'))
      {
        $(this).val('').addClass('blacktext');
      }
    }).bind('blur', function(){
      if($(this).val() == l('geefopmerkingop') || trim($(this).val()) == '')
      {
        $(this).val(l('geefopmerkingop')).removeClass('blacktext');
      }
      $(this).val(str_replace("\t", "", str_replace("\r", "", str_replace("\n", "", $(this).val()))));
    }).bind('keydown', function(e){
      if(e.keyCode == 13)
      {
        return false;
      }else{
        if(e.keyCode == 86 && (e.ctrlKey || e.metaKey))
        {
          return false;
        }
      }
    }).bind('keyup', function(){
      thel = $(this).val().length;
      if(thel > 150)
      {
        $(this).val($(this).val().substr(0, 150));
        thel = 150;
      }
      $(".counter.flright").html('(' + thel + '/150)');
    });
    
    $(".default.geenvoorraad-button.logeerstin.nietinassortiment").click(function(){
      $(".nietinassortitxt").fadeIn('slow');
    });

    $("h2#h_stocklocations").css({ 'cursor' : 'pointer' }).click(function(){
      if($(this).parent().filter('.collapsed').length > 0)
      {
        $(this).parent().slideUp('fast', function(){
          $(this).removeClass('collapsed').slideDown('fast');
        });
      }else{
        $(this).parent().slideUp('fast', function(){
          $(this).addClass('collapsed').slideDown('fast');
        });
      }
    });
    
    $("div.delfavo").live('click', function(){
      document.location.href = '/s/22/&delFav=' + $(this).attr('rel');
    });
    
    $("div#addtofavs").click(function(){
      $(this).effect('transfer', { to: "#favorieten-button", className: 'ui-effects-transfer' }, 750, function(){
        $.get('simple_ajax.php?addFav=' + $("input#artcode").val(), function(d){}, 'text');
      });
    });
    
    $("tr[href]").click(function(){
      document.location.href = $(this).attr('href');
    });
    
    $("span.inputcb").click(function(){
      $("input.inputcb").click();
    });
    
    $("div.weergavecontainer div.view a").click(function(){
      $("div.weergavecontainer div.view a").attr('id', '');
      $(this).attr('id', 'active');
      appendViewAClick = '';
      if($(this).hasClass('clearall')){
        $(this).removeClass('clearall');
        appendViewAClick = "&clearfilter=1";
        $("p.r-emptymenu.r-nothingfound").remove();
      }else{
        appendViewAClick = "&ajax=1";
      }
      clickObj = $(this);
      $("div.greyoutcontainer").addClass('halfOpacity');
      $.post($(this).attr('href') + appendViewAClick, {}, function(d){
        if($(d).find("p[numresults]").length == 1 && $(d).find("p[numresults]").attr('numresults') !== '0' && $(".r-emptymenu.r-nothingfound").length < 0){
          $("div#content-midden p:eq(0)").html($(d).find("div#content-midden p:eq(0)").html());
        }
        
        cObj = $(
          "div#content-midden ul.productlijst-groot, " +
          "div#content-midden ul.productlijst-klein, " +
          "div#content-midden div.diverse-producten, " +
          "div#content-midden div#grid-bekeken,      " +
          "div#content-midden div.custom-prod-view   "
        );
        
        if(clickObj.attr('class') == 'default') aObj = '<ul class="productlijst-groot"></ul>';
        if(clickObj.attr('class') == 'list')    aObj = '<ul class="productlijst-klein"></ul>';
        if(clickObj.attr('class') == 'blocks')  aObj = '<div class="diverse-producten"></div>';
        if(clickObj.attr('class') == 'grid')    aObj = '<div id="grid-bekeken"></div>';
        if(clickObj.attr('class') == 'custom')  aObj = '<div class="custom-prod-view"></div>';
        
        //  aObj = '<ul class="productlijst-groot"></ul>';
        //  $("div#content-midden p:eq(0)").html('<a href="javascript: slideOut();" class="filters" id="filterarikelen">' + l('filterkenm') + '</a>');
        //}
        
        cObj.after(aObj);
        cObj.eq(0).remove();
        
        $(
            "div#content-midden ul.productlijst-groot, " +
            "div#content-midden ul.productlijst-klein, " +
            "div#content-midden div.diverse-producten, " +
            "div#content-midden div#grid-bekeken,      " +
            "div#content-midden div.custom-prod-view   "
          ).html($(d).find(
            "div#content-midden ul.productlijst-groot, " +
            "div#content-midden ul.productlijst-klein, " +
            "div#content-midden div.diverse-producten, " +
            "div#content-midden div#grid-bekeken,      " +
            "div#content-midden div.custom-prod-view   "
          ).html());
        if($(d).find("p[numresults]").length == 1 && $(d).find("p[numresults]").attr('numresults') !== '0' && $(".r-emptymenu.r-nothingfound").length < 0){
          $("p.r-emptymenu.r-nothingfound").remove();
        }
        $("div.greyoutcontainer").removeClass('halfOpacity');
      }, 'html');
      return false;
    });
    
    $("div.weergavecontainer div.center>a.sorter, div.weergavecontainer div.center>a.perpage").click(function(){
      if($(this).hasClass('sorter'))  $("div.weergavecontainer div.center>a.sorter").removeClass('active');
      if($(this).hasClass('perpage')) $("div.weergavecontainer div.center>a.perpage").removeClass('active');
      $(this).addClass('active');
      clickObj = $(this);
      $("div.greyoutcontainer").addClass('halfOpacity');
      $.post($(this).attr('href') + "&ajax=1", {}, function(d){
        if($(d).find("p[numresults]").length == 1 && $(d).find("p[numresults]").attr('numresults') !== '0' /* && $(".r-emptymenu.r-nothingfound").length < 0 */){
          $("div#content-midden p:eq(0)").html($(d).find("div#content-midden p:eq(0)").html());
        }
        $(
            "div#content-midden ul.productlijst-groot, " +
            "div#content-midden ul.productlijst-klein, " +
            "div#content-midden div.diverse-producten, " +
            "div#content-midden div#grid-bekeken,      " +
            "div#content-midden div.custom-prod-view   "
          ).html($(d).find(
            "div#content-midden ul.productlijst-groot, " +
            "div#content-midden ul.productlijst-klein, " +
            "div#content-midden div.diverse-producten, " +
            "div#content-midden div#grid-bekeken,      " +
            "div#content-midden div.custom-prod-view   "
          ).html());
        $("div#content-midden div.abspaginatecontainer").html($(d).find("div.abspaginatecontainer").html());
        if($(d).find("p[numresults]").length == 1 && $(d).find("p[numresults]").attr('numresults') !== '0' && $(".r-emptymenu.r-nothingfound").length < 0){
          $("p.r-emptymenu.r-nothingfound").remove();
        }
        $("div.greyoutcontainer").removeClass('halfOpacity');
        $("p.firsttextelement").html($(d).find("p.firsttextelement").html());
      }, 'html');
      return false;
    });
    
    $("div#filterkenmerken form input[type='checkbox']").click(function(){
      applyFilters();
    });
    
    $("div#filterkenmerken h3").click(function(){
      if($(this).parent().next().find("li").length > 0)
      {
        if($(this).parent().next().find("li.active").length > 0){
          $(this).parent().next().find("li").removeClass('active').addClass('notactive');
          $(this).parent().next().find("a").removeClass('active').addClass('notactive');
          $(this).parent().next().find("input").attr('disabled', true);
        }else{
          $(this).parent().next().find("li").removeClass('notactive').addClass('active');
          $(this).parent().next().find("a").removeClass('notactive').addClass('active');
          $(this).parent().next().find("input").removeAttr('disabled');
        }
      }else{
        if($(this).parent().find("input:checked").length > 0){
          $(this).parent().find("input").attr('checked', false);
        }else{
          $(this).parent().find("input").attr('checked', true);
        }
      }
      applyFilters();
    });
    
    if($('input.zoeken').length > 0)
    {
      var autoCompleteSrch = $('input.zoeken').autocomplete({ 
        serviceUrl:'/autocomplete.php',
        minChars:1, 
        delimiter:' ', // regex or character
        maxHeight:400,
        width:174,
        zIndex: 9999,
        deferRequestBy: 125, //miliseconds
        params: { fromshop : 'true', oQuery : '' },
        noCache: true,
        // callback function:
        onSelect: function(value){
          $('input.zoeken').val($('input.zoeken').val() + ' ');
        }
      });
      
      $('input.zoeken').keyup(function(){
        autoCompleteSrch.setOptions({ params: { oQuery : $('input.zoeken').val() } });
      });
    }

    // EXIT
    
    $(document).keydown(function(e){
      if(e.keyCode == 69){
        // applyFilters();
      }
    });
    
  });
  
  //$(window).bind('unload', function(){
  //  ___LeavePage();
  //});
  
  function slideOut(){
    if($("#filterkenmerken").is(":visible"))
    {
      $("a.filters").removeClass('active');
      $("#filterkenmerken").fadeOut('fast');
    }else{
      $("a.filters").addClass('active');
      $("#filterkenmerken").fadeIn('fast');
    }
  }

  function navGotoPage(p,e){
    $(e).attr('orihref', $(e).attr('href')).removeAttr('href');
    $("div.greyoutcontainer").addClass('halfOpacity');
    $.post($(e).attr('orihref') + "&ajax=1", {}, function(d){
      $("div#content-midden p:eq(0)").html($(d).find("div#content-midden p:eq(0)").html());
      $(
          "div#content-midden ul.productlijst-groot, " +
          "div#content-midden ul.productlijst-klein, " +
          "div#content-midden div.diverse-producten, " +
          "div#content-midden div#grid-bekeken,      " +
          "div#content-midden div.custom-prod-view   "
        ).html($(d).find(
          "div#content-midden ul.productlijst-groot, " +
          "div#content-midden ul.productlijst-klein, " +
          "div#content-midden div.diverse-producten, " +
          "div#content-midden div#grid-bekeken,      " +
          "div#content-midden div.custom-prod-view   "
        ).html());
      $("div#content-midden div.abspaginatecontainer").html($(d).find("div.abspaginatecontainer").html());
      $("div#content-midden p:eq(0)").html($(d).find("div#content-midden p:eq(0)").html());
      $("div.greyoutcontainer").removeClass('halfOpacity');
      $("p.firsttextelement").html($(d).find("p.firsttextelement").html());
    });
    return false;
  }
  
  function applyFilters(){
    filterBase = $("div#filterkenmerken div.content");
    filterSlider = filterBase.find("#slider-range");
    if(filterSlider.length > 0)
    {
      priceRangeStart = filterSlider.slider('values')[0];
      priceRangeEnd   = filterSlider.slider('values')[1];
      $("input#PriceStart").val(priceRangeStart);
      $("input#PriceEnd").val(priceRangeEnd);
    }
    
    $(
        "div#content-midden ul.productlijst-groot, " +
        "div#content-midden ul.productlijst-klein, " +
        "div#content-midden div.diverse-producten, " +
        "div#content-midden div#grid-bekeken,      " +
        "div#content-midden div.custom-prod-view   "
      );
    $("div.greyoutcontainer").addClass('halfOpacity');
    
    $.post($("div.weergavecontainer div.view a#active").attr('href') + "&page=1" + "&ajax=1", $("div#filterkenmerken form").serializeArray(), function(d){
      $("p.r-emptymenu.r-nothingfound").remove();
      $(
          "div#content-midden ul.productlijst-groot, " +
          "div#content-midden ul.productlijst-klein, " +
          "div#content-midden div.diverse-producten, " +
          "div#content-midden div#grid-bekeken,      " +
          "div#content-midden div.custom-prod-view   "
        ).html($(d).find(
          "div#content-midden ul.productlijst-groot, " +
          "div#content-midden ul.productlijst-klein, " +
          "div#content-midden div.diverse-producten, " +
          "div#content-midden div#grid-bekeken,      " +
          "div#content-midden div.custom-prod-view   "
        ).html());
      $("div.greyoutcontainer").removeClass('halfOpacity');
      
      if($(d).find("p.emptymenu.nothingfound").length > 0){
        $(
          "div#content-midden ul.productlijst-groot, " +
          "div#content-midden ul.productlijst-klein, " +
          "div#content-midden div.diverse-producten, " +
          "div#content-midden div#grid-bekeken,      " +
          "div#content-midden div.custom-prod-view   "
        ).before('<p class="r-emptymenu r-nothingfound">' + l('nofilterresults') + '</p>');
        $("div#content-midden p:eq(0)").html(l('filternoresults') + ' ' + '<a href="javascript: slideOut();" class="filters' + ($("div#filterkenmerken").is(":visible") ? ' active' : '') + '" id="filterarikelen">' + l('filterkenm') + '</a>' );
      }else{
        $("div#content-midden p:eq(0)").html($(d).find("div#content-midden p:eq(0)").html());
      }
      
      $("div#content-midden div.abspaginatecontainer").html($(d).find("div.abspaginatecontainer").html());
      //$("#filterkenmerken").html(OldFilterDetails);
    }, 'html');
    
    
  }
  
  function clearProdFilter(){
    $("div.weergavecontainer div.view a#active").addClass('clearall').click();
  }
  
  function calcStaffelPrijs(newaant)
  {
    if($(".staffelprijs").length > 0)
    {
      realnewaant = newaant * parseInt($("#staffeleenheid").val());
      
      if($("ul.staffeloverzicht").length > 0)
      {
        $("ul.staffeloverzicht li").each(function(a,b){
          staffel = parseInt($(this).attr('rel'));
          if(realnewaant >= staffel){
            lastWhereGreater = a;
          }
        });
        
        $("ul.staffeloverzicht li.active").removeClass('active');
        $("ul.staffeloverzicht li:eq(" + (lastWhereGreater) + ")").addClass('active');
      }
      
      if(lastWhereGreater > -1)
      {
        pprodprijs  = parseFloat($("ul.staffeloverzicht li:eq(" + lastWhereGreater + ") input").val());
        $("img#deprijs").attr('src', '/plugins/gd-label/tite-gd.php?txt=' + $("ul.staffeloverzicht li:eq(" + (lastWhereGreater) + ") span.prijscalculate").text());
        $("#productfoto #deprijs, #productfoto #deprijs-erachter a").html(l('currencyhtml') + ' ' + $("ul.staffeloverzicht li:eq(" + (lastWhereGreater) + ") span.prijscalculate").text());
      }else{
        pprodprijs = parseFloat($("#prodprijs").val());
      }
      
      $(".staffel").html(realnewaant);
      thePrijsfactor = 1;
      if($("#prijsfactor").length > 0)
      {
        thePrijsfactor = parseInt($("#prijsfactor").val());
      }
      $(".staffelprijs").html(number_format(newaant * parseInt($("#staffeleenheid").val()) * (pprodprijs / thePrijsfactor), 2, ",", ""));
    }else{
      if($("ul.staffeloverzicht").length > 0)
      {
        lastWhereGreater = -1;
        $("ul.staffeloverzicht li").each(function(a,b){
          staffel = parseInt($(this).attr('rel'));
          // alert(staffel);
          // alert(newaant);
          if(newaant >= staffel){
            lastWhereGreater = a;
          }
        });
        
        // alert(lastWhereGreater);
        
        $("ul.staffeloverzicht li.active").removeClass('active');
        $("ul.staffeloverzicht li:eq(" + (lastWhereGreater) + ")").addClass('active');
      }
      
      if(lastWhereGreater > -1)
      {
        $("img#deprijs").attr('src', '/plugins/gd-label/tite-gd.php?txt=' + $("ul.staffeloverzicht li:eq(" + (lastWhereGreater) + ") span.prijscalculate").text());
        $("#productfoto #deprijs, #productfoto #deprijs-erachter a").html(l('currencyhtml') + ' ' + $("ul.staffeloverzicht li:eq(" + (lastWhereGreater) + ") span.prijscalculate").text());
      }
    }
  }
  
  function revert_ProductGeenOptiesAantal()
  {
    clearTimeout(revertPGOA);
    revertPGOA = setTimeout(function(){
      $(".no-opts-aantal").stop().animate({'marginTop' : (orgh) + 'px'}, 200);
    }, 2000);
  }
  
  function confirmClearCartS100(){
    var answer = confirm(l('qsureclearcart'))
    if(answer){
      document.location.href = '/s/100&clearall=true';
      ___ClearCart();
      update_spc_korting();
    }
  }
  
  function confirmClearCart(){
    var answer = confirm(l('qsureclearcart'))
    if(answer){
      $.post('/simple_ajax.php', {'rmprod' : 'all' }, function(d){
        // alert(d.r);
      }, "json");
      CollapseMandje(1);
      //setTimeout(function(){
      $("div#productenlijst ul").remove();
      UpdateCartLabel();
      LeegMandje();
      ___ClearCart();
      update_spc_korting();
      //}, 500);
    }
  }

  function simpleclose()
  {
    //$("#fancy_close").click();
    //$.fancybox.close;
    //parent.$.fancybox.close;
    //setTimeout(function(){
      $("#fancybox-close").click();
    //}, 1000);
  }

  function iframeclose(fromcart,aantal,prijs,sprod,tobj,prodtitle)
  {
    if(aantal && max_use_voorraad > -1 && aantal > max_use_voorraad)
    {
      aantal = max_use_voorraad;
    }
    
    prod = sprod;
    //$("#fancy_close").click();
    //$("#fancybox-close").click();
    //$.fancybox.close;
    //parent.$.fancybox.close;
    simpleclose();
    
    if(fromcart > 0)
    {
      setTimeout(function(){
        toObj = '.plaatsinwinkelwagen';
        if(fromcart > 1)
        {
          toObj = $(tobj).parent().parent();
          var prodcont = prodtitle;
        }else{
          toObj = $(toObj);
          var prodcont = $('h1').html();
        }
        
        if(prodcont.length > 25)
        {
          prodcont = prodcont.substr(0, 25) + '...';
        }
        setTimeout(function(){
          // toObj.css({ 'border' : '1px solid red !important' });
          toObj.effect('transfer', { to: "#winkelmandje", className: 'ui-effects-transfer' }, 750, function(){
            var staffeleenheid = '';
            if($("#staffeleenheid").length > 0)
            {
              staffeleenheid = '<input type="hidden" value="' + $("#staffeleenheid").val() + '" />';
            }
            $("#meerproducten").before('<ul class="product"><li class="col1">' + aantal + 'x</li><li class="col2"><a href="/p/' + prod + '">' + prodcont + '</a></li><li class="col3"><a class="delete" href="javascript:niets();"></a></li><li class="prijs">' + (prijs) + '</li>' + staffeleenheid + '</ul>');
            ___ProductToCart(prod,aantal,prijs);
            CartInit();
            MandjeClickable();
          });
        },500);
      },100);
    }
  }

  function chatOffline()
  {
    $("#chat-init #linkchatmet").css({ 'background-image' : 'url(../images/status_busy.png)' } );
    $("#linkchatmet").html(l('chatoffline'));
    $("#chat-init").css({ 'cursor' : 'default !important' } );
    $("#chat-init img").css({ 'cursor' : 'default !important' } );
    $("#linkchatmet").unbind('click');
  }
  
  function chatOnline()
  {
    $("#chat-init #linkchatmet").css({ 'background-image' : 'url(../images/emoticon_smile.png)' } );
    $("#linkchatmet").html(l('chatmmdw'));
    $("#chat-init").css({ 'cursor' : 'pointer !important' } );
    $("#chat-init img").css({ 'cursor' : 'pointer !important' } );
    $("#linkchatmet").click(function(){
      enableOlarkChat();
      $(this).unbind('click');
    });
  }

  function enableOlarkChat()
  {
    if($("#chat-init").length > 0)
    {
      OlarkObj.set(1);
      
      $('html, body').animate({scrollTop:0}, 'slow');
      
      $("#chat-init").parent().slideUp(function(){
        $("#chat-init").parent().addClass('chat-active');
        $("#habla_window_div").addClass('showit');
        $("#chat-init").parent().slideDown(function(){
          $("textarea#habla_wcsend_input").focus();
        });
      });
    }
  }

  function quick_enableOlarkChat()
  {
    if($("#chat-init").length > 0)
    {
      //OlarkObj.set(1);
      //$('html, body').animate({scrollTop:0}, 1);
      $("div#imageabove").hide();
      $("#chat-init #linkchatmet").hide();
      $("#chat-init").parent().hide();
      $("#chat-init").parent().addClass('chat-active');
      $("#habla_window_div").addClass('showit');
      $("#chat-init").parent().show();
      $("textarea#habla_wcsend_input").focus();
    }
  }

  function styleswitch(restore,c1,c2,c3,c4){
    $("body").prepend('<div id="switchdiv" style="width: 100%; height: 100%; position: fixed; top: 0; left: 0; background-color: #000; z-index: 99999; display: none;"></div>');
    $("#switchdiv").fadeIn("slow", function(){
      if(restore < 1) $("#styleswap").attr('href', '/css/formatted.style.css.php?c1='+c1+'&c2='+c2+'&c3='+c3+'&c4='+c4);
      if(restore > 0) $("#styleswap").attr('href', '/css/formatted.style.css.php?restore=true');
      if($("#styleswapcustom").length > 0){
        if(restore < 1) $("#styleswapcustom").attr('href', '/graphics/' + shopId + '/custom_style.css.php?c1='+c1+'&c2='+c2+'&c3='+c3+'&c4='+c4);
        if(restore > 0) $("#styleswapcustom").attr('href', '/graphics/' + shopId + '/custom_style.css.php?restore=true');
      }
      rnd = new Date().getTime();
      if(restore < 1){
        clr = '&color=' + c2;
      }else{
        clr = '';
      }
      $("#searchloader img").load(function(){
        setTimeout(function(){
          $("#switchdiv").fadeOut("slow", function(){
            $(this).remove();
          });
        }, 500);
      }).attr('src', '/plugins/gif-loader/?clr_rld=' + rnd + clr + '&reload=' + restore);
    });
  }

  function menu(){}
  function niets(){}
  
  function addMenuClick(theObj){
    if(($(theObj).parent().attr('class')).match(/active/i) == null){
      $(theObj).click(function(){
        $(this).unbind('click');
        $(this).parent().addClass('active');
        $(this).addClass('active');
        addMenuClick($(this));
        $(this).next().css({'display' : 'block'});
      });
    }else{
      $(theObj).click(function(){
        $(this).unbind('click');
        $(this).parent().removeClass('active');
        $(this).removeClass('active');
        addMenuClick($(this));
        $(this).next().css({'display' : 'none'});
      });     
    }
  }

  function addSubMenuClick(theObj){
    if(($(theObj).parent().attr('class')).match(/innersel/i) == null){
      $(theObj).click(function(){
        $(this).unbind('click');
        $(this).parent().addClass('innersel');
        //$(this).addClass('active');
        addSubMenuClick($(this));
        $(this).next().css({'display' : 'block'});
      });
    }else{
      $(theObj).click(function(){
        $(this).unbind('click');
        $(this).parent().removeClass('innersel');
        //$(this).removeClass('active');
        addSubMenuClick($(this));
        $(this).next().css({'display' : 'none'});
      });     
    }
  }
  
  function SwapTo(){
    var total = $(".jqGSPagination li").size();
    CurrentCarouselAt = CurrentCarouselAt+1;
    if(CurrentCarouselAt >= total){
      CurrentCarouselAt = 0;
    }
    $(".jqGSPagination li a").eq(CurrentCarouselAt).click();
  }
  
  function printS(){
    print();
  }
  
  function collapse(what){
    $(what).slideToggle("fast");
  }
  
  function trim(value) {
    value = value.replace(/^\s+/,''); 
    value = value.replace(/\s+$/,'');
    return value;
  }
  
  function get_payment_methods(){
    $.post('/simple_ajax.php', { 'checkout' : 'true' }, function(d){
      $(".leftspace7px, p.dev.normal").remove();
      $(".winkelwagen-indeling-bg").hide();
      $(".winkelwagen-content-klein").hide();
      $(".winkelwagen-footer").hide();
      $("#orderload").hide();
      if($("textarea.orderopmerking").length > 0)
      {
        theTextAreaValue = $("textarea.orderopmerking").val();
        $("textarea.orderopmerking").hide();
        $.post('/simple_ajax.php', { 'orderComment' : theTextAreaValue }, function(d){}, 'json');
      }
      $("h1").html(l('kiesafrekenmethode'));
      $(".winkelwagen-indeling-bg.paymeth").before('<br />' + l('kiesbettmeth') + '<br />' + d);
      ___DoOrder();
    }, 'html');
  }

  function str_replace (search, replace, subject, count) {
    var i = 0, j = 0, temp = '', repl = '', sl = 0, fl = 0,
            f = [].concat(search),
            r = [].concat(replace),
            s = subject,
            ra = r instanceof Array, sa = s instanceof Array;
    s = [].concat(s);
    if (count) {
        this.window[count] = 0;
    }

    for (i=0, sl=s.length; i < sl; i++) {
        if (s[i] === '') {
            continue;
        }
        for (j=0, fl=f.length; j < fl; j++) {
            temp = s[i]+'';
            repl = ra ? (r[j] !== undefined ? r[j] : '') : r[0];
            s[i] = (temp).split(f[j]).join(repl);
            if (count && s[i] !== temp) {
                this.window[count] += (temp.length-s[i].length)/f[j].length;}
        }
    }
    return sa ? s : s[0];
  }

  function mktime() {
    var d = new Date(), r = arguments, i = 0,
      e = ['Hours', 'Minutes', 'Seconds', 'Month', 'Date', 'FullYear'];
    for (i = 0; i < e.length; i++) {
      if (typeof r[i] === 'undefined') {
        r[i] = d['get' + e[i]]();
        r[i] += (i === 3); // +1 to fix JS months.
      } else {
        r[i] = parseInt(r[i], 10);
        if (isNaN(r[i])) {
          return false;
        }
      }
    }
    
    r[5] += (r[5] >= 0 ? (r[5] <= 69 ? 2e3 : (r[5] <= 100 ? 1900 : 0)) : 0);
    d.setFullYear(r[5], r[3] - 1, r[4]);
    d.setHours(r[0], r[1], r[2]);
    return (d.getTime() / 1e3 >> 0) - (d.getTime() < 0);
  }
  
  function explode (delimiter, string, limit) {
    var emptyArray = { 0: '' };
    
    if ( arguments.length < 2 ||
      typeof arguments[0] == 'undefined' ||
      typeof arguments[1] == 'undefined' ) {
      return null;
    }
 
    if ( delimiter === '' ||
      delimiter === false ||
      delimiter === null ) {
      return false;
    }
 
    if ( typeof delimiter == 'function' ||
      typeof delimiter == 'object' ||
      typeof string == 'function' ||
      typeof string == 'object' ) {
      return emptyArray;
    }
 
    if ( delimiter === true ) {
      delimiter = '1';
    }
    
    if (!limit) {
      return string.toString().split(delimiter.toString());
    } else {
      var splitted = string.toString().split(delimiter.toString());
      var partA = splitted.splice(0, limit - 1);
      var partB = splitted.join(delimiter.toString());
      partA.push(partB);
      return partA;
    }
  }
  
  function strpos (haystack, needle, offset) {
      // http://kevin.vanzonneveld.net
      // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
      // +   improved by: Onno Marsman    
      // +   bugfixed by: Daniel Esteban
      // +   improved by: Brett Zamir (http://brett-zamir.me)
      // *     example 1: strpos('Kevin van Zonneveld', 'e', 5);
      // *     returns 1: 14
      var i = (haystack + '').indexOf(needle, (offset || 0));
      return i === -1 ? false : i;
  }
  
  function get_current_product_pic()
  {
  // alert(1);
    // Verkrijg indien beschikbaar (anders false) de BIG image van het product waar momenteel naar wordt gekeken.
    var curPic = $("div#productfoto div#pics div.show");
    if(curPic.length < 1) curPic = $("div#productfoto div#pics img.normal").parent();
    
    if(curPic.length > 0)
    {
      var curPicPath = curPic.find("img.normal").attr('src');
      // plaatje kan ook big zijn of normal
      
    //  alert(curPicPath); 
      if(curPicPath)
      {
        
          curPicPath = curPicPath.substr(strpos(curPicPath, "pictures/") + 9);
          window.location = '/download.php?download_file=' + curPicPath;
        // window.open(window.location);
      }
      return curPicPath;
    }else{
      return false;
    }
  }
  
  function sprintf () {
    var regex = /%%|%(\d+\$)?([-+\'#0 ]*)(\*\d+\$|\*|\d+)?(\.(\*\d+\$|\*|\d+))?([scboxXuidfegEG])/g;
    var a = arguments,
        i = 0,
        format = a[i++];
    
    // pad()
    var pad = function (str, len, chr, leftJustify) {
        if (!chr) {
            chr = ' ';
        }
        var padding = (str.length >= len) ? '' : Array(1 + len - str.length >>> 0).join(chr);
        return leftJustify ? str + padding : padding + str;
    };
    
    // justify()
    var justify = function (value, prefix, leftJustify, minWidth, zeroPad, customPadChar) {
        var diff = minWidth - value.length;
        if (diff > 0) {
            if (leftJustify || !zeroPad) {
                value = pad(value, minWidth, customPadChar, leftJustify);
            } else {
                value = value.slice(0, prefix.length) + pad('', diff, '0', true) + value.slice(prefix.length);
            }
        }
        return value;
    };
    
    // formatBaseX()
    var formatBaseX = function (value, base, prefix, leftJustify, minWidth, precision, zeroPad) {
        // Note: casts negative numbers to positive ones
        var number = value >>> 0;
        prefix = prefix && number && {
            '2': '0b',
            '8': '0',
            '16': '0x'
        }[base] || '';
        value = prefix + pad(number.toString(base), precision || 0, '0', false);
        return justify(value, prefix, leftJustify, minWidth, zeroPad);
    };
    
    // formatString()
    var formatString = function (value, leftJustify, minWidth, precision, zeroPad, customPadChar) {
        if (precision != null) {
            value = value.slice(0, precision);
        }
        return justify(value, '', leftJustify, minWidth, zeroPad, customPadChar);
    };
    
    // doFormat()
    var doFormat = function (substring, valueIndex, flags, minWidth, _, precision, type) {
        var number;
        var prefix;
        var method;
        var textTransform;
        var value;
    
        if (substring == '%%') {
            return '%';
        }
    
        // parse flags
        var leftJustify = false,
            positivePrefix = '',
            zeroPad = false,
            prefixBaseX = false,
            customPadChar = ' ';
        var flagsl = flags.length;
        for (var j = 0; flags && j < flagsl; j++) {
            switch (flags.charAt(j)) {
            case ' ':
                positivePrefix = ' ';
                break;
            case '+':
                positivePrefix = '+';
                break;
            case '-':
                leftJustify = true;
                break;
            case "'":
                customPadChar = flags.charAt(j + 1);
                break;
            case '0':
                zeroPad = true;
                break;
            case '#':
                prefixBaseX = true;
                break;
            }
        }
    
        // parameters may be null, undefined, empty-string or real valued
        // we want to ignore null, undefined and empty-string values
        if (!minWidth) {
            minWidth = 0;
        } else if (minWidth == '*') {
            minWidth = +a[i++];
        } else if (minWidth.charAt(0) == '*') {
            minWidth = +a[minWidth.slice(1, -1)];
        } else {
            minWidth = +minWidth;
        }
    
        // Note: undocumented perl feature:
        if (minWidth < 0) {
            minWidth = -minWidth;
            leftJustify = true;
        }
    
        if (!isFinite(minWidth)) {
            throw new Error('sprintf: (minimum-)width must be finite');
        }
    
        if (!precision) {
            precision = 'fFeE'.indexOf(type) > -1 ? 6 : (type == 'd') ? 0 : undefined;
        } else if (precision == '*') {
            precision = +a[i++];
        } else if (precision.charAt(0) == '*') {
            precision = +a[precision.slice(1, -1)];
        } else {
            precision = +precision;
        }
    
        // grab value using valueIndex if required?
        value = valueIndex ? a[valueIndex.slice(0, -1)] : a[i++];
    
        switch (type) {
        case 's':
            return formatString(String(value), leftJustify, minWidth, precision, zeroPad, customPadChar);
        case 'c':
            return formatString(String.fromCharCode(+value), leftJustify, minWidth, precision, zeroPad);
        case 'b':
            return formatBaseX(value, 2, prefixBaseX, leftJustify, minWidth, precision, zeroPad);
        case 'o':
            return formatBaseX(value, 8, prefixBaseX, leftJustify, minWidth, precision, zeroPad);
        case 'x':
            return formatBaseX(value, 16, prefixBaseX, leftJustify, minWidth, precision, zeroPad);
        case 'X':
            return formatBaseX(value, 16, prefixBaseX, leftJustify, minWidth, precision, zeroPad).toUpperCase();
        case 'u':
            return formatBaseX(value, 10, prefixBaseX, leftJustify, minWidth, precision, zeroPad);
        case 'i':
        case 'd':
            number = (+value) | 0;
            prefix = number < 0 ? '-' : positivePrefix;
            value = prefix + pad(String(Math.abs(number)), precision, '0', false);
            return justify(value, prefix, leftJustify, minWidth, zeroPad);
        case 'e':
        case 'E':
        case 'f':
        case 'F':
        case 'g':
        case 'G':
            number = +value;
            prefix = number < 0 ? '-' : positivePrefix;
            method = ['toExponential', 'toFixed', 'toPrecision']['efg'.indexOf(type.toLowerCase())];
            textTransform = ['toString', 'toUpperCase']['eEfFgG'.indexOf(type) % 2];
            value = prefix + Math.abs(number)[method](precision);
            return justify(value, prefix, leftJustify, minWidth, zeroPad)[textTransform]();
        default:
            return substring;
        }
    };
    return format.replace(regex, doFormat);
  }
  
  function is_int (mixed_var) {
      if (typeof mixed_var !== 'number') {
          return false;
      }
  
      return !(mixed_var % 1);
  }
  
  function update_spc_korting()
  {
    if($("div.kortingsactie-nogxeuro").length > 0)
    {
      $.post('/simple_ajax.php', { 'spcKortingsActie' : 'true' }, function(d){
        $("div.kortingsactie-nogxeuro").before(d.r).remove();
        if($("b.updateNumFree").length > 0)
        {
          $("b.updateNumFree").html(parseInt($(d.r).find("b.nfree").html())-1);
        }
      }, 'json');
    }
  }
  
  /* OK */ function ___ProductToCart(     a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z){
    update_spc_korting();
    if(typeof(__ProductToCart)    == 'function'){ __ProductToCart(    a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z); }}
  /* OK */ function ___ViewProductCat(    a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z){ if(typeof(__ViewProductCat)   == 'function'){ __ViewProductCat(   a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z); }}
  /* OK */ function ___ViewProduct(       a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z){ if(typeof(__ViewProduct)      == 'function'){ __ViewProduct(      a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z); }}
  /* OK */ function ___RegisterAccount(   a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z){ if(typeof(__RegisterAccount)  == 'function'){ __RegisterAccount(  a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z); }}
  /* OK */ function ___DoOrder(           a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z){ if(typeof(__DoOrder)          == 'function'){ __DoOrder(          a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z); }}
  /* OK */ function ___ShowCart(          a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z){ if(typeof(__ShowCart)         == 'function'){ __ShowCart(         a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z); }}
  /* OK */ function ___ViewFactuurlijst(  a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z){ if(typeof(__ViewFactuurlijst) == 'function'){ __ViewFactuurlijst( a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z); }}
  /* OK */ function ___ViewAccount(       a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z){ if(typeof(__ViewAccount)      == 'function'){ __ViewAccount(      a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z); }}
  /* OK */ function ___ClearCart(         a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z){ if(typeof(__ClearCart)        == 'function'){ __ClearCart(        a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z); }}




$(document).ready(function(){

  $("#filteranimate").toggle(function(){
    /// Voer uit bij mouse on
      $(this).animate({ 'height' : '100px' }, 30);
      $(this).find("#aanwijzing").css({'display' : 'none'});
      $(this).find("div.filters").css({'display' : 'block'});
    }, function(){
        /// Voer uit bij mouse out
      //$(this).animate({ 'height' : '16px' }, 30);
      //$(this).find("#aanwijzing").css({'display' : 'block'});
      //$(this).find("div.filters").css({'display' : 'none'});
    });
  
  
    // DROPDOWN
    $("div.dropdown-bg").toggle(function(){
    /// Voer uit bij mouse on
      $(this).find("div.dropdown-content").css({'display' : 'block'});
      $(this).addClass('active');
      //$("div.filteroverlay").css({'display' : 'block'});
    }, function(){
    /// Voer uit bij mouse out
      $(this).find("div.dropdown-content").css({'display' : 'none'});
      $(this).removeClass('active');
    });
    
   /* // FILTEROVERLAY
    $("div.filteroverlay").click(function(){
      $(this).css({'display':'none'});
      if($("div.dropdown-content:visible").length > 0)
      {
        $("div.dropdown-content:visible ul li.sluit a").click();
      }
    });*/
    
    // SLUITKNOP
    $("div.dropdown-content a.sluit").click(function(){
    /// Voer uit bij click
      $("div.dropdown-content.active").click();
      $("div.filteroverlay").css({'display':'none'});
      $("ul.filterblocks").html('');
      $.each($("div.dropdown-content ul li.active"), function() {
        // console.log(this);
        $("ul.filterblocks").append('<li class="filterselecteditem">' + $(this).html() + '<div class="xje unbinded">X</div></li>');
        //alert(this);
      });
      
      $("li.filterselecteditem div.xje.unbinded").click(function(){
        $(this).parent().remove();
      });
      $("li.filterselecteditem div.xje.unbinded").removeClass('unbinded');
    });
    
    //$("div.xje").click(function(){
    //$("ul.filterblocks li").live("click", function(){
      
      //alert("test");
      //return false;
      //$(this).parent().removeClass('active');
    //});
    
    // LIST ITEMS
    $("div.dropdown-content ul li.item").toggle(function(){
    /// Voer uit bij mouse on
      $(this).addClass('active');
      //alert('list items active maken');
      //$("ul.filterblocks").html( $("div.dropdown-content ul li").get() );
      //alert($("div.dropdown-content ul li.active").get());
    }, function(){
    /// Voer uit bij mouse out
      $(this).removeClass('active');
    });

  
  
  
  /*
  $("div.product-select-boxes input").focus(function(){
    $('div.product-select-boxes ul').css({ display : 'block' });
  });
  $("div.product-select-boxes ul li a").click(function(){
    $('div.product-select-boxes ul').css({ display : 'none' });
  });

  $("div.product-select-boxes input").blur(function(){
    $('div.product-select-boxes ul').css({ display : 'none' });
  });
  $("div.product-select-boxes ul li a").click(function(){
    $('div.product-select-boxes ul').css({ display : 'none' });
  });
  */
  
  
  $("div#downloadImage").show().click(function(){
    get_current_product_pic();
  });
  
});












