function resize_pic(maxwidth, maxheigth, thispicid, thisturn)
{
    if(!thisturn)
    {
        thisturn=1;
    }
    else
    {
        thisturn++;
    }
    var javascrexpr = "exec_resize_pic(" + maxwidth + ", " + maxheigth + ", '" + thispicid + "', '" + thisturn + "')";
    var random = (Math.random())*200;
    random = Math.abs(random);
    var t=setTimeout(javascrexpr,random);
}
function exec_resize_pic(maxwidth, maxheigth, thispicid, thisturn)
{
    var thepiconmypage = document.getElementById(thispicid);
    if(thepiconmypage!=null)
    {
        var image_source = thepiconmypage.src;
        var oImg = new Image();
        oImg.src = image_source;
        if (oImg.complete)
        {
            var width_of_this_pic_is_what_pr1_of_max = oImg.width / maxwidth;
            var height_of_this_pic_is_what_pr1_of_max = oImg.height / maxheigth;
            if(width_of_this_pic_is_what_pr1_of_max >= height_of_this_pic_is_what_pr1_of_max)
            {
                var newwidth = Math.floor(oImg.width / width_of_this_pic_is_what_pr1_of_max);
                var newheigth = Math.floor(oImg.height / width_of_this_pic_is_what_pr1_of_max);
                thepiconmypage.style.width = newwidth + 'px';
                thepiconmypage.style.height = newheigth + 'px';
            }
            else
            {
                var newwidth = Math.floor(oImg.width / height_of_this_pic_is_what_pr1_of_max);
                var newheigth = Math.floor(oImg.height / height_of_this_pic_is_what_pr1_of_max);
                thepiconmypage.style.width = newwidth + 'px';
                thepiconmypage.style.height = newheigth + 'px';
            }
        }
        else if(thisturn<3)
        {
            resize_pic(maxwidth, maxheigth, thispicid, thisturn);
        }
    }
}
