// corelio advertising by adhese.com
var adheseLang = "fr";
var adheseSite = "dso";
var adheseCookie;
var adheseLoc;
var adheseProfile;
var adheseRand;
var adheseIframe = false;
var adhesePreviewMode = false;
var adheseDemoMode = false;
var adhesePreviewCreativeId = undefined;
var adhesePreviewTemplateId = undefined;
var adhesePageview = 1;
var adheseLocation = "";

function checkForPreview() {
	//check for preview parameter
	if (location.search.indexOf("adhesePreview")!=-1) {
		var p = location.search.substring(1).split("&");
		for (var x=0; x<p.length; x++) {
			if (p[x].split("=")[0]=="adhesePreviewCreativeId") {
				adhesePreviewCreativeId = p[x].split("=")[1];
				if (adhesePreviewTemplateId) break;
			}
			if (p[x].split("=")[0]=="adhesePreviewCreativeTemplate") {
				adhesePreviewTemplateId = p[x].split("=")[1];
				if (adhesePreviewTemplateId) break;
			}
		}
		createAdheseCookie("adhese_preview",adhesePreviewCreativeId+"&"+adhesePreviewTemplateId,0);
		adhesePreviewCreativeId = unescape(adhesePreviewCreativeId);
		adhesePreviewMode = true;
		addAdheseLoadEvent(showPreviewSign);
	} else if (readAdheseCookie("adhese_preview")) {
		var v = readAdheseCookie("adhese_preview").split("&");
		adhesePreviewCreativeId = unescape(v[0]);
		adhesePreviewTemplateId = v[1];
		adhesePreviewMode = true;
		addAdheseLoadEvent(showPreviewSign);
	}
}

function checkForDemo() {
	//check for preview parameter
	if (location.search.indexOf("adheseDemo")!=-1) {
		createAdheseCookie("adhese_demo","y",0);
		adheseDemoMode = true;
	} else if (readAdheseCookie("adhese_demo")) {
		adheseDemoMode = true;
	}
}

