function resizeImg(_oObj, _w){resizeImg2(_oObj,_w,0);
}

function resizeImg2(_oObj, _w, _h){
	Imagesize(_oObj,_w,_h);
}

//按比例显示图片的大小
function Imagesize(ImgD,towidth,toheight)
{
        var mode = 'FixMax';   
             
        var image=new Image(); 
     
        image.src=ImgD.src; 
        var width = image.width;
        var height = image.height;      
        if(width >0 && height>0)
        {
        switch(mode)
        {
            case'FixMax': 
            if(toheight>0)
            {  
     
                if(width/height >= towidth/toheight)
                  {
                    if(width>towidth)
                      {
                        towidth = towidth;
                        toheight = (height*towidth)/width;
                      }
                      else
                      {
                        towidth = width;
                        toheight = height;
                      }
                  }
                 else
                 {
                    if(height>toheight)
                    {
                        towidth = (width*toheight)/height;
                       // toheight = height;
                    }
                    else
                    {
                        towidth = width;
                        toheight = height;
                    }
                 
                 }
           
           }
           else
           {
                if(towidth >0)                
                    {
                        if(width>towidth)
                            toheight = (height*towidth)/width; 
                        else
                        {
                            towidth = width;
                            toheight = height;
                        }  
                    }
                else
                    {
                        towidth = width;
                        toheight = height;
                    
                    }   
                    
           }
                 break;
              case"MaxW":
                    if(width>towidth)
                    break;
              case"FixW":
                 toheight = (height*towidth)/width;
                 break;
              case"FixH":
                 towidth = (width*toheight)/width;
                 break;
              case 'FixWH':
                    break;
            }  
          } 
          //alert(towidth);
            ImgD.width = towidth;
            ImgD.height = toheight;   
            
 }