function setImgSize(theURL,sImage,stand,ctand) {
    var imgObj;
    var sizeStand=stand;
    var CStand=ctand;
    if(arguments.length>=3) {
        sizeStand=arguments[2];
    }
    imgObj=new Image();
    imgObj.src=theURL;
    if(ctand==0) {
        if((imgObj.width!=0)&&(imgObj.height!=0)) {
            if(imgObj.width>sizeStand||imgObj.height>sizeStand) {
                if(imgObj.width>imgObj.height) {
                    var iHeight=imgObj.height*sizeStand/imgObj.width;
                    sImage.height=iHeight;
                    sImage.width=sizeStand;
                }
                else {
                    var iWidth=imgObj.width*sizeStand/imgObj.height;
                    sImage.width=iWidth;
                    sImage.height=sizeStand;
                }
            }
            else {
                sImage.width=imgObj.width;
                sImage.height=imgObj.height;
            }
        }
        else {
            sImage.width=sizeStand;
            sImage.height=sizeStand;
        }
    }
    else {
        if((imgObj.width!=0)&&(imgObj.height!=0)) {
            if(imgObj.width>sizeStand||imgObj.height>CStand) {
                var wi=imgObj.width/sizeStand;
                var hi=imgObj.height/CStand;
                if(wi>hi) {
                    var iHeight=imgObj.height*sizeStand/imgObj.width;
                    sImage.height=iHeight;
                    sImage.width=sizeStand;
                }
                else {
                    var iWidth=imgObj.width*CStand/imgObj.height;
                    sImage.width=iWidth;
                    sImage.height=CStand;
                }
            }
            else {
                sImage.width=imgObj.width;
                sImage.height=imgObj.height;
            }
        }
        else {
            sImage.width=sizeStand;
            sImage.height=CStand;
        }
    }
}

 function pic_reset(drawImage,thumbs_size) {
     var imgObj;
     imgObj=new Image();
     imgObj.src=drawImage.src;
     var max = thumbs_size.split(',');
     var fixwidth = max[0];
     var fixheight = max[1];
     var w=imgObj.width;
     var h=imgObj.height;
     var hbak = h;
     if(w == h) {
         drawImage.width=fixwidth;
         drawImage.height=fixheight;
     }else if(w>fixwidth) {
         if(w<h) {
             drawImage.height = fixheight;
             drawImage.width=w/(h/fixheight);
         }else{
            drawImage.width=fixwidth;
            drawImage.height=h/(w/fixwidth);
            hbak=drawImage.height;
         }
         }
     if(hbak>fixheight) { drawImage.height=fixheight;drawImage.width=w/(h/fixheight);}
 }
