Question: I am using Openlayers-2.12 release.
But anchored popup offset is not working properly. It displays popup for left side in other half of map although i have given relative positioning as "tr".

```
var popup = new OpenLayers.Popup.Anchored("popup");
var offset = {'size':new OpenLayers.Size(10,12),'offset':new OpenLayers.Pixel(0,-12)};
popup.offset = offset;
popup.relativePosition = "tr";

```

Any help?

Answer: 
I am answering my own question by thinking that it may help others.
It works fine if i use only popup instead of anchored popup.
It appears rather then an offset attribute they give access to a function that's used in calculating the x,y position.

```
popup.calculateNewPx = function(px){
    // modify OpenLayers.Pixel object here
    return px;
}

```

Reference: <http://dev.openlayers.org/docs/files/OpenLayers/Popup/Anchored-js.html#OpenLayers.Popup.Anchored.calculateNewPx>

More specifically this is what I ended up doing.

```
popup.calculateNewPx = function(px){
    if (popup.size !== null){
        switch (popup.relativePosition){
            case 'tl':
                px = px.add((popup.size.w * -1) - popup.offset, (popup.size.h * -1) - popup.offset);
                break;
            case 'bl':
                px = px.add((popup.size.w * -1) - popup.offset, popup.offset);
                break;
            case 'tr':
                px = px.add(popup.offset, (popup.size.h * -1) - popup.offset);
                break;
            case 'br':
                px = px.add(popup.offset, popup.offset);
                break;
        }
    }
    return px;
};

```