var CurrentImage = 0;

function _changeImage(ImagesNumber, Url, Max, caption, LightBoxImage)
{
    var oImg = $('propMainImageID');
    CurrentImage = ImagesNumber;
    oImg.src = "http://shared.findproperty.co.za/images/property_details/load.png";
    $("propdetails_imgcount").innerHTML = "<span style='color:#000;font-weight:700;'>Photo " + ImagesNumber + " of " + Max + "</span>"
    var oTestImg = new Image();
    oImg.style.visibility = "hidden";
    oTestImg.onload = function ()
    {
        var oLeftTD = $('propdetails_left');
        oImg.src = Url;
        $('mainImageLightboxLink').href = LightBoxImage;
        // IE6 must first have the image preloaded or else it sees strange widths and heights from properdetailsmainimg
        if (oTestImg.width)
        {
            var iAspectRatio = oTestImg.height / oTestImg.width;

            // Resize image but maintain aspect ratio
            oImg.style.width = "320px";
            oImg.style.height = Math.round(320.0*iAspectRatio) + "px";

            // Some browsers need to be reminded that the parent TD doesn't need to uber-stretch any more
            oLeftTD.style.width = oImg.style.width;
            oLeftTD.style.height = oImg.style.height;
        }
        else
        {
            // Enforce a standard width and height
            oImg.style.width = oLeftTD.style.width = "320px";
            oImg.style.height = "240px";
        }

        oImg.style.visibility = "visible";
    }
    oTestImg.src = Url;
}


