var flag=false; function drawimage_ny(imgd){ var image=new image(); image.src=imgd.src; if(image.width>0 && image.height>0){ flag=true; if(image.width>740){ imgd.width=740; imgd.height=math.round(740/(image.width/image.height)); } else{ imgd.width=image.width; imgd.height=image.height; } } }