﻿var _justLoaded = true; var _categorieTreeLoaded = false; var _delayedContent = null; var _delayedContentAttempt = 0; $(document).ready(function () { $("input[placeholder]").placeholder(); if ($.address) { $("a").live("click", function () { var b = /address:/.test($(this).attr("rel")) ? $(this).attr("rel").split("address:")[1].split(" ")[0] : null; if (b) { $.address.value(b); return false } }); $.address.internalChange(function (c) { var b = CreateContent(c); LoadContent(b); Sync(b) }).externalChange(function (c) { var b = null; if (c.path == "/") { if (!_justLoaded) { b = CreateContent("root", 0) } } else { b = CreateContent(c) } _justLoaded = false; if (b) { LoadContent(b); Sync(b) } }).history(true).autoUpdate(true) } else { InitializeForm(); InitializeCollapsingArea(); InitializeImageGallery() } var a = document.createElement("script"); a.type = "text/javascript"; a.src = "http://maps.google.com/maps/api/js?sensor=false&language=nl&callback=InitializeMap"; document.body.appendChild(a); $("input#Query").keypress(function (b) { if (b.which == 13) { OpenQuery($("#Query")); b.preventDefault() } }) }); function GetCategorieTreeElement() { return $("#CategorieTree") } function GetCategorieTree() { return GetCategorieTreeElement().data("tTreeView") } function GetCategorieTreeItem(a) { if ((typeof a == "string") || (typeof a == "number")) { return GetCategorieTreeElement().find("input[name='itemValue'][value='" + a + "']").closest(".t-item") } else { return null } } function TreeParentItem(a) { if ((a) && (a.length) && (a.length == 1)) { return $(a).closest(".t-item").parent().closest(".t-item") } else { return null } } function CategorieTreeExpandPath(b) { var a = GetCategorieTree(); b = TreeParentItem(b); while ((b) && (b.length == 1)) { if ($("> div > span.t-plus", b).length == 1) { a.expand(b) } b = TreeParentItem(b) } } function CreateContent(e, f, c, d) { var a; if (typeof e == "string") { a = e } else { if (typeof e == "object") { if (e.pathNames.length > 1) { a = e.pathNames[0]; f = e.pathNames[1] } if (e.pathNames.length > 2) { d = e.pathNames[2] } c = e.parameters } } var b = { type: a, id: f, page: d, parameters: c }; if (typeof b.type != "string") { b.type = "" } if ((typeof b.id != "string") && (typeof b.id != "number")) { b.id = "" } if (typeof b.parameters != "object") { b.parameters = {} } return b } function OnLoadCategorieTree(a) { window.setTimeout("_categorieTreeLoaded = true;", 3000) } function OnSelectCategorieTree(a) { return OpenCategorie(GetCategorieTree().getItemValue(a.item)) } function OpenQuery(a) { if ((typeof a == "object") && (a.val)) { a = a.val() } if (typeof a == "string") { OpenContent({ id: "ft", type: "Query", query: escape(a) }) } return false } function OpenCategorie(a) { return OpenContent({ id: a, type: "Categorie" }) } function OpenProduct(a) { return OpenContent({ id: a, type: "Product" }) } function OpenContent(b, c) { if ((b) && (b.id) && (b.type)) { var a = "/" + b.type + "/" + b.id; if (b.page) { a += "/" + b.page } if (b.query) { a += "?query=" + b.query } if ($.address) { $.address.value(a) } else { document.location.href = a } } } function LoadContent(b) { if (b) { OnBeforeContentLoad(b); var a = Path.UpdateContent; if ((typeof b.type == "string") && (typeof b.id != "undefined")) { a += b.type + "/" + b.id; if (typeof b.page != "undefined") { a += "/" + b.page } } $("#ContentContainer").load(a, b.parameters, function () { OnAfterContentLoad(b) }) } } function OnBeforeContentLoad(a) { $("#ContentContainer").html($("#LoadingContent").html()) } function OnAfterContentLoad(a) { if (a) { if (a.type.toLowerCase() == "product") { $("#ProductHistoryContainer").load(Path.UpdateProductHistory) } else { if (a.type.toLowerCase() == "static") { InitializeForm(); InitializeMap(); InitializeCollapsingArea() } } $("html, body").animate({ scrollTop: 0 }, "slow"); InitializeImageGallery(); InitializeMenu(a); LogContent(a) } } function LogContent(b) { if ((b) && (b.type) && (b.id)) { var a = $("input#logvalue").val(); if (a == null) { if ((b.parameters) && (b.parameters.query)) { a = b.parameters.query } else { a = b.id } } if (a != null) { _gaq.push(["_trackEvent", b.type, unescape(a)]); if ((b.parameters) && (b.parameters.query)) { var c = b.type + "/ft?query=" + unescape(a); if (typeof b.page != "undefined") { c += "&page=" + b.page } _gaq.push(["_trackPageview", c]) } else { _gaq.push(["_trackPageview", b.type + "/" + unescape(a)]) } } } } function InitializeImageGallery() { var a = $(".ad-gallery").adGallery({ loader_image: "Content/CSS/Gallery/loader.gif", display_next_and_prev: true, display_back_and_forward: true, effect: "fade", width: 300, height: 200, enable_keyboard_move: true, slideshow: false }) } function InitializeCollapsingArea() { $(".CollapsibleArea").hide(); $(".CollapsibleToggleButton").each(function () { $(this).html("» " + $(this).html()); $(this).addClass("ClickableTitle") }); $(".CollapsibleToggleButton").click(function (a) { a.preventDefault(); $(this).next().slideToggle() }) } function InitializeForm() { $("form#ReactieForm").submit(function (b) { $(":submit", this).attr("disabled", "disabled"); var a = $(this).attr("action"); $("form#ReactieForm").unbind("submit"); $("#ContentContainer").load(a, $(this).serializeArray(), InitializeForm); b.preventDefault() }) } function InitializeMenu(a) { if (a) { $("ul#MenuBar li").removeClass("selected"); if (a.type.toLowerCase() == "static") { $("ul#MenuBar li." + a.id).addClass("selected") } else { $("ul#MenuBar li.producten").addClass("selected") } } } var mapInfoWindow; function InitializeMap() { var c = $("div#MapCanvas"); if ((c.length == 1) && (google) && (google.maps)) { var e = new google.maps.LatLng(WebOnderdeel.Map.Latitude, WebOnderdeel.Map.Longitude); var b = { zoom: 12, center: e, mapTypeId: google.maps.MapTypeId.ROADMAP }; var d = new google.maps.Map(c[0], b); var a = new google.maps.Marker({ position: e, map: d, title: WebOnderdeel.BedrijfsNaam, icon: new google.maps.MarkerImage(WebOnderdeel.MarkerImage) }); mapInfoWindow = new google.maps.InfoWindow({ content: $("div#MapInfoWindow").html() }); google.maps.event.addListener(a, "click", function () { mapInfoWindow.open(d, a) }) } } function Sync(a) { SyncNavigation(a); SyncQuery(a) } function SyncNavigation(b) { if ((!_categorieTreeLoaded) && (_delayedContentAttempt < 5)) { _delayedContentAttempt++; _delayedContent = CreateContent(b.type, b.id, b.parameters, b.page); window.setTimeout("SyncNavigation(_delayedContent);", 100) } else { if ((b) && (b.type.toLowerCase() == "categorie")) { var a = GetCategorieTreeItem(b.id); if ((a != null) && (a.length > 0)) { GetCategorieTreeElement().find(".t-state-selected").removeClass("t-state-selected"); a.find("> div > span.t-in").addClass("t-state-selected"); CategorieTreeExpandPath(a) } } else { GetCategorieTreeElement().find(".t-state-selected").removeClass("t-state-selected") } } } function SyncQuery(a) { if ((a) && (a.type.toLowerCase() == "query") && (a.parameters) && (a.parameters.query)) { $("#Query").val(unescape(a.parameters.query)) } };
