//Common js functions for Van Speyk Watches website - by NetFiesta - v2.0 $(document).ready(function () { var scrolling_by_menu = false; url = History.getState().url.replace(/^.*\/\/[^\/]+/, ''); /* $(document).scroll(function () { if ($(".page:visible").length > 1 && scrolling_by_menu == false) { if ($(document).scrollTop() < 950) $("body").removeClass("bgpos"); else $("body").addClass("bgpos"); } }); */ //Check URL on landing if need to be scrolled to other part then homepage if (url == "/vitesse") gotoDynamicPart("vitesse", null, null, 1500, false); if (url == "/history" || url == "/historie") gotoDynamicPart("history", null, null, 1500, false); if (url == "/collectie" || url == "/collection") gotoCollection("collection", null, null, 1500, true); if (url == "/testimonials" || url == "/ervaringen") gotoDynamicPart("testimonials", null, null, 1500, false); if (url == "/dealers") gotoDynamicPart("dealers", null, null, 1500, false); if (url == "/contact") gotoDynamicPart("contact", null, null, 1500, false); //End check URL on landing if ($("body.scroller").length > 0) { $(".lnk_home").click(function () { gotoDynamicPart("home", "Van Speyk Horloges", "/", 1500, true); return false; }); $("#lnk_vitesse").click(function () { gotoDynamicPart("vitesse", "Van Speyk timesponsor Vitesse", "/vitesse", 1500, true); return false; }); $("#lnk_history").click(function () { gotoDynamicPart("history", "History of Van Speyk", "/history", 1500, true); return false; }); $("#lnk_testimonials").click(function () { gotoDynamicPart("testimonials", "Ervaringen en berichten over Van Speyk horloges", "/testimonials", 1500, true); return false; }); $("#lnk_dealers").click(function () { gotoDynamicPart("dealers", "Van Speyk Dealers", "/dealers", 1500, true); return false; }); $("#lnk_collection").click(function () { gotoCollection("collection", "Van Speyk horloge collectie", "/collection", 1500, true); return false; }); $("#lnk_contact").click(function () { gotoDynamicPart("contact", "Van Speyk contact", "/contact", 1500, true); return false; }); } if ($("#slider-wrapper").length > 0) { var myslider = new Cute.Slider(); myslider.setup("home-slider", "slider-wrapper"); } $("div.q").click(function () { $(this).next().slideToggle(); }); $("input[type=submit].checkform").click(function () { checkForm($(this).parents('form').attr("id"), $(this).prev(".checkform_section").val()); return false; }); $("#specs .group:eq(1)").nextAll("li:not(.group)").css("display", "none"); $("#specs .group:eq(0)").addClass("down"); $("#specs .group").click(function () { $(this).nextUntil("li.group").slideToggle(); $(this).toggleClass("down"); }) if ($("#order_country").length) { $("#order_country").select2({ placeholder: "Choose a country" }) } $("input[type=radio]").button(); //Alternative up & down button var scroller_end_value = (-(($("#alternatives #scroller div").length - 4) * 235)); if ($("#pr_cat_current").length > 0) { if (parseInt(sessionStorage['current_cat_uid']) != parseInt($("#pr_cat_current").val())) sessionStorage.clear(); sessionStorage['current_cat_uid'] = parseInt($("#pr_cat_current").val()); } if (!sessionStorage['scroll_pos']) { var s = 0; } else { block_pos = parseInt(sessionStorage['scroll_pos']); s = block_pos; $("#alternatives #scroller>div").css({ marginTop: ((-235 * block_pos) + 16) + "px" }); } if (parseInt($("#alternatives #scroller>div").css("margin-top")) > 0) $("#alternatives .up").removeClass("active"); if ((parseInt($("#alternatives #scroller>div").css("margin-top")) - 20) < scroller_end_value) $("#alternatives .down").removeClass("active"); $("#alternatives .up").on("click", function () { $("#alternatives #scroller>div").finish(); if (parseInt($("#alternatives #scroller>div").css("margin-top")) < 0) { $("#alternatives #scroller>div").finish().animate({ marginTop: "+=235px" }, 600); $("#alternatives .down").addClass("active"); s--; sessionStorage['scroll_pos'] = s; //Disable up button if (parseInt($("#alternatives #scroller>div").css("margin-top")) > -235) $("#alternatives .up").removeClass("active"); } }) $("#alternatives .down").on("click", function () { $("#alternatives #scroller>div").finish(); if ((parseInt($("#alternatives #scroller>div").css("margin-top")) - 20) > scroller_end_value) { $("#alternatives #scroller>div").finish().animate({ marginTop: "-=235px" }, 600); $("#alternatives .up").addClass("active"); s++; sessionStorage['scroll_pos'] = s; //Disable down button if ((parseInt($("#alternatives #scroller>div").css("margin-top")) - 20) < (scroller_end_value + 235)) $("#alternatives .down").removeClass("active"); } }) //End alternative up & down button $(".underconstruction").click(function () { alert("Dit onderdeel van de website is nog in ontwikkeling.\nOnze excuses voor het ongemak.\n\nThis part of the website is still in development.\nSorry for the inconvenience."); return false; }); //Click in block1 on green button $("#order_complete_step1").on("click", function () { $("#block1").animate({ marginLeft: "-=1020px" }, 400, function () { $(this).children(".overlay").fadeIn(1300); $("#block2 .fulloverlay").hide(); $("#block2").animate({ opacity: "1" }, 1300); }); return false; }); //Click in block2 on blue button $("#block2 input[type=button]").on("click", function () { $("#block1 .overlay").fadeOut(300); $("#block2 .fulloverlay").show(); $("#block2").animate({ opacity: "0.25" }, 1300); $("#block1").animate({ marginLeft: "+=1020px" }, 400); return false; }); //Click in block3 on blue button $("#block3 input[type=button]").on("click", function () { $("#block2 .overlay").fadeOut(300); $("#block3 .fulloverlay").show(); $("#block3").animate({ opacity: "0.25" }, 1300); $("#block2").animate({ marginLeft: "+=1050px" }, 400); return false; }); $("#frm_basket input[type=text].amount").focus(function () { $(this).select(); }); $("#frm_basket .amount, #order_country").on({ change: function () { $("#frm_basket").submit(); }, keyup: function () { $("#frm_basket").submit(); } }); //Product slider functions if ($("#pr_slider").length > 0) { var pr_slider = new $JssorSlider$('pr_slider', { $AutoPlay: false, $ArrowKeyNavigation: true, $DragOrientation: 0, $ArrowNavigatorOptions: { $Class: $JssorArrowNavigator$, $ChanceToShow: 2 }, $ThumbnailNavigatorOptions: { //[Optional] Options to specify and enable thumbnail navigator or not $Class: $JssorThumbnailNavigator$, //[Required] Class to create thumbnail navigator instance $ChanceToShow: 2, //[Required] 0 Never, 1 Mouse Over, 2 Always $AutoCenter: 1, $ActionMode: 1, //[Optional] 0 None, 1 act by click, 2 act by mouse hover, 3 both, default value is 1 $Lanes: 4, //[Optional] Specify lanes to arrange thumbnails, default value is 1 $DisplayPieces: 4, //[Optional] Number of pieces to display, default value is 1 $Orientation: 2 //[Optional] Orientation to arrange thumbnails, 1 horizental, 2 vertical, default value is 1 } }); zoomoptions = { scrollZoom: true, cursor: "move", zoomWindowWidth: 298, zoomWindowHeight: 467, zoomType: "window", containLensZoom: true, lensFadeIn: 750 }; pr_slider.$On($JssorSlider$.$EVT_PARK, function (position, fromPosition) { $(".zoomer" + fromPosition).elevateZoom({ zoomEnabled: false }); $(".zoomContainer").remove(); if ($(".zoomer" + position).length > 0) { $(".zoomer" + position).elevateZoom(zoomoptions); } if (fromPosition != -1) setTimeout("if($('.zoomContainer').length > 1) {$('.zoomContainer:eq(0)').remove();}", 100); }); } //End product slider functions //Start facebook plugin $(".facebook-wall").jQueryFacebookWall({ appId: fb_appid, domain: fb_domain, installDirectory: "/js/jqueryfacebookwall/", facebookUser: "195066993920273", display: "wall", displayAnimation: true, displayAnimationDelay: 250, language: "english", likeAndCommentBackup: "popup", facebookLoginButton: { show: true, position: "left" }, posts: { show: true, feedType: "feed", limit: 10, order: 5 }, comments: { limit: 20, showAtStart: 5, showMoreNum: 10 }, photos: { show: true, type: "uploaded", numColumns: 3, showAtStart: 18, limit: 30, order: 2 }, events: { show: false }, videos: { show: false }, likes: { show: false }, albums: { show: false }, debug: false }); //End facebook plugin }); var carrouselloaded = false; function gotoCollection(id, title, url, scrollspd, pushstate) { if (pushstate == true) History.pushState("", title, url); $("#" + id).show(0, function () { if (carrouselloaded == false) { $('#icarousel1').iCarousel({ slides: 5, // How many slides will be shown (Must be an odd number) make3D: false, // To Enable or Disable 3D effect. perspective: 0, // The 3D perspective option. (Min 0 & Max 100); animationSpeed: 500, // Slide transition speed (Microsecond) pauseTime: 5000, // How long each slide will show (Microsecond) directionNav: true, // Next & Previous navigation autoPlay: false, // To Enable or Disable the autoplay keyboardNav: true, // To Enable or Disable the keyboard navigation touchNav: true, // To Enable or Disable the touch navigation mouseWheel: false, // To Enable or Disable the mousewheel navigation pauseOnHover: false, // To Enable or Disable the carousel when mouse come over it randomStart: false, // Start on a random slide slidesSpace: '425', // Spaces between slides slidesTopSpace: '-60', // Top Space for the slides timer: 'Pie', // Timer style: "Pie", "360Bar" or "Bar" timerBg: '#fff', // Timer background timerColor: '#000', // Timer color timerOpacity: 0.5, // Timer opacity timerDiameter: 20, // Timer diameter timerPadding: 3, // Timer padding timerStroke: 3, // Timer stroke width timerBarStroke: 1, // Timer Bar stroke width timerBarStrokeColor: '#EEE', // Timer Bar stroke color timerBarStrokeStyle: 'solid', // Timer Bar stroke style timerBarStrokeRadius: 4, // Timer Bar stroke radius onAfterLoad: function () { carrouselloaded = true; } // Triggers when carousel has loaded }); $('#icarousel2').iCarousel({ slides: 5, make3D: false, perspective: 0, animationSpeed: 500, pauseTime: 5000, directionNav: true, autoPlay: false, keyboardNav: true, touchNav: true, mouseWheel: false, pauseOnHover: false, randomStart: false, slidesSpace: '425', slidesTopSpace: '-60', timer: 'Pie', timerBg: '#fff', timerColor: '#000', timerOpacity: 0.5, timerDiameter: 20, timerPadding: 3, timerStroke: 3, timerBarStroke: 1, timerBarStrokeColor: '#EEE', timerBarStrokeStyle: 'solid', timerBarStrokeRadius: 4, onAfterLoad: function () { carrouselloaded = true; } // Triggers when carousel has loaded }); $('#icarousel3').iCarousel({ slides: 5, make3D: false, perspective: 0, animationSpeed: 500, pauseTime: 5000, directionNav: true, autoPlay: false, keyboardNav: true, touchNav: true, mouseWheel: false, pauseOnHover: false, randomStart: false, slidesSpace: '425', slidesTopSpace: '-60', timer: 'Pie', timerBg: '#fff', timerColor: '#000', timerOpacity: 0.5, timerDiameter: 20, timerPadding: 3, timerStroke: 3, timerBarStroke: 1, timerBarStrokeColor: '#EEE', timerBarStrokeStyle: 'solid', timerBarStrokeRadius: 4, onAfterLoad: function () { carrouselloaded = true; } // Triggers when carousel has loaded }); } }); setTimeout( function () { $("#" + id).animatescroll({ scrollSpeed: scrollspd, easing: 'easeInOutCubic', padding: 100, onScrollStart: function () { scrolling_by_menu = true; $("body").addClass("bgpos"); }, onScrollEnd: function () { scrolling_by_menu = false; activateMenuItem($("#lnk_" + id)); $('.icarousel').trigger('iCarousel:play'); } }); }, 350); } function gotoDynamicPart(id, title, url, scrollspd, pushstate) { $('.icarousel').trigger('iCarousel:pause'); if (pushstate == true) History.pushState("", title, url); //if (id != "home") //$("#" + id).appendTo("#content_container"); $("#" + id).show(0); setTimeout( function () { $("#" + id).animatescroll({ scrollSpeed: scrollspd, easing: 'easeInOutCubic', padding: 100, onScrollStart: function () { scrolling_by_menu = true; if (id == "home") $("body").removeClass("bgpos"); else $("body").addClass("bgpos"); }, onScrollEnd: function () { scrolling_by_menu = false; if (id == "home") { $(".page:not(#home)").hide(); activateMenuItem($(".lnk_home")); } else { activateMenuItem($("#lnk_" + id)); } } }); }, 350); } function startVitesseItem() { gotoDynamicPart("vitesse", "Van Speyk timesponsor Vitesse", "/vitesse", 1500, true); } function startCollectionItem() { gotoCollection("collection", "Van Speyk horloge collectie", "/collection", 1500, true); } function activateMenuItem(currentitem) { $("menu a").removeClass("active"); currentitem.addClass("active"); } function btEscape(input) { return input.replace("&", "%26").replace("=", "%3D"); } function checkAjaxError(xhr) { alert((xhr.responseText)); } function createAjaxPost(form_id) { var querystring = ""; $("#" + form_id + " input[type=text], #" + form_id + " input[type=hidden]:not(#__VIEWSTATE):not(#__EVENTVALIDATION):not(#__EVENTTARGET):not(#__EVENTARGUMENT):not(#__PREVIOUSPAGE), #" + form_id + " input[type=password]").each(function () { querystring += $(this).attr("name") + "=" + btEscape($(this).val()) + "&"; }); $("#" + form_id + " input[type=radio]:checked").each(function () { querystring += $(this).attr("name") + "=" + $(this).val() + "&"; }); $("#" + form_id + " select").each(function () { querystring += $(this).attr("name") + "=" + escape($(this).val().substr(0, 25)) + "&"; }); $("#" + form_id + " textarea").each(function () { querystring += $(this).attr("name") + "=" + escape($(this).val().substr(0, 25)) + "&"; }); $("#" + form_id + " input[type=checkbox]:checked").each(function () { querystring += $(this).attr("name") + "=1&"; }); return querystring.slice(0, -1); } function checkForm(form_id, section) { disableSubmitButton(form_id); querystring = createAjaxPost(form_id); $.ajax({ type: "POST", url: "ajax/checkform/" + form_id + "/" + section, cache: false, dataType: "script", data: querystring, error: checkAjaxError, success: function (msg) { enableSubmitButton(form_id); msg; } }); return false; } function disableSubmitButton(form_id) { s_btn = $("#" + form_id + " input[type=submit]"); s_btn.attr("disabled", true); s_btn.addClass("disabled"); } function enableSubmitButton(form_id) { s_btn = $("#" + form_id + " input[type=submit]"); s_btn.attr("disabled", false); s_btn.removeClass("disabled"); } function markErrorField(elm) { do_element = $("#" + elm); if (do_element.is("select")) { $("label[for=" + elm + "]").addClass("errorlabel"); $("#ss_" + elm).addClass("errorfield"); } else { do_element.addClass("errorfield"); do_element.prev("label").addClass("errorlabel"); $("#label_"+elm).addClass("errorlabel"); } //Focus first error element $(".errorfield").eq(0).focus(); } function clearErrors() { $(".errorfield").removeClass("errorfield"); $(".errorlabel").removeClass("errorlabel"); }