function createAdheseCookie(name,value,days) {
	if (days && days > 0) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readAdheseCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseAdheseCookie(name) {
	createAdheseCookie(name,"",-1);
}

function showPreviewSign() {
	var p = document.createElement('DIV');
	var msg = "<div onclick='quitAdhesePreview(); return false;' style='font-family:Helvetica,Verdana; font-size:12px; text-align:center; background-color:#000000; color: #ffffff; position:fixed; top:0px; left:6px; padding:4px; border-style:dashed; border:2px; border-color:#000000;z-index:9999'>";
	msg += "<p><b>Disable<br>Adhese<br>preview</b></p></div>";
	p.innerHTML = msg;
	document.body.appendChild(p);
}

function quitAdhesePreview() {
	eraseAdheseCookie("adhese_preview");
	location.href = location.href.split("?")[0]
}

function getAdheseLoc() {
	var l = location.pathname;
	if (l.charAt(0)=='/') l = l.substring(1,l.length);
	if (l.charAt(l.length-1)=='/') l = l.substring(0,l.length-1);
	var m = undefined;	
	if (l.indexOf('/')!=-1) {
		l = l.substring(0,l.lastIndexOf('/'));
		m = l.split('/');
	} else {
		m = new Array();
		m[0] = l;
	}
	var loc = "_";
	if (m!=undefined) {
		for (var x=0; x<m.length; x++) {
			loc += m[x] + '_';
		}
	}
	return loc;
}

function clearURL(s){
	// clears url from # and ?
	var r = s;
	r = r.split(" ").join("_");
	r = r.split("|").join("_");
	if(r.indexOf("#")>0){
		r = r.substr(0, r.indexOf("#"));
	}
	if(r.indexOf("?")>0){
		r = r.substr(0, r.indexOf("?"));
	}
	return r
}

function getAdheseProfileData() {
	var p = new Object();
	if(typeof(user_postcode) != 'undefined') {
		p.zip = user_postcode;
	}
	if(typeof(user_leeftijd) != 'undefined') {
		p.age = user_leeftijd;
	}
	if(typeof(user_geslacht) != 'undefined') {
		p.gender = user_geslacht;
		if (p.gender == "M") p.gender = "1";
		else if (p.gender == "V") p.gender = "3";
		else p.gender = "0";
	}
	if(typeof(user_abo) != 'undefined') {
		p.abo = user_abo;
	}
	
	//set adheseSite as memberStatus
	p.memberstatus = adheseSite;
	
	// add interests
	p.interest = "";
	if(typeof(job_functie) != 'undefined') {
		p.interest += "jobs" + job_functie;
	}
	
	// add brands
	p.brand = AdheseBrowserDetect.browser + ";" + AdheseBrowserDetect.browser + AdheseBrowserDetect.version + ";" + AdheseBrowserDetect.OS;
	
	p.count = adhesePageview;
	return p;
}

function initPageAdhese() {
	checkForPreview();
	checkForDemo();
	if(typeof(adheseRand) == 'undefined') {
		adheseRand = Math.round(Math.random()*1000);
	}
	
	// count pageview / day
	var v = readAdheseCookie("adhese_count");
	if (v!=undefined) adhesePageview = parseInt(v);
	createAdheseCookie("adhese_count",adhesePageview+1,0);
	
	
	adheseLoc = getAdheseLoc();
	adheseProfile = getAdheseProfileData();
}

function getAdheseAdLoc() {
	if(typeof(adhese_extra) != 'undefined') {
		if(adhese_extra == "nbo_videopartner" || adhese_extra == "dso_videopartner" || adhese_extra == "ave_videopartner"){
			if(typeof(provider) != undefined){
				return new Array("_" + adhese_extra + '_' + provider + "_");		
			}
		}else{
			return new Array("_" + adhese_extra + "_");
		}
	}
	if(typeof(sectie) == 'undefined') {
		sectie = "0";
	}
	if(typeof(subsectie) == 'undefined') {
		subsectie = "110";
	}
	if(typeof(section) == 'undefined') {
		section = "unknown";
	}
	var adh_channel = "";
	if(typeof(kanaal) != 'undefined') {
		adh_channel = "_kanaal_" + kanaal + "_";
	}
	if(typeof(channel) != 'undefined') {
		adh_channel = "_kanaal_" + channel + "_";
	}
	var loc = "_";
	adheseLang = "nl";
	if (location.host.indexOf("nieuwsblad")!=-1 && location.pathname.toLowerCase().indexOf("sportwereld")!=-1) {
		if (location.pathname=="/sportwereld/" || location.pathname.indexOf("index.html")!=-1) loc += "spo_home_";
		else loc += "spo_"+sectie+"_"+subsectie+"_";
		adheseSite = "nbo";
	} else if (location.host == "preview.nieuwsblad.be" || location.host == "test.nieuwsblad.be") { 
		loc = "_nbo_preview_"; 
	} else if (location.host == "preview.standaard.be") { 
		loc = "_dso_preview_";	
	} else if (location.host.indexOf("nieuwsblad")!=-1) {
		adheseSite = "nbo";
		if (location.search.indexOf("genericId=508")!=-1) {
			loc += "nbo_thema_fortis_";
		} else if (location.host.indexOf("verenigingen.nieuwsblad.be")!=-1) {
			loc += "nbo_verenigingen_";
		} else if (location.search.indexOf("genericId=404")!=-1) {
			loc += "nbo_thematic_";
		} else if (location.search.indexOf("genericId=507")!=-1) {
			loc += "nbo_dossier_batibouw_";
		} else if (location.pathname=="/" || location.pathname.indexOf("index.html")!=-1 || location.pathname.indexOf("cmstester.aspx")!=-1) {
			if(typeof(gentenaar) != 'undefined' && gentenaar) {
				loc += "nbo_gentenaarhome_";
			} else {
				loc += "nbo_home_";
			}
		} else if(location.pathname.indexOf("sportwereld")!=-1 || (typeof(cimpage) != 'undefined' && cimpage.indexOf('sw/')!=-1)) {
			loc += "spo_"+section+"_";
			//loc += "spo_"+sectie+"_"+subsectie+"_";
			adheseSite = "spo";	
		} else if(typeof(postcode) == 'undefined' || postcode == '') {
			loc += "nbo_"+section+"_";
			//loc += "nbo_"+sectie+"_"+subsectie+"_";
		} else {
			loc += "nbo_zip-"+postcode+"_";
		} 
	} else if (location.host.indexOf("standaard.be")!=-1) {
		if (location.search.indexOf("kanaalid=715")!=-1)
			loc += "dso_dossier_batibouw_";
		else 
			loc += "dso_"+section+"_";
		//else if (location.pathname=="/" || location.pathname=="/index.html" || location.pathname.indexOf("cmstester.aspx")!=-1 || location.pathname=="/index.aspx")
		//	loc += "dso_home_";
		//else
		//	loc += "dso_"+sectie+"_"+subsectie+"_";
		adheseSite = "dso";
	} else if (location.host.indexOf("actu24")!=-1 || location.host.indexOf("lavenir")!=-1) {
		adheseLang = "fr";
		if (location.pathname=="/" || location.pathname=="/index.html" || location.pathname=="/index.aspx")
			loc += "ave_home_";
		else if(typeof(zipcode) == 'undefined' || zipcode == '')
			loc += "ave_"+section+"_";
		else
			loc += "ave_zip-"+zipcode+"_";
		adheseSite = "ave";
	} else if (location.host.indexOf("jobat")!=-1) {
		if(typeof(taal) == 'undefined') taal = "nl";
		if(typeof(categorie) == 'undefined') categorie = "0";
		loc += "jobat_" + taal + "_" + categorie + "_";
		adheseSite = "jobat";
	} else if (location.host.indexOf("sportwereld.be")!=-1) {
		loc += "spo_"+section+"_";
		//loc += "spo_"+sectie+"_"+subsectie+"_";
		adheseSite = "nbo";
	} else if (location.host.indexOf("gezondheid.be")!=-1) {
		adheseLang = "--";
		loc += "gezondheid.be_topical_";
	} else if (location.host.indexOf("vroom.be")!=-1) {
		adheseLang = "--";
		loc += "vroom.be_topical_";
	} else if (location.host.indexOf("zdnet.be")!=-1) {
		adheseLang = "--";
		loc += "zdnet.be_topical_";
	} else if (location.host.indexOf("clickx.be")!=-1) {
		adheseLang = "--";
		loc += "clickx.be_topical_";
	// food and shop
	} else if (location.host.indexOf("qa-nl.spotter.krimson.be") != -1 || location.host.indexOf("spotter.nieuwsblad.be") != -1 || location.host.indexOf("nl.spotter.local") != -1 ){
		if(location.pathname == "/"){
			loc += "fns_nl_home_"
		}else{
			loc += "fns_nl_";
		}		
		// postcode
		if(typeof(postcode) != undefined){
			loc += "zip-" + postcode + "_";
		}
	} else if (location.host.indexOf("qa-fr.spotter.krimson.be") != -1 || location.host.indexOf("spotter.lavenir.net") != -1 || location.host.indexOf("fr.spotter.local") != -1 ){
		if(location.pathname == "/"){
			loc += "fns_fr_home_"
		}else{
			loc += "fns_fr_";
		}
		// postcode
		if(typeof(postcode) != undefined){
			loc += "zip-" + postcode + "_";
		}
	} else if (location.host.indexOf("itprofessional.be")!=-1) {
		adheseLang = "--";
		loc += "itprofessional.be_topical_";
	// zimmo.be
	}else if(location.host.indexOf("productie.zimmo.be")!=-1){
		loc = "_zimmo_nl_productie_";
	}else if(location.host.indexOf("zimmo.be")!=-1){
		if(typeof(sitelang) != undefined){
			adheseLang = sitelang;
		}
		loc += "zimmo_"+adheseLang+"_";
		
	} else if (location.host.indexOf("inmemoriam.be")!=-1 || location.host.indexOf("im.brainlane.com")!=-1 ) {
		adheseLang = "--";
		if (location.pathname == "/nl" || location.pathname == "/nl/"){
			loc += "inmemoriam_nl_home_";
		}else if(location.pathname.indexOf("/nl/") != -1){
			loc += "inmemoriam_nl_";
		}else if (location.pathname == "/fr" || location.pathname == "/fr/"){
			loc += "inmemoriam_fr_home_";
		}else if(location.pathname.indexOf("/fr/") != -1){
			loc += "inmemoriam_fr_";
		}
	} else if (location.host.indexOf("flanderstoday.eu")!= -1 || location.host.indexOf("mediargus.be")!= -1){
		loc = "_fla_today_";
	} 
	
	var res = new Array();
	res[0] = loc;
	if (adh_channel != "") 
		res[1] = "_" + adheseSite + adh_channel;
	adheseLocation = loc;
	return res;
}

function initAdhese(templateId) {
	var loc = getAdheseAdLoc();
	adheseProfile = getAdheseProfileData();	
	if (adhesePreviewMode) {
		if (templateId == adhesePreviewTemplateId){
			tagAdhesePreview(adhesePreviewCreativeId);
		} else {
			tagAdhese(loc, templateId);
		}
	} else if (adheseDemoMode && (templateId == "BAN" || templateId == "SKY" || templateId == "IMU")) {
		if (templateId == "BAN") {
			var ids = new Array("12922", "12984", "12299");
			tagAdhesePreview("http://vum.adhese.org/creatives/preview/tag.do?id=" + ids[Math.round(Math.random() * (ids.length-1))]);
		}
		if (templateId == "SKY") {
			var ids = new Array("13157", "13230");
			tagAdhesePreview("http://vum.adhese.org/creatives/preview/tag.do?id=" + ids[Math.round(Math.random() * (ids.length-1))]);
		}
		if (templateId == "IMU") {
			var ids = new Array("13097", "13183", "12470");
			tagAdhesePreview("http://vum.adhese.org/creatives/preview/tag.do?id=" + ids[Math.round(Math.random() * (ids.length-1))]);
		}
	} else {
		tagAdhese(loc, templateId);
	}
}

function initAdheseIframe(templateId, width, height) {
	var loc = getAdheseAdLoc();
	if (adhesePreviewMode) {
		if (templateId == adhesePreviewTemplateId){
			tagAdhesePreview(adhesePreviewCreativeId);
		} else {
			tagAdheseIframe(loc, templateId, width, height);
		}
	} else {
		tagAdheseIframe(loc, templateId, width, height);
	}
}

function tagAdhese(h, t) {
	var slot = h[0] +'-'+ t;
	if (h.length>1) {
		slot = h[1] +'-'+ t + "/sl" + h[0] +'-'+ t;
	}
	if (adheseProfile != undefined && adheseProfile.zip != undefined && adheseProfile.zip != 'undefined' && adheseProfile.zip != 'null') {
		document.write('<scr' + 'ipt type="text/javascript" src="http://ads.adhese.be/ad3/sl'+ slot +'/la' + adheseLang + '/rn' + adheseRand + '/pv' + adheseProfile.count + '/ci' + adheseProfile.zip + '/ag' + adheseProfile.age + '/ge' + adheseProfile.gender + '/br' + adheseProfile.brand + '/ms' + adheseProfile.memberstatus + '/?t=' + new Date().getTime() + '"><\/scr' + 'ipt>');
	} else if (adheseProfile != undefined && adheseProfile.interest != undefined && adheseProfile.interest != '' && adheseProfile.interest != 'undefined' && adheseProfile.interest != 'null') {
		document.write('<scr' + 'ipt type="text/javascript" src="http://ads.adhese.be/ad3/sl'+ slot +'/la' + adheseLang + '/rn' + adheseRand + '/pv' + adheseProfile.count + '/br' + adheseProfile.brand + '/ms' + adheseProfile.memberstatus + '/?t=' + new Date().getTime() + '"><\/scr' + 'ipt>');
	} else {
		document.write('<scr' + 'ipt type="text/javascript" src="http://ads.adhese.be/ad3/sl'+ slot +'/la' + adheseLang + '/rn' + adheseRand + '/pv' + adheseProfile.count + '/br' + adheseProfile.brand + '/ms' + adheseProfile.memberstatus + '/?t=' + new Date().getTime() + '"><\/scr' + 'ipt>');
	}
}

function tagAdheseIframe(h, t, wi, he) {
document.write('<iframe name="iframe-tag" width="' + wi + '" height="' + he + '" frameborder="no" border="0" margin="0" src="http://host3.adhese.be/tag/iframe-tag.html?' + h[0] + '&' + t + '&' + wi + '&' + he + '&' + adheseRand + '"></iframe>');
}

function tagAdhesePreview(c) {
document.write('<scr' + 'ipt language="JavaScript" type="text/javascript" src="http://vum.adhese.org/creatives/preview/tag.do?id=' + c + '"><\/scr' + 'ipt>');
}

function addAdheseLoadEvent(func) {
	var ol = window.onload;
	if (typeof window.onload != 'function') {window.onload = func;}
	else {window.onload = function() {ol(); func();}}
}

function refreshAds() {
	
}

var AdheseBrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "unknownBrowser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "unknownVersion";
		this.OS = this.searchString(this.dataOS) || "unknownOS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.userAgent,
			subString: "Windows NT 6.1",
			identity: "Windows7"
		},
		{
			string: navigator.userAgent,
			subString: "Windows NT 6.0",
			identity: "WindowsVista"
		},
		{
			string: navigator.userAgent,
			subString: "Windows NT 5.1",
			identity: "WindowsXP"
		},
		{
			string: navigator.userAgent,
			subString: "Windows 98",
			identity: "Windows98"
		},
		{
			string: navigator.userAgent,
			subString: "Windows 95",
			identity: "Windows95"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			   string: navigator.userAgent,
			   subString: "iPhone",
			   identity: "iPhone"
	    },
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};

