JavaScript intgration problem?

from my connector .js am calling a functio[code]
[b]
nfunction test(id) {
document.getElementById(id).oncontextmenu = function(e) {

    // e.target is the target of the event or "source element"
    alert("subin");
};

}
[/b]
[/code]

connector js as follow[b]

var self;
me_js_test_DraculaTeeth = function() {
    // window.alert("we r in js connector class")
    var element = $(this.getElement());
    self = this;
    this.onStateChange = function() {
        var data = self.getState();
        // window.alert(self.getState());
        try {
            drawGraphNodes(data);
        } catch (err) {
            self.onStateChanged();
        }
    }
    this.registerRpc({
        refresh : function() {
        }
    });

}

function drawGraphNodes(data) {

    var g = new Graph();
    for (var i = 0; i < data._FromList.length; i++) {

        g.addEdge(data._FromList[i]
, data._toList[i]
, {
            directed : true,
            stroke : '#bfb',
            fill : '#56f',
            label : 'sampling'
        });
        
    }
    var layouter = new Graph.Layout.Spring(g);
    layouter.layout();

    var renderer = new Graph.Renderer.Raphael('canvas', g, 1300, 600);
    renderer.draw();
    test("subin");
}
function test(id) {
    document.getElementById(id).oncontextmenu = function(e) {

        // e.target is the target of the event or "source element"
        alert("subin");
    };
}
[/i]
[/i]

[/b]

[i]
[i]
for mouse click event then the componet itself automaticaly adding repetedly help me to fix this

thanks in advance
[/i]
[/i]