you have to iterate through your images and make comparisons to find out<script language="javascript">
function tellwhich()
{
  var images = document.all("xx");
  if (images)
  {
     if (images.length)
     {
for (var i=0; i < images.length; i++)
{
if (images[i] == window.event.srcElement)
{
alert("you are no. " + (i + 1));
break;
}
}
     }
     else
alert("you are the only one");
  }
  else
alert("you do not exist, or you do not have the right id");
}</script>
<img src="zip.gif" id="xx" ondblclick="tellwhich();">
<img src="zip.gif" id="xx" ondblclick="tellwhich();">
<img src="zip.gif" id="xx" ondblclick="tellwhich();">