function AdheseTracker(d, i) {
	this.visiblePerc = 0.50;
	this.viewPortDivID= d;
	this.isVisible = false;
	this.overStart = [];
	this.creativeID = i;
	this.arr = new Array();
	this.timeout = null;
	this.image = document.createElement('img');
	
	var me = this;
	
	var onsF = window.onscroll;
	var scrollF = function() {me.checkVisible(me);};
	if (typeof window.onscroll != 'function') {window.onscroll = scrollF;}
	else {window.onscroll = function() {onsF(); scrollF();}}
	
	var onbF = window.onblur;
	var blurF = function() {if (me.isVisible) me.stopTimer("visible");};
	if (typeof window.onblur != 'function') {window.onblur = blurF;}
	else {window.onblur = function() {onbF(); blurF();}}
	
	var onfF = window.onfocus;
	var focusF = function() {if (me.isVisible) me.startTimer("visible");};
	if (typeof window.onfocus != 'function') {window.onfocus = focusF;}
	else {window.onfocus = function() {onfF(); focusF();}}
	
	me.addMouseEvents();
	me.addListener(this.image, 'load',	function(e){me.imageLoaded(me);}, false);
	me.checkQueue();
	
}
AdheseTracker.prototype.getViewH = function() {
    if (typeof window.innerWidth != 'undefined') {
        return window.innerHeight;
    } else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) {
        return document.documentElement.clientHeight;
    } else {
        return document.getElementsByTagName('body')[0].clientHeight;
    }
    return 0;
}
AdheseTracker.prototype.getPosY = function() {
    var oElement = document.getElementById(this.viewPortDivID);
	var posX = 0;
	var posY = 0;
    if (typeof(oElement.offsetParent) != 'undefined') {
        for (posX = 0, posY = 0; oElement; oElement = oElement.offsetParent) {
            posX += oElement.offsetLeft;
            posY += oElement.offsetTop;
        }
    } else {
        posX += oElement.x;
        posY += oElement.y;
    }
    return posY;
}
AdheseTracker.prototype.getScrollY = function() {
    if (document.documentElement && document.documentElement.scrollTop) {
        return document.documentElement.scrollTop;
    } else if (document.body && document.body.scrollTop) {
        return document.body.scrollTop;
    } else if (window.pageYOffset) {
        return window.pageYOffset;
    } else if (window.scrollY) {
        return window.scrollY;
    }
    return 0;
}
AdheseTracker.prototype.getDivH = function() {
	return document.getElementById(this.viewPortDivID).offsetHeight;
}
AdheseTracker.prototype.checkVisible = function(){
	var posY = this.getPosY();
	var scrollY = this.getScrollY();
	var viewH = this.getViewH();
	var divH = this.getDivH();

	if((posY + (divH*this.visiblePerc) - scrollY) < viewH && (posY + (divH*(1-this.visiblePerc)) - scrollY) > 0){
		if(!this.isVisible){
			this.isVisible = true;
			this.startTimer("visible");
		}		
	}else{
		if(this.isVisible){
			this.isVisible = false;
			this.stopTimer("visible");
		}
	}				
}
AdheseTracker.prototype.mouseover = function(t) {
	this.startTimer("mouse");	
}
AdheseTracker.prototype.mouseout = function() {
	this.stopTimer("mouse");
}
AdheseTracker.prototype.startTimer = function(t) {
	this.overStart[t] = new Date().getTime();
}
AdheseTracker.prototype.stopTimer = function(t) {
	var dur = Math.round((new Date().getTime() - this.overStart[t])*0.001);
	if (dur>0) {
		this.log("http://track.corelio.adhese.be/log/creative/"+this.creativeID+"/"+t+"/"+dur+"sec/");
	}
}
AdheseTracker.prototype.addMouseEvents = function() {
	var me = this;
	document.getElementById(this.viewPortDivID).onmouseover = function() {me.mouseover(me);};
	document.getElementById(this.viewPortDivID).onmouseout = function() {me.mouseout(me);};
	this.checkVisible();
}
AdheseTracker.prototype.log = function(s){
	this.arr.push(s);	
}
AdheseTracker.prototype.addListener = function(element, type, expression, bubbling){
  bubbling = bubbling || false;
  if(window.addEventListener)	{ // Standard
    element.addEventListener(type, expression, bubbling);
    return true;
  } else if(window.attachEvent) { // IE
    element.attachEvent('on' + type, expression);
    return true;
  } else return false;
}                                
AdheseTracker.prototype.popFromArray = function(){
	return this.arr.shift(); 
}
AdheseTracker.prototype.processQueue = function(m){
	if(m.arr.length != 0){
		m.image.src = this.popFromArray();
	}else{
		m.checkQueue();
	}
}
AdheseTracker.prototype.imageLoaded = function(m){
	m.processQueue(m);
}
AdheseTracker.prototype.checkQueue = function(){
	var me = this;
	if (me.arr.length == 0) {
		clearTimeout(me.timeout);
		me.timeout = setTimeout(function() {me.processQueue(me)}, 500);
	}
}

AdheseBrowserDetect.init();

//init overall / once per page load
initPageAdhese();

