﻿// JScript 文件
 // 说明：用 JavaScript 实现网页图片等比例缩放
 function DrawImage(ImgD,FitWidth,FitHeight)
 {     
     var image=new Image();     
     image.src=ImgD.src;     
     if(image.width>0 && image.height>0){       
         //如果图片比较宽  
         if(image.width/image.height>= FitWidth/FitHeight)
         {             
             //宽度大于预定宽度
             if(image.width>FitWidth){                 
                 ImgD.width=FitWidth;                 
                 ImgD.height=(image.height*FitWidth)/image.width;             
             }else{                 
                 ImgD.width=image.width;                 
                 ImgD.height=image.height;             
             }        
        } 
        else
        {             
             //如果图片比较窄 
             if(image.height>FitHeight)
             {                 
                 ImgD.height=FitHeight;                 
                 ImgD.width=(image.width*FitHeight)/image.height;             
             }
             else
             {                 
                  ImgD.width=image.width;                 
                  ImgD.height=image.height;             
             }         
         }     
     } 
 } 
 
  // 说明：用 JavaScript 实现网页图片宽度不超过一定数值
 function DrawImageW(ImgD,FitWidth,FitHeight)
 {     
     var image=new Image();     
     image.src=ImgD.src;     
     if(image.width>0 && image.height>0){         
         if(image.width>FitWidth){                 
             ImgD.width=FitWidth;                 
             ImgD.height=(image.height*FitWidth)/image.width;             
         }
         else
         {                 
             ImgD.width=image.width;                 
             ImgD.height=image.height;             
         }            
     } 
 } 
 
 
  //TRIM
 String.prototype.Trim = function() { return this.replace(/(^\s*)|(\s*$)/g, ""); }  
 String.prototype.LTrim = function() { return this.replace(/(^\s*)/g, ""); }  
 String.prototype.RTrim = function() { return this.replace(/(\s*$)/g, ""); } 
     