L.S.

I`m trying to do the following:

1. rewrite 'a' in div:menu to onclick functions.
2. addEvent(a, click, doAjax);
3. use the original href as a param for doAjax.

The latter is where the problem starts. The rewrite function is:
<script type=text/javascript>
function urlRewrite()
{
var menu = document.getElementById('menu');
aLinks = menu.getElementsByTagName('a');

for(var x=0; x<aLinks.length; x++)
{
elem = aLinks[x];
param = elem.getAttribute('href');
addEvent(elem, 'click', function (){ doAjax } );
elem.href = elem.href.replace(elem.href, "#" + param);
}
}
<script>

Now, the problem is, doAjax needs to know the href of the button clicked, but with addEvent i cant parse variables to the function.

<script type="text/javascript">
function addEvent( obj, type, fn)
{
if (obj.addEventListener)
{
obj.addEventListener( type, fn, false );
}
else if (obj.attachEvent)
{
obj["e"+type+fn] = fn;
obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
obj.attachEvent( 'on'+type, obj[type+fn] );
}
}
</script>

One solution would be to set addEvent(obj, click, getTarget) and call doAjax from there, but that becomes too messy.
<script type="text/javascript">
function getTarget(e) {
var targ;
if (!e) var e = window.event;
if (e.target) targ = e.target;
else if (e.srcElement) targ = e.srcElement;
if (targ.nodeType == 3) // defeat Safari bug
targ = targ.parentNode;

doAjax(targ);
}
</script>

Can anyone give me some insight on the best practice from here ?

Kind regards,

Dennis