
function rewrite() {
	var list = document.getElementsByTagName( 'a' );
	for( var i=0; i<list.length; i++ ) {
		var s;
		if ( s=list[i].rel.match( /trade(\d+)/ ) ) {
			var c = list[i].rel.match( /c(\d+)/ );
			if ( c && c.length ) {
				c=c[1];
			} else {
				c=0;
			}
			var l = list[i].rel.match( /l\-([a-zA-Z0-9\-]+)/ );
			if ( l && l.length ) {
				l='l=' + l[1]+'&';
			} else {
				l='';
			}

			list[i].href="/cgi-bin/atl/out.cgi?"+l+"c="+c+"&s="+s[1]+"&u="+list[i].href;
		}
	}
}

window.onload=rewrite;

