I'm trying to add tag on an image using java script.
Image cache creates the cached image when the image is first loaded, so that when the java script code tries to add tags on to image it places them wrong places becouse of image is not ready yet. It places them as a line.
When java script code is called the second time, it places tags on correct places becouse of cached image is already created.

How can I understand in java script domain that image cache finished it's job and create the cached image?

The image is placed in a div which it's id is '#tag_container'
The image's id is '#imagecache_taggable_image'

Drupal.behaviors.tagRestore = function (context) {
   ...
   ...
    $('#tag_container').addAnnotations(tag_locations );
    // first time I called addAnnotations #imagecache_taggable_image is not ready
    // so that it places tags wrong places  as a line
   ...
   ...

}

Kind regards...