jQuery(document).ready(function($){ var baseurl = 'http://www.totallycampers.com'; var landen = ['au', 'zn', 'uc', 'nz']; var urlParams = {}; (function () { var e, a = /\+/g, // Regex for replacing addition symbol with a space r = /([^&=]+)=?([^&]*)/g, d = function (s) { return decodeURIComponent(s.replace(a, " ")); }, q = window.location.search.substring(1); while (e = r.exec(q)) urlParams[d(e[1])] = d(e[2]); })(); function changeCities(){ var land = $("#bestemming").val(); $("#vanuit_au, #vanuit_nz, #vanuit_uc, #vanuit_zn, #naar_au, #naar_nz, #naar_uc, #naar_zn").hide().val('---'); switch(land) { case 'Australië': case 'Australia': $("#vanuit_au, #naar_au").show(); break; case 'Nieuw Zeeland': case 'New Zealand': $("#vanuit_nz, #naar_nz").show(); break; case 'USA & Canada': $("#vanuit_uc, #naar_uc").show(); break; case 'Zuid-Afrika & Namibië': case 'South Africa & Namibia': $("#vanuit_zn, #naar_zn").show(); break; } } function createDropDown(keuze, header){ var land = $("#landkeuze").val(); if (typeof header == "undefined") { header = ""; } var source = $("#"+keuze); var selected = source.find('option[selected]'); if ($.browser.msie && parseInt($.browser.version) == 8) { selected = source.find('option[selected="selected"]'); } var options = $("option", source); if(header == "kinderen 4-5 jr. (boosterseat)"){ $("#quicksearchbar").prepend(' ALLEEN 4WD modellen weergevenALLEEN modellen met douche/toilet weergeven'); } else if(header == "children 4-6 yrs. (boosterseat)"){ $("#quicksearchbar").prepend(' only show 4WD modelsonly show shower/toilet models'); } else { $("#quicksearchbar").prepend(''); } if(keuze != 'landkeuze') { if(jQuery.inArray(land, landen) === -1){ $("."+keuze).addClass("inactive"); $(".cblabel").addClass("inactive"); $(".check").attr("disabled", true); } } if(header != ""){ $("."+keuze).append(''+header+''); } $("."+keuze).append('
' + selected.text() + '' + selected.val() + '
') $("."+keuze).append('
') options.each(function(){ $("."+keuze+" dd ul").append('
  • ' + $(this).text() + '' + $(this).val() + '
  • '); }); source.hide(); } /* $("ul.sub-menu").parent().append(""); $("ul#menu-menu li span").click(function() { $(this).parent().find("ul.sub-menu").slideDown('slow').show(); $(this).parent().hover(function() { }, function(){ $(this).parent().find("ul.sub-menu").slideUp('slow'); }); }).hover(function() { $(this).addClass("subhover"); }, function(){ $(this).removeClass("subhover"); }); */ if(language == 'nl'){ createDropDown('verhuurmaatschappij', 'Verhuurmaatschappij'); createDropDown('boosterseats', 'kinderen 4-5 jr. (boosterseat)'); createDropDown('childseats', 'Waarvan:
    kinderen 0-3 jr. (childseat)'); createDropDown('totaalaantalpersonen', 'Totaal aantal personen:'); createDropDown('naarstadkeuze'); createDropDown('vanstadkeuze'); createDropDown('landkeuze'); } if(language == 'en'){ createDropDown('verhuurmaatschappij', 'Rental company'); createDropDown('boosterseats', 'children 4-6 yrs. (boosterseat)'); createDropDown('childseats', 'children 0-3 yrs. (childseat)'); createDropDown('totaalaantalpersonen', 'Total persons:'); createDropDown('naarstadkeuze'); createDropDown('vanstadkeuze'); createDropDown('landkeuze'); } function toggleDropdown(dropdown, e){ $(".dropdown."+dropdown+" dd ul").toggle(); e.preventDefault(); } $(".dropdown dt a").not(".inactive dt a").click(function(e) { var dropdown = $(this).parent().parent().attr('rel'); toggleDropdown(dropdown, e); }); $(document).bind('click', function(e) { var $clicked = $(e.target); if (! $clicked.parents().hasClass("dropdown")) $(".dropdown dd ul").hide(); }); $(".dropdown dd ul li a, .check").click(function(e) { var dropdown = $(this).parent().parent().parent().parent().attr('rel'); var text = $(this).html(); $(".dropdown."+dropdown+" dt a").html(text); $(".dropdown."+dropdown+" dd ul").hide(); var source = $(this).closest('dl').attr('rel'); var target = $("#"+source); target.val($(this).find("span.value").html()); if($(this).context == 'a'){ e.preventDefault(); } if(dropdown == 'landkeuze') { var land = target.val(); var l = ''; if(language == 'en') { switch(land) { case 'au': link = baseurl+"/en/campers/australia/"; break; case 'nz': link = baseurl+"/en/campers/new-zealand/"; break; case 'uc': link = baseurl+"/en/campers/usa-canada/"; break; case 'zn': link = baseurl+"/en/campers/south-africa-namibia/"; break; } } else { switch(land) { case 'au': link = baseurl+"/nl/campers/australie/"; break; case 'nz': link = baseurl+"/nl/campers/nieuw-zeeland/"; break; case 'uc': link = baseurl+"/nl/campers/usa-canada/"; break; case 'zn': link = baseurl+"/nl/campers/zuid-afrika-namibie/"; break; } } window.location.href = link; } else { $(".camperaanbod").empty().html('

    Resultaten ophalen

    '); var data = {}; var selected = $("#sidebar").find('dt'); selected.not(".init").each(function(){ var value = $(this).find(".value").text(); var key = $(this).parent().attr('rel'); data[key] = value; }); if($("input[name='4wd']").is(':checked')){ data['4wd'] = 1; } if($("input[name='toilet']").is(':checked')){ data['toilet'] = 1; } data['language'] = language; $.ajax({ type: "POST", data: data, url: baseurl+'/tc/wp-content/themes/totallycampers/xhr.php', success: function(data) { if ($(window).width() <= 992){ $("#quicksearchbar").hide(); } $(".camperaanbod").empty().html(data); } }); } }); $(".vraag").click(function(){ var span = $(this).find("span") var pijltje = $(this).find("span").text(); if(pijltje == '▾'){ span.empty().text('▴'); } else { span.empty().text('▾'); } $(this).next(".antwoord").toggle('fast'); }); $(".wpcf7-submit").attr('value', ''); $("#vanuit_au, #vanuit_nz, #vanuit_uc, #vanuit_zn, #naar_au, #naar_nz, #naar_uc, #naar_zn").hide(); if(urlParams.l == 'au'){ $("#vanuit_au, #naar_au").show(); $("#bestemming").prop("selectedIndex", 0); if('vs' in urlParams == true) { $("#vanuit_au").val(urlParams.vs); } if('ns' in urlParams == true) { $("#naar_au").val(urlParams.ns); } } else if(urlParams.l == 'nz'){ $("#vanuit_nz, #naar_nz").show(); $("#bestemming").prop("selectedIndex", 1); if('vs' in urlParams == true) { $("#vanuit_nz").val(urlParams.vs); } if('ns' in urlParams == true) { $("#naar_nz").val(urlParams.ns); } } else if(urlParams.l == 'uc'){ $("#vanuit_uc, #naar_uc").show(); $("#bestemming").prop("selectedIndex", 2); if('vs' in urlParams == true) { $("#vanuit_uc").val(urlParams.vs); } if('ns' in urlParams == true) { $("#naar_uc").val(urlParams.ns); } } else if(urlParams.l == 'zn'){ $("#vanuit_zn, #naar_zn").show(); $("#bestemming").prop("selectedIndex", 3); if('vs' in urlParams == true) { $("#vanuit_zn").val(urlParams.vs); } if('ns' in urlParams == true) { $("#naar_zn").val(urlParams.ns); } } else { changeCities(); } $("#bestemming").change(function(){ changeCities(); }); if('q' in urlParams == true){ $("#personen").val(urlParams.q); } if('c' in urlParams == true) { $("#kinderentot4jaar").val(urlParams.c); } if('b' in urlParams == true) { $("#kinderenvanaf4jaar").val(urlParams.b); } if('ca' in urlParams == true) { $("#voertuig").val(urlParams.ca); } var slideframeW = $("#slideframe"); var slides = $(".slide").length; var totaleBreedte = slides * slideframeW; var active = false; var sliderwidth = slides * slideframeW; var sliderwidthNeg = slides * -slideframeW; $("#slidescroll").css("width", + totaleBreedte + "px"); function naarrechts(){ if(active == false && $("#slidescroll").length) { var ml = $("#slidescroll").css('marginLeft').replace('px', '' ); if(ml > (sliderwidthNeg+slideframeW)) { active = true; $("#slidescroll").animate( { marginLeft: "-="+slideframeW+"px" },{ queue: false, duration: 700, complete: function(){ active = false; } }); } else { $("#slidescroll").animate( { marginLeft: "0px" } ) } } } function naarlinks(){ if(active == false && $("#slidescroll").length) { var ml = $("#slidescroll").css('marginLeft').replace('px', '' ); if(ml < 0 ) { active = true; $("#slidescroll").animate( { marginLeft: "+="+slideframeW+"px" },{ queue: false, duration: 700, complete: function(){ active = false; } }); } else { $("#slidescroll").animate( { marginLeft: "-"+(slides-1) * slideframeW+"px" } ) } } } $(".naarrechts").click(function(){ naarrechts(); }); $(".naarlinks").click(function(){ naarlinks(); }); function autoScroll(){ naarrechts(); } setInterval(autoScroll, 6000); if(typeof urlParams.lang !== 'undefined'){ $("#en, #zh, #fr, #de").hide(); $("#"+urlParams.lang).show(); } else { $("#zh, #fr, #de").hide(); } $(".caption-nl, .caption-en").hide(); $(".caption-"+language).show(); if ($(window).width() <= 992){ $("#quicksearchbar").hide(); } $(".quicksearch").on('click', function(){ $("#quicksearchbar").toggle(); if($(".quicksearch .caretqs").hasClass("up")){ $(".quicksearch .caretqs").removeClass("up").addClass("down"); } else { $(".quicksearch .caretqs").removeClass("down").addClass("up"); } }); });