Gallery has gone bonky - portrait / landscape issue

hi,

i am building an xml gallery that pops up portrait and landscape images. the pop-up should fit each image. I had this working fine with the code below and then I added a few landscape images with different dimensions. now the landscape ones all pop-up with too much space around them.

the first part of the function just puts the imeges in the right place on the movie;

frame_grabber.onEnterFrame = function() {
_root.myMonkey = _root.picture._width;
if (_root.myMonkey>308) {
_root.picture._x = (888+50)-_root.picture._width-18;
_root.picture._y = 487-_root.picture._height-18;
} else {
_root.picture._x = 614.4;
_root.picture._y = 68.0;
}
_root.myWidth = Math.floor(_root.picture._width1.565);
_root.myHeight = Math.floor(_root.picture._height
1.57);
};

i tried to add an if statement to detect the width of the small image and then apply the maths accordingly but it doesn’t do anything.

frame_grabber.onEnterFrame = function() {
_root.myMonkey = _root.picture._width;
if (_root.myMonkey>308) {
_root.picture._x = (888+50)-_root.picture._width-18;
_root.picture._y = 487-_root.picture._height-18;
} else {
_root.picture._x = 614.4;
_root.picture._y = 68.0;
}
if (_root.myWidth = 401) {
_root.myWidth = Math.floor(_root.picture._width1.565);
_root.myHeight = Math.floor(_root.picture._height
1.57);
} else if (_root.myWidth = 475) {
_root.myWidth = Math.floor(_root.picture._width1.322);
_root.myHeight = Math.floor(_root.picture._height
1.199);
}
};

can anyone see where i am going wrong? any advice would stop me tearing the remaing hairs from my head. cheers

btw, there is a button that sends the pop-up info to the function above with this code;

on (release) {
target_winName = “gallery”;
_root.width = _root.myWidth+20;
_root.height = _root.myHeight+55;
toolbar = 0;
location = 0;
directories = 0;
status = 0;
menubar = 0;
scrollbars = 0;
resizable = 1;
//sends data back to the function
openWinCentre(address, target_winName, width, height, toolbar, location, directories, status, menubar, scrollbars, resizable);
}

the answer was there before my very eyes.

frame_grabber.onEnterFrame = function() {
_root.myMonkey = _root.picture._width;
if (_root.myMonkey>308) {
_root.picture._x = (888+50)-_root.picture._width-18;
_root.picture._y = 487-_root.picture._height-18;
_root.myWidth = Math.floor(_root.picture._width1.322);
_root.myHeight = Math.floor(_root.picture._height
1.199);
} else {
_root.picture._x = 614.5;
_root.picture._y = 68.0;
_root.myWidth = Math.floor(_root.picture._width1.565);
_root.myHeight = Math.floor(_root.picture._height
1.57);
}
};