var exceptionmessage = null; try { var avia_already_defined = false; if (typeof(_an_tracker) !== 'undefined') { avia_already_defined = true; } // First, define JS versions of methods not allowed from FBJS. _an_tracker = { _fbjs: false, createImage : function(imgsrc) { var img = document.createElement('img'); img.src = imgsrc; img.style.height = '0px'; img.style.width = '1px'; img.style.border = '0px'; return img; }, createHiddenIFrame : function(iframe_url) { var iframe = document.createElement('iframe'); iframe.src = iframe_url; iframe.style.height = '0px'; iframe.style.width = '1px'; iframe.style.border = '0px'; return iframe; }, getRootElement : function() { return document.body; }, getTagNameForNode : function(node) { return node.tagName; }, getClassNameForNode : function(node) { return node.className; }, getParentForNode : function(node) { return node.parentNode; }, getSrcForImage : function(image) { return image.src; }, getHrefForAnchor : function(anchor) { return anchor.href; }, setHrefForAnchor : function(anchor, new_href) { anchor.href = new_href; } }; // Demo reporting is defined only for pure JS implementations; it's not allowed on FB. _an_tracker.add_demo_to_url = function (url) { if (typeof(adnectar_user_id) != 'undefined') { url = url.replace('_adnectar_user_id_', escape(adnectar_user_id)); } if (typeof(adnectar_birthday) != 'undefined') { url = url.replace('_adnectar_birthday_', escape(adnectar_birthday)); } if (typeof(adnectar_sex) != 'undefined') { url = url.replace('_adnectar_sex_', escape(adnectar_sex)); } if (typeof(adnectar_country) != 'undefined') { url = url.replace('_adnectar_country_', escape(adnectar_country)); } return url; } _an_tracker.update_click_urls = function () { var root = _an_tracker.getRootElement(); var i, anchors, href; var anchors = root.getElementsByTagName('a'); for (var i = 0; i < anchors.length; i++) { var href = _an_tracker.getHrefForAnchor(anchors[i]); var new_href = _an_tracker.add_demo_to_url(href); if (new_href != href) { _an_tracker.setHrefForAnchor(anchors[i], new_href); } } } _an_tracker.appendANOptionsToBeaconUrl = function(beacon_url) { beacon_url += '&site_key=' + this._an_site_key; if (typeof(adnectar_creative_key) != 'undefined') { beacon_url += '&creative_key=' + adnectar_creative_key; } if (typeof(adnectar_creative_url) != 'undefined') { beacon_url += '&creative_url=' + adnectar_creative_url; } if (typeof(adnectar_user_id) != 'undefined') { beacon_url += '&actor_user_id=' + adnectar_user_id; } if (typeof(adnectar_birthday) != 'undefined') { beacon_url += '&actor_birthday=' + adnectar_birthday; } if (typeof(adnectar_sex) != 'undefined') { beacon_url += '&actor_sex=' + adnectar_sex; } if (typeof(adnectar_country) != 'undefined') { beacon_url += '&actor_country=' + adnectar_country; } return beacon_url; }; _an_tracker._an_base_url = 'http://goods.adnectar.com/'; _an_tracker._an_version = '3.0.0'; _an_tracker._an_site_key = 'a9aa425c93ef5dff380c'; _an_tracker._an_reporting_functions = []; _an_tracker.sendBeacon = function(method, url_params) { var beacon_url = this._an_base_url + method + '?api_version=' + this._an_version; beacon_url = this.appendANOptionsToBeaconUrl(beacon_url); if (url_params != null) { beacon_url += '&' + url_params; } var random = Math.floor(Math.random() * 10000000); beacon_url += '&ord=' + random; // If this happens to be a goods.adnectar.com URL, send to a random host. var random = Math.floor(Math.random() * 100); var new_hostname = "goods" + random + ".adnectar.com"; beacon_url = beacon_url.replace("goods.adnectar.com", new_hostname); var img = _an_tracker.createImage(beacon_url); var adnectar_container = document.getElementById('adnectar_container'); if (adnectar_container != null) { adnectar_container.appendChild(img); } }; _an_tracker.loadHiddenIFrame = function(iframe_url) { var iframe = _an_tracker.createHiddenIFrame(iframe_url); var adnectar_container = document.getElementById('adnectar_container'); if (adnectar_container != null) { adnectar_container.appendChild(iframe); } }; _an_tracker.onScriptLoad = function() { this.loadHiddenIFrame('http://goods.adnectar.com/static/quantcast_1.html'); }; _an_tracker.reportCreatives = function() { this.sendBeacon('analytics/record_impression', 'impression_context=page_view'); for (var i = 0; i < _an_tracker._an_reporting_functions.length; i++) { var reporting_function = _an_tracker._an_reporting_functions[i]; if (typeof(reporting_function) === 'function') { reporting_function(); } } }; _an_tracker.handleException = function(exceptionmessage, additional_url_params) { try { var url_params = 'exception_message=' + escape(exceptionmessage); url_params += '&context=avia_runtime'; if (additional_url_params !== null && additional_url_params !== '') { url_params += '&' + additional_url_params; } _an_tracker.sendBeacon('apis/record_exception', url_params); } catch (e) { // If we fail to report the exception, ignore the failure. } }; _an_tracker.add_reporting_function = function(reporting_function) { _an_tracker._an_reporting_functions.push(reporting_function); }; _an_tracker.onScriptLoad(); // Report all the creatives for this page. if (avia_already_defined === false) { _an_tracker.reportCreatives(); } } catch (e) { exceptionmessage = e.message; } try { if (exceptionmessage != null) { var url_params = 'exception_message=' + escape(exceptionmessage); url_params += '&context=avia_init'; _an_tracker.sendBeacon('apis/record_exception', url_params); } } catch (e) { // If we fail to report the exception, ignore it. }