﻿function setPhotoSize(elem, width, height) {
    //if ($.browser.version == "6.0") {
        elem = $(elem);
        var image = new Image();
        image.src = elem.attr("src");

        if (image.width > 0 && image.height > 0) {

            var rate = (width / image.width < height / image.height)
						? width / image.width
						: height / image.height;
            //alert("width : "+width + " ; height : "+height);
            //alert("image.width : "+image.width + " ; image.height : "+image.height);
            //alert("width/image.width : "+width/image.width + " ; height/image.height : "+height/image.height);

            if (rate <= 1) {
                //alert(rate);
                elem.width(image.width * rate);
                //alert("elem.width : "+elem.width() + " ; image.width*rate : "+image.width*rate);
                elem.height(image.height * rate);
                //alert("elem.height : "+elem.height() + " ; image.height*rate : "+image.height*rate);
            }
            else {
                elem.width(image.width);
                elem.height(image.height);
            } 
        }
   // }
}
