// track downloads - (c) 2006 Thomas Kessler
function download(a) {
	if (document.getElementById) {
		var img = document.getElementById('dl_img');
		if (img) {
			img.src = "download.chtml?href=" + escape(a.href) + "&rnd=" + escape(Math.random());
		}
	}
	return true;
}
function download_init() {
	if (document.getElementById) {
		var arr = new Array('dl_1', 'dl_2', 'dl_3', 'dl_4', 'dl_5a', 'dl_5b', 'dl_6');
		for (var i in arr) {
			var dl = document.getElementById(arr[i]);
			if (dl) {
				dl.onmousedown = new Function("return download(this);");
			}
		}
	}
}
window.onload = function () {
	download_init();
}
window.onpageshow = function (evt) {
	if (evt.persisted) window.onload();
}

/* google did it like that with a http-redir
Google returns its links in the form:
<a href="http://www.42.org/~sec/blogmal/"
onmousedown="return rwt(this,'res','2','')">

where the rwt() function is defined in the header of that page:
function rwt(el,ct,cd,sg){
  el.href="/url?sa=t" +
	"&ct="+escape(ct)+
	"&cd="+escape(cd)+
	"&url="+escape(el.href).replace(/\+/g,"%2B")+
	"&ei=eDMcQ5uFIcHiiALL4pzuDg"+ sg;
 el.onmousedown="";
 return true;
}
*/
