$(function(){ // Google Analytics $(".trackPageview").click(function(){ _gaq.push(['_trackPageview',this.href]); }); $("#product-specificaties,#accessoire-specificaties").click(function(){ _gaq.push(['_trackEvent', 'product', 'specificaties',this.rel]); }); // menu $("#menu-wrapper .menu#hoofdmenu").animate({ width:170 }) if(!bHomepage){ var sluitMenu = setTimeout(function(){ $("#menu-wrapper .menu#hoofdmenu").trigger("mouseout"); },3000); } $("#menu-wrapper .menu").hover(function(){ clearTimeout(sluitMenu); if(!$(this).is(":animated")) $(this).animate({width:170}) },function(){ t = $(this); setTimeout(function(){ if(!t.is(":animated")) t.animate({width:44}) },6000); }); // safari position fixed / webkit transform bug, ie6 position fixed support var ua = navigator.userAgent; if(ua.indexOf("Safari") !== -1 && ua.indexOf("Chrome") == -1 || $.browser.msie && parseInt($.browser.version) == 6){ $("#menu-wrapper").css("position","absolute"); $(window).scroll(function(){ $("#menu-wrapper").css("top",$(window).scrollTop()+51); }) } // remove menu link on mobile devices if(is_mobile()) $(".menu .kop").removeAttr('href'); // producten footer $("#producten-footer-link").click(function(){ $("#producten-footer").slideToggle(); return false }); // menu accordion var pAccordion = $(".accordion"); if(pAccordion.length){ var pAccordionDT = pAccordion.find("dt"); var pAccordionDD = pAccordion.find("dd"); pAccordionDT.each(function(index){ var slideBG = $('').prependTo($(this)); if(!index) slideBG.animate({width:$(this).find("a").outerWidth()},250); }); pAccordionDD.each(function(index){ //hoogte vast zetten = mooiere animatie $(this).css("height",$(this).height()); if(index){ $(this).hide(); } }); pAccordionDT.click(function(){ if(!$(this).hasClass("open")){ $(pAccordionDT).removeClass("open"); $(pAccordionDD).removeClass("open").slideUp(); $(this).addClass("open").next().slideDown().addClass("open"); $(".slide-bg").animate({ width:0 },250); } return false; }).hover(function(){ if(!$(this).hasClass("open")){ $(this).find(".slide-bg").animate({ width:$(this).find("a").outerWidth() },250); } },function(){ if(!$(this).hasClass("open")){ $(this).find(".slide-bg").animate({ width:0 },250); } }); } // product lijntekening var lijntekening = $("#product-lijntekening"); var sleep = $("#lijntekening-sleep"); var maxSleep = lijntekening.width(); lijntekening.hover(function(){ $(document).bind('mousemove',function(e){ var slepen = parseInt(e.pageX - lijntekening.offset().left); if(slepen > 10 && slepen < 648){ $("#lijntekening").css({ width: ((slepen-maxSleep)*-1) }); } }); }, function(){ $(document).unbind("mousemove"); }).click(function(){ return false }); // dealer land-keuze var landKeuze = $("#land-keuze a"); if(landKeuze.length){ var landOpties = $("#landen-opties"); landKeuze.click(function(){ landOpties.slideToggle(); return false }) landOpties.find("a").click(function(){ landKeuze.html($(this).text()); landOpties.slideUp(); this.options = this.rel.split(","); map.setCenter(new google.maps.LatLng(this.options[0], this.options[1])); map.setZoom(parseInt(this.options[2])); return false; }) } // nieuws var leesMeer = $(".nieuws-item .lees-meer"); if(leesMeer.length){ var tekstHeight = $($(".nieuws-tekst")[0]).height(); if($.browser.msie && parseInt($.browser.version) == 6){ /* IE6 thickbox hover */ var t = $(this); $(".nieuws-item .thickbox").hover(function(){ t.addClass("hover"); },function(){ t.removeClass("hover"); }) } leesMeer.click(function(){ var tekst = $(this).prev(".nieuws-tekst"); if(tekst.hasClass("open")){ scrollHeight = tekstHeight; tekst.removeClass("open"); } else { scrollHeight = tekst.addClass("open").attr("scrollHeight"); } tekst.animate({ height: scrollHeight }) return false; }); } // formulieren var formInputs = $("input.text, textarea.blurthis"); if(formInputs.length){ formInputs.each(function(){ this.computedValue = this.value; }).focus(function(){ this.placeholder = this.value; if(this.value == this.computedValue) this.value = ""; }).blur(function(){ if(this.value == "") this.value = this.placeholder }); } // custom checkboxes var customCheckboxes = $(".custom-checkbox"); if(customCheckboxes.length){ var t = null; var jsCheckbox = null; customCheckboxes.each(function(){ t = $(this).css({ position: "absolute", left: "-9999px" }); jsCheckbox = $('
').insertAfter(t); if(t[0].checked){ jsCheckbox.addClass("active"); } jsCheckbox.click(function(){ var checkbox = $(this).prev(".custom-checkbox"); if(checkbox.is(":checked")){ $(this).removeClass("active"); checkbox.attr("selected", "selected"); } else { $(this).addClass("active"); checkbox.removeAttr("checked"); } }); }); } // product bestellen var bestelKnop = $(".offerte-toevoegen"); var webshopMenu = $("#webshop"); var winkelmandjeItems = $("#winkelmandje-items"); if(bestelKnop.length){ var cookieExpire = 1; //days if(!readCookie("winkelmand")){ createCookie('winkelmand','{"totaal":0,"product":{},"accessoire":{}}',cookieExpire); } json = $.parseJSON(readCookie('winkelmand')); bestelKnop.click(function(){ webshopMenu.trigger("mouseenter"); winkelmandjeItems.html(json.totaal+1); var objID = this.id.split("ID"); //product of accessoire var objString = "json."+objID[0]+"."+this.id; var obj = eval(objString); if(typeof obj !== "undefined"){ //ophogen obj.aantal = obj.aantal+1; } else { //aanmaken newObject = eval(objString+"= new Object()"); newObject.aantal = 1; } json.totaal++; createCookie('winkelmand',JSON.stringify(json),cookieExpire); return false; }); } // dealer offerte prijzen var aantalInput = $(".product-aantal"); if(aantalInput.length){ var subtotaal = 0; var subtotaalPrijs = $("#subtotaal-prijs"); aantalInput.keyup(function(){ subtotaal = 0; aantalInput.each(function(){ subtotaal+1; prijs = $(this).attr("alt"); aantal = this.value; subtotaal += prijs*aantal; }); var finalValue = $().number_format(subtotaal); subtotaalPrijs.html("€ "+finalValue); }); // onload prijs uitrekenen $(aantalInput[0]).trigger("keyup"); } // webshop var verwijderKnop = $(".verwijderen"); if(verwijderKnop.length){ json = $.parseJSON(readCookie('winkelmand')); json.totaal += 0; verwijderKnop.click(function(){ type = this.id.split("ID"); eval("delete json."+type[0]+"."+this.id); $(this).closest("tr").remove(); webshopMenu.trigger("mouseenter"); winkelmandjeItems.html(json.totaal-1); json.totaal = json.totaal-1; createCookie('winkelmand',JSON.stringify(json),1); return false }); } $("a#bestelling-afronden").click(function(){ $(this).remove(); $("#afronden").slideDown(); return false; }); if($("legend").hasClass("eriseensessiedusklapuit")){ $("a#bestelling-afronden").remove(); $("#afronden").slideDown(); return false; } $(".click_info_accessoires").click(function(){ $(this).hide().next().show(); return false }); $(".meer_info_accessoires").click(function(){ $(this).hide().prev().show(); return false }); // dealer extranet $(".product-toebehoren .hoofdgroep-titel").click(function(){ var categorieID = this.className.replace("hoofdgroep-titel categorieID-",""); categorieID = parseInt(categorieID); $(".hoofdgroep.categorieID-"+categorieID+",.subgroep.categorieID-"+categorieID).toggle(); }); }); function createCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; } function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } function is_mobile() { return (/iphone|ipad|ipod|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase())); }