var  flag=false;

function  DrawImage(ImgD,style)
{
    var maxW=120,maxH=120;
    if(style==1)
    {
        var maxW=120;
        var maxH=120;
    }

     var  image=new  Image();
     image.src=ImgD.src;
     if(image.width>0  &&  image.height>0)
     {
       flag=true;
       if(image.width/image.height>=maxW/maxH)
       {
         if(image.width>maxW)
         {
         ImgD.width=maxW;
         ImgD.height=(image.height*maxW)/image.width;
         }
         else
         {
         ImgD.width=image.width;
         ImgD.height=image.height;
         }
         //ImgD.alt=image.width+"กม"+image.height;
         }
       else
       {
         if(image.height>maxH)
         {
         ImgD.height=maxH;
         ImgD.width=(image.width*maxH)/image.height;
         }
         else
         {
         ImgD.width=image.width;
         ImgD.height=image.height;
         }
        // ImgD.alt=image.width+"กม"+image.height;
         }
       }
}
