Problem with width and height of an <img> in .animate()
<p>I have a div.  Inside the div is another group of divs that each contain an img.  I am trying to setup a mouse over that makes the current img expand using .hover() and .animate().  I wanted the code to figure out whether it was a landscape or portrait image then expand it in width or height not to exceed the bounds of the containing div.  </p>

<p>Here's the code inside of document ready. </p>

<pre><code>$('.clGalleryImage').hover(function() {
    $varHeight = $('.clGalleryImage:hover').height();
    $varWidth = $('.clGalleryImage:hover').width();
    if($varHeight &gt; $varWidth) {
        $('.clGalleryImage:hover').animate({marginTop:0, height:125}, 'slow');
    } else {
        $('.clGalleryImage:hover').animate({marginLeft:0, width:125}, 'slow');
    }
}, function() { 
    ...
});
</code></pre>

<p>The handlerOut part of the .hover is incomplete so ignore that.  The problem is with the handlerIn.  When I hover over an img that is portrait the function works great.  The image grows in width and height proportionally and stops growing at the border of the containing div.  But when I hover over a landscape img (the else in the code above) it only grows in the width, not height proportionally.  Is this by design?</p>

<p>I apologize if this is a newbie question but it has been bugging me all day.  Eventually I coded it to work manually around the images I chose.  I'd rather the code work with whatever the proportions of the image, then have to edit the image prior to using it.</p>

<p>Thanks</p>

<p>I suppose I should include the div and the CSS.</p>

<p>The div</p>

<pre><code>&lt;div class="clGalleryImageContainer"&gt;
    &lt;img class="clGalleryImage" src="/New/Images/Molds/Molds001_th.jpg" alt="Mold Gallery Image 001" title="This is some description Text." /&gt;
&lt;/div&gt;
</code></pre>

<p>The CSS</p>

<pre><code>.clGalleryImage { display:block; height:100px; margin-left:auto; margin-right:auto; margin-top:12px;}
.clGalleryImageContainer { position:relative; float:left; width:150px; height:125px; border: 1px solid white; background-color:black; margin-top:12px; margin-left:21px; margin-bottom:12px;}
</code></pre>
