// JavaScript Document
  //根据Id查询对象   
  function   EuwFindObj(n,   d)   {   //v4.01   
  var   p,i,x;   if(!d)   d=document;   if((p=n.indexOf("?"))>0&&parent.frames.length)   {   
  d=parent.frames[n.substring(p+1)].document;   n=n.substring(0,p);}   
  if(!(x=d[n])&&d.all)   x=d.all[n];   for   (i=0;!x&&i<d.forms.length;i++)   x=d.forms[i][n];   
  for(i=0;!x&&d.layers&&i<d.layers.length;i++)   x=EuwFindObj(n,d.layers[i].document);   
  if(!x   &&   d.getElementById)   x=d.getElementById(n);   return   x;   
  }   
    
  //按比例缩放图片，   
  //参数   最大宽度，最大高度，图片Id（这里Id是传入的字符串，而不是对象）   
  function   ResizeRatio(maxWidth,maxHeight,objImgTmp)   
  {   
          var   hRatio;   
          var   wRatio;   
          var   Ratio   =   1;   
          var   isKernel   =   true;   
  var   objImg   =   EuwFindObj(objImgTmp);   
          if   (objImg==null)   {isKernel   =   false};   
          if   (isKernel   &&   objImg.width==0)   {isKernel   =   false};   
          var   width   =   0;   
          var   height   =   0;   
          if   (isKernel){   
                  var   imgTmp   =   new   Image();   
                  imgTmp.src   =   objImg.src;   
                  width   =   imgTmp.width;   
                  height   =   imgTmp.height;   
  if   (width==0){   
  var   timer=window.setTimeout("ResizeRatio("   +   maxWidth   +   ","   +   maxHeight   +   ",'"   +   objImgTmp   +   "')",500);   
  }else{   
  wRatio   =   EuwStr2Float(maxWidth   /   width,2);   
  hRatio   =   EuwStr2Float(maxHeight   /   height,2);   
  //alert(wRatio   +   "--"   +   hRatio);   
  if   (maxWidth==0){//   
  if   (hRatio<1)   Ratio   =   hRatio;   
  }else   if   (maxHeight==0){   
  if   (wRatio<1)   Ratio   =   wRatio;   
  }else   if   (wRatio<1   ||   hRatio<1){   
  Ratio   =   (wRatio<=hRatio?wRatio:hRatio);   
  }   
  if   (Ratio<1){   
    objImg.width   =   width   *   Ratio;   
    objImg.height   =   height   *   Ratio;   
  }else{   
    objImg.width   =   width;   
    objImg.height   =   height;   
  }   
  }   
          }else{   
                  var   timer=window.setTimeout("ResizeRatio("   +   maxWidth   +   ","   +   maxHeight   +   ",'"   +   objImgTmp   +   "')",500);   
          }   
  }   
    
  //转换数字函数   
  function   EuwStr2Float(as_str,ai_digit,as_type)   
  {   
        var   fdb_tmp   =   0;   
        var   fi_digit   =   0;   
        var   fs_digit   =   "1";   
        var   fs_str   =   ""   +   as_str;   
        var   fs_tmp1   =   "";   
        var   fs_tmp2   =   "";   
        var   fi_pos   =   0;   
        var   fi_len   =   0;   
        fdb_tmp   =   parseFloat(isNaN(parseFloat(fs_str))?0:fs_str);   
    
        switch   (true)   
        {   
              case   (ai_digit==null)://   
                    fdb_tmp   =   fdb_tmp;   
                    break;   
              case   (ai_digit==0)://   
                    fdb_tmp   =   Math.round(fdb_tmp);   
                    break;   
              case   (ai_digit>0)://   
                    for   (var   i=0;i<ai_digit;i++)   fs_digit   +="0";   
                    fi_digit   =   parseInt(fs_digit);   
                    fdb_tmp   =   Math.round(fdb_tmp   *   fi_digit)   /   fi_digit;   
                    if   (as_type=="str")   
                    {   
                          fs_tmp1   =   fdb_tmp.toString();   
                          fs_tmp1   +=((fs_tmp1.indexOf(".")!=-1)?"":".")   +   fs_digit.substr(1);   
                          fi_pos   =   fs_tmp1.indexOf(".")   +   1   +   ai_digit;   
                          fdb_tmp   =   fs_tmp1.substr(0,fi_pos);   
                    }   
                    break;   
        }   
        return   fdb_tmp;   
  }

  function ToggleNode(nodeObject, imgObject){
         if (nodeObject.style.display == '') {
             nodeObject.style.display = 'none';
             imgObject.src = 'images/collapse.gif';
         } else {
             nodeObject.style.display = '';
             imgObject.src = 'images/expand.gif';
         }
}

function MaxImg(id, maxWidth) {    
    var i = new Image();    
     i.src = id.src;    
    if (id.width > maxWidth) {    
         id.height = id.height*maxWidth/id.width;    
         id.width = maxWidth;    
     }    
}
