function initEvents(withTracking) {
	links = document.links;
	for (i in links) {
		l = links[i];
		if (l.href) {
			if (l.href.substr(l.href.length - 4) == '.pdf') {
					l.onclick = function (e) {
					popupwindow2(this.href, 800, 600);
					base = location.protocol + '//' + location.host;
					if (this.hostname == 'download.avantro.de') {
						base = this.protocol + '//' + this.hostname;
						href = this.href.substr (base.length);
						trackEvent('Download PDF', href);
					} else {
						href = this.href.substr (base.length);
						track(href);
					}
					return false;
				}
			} else { 
				if (l.hostname != window.location.hostname && (l.protocol == 'http:' || l.protocol == 'https:')) {
					l.onclick = function (e) {
						if (this.hostname == 'download.avantro.de') {
							base = this.protocol + '//' + this.hostname;
							href = this.href.substr (base.length);
							trackEvent('Download' + href);
						} else {
							trackEvent('http extern', this.hostname);
						}
					}
				}
			}
		}
	}
	images = document.getElementsByTagName('img');
	for (i in images) {
		img = images[i];
		img.onclick = function (e) {
			trackEvent('img click', this.src);
		}
		
	}
}


function trackEvent (category, action) {
	if (window.location.hostname == 'www.avantro.de') {
		_gaq.push(['_trackEvent', category, action]);		
	}
}


function track (s) {
	if (window.location.hostname == 'www.avantro.de') {
		_gaq.push(['_trackPageview', s]);		
	}
}


function popupwindow2(popupURL, w, h) {
    popup=window.open(popupURL ,"coolgiantsdetails","screenX=10,left=10,screenY=10,top=10,width=" + w + ",height=" + h + ",scrollbars=no");
   popup.focus();
}
