<p class="noPrint" id="back-top" style="display: none;"><a href="#body-top"><span class="fa-stack fa-3x"> <i class="fa fa-circle fa-stack-2x fa-inverse"></i> <i class="fa fa-chevron-circle-up fa-stack-1x"></i> </span> </a></p>
<script>
function getBrokerCookie() {
const name = "vivium.be-my-broker=";
const decodedCookie = decodeURIComponent(document.cookie);
const cookies = decodedCookie.split(';');
for (let cookie of cookies) {
cookie = cookie.trim();
if (cookie.startsWith(name)) {
const jsonString = cookie.substring(name.length);
return JSON.parse(jsonString);
}
}
return null;
}
function findABrokerLink() {
const baseUrl = "https://www-aws74-accp01.nonprod.vivium.be";
const l = themeDisplay.getLanguageId().substring(0, 2);
const lang = (l === 'nl' || l === 'fr') ? l : 'nl';
console.log("Current language:", lang);
const segment = window.location.pathname.includes('employed') ? 'self-employed' : 'private-individuals';
const targetURL = `${baseUrl}/${lang}/web/${segment}/${lang === 'nl' ? 'vind-een-makelaar' : 'trouver-un-courtier'}`;
console.log("constructed URL" + targetURL);
}
function updateFavoLink() {
var theFavoriteBroker = getBrokerCookie();
try {
if (theFavoriteBroker && theFavoriteBroker.prodId) {
//console.log("theFavoriteBroker", theFavoriteBroker.prodId);
const elements = document.getElementsByClassName('favoriteLink');
if (elements.length > 0) {
const link = elements[0];
try {
link.href = findABrokerLink() + "?oid=" + theFavoriteBroker.prodId;
//console.log("Success! Link updated to:", link.href);
} catch (e) {
console.error("Cookie object error:", e);
}
}
}
const pElements = document.getElementsByClassName('searchOther');
if (pElements.length > 0) {
const pLink = pElements[0].querySelector('a');
if (pLink) {
pLink.href = findABrokerLink();
//console.log("Paragraph link updated.");
}
}
} catch (error) {
console.error("Error updating links:", error);
}
findABrokerLink();
}
setTimeout(updateFavoLink, 500);
</script>