The statement I'm concerned about in the following statement is fancybox = 1; That needs to happen if my maxWidth for any of the temporary images I create is over 480.

A little background on the html this interacts with:
I have a link wrapped around an image.
The image is a resized version, and the link's href is to the original, unsized image.
There is a series of these link wrapped images
A div, addon-large-image, wraps the whole thing.

For some reason, this code works if I have 'alert(m);' included. I correctly end up in side my final if statement (in this case I do have images wider then 480) and the last alert I get is "Triggered". However, if I comment out 'alert(m);', and change nothing else, 'alert("Triggered");' fails to fire, showing me that I have not, in fact, entered my last conditional.

Any thoughts on what I'm doing wrong here? I have a programming background in Java, but I'm relatively new to Jquery in any heavy sense, so I'm guessing I have a syntax problem of some sort that 'alert(m);' is sort of incidentally fixing.

'tallest' is irrelevant in the scope of my problem, it does what it's supposed to correctly, is used elsewhere, and existed before I implemented maxWidth.

@Jacob: I just looked at your code again. My guess is maxWidth === 0 which is what you initialized it to. if (maxWidth > 480) { fancybox = 1; alert("Triggered"); } never enters because the foreach starts to run, but it is not complete by the time you check if (maxWidth > 480) . I would put that bit of code with your last alert into the function in the for each and only call it once your on the last element.
–
nickytonlineJan 14 '10 at 19:39

Ahh, you all are right that the object isn't creating correctly. It also explains why the first alert I get is 0, and all the following ones are widths. I added a count and moved my Triggered if inside the loop, so it only executes on the final run through, but I still have the same problem where my images aren't generated fast enough to get their widths correctly unless the alert is included. Is there a way to ensure that width is only pulled after the image is completely generated?
–
JacobJan 14 '10 at 19:46