function autoimg(id,mw,mh,nw,nh)
{
    id=document . getElementById(id) . getElementsByTagName("img");
    for(var i=0;i<id.length;i++)
    {
        reg(i);
    }
    function reg(i)
    {
        id[i].complete?set():id[i].onload=set;
        function set()
        {
            if(mw>=id[i].width&&mh>=id[i].height){return;}
            else if(id[i].width/id[i].height>1)
            {
                id[i].width=nw;
            }
            else
            {
                id[i].height=nh;
            };
        }
    }

}

