Доброго времени суток. 
есть следующий код:
shapes = [];
  createRect = function (x, y) {
        shape = r.rect(x, y, 95, 25, 20);
        shapes.push(shape);
        text = r.text(x + 40, y + 10, "New node");
        texts.push(text);
        for (i = 1; i < shapes.length; i++) {
            //color = Raphael.getColor();//рандомний колір
            tcolor = "#4C5053";
            scolor = "#BDBFC1";
            fcolor = "#FCFEFF";
            shapes[i].attr({ fill: fcolor, stroke: scolor, "stroke-width": 2, cursor: "move" });
            texts[i].attr({ fill: tcolor, stroke: "none", "font-size": 15, cursor: "move" });
            array = new Object();
            array[i] = ("shapes" + i);
            shapes[i].pair = texts[i];
            texts[i].pair = shapes[i];
            shapeLength = shapes.length;
            //alert(shapeLength);
            shapes[i].drag(move, dragger, up);
            texts[i].drag(move, dragger, up);
        };
    }; //endcreaterect
document.getElementById("image").onclick = function () {
        createRect(CRX, CRY);
        Select();
        changeC();
    };
здесь я создаю , с помощью библиотеки Raphael прямоугольники при нажатии на картинку  "image".
как мне определить, по какому прямоугольнику я делаю клик?