Resizing pop up windows based on image size

I don’t think anyone asked that question before. They did ask about popups for thumbnail galleries in flash, but never mentioned a popup window that will resize itself without knowing the image dimension.

So here is the deal:
I have a thumbnail gallery in flash and i want to open a new popup window after user clicks on any thumbnail. But I want the popup to automatically resize itself based on the image width and height, plus maybe like 10 px border around. IMPORTANT part is that i dont want to specify the width and height of the image in my xml file for my gallery. I just want each thumbnail to point to an image such as “images/picture1.jpg”, and then I want that window to automatically resize to the image’s size. Now i know there must be a way. im thinkin javascript but i kno nothing about it, and it seemed to me like a client side question so please somebody help me and I will be grateful.