I have written javascript functions to do zoomin and zoomout of an image via pinching.Now i want to generalize the below code so that i can add the javascript to the commonjavascript file.

```
    var scale = 1;
    var newScale;

    function saveChanges() {
           scale = newScale;
    }
    function getAngleAndScale(e) {
        e.preventDefault();
        newScale = scale * e.scale;
        var tString = "scale(" + newScale + ")";
        document.getElementById("DocumentViewerImage").style.webkitTransform = tString;
    }
    function init(element) {

```

alert(element);
 document.getElementById("DocumentViewerImage").addEventListener("gesturechange", getAngleAndScale, false);
 document.getElementById("DocumentViewerImage").addEventListener("gestureend", saveChanges, false);
 }

In the above code i have hard coded the image id.I want to get the client id of the images and then pass it to javascript to make a call.How can i make it generic?How do i get client id and in which event shall i make a call?

I am using this code now:
 in the image tag: id="DocumentViewerImage" style="vertical-align: middle; margin-top: 2%;" onload="init(this);" 
but in javascript if i say alert(element),i am getting as [objectHTMLImageElement].How do i get id of the image tag?
Thanks