(function(){var lastTime=0;var vendors=['ms','moz','webkit','o'];for(var x=0;x<vendors.length&&!window.requestAnimationFrame;++x){window.requestAnimationFrame=window[vendors[x]+'RequestAnimationFrame'];window.cancelAnimationFrame=window[vendors[x]+'CancelAnimationFrame']||window[vendors[x]+'CancelRequestAnimationFrame'];}
if(!window.requestAnimationFrame)
window.requestAnimationFrame=function(callback,element){var currTime=new Date().getTime();var timeToCall=Math.max(0,16-(currTime-lastTime));var id=window.setTimeout(function(){callback(currTime+timeToCall);},timeToCall);lastTime=currTime+timeToCall;return id;};if(!window.cancelAnimationFrame)
window.cancelAnimationFrame=function(id){clearTimeout(id);};}());window.AB={getDomain:function(){try{var i=0,domain=document.domain,p=domain.split('.'),s='_gd'+(new Date()).getTime();while(i<(p.length-1)&&document.cookie.indexOf(s+'='+s)==-1){domain=p.slice(-1-(++i)).join('.');document.cookie=s+"="+s+";domain="+domain+";";}
document.cookie=s+"=;expires=Thu, 01 Jan 1970 00:00:01 GMT;domain="+domain+";";return domain;}catch(error){return null;}},getSubdomain:function(hostname){var domain=window.AB.getDomain();var subdomain=null;if(domain){var ii=hostname.indexOf(domain);subdomain=hostname.substring(0,ii);if(subdomain&&subdomain.length){subdomain=subdomain.slice(0,subdomain.length-1);}}else{subdomain=hostname.split('.')[2]?hostname.split('.')[0]:'';}
return subdomain;},converted:function(){var uuid='';if(typeof Storage!=='undefined'){uuid=localStorage.getItem('abtesting.ai-uuid')||'';}
var xhr=new XMLHttpRequest();xhr.withCredentials=true;xhr.open('POST','https://external.abtesting.ai/visitor_converted/',true);xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');xhr.send(encodeURI('url='+window.location.href+'&uuid='+uuid));if(window.gtag){gtag('event','abtesting_ai_conversion',{event_category:'abtesting_ai',event_label:'abtesting_ai_conversion',value:1});}else if(window.ga){ga('send',{hitType:'event',eventCategory:'abtesting_ai',eventAction:'abtesting_ai_conversion',eventLabel:'abtesting_ai_conversion',eventValue:1});}},visited:function(){var uuid='';if(typeof Storage!=='undefined'){uuid=localStorage.getItem('abtesting.ai-uuid')||'';}
var e=document.documentElement;var g=document.getElementsByTagName('body')[0];var width=window.innerWidth||e.clientWidth||g.clientWidth;var params='width='+width
+'&url='+encodeURIComponent(window.location.href)
+'&referrer='+encodeURIComponent(document.referrer);+'&uuid='+encodeURIComponent(uuid)
+'&url_params='+encodeURIComponent(window.location.search);var xhr=new XMLHttpRequest();xhr.withCredentials=true;xhr.open('POST','https://external.abtesting.ai/visitor_visited/',true);xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');xhr.send(params);},lookupElementByXPath:function(path){if(path.startsWith('/iframe')){var newPath=path.slice(7);var iframes=document.getElementsByTagName('iframe');for(var ii=0;ii<iframes.length;ii++){try{var iframe=iframes[ii];var innerDoc=iframe.contentDocument||iframe.contentWindow.document;var result=innerDoc.evaluate(newPath,innerDoc.documentElement,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null);if(result&&result.singleNodeValue){return result.singleNodeValue;}}catch(error){continue;}}}else{var result=document.evaluate(path,document.documentElement,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null);return result.singleNodeValue;}
return null;},state:null,alterDOM:function(){function alterElement(elementToChange){var element=AB.lookupElementByXPath(elementToChange.xpath);if(!element){requestAnimationFrame(alterElement.bind(this,elementToChange));}else{if(elementToChange.change){var change=elementToChange.change;if(change.property_level_2===null){if(element.tagName.toLowerCase()==='image'&&change.property_level_1==='href'){element.setAttributeNS('http://www.w3.org/1999/xlink','href',change.value);}else if(element.tagName==='IMG'&&change.property_level_1==='src'){element.src='';element.removeAttribute('srcset');if(element.parentElement.tagName==='PICTURE'){for(var i=0;i<element.parentElement.children.length;i++){var child=element.parentElement.children[i];child.srcset='';child.srcset=change.value;child.src='';child.src=change.value;}}}
element[change.property_level_1]=change.value;}else if(change.property_level_1==='style'){element.style.setProperty(change.property_level_2,change.value,"important");}else{element[change.property_level_1][change.property_level_2]=change.value;}
if(window.wixBiSession||window.wixDealerLightbox||window.wixTagManager||window.wixEmbedsAPI){requestAnimationFrame(alterElement.bind(this,elementToChange));}}
if(elementToChange.event){var event=elementToChange.event;var callback=null;if(event.execute_converted){callback=function(e){AB.converted();};}else{callback=new Function('event',event.custom_callback);}
if(event.name==='elementLoaded'){callback();}else if(element.addEventListener){element.addEventListener(event.name,callback,false);}else if(element.attachEvent){element.attachEvent(event.fallback_name,callback);}}}}
var state={"changes_dict": {}, "webpage_settings": {}, "changes_dict_regex": {}, "current_path": "/halifax/halifax-considers-taking-over-housing-from-the-province/Content", "current_subdomain": "", "target_coversion_paths": [], "variation_id": "", "analytics_web_property_id": null, "analytics_dimension_id": null};AB.state=state;state.changes_dict=state.changes_dict||{};state.webpage_settings=state.webpage_settings||{};state.changes_dict_regex=state.changes_dict_regex||{};state.current_path=state.current_path||'';state.current_subdomain=state.current_subdomain||'';state.target_coversion_paths=state.target_coversion_paths||[];state.current_full_url=window.location.href;function get_changes(){var allChanges=[];var key=state.current_subdomain+'>>>'+state.current_path;if(state.changes_dict[key]){if(state.webpage_settings[key]&&state.webpage_settings[key].match_only_full_url&&state.current_full_url!=state.webpage_settings[key].full_url){allChanges=[];}else{allChanges=state.changes_dict[key];if(state.webpage_settings[key]&&state.webpage_settings[key].variation_id){AB.state.variation_id=state.webpage_settings[key].variation_id}else{AB.state.variation_id=null}}}
for(var key in state.changes_dict_regex){var subdomain=key.split('>>>')[0];var regex=key.split('>>>')[1];var changes=state.changes_dict_regex[key];if(state.current_path.match(new RegExp(regex))&&state.current_subdomain==subdomain){allChanges=allChanges.concat(changes);}}
return allChanges;}
function execute_changes(isFirstTime){var changes=get_changes();changes.push({xpath:'//body',change:{property_level_1:'style',property_level_2:'visibility',value:'visible'}});for(var i=0;i<changes.length;i++){var elementToChange=changes[i];alterElement(elementToChange);}
for(var i=0;i<state.target_coversion_paths.length;i++){var path=state.target_coversion_paths[i].path;var subdomain=state.target_coversion_paths[i].subdomain;var match_type=state.target_coversion_paths[i].match_type;var full_url=state.target_coversion_paths[i].full_url;if(match_type==='full'&&state.current_path===path&&state.current_subdomain===subdomain){AB.converted();}else if(match_type=='regex'&&state.current_full_url.match(full_url)){AB.converted();}}}
var timesExecuted=0;var timeoutToWait=10;var maxTimesExecuted=600;function setGoogleAnlayticsDimension(){if(window.dataLayer&&!window.gtag&&timesExecuted<maxTimesExecuted){timesExecuted++;setTimeout(setGoogleAnlayticsDimension,timeoutToWait);return;}else if(window.dataLayer&&!window.gtag&&AB.state.analytics_web_property_id&&AB.state.analytics_dimension_id&&AB.state.variation_id){window.gtag=function(){dataLayer.push(arguments);};gtag('js',new Date());gtag('config',AB.state.analytics_web_property_id);}else if(!window.dataLayer&&!window.gtag&&!window.ga&&timesExecuted<maxTimesExecuted){timesExecuted++;setTimeout(setGoogleAnlayticsDimension,timeoutToWait);return;}
if(window.gtag&&AB.state.analytics_web_property_id&&AB.state.analytics_dimension_id&&AB.state.variation_id){var custom_map={};custom_map[AB.state.analytics_dimension_id.slice(3)]='variation';gtag('config',AB.state.analytics_web_property_id,{'custom_map':custom_map});gtag('event','abtesting_ai_variation',{'variation':AB.state.variation_id});}else if(window.ga&&AB.state.analytics_web_property_id&&AB.state.analytics_dimension_id&&AB.state.variation_id){ga('set',AB.state.analytics_dimension_id.slice(3),AB.state.variation_id);}}
execute_changes(true);setGoogleAnlayticsDimension();if(window.history){var _wr=function(type){var orig=history[type];return function(){var rv=orig.apply(this,arguments);var e=new Event(type);e.arguments=arguments;window.dispatchEvent(e);return rv;};};history.pushState=_wr('pushState');history.replaceState=_wr('replaceState');history.popState=_wr('popState');var onUrlChange=function(e){state.current_path=e.arguments[2];state.current_subdomain=AB.getSubdomain(e.target.location.hostname);state.current_full_url=e.target.location.href;execute_changes();setGoogleAnlayticsDimension();AB.visited();};window.addEventListener('pushState',onUrlChange);window.addEventListener('replaceState',onUrlChange);window.addEventListener('popState',onUrlChange);}
if(window.Squarespace){window.addEventListener('mercury:load',function(){AB.alterDOM()});}}}
AB.alterDOM();