/// (function ($) { /// /// Gets the current site varation code /// This is done by parsing a script node from the page that contains JSON /// function GetSiteVariationCode() { var lSiteVariationCode; $("head").find("script[type=application/x-website-settings]:first").each(function () { try { // We have to know in which site variation we are var lWebsiteSettings = JSON.parse(this.innerHTML); lSiteVariationCode = lWebsiteSettings.siteVariationCode; } catch (e) { $.console.warn("Couldn't read the site-variation from the page"); } }); return lSiteVariationCode; } $(document).ready(function () { // Bind an event on tab select. $(".content-subsections").bind("tabsselect", function (event, ui) { var lSiteVariationCode = GetSiteVariationCode(); // Get the tracking path var lTrackingPath = "/segments/" + (lSiteVariationCode == "hotelplan-ch-de" ? "de" : "fr") + "-position-" + (ui.index + 1) + "/" + $(ui.tab).parent().attr("data-track-name"); try { // Invoke the page tracker pageTracker._trackPageview(lTrackingPath); } catch (err) { $.console.warn("An error occured while invoking the page tracker"); } }); // Bind an event when a hotel/trip is clicked $(".content-subsections .subsection li.acco-record").bind("click", function (event) { var lSiteVariationCode = GetSiteVariationCode(); // Get data from the selected TAB var lSelectedTabNumber = $(".content-subsections").tabs("option", "selected") + 1; var lDataTrackName = $('.content-subsections').find('.ui-tabs-selected').attr("data-track-name"); var lAccoName = $(this).find(".acco-record-title strong").text().split(" ").join("-").toLowerCase(); // Get the tracking path var lTrackingPath = "/segments/" + (lSiteVariationCode == "hotelplan-ch-de" ? "de" : "fr") + "-position-" + lSelectedTabNumber + "/" + lDataTrackName + "/" + lAccoName; try { // Invoke the page tracker pageTracker._trackPageview(lTrackingPath); } catch (err) { $.console.warn("An error occured while invoking the page tracker"); } }); }); })(jQuery);