// javascript document var flag_img=false; function drawimage(imgd,int_width,int_height){ var image=new image(); //var int_width=323; //var int_height=316; image.src=imgd.src; if(image.width>0 && image.height>0){ flag_img=true; if(image.width/image.height>= int_width/int_height){ if(image.width>int_width){ imgd.width=int_width; imgd.height=(image.height*int_width)/image.width; }else{ imgd.width=image.width; imgd.height=image.height; } var m_top = (int_height-imgd.height)/2; //imgd.style.margin= m_top+"px 0px"; //alert($(imgd).css('margin')); //$(imgd).css("margin","auto 0px"); //imgd.alt=image.width+"×"+image.height; } else{ if(image.height>int_height){ imgd.height=int_height; imgd.width=(image.width*int_height)/image.height; }else{ imgd.width=image.width; imgd.height=image.height; } var m_height = (int_width-imgd.width)/2; //imgd.style.margin="0px "+m_height+"px"; //$(imgd).css("margin","auto 0px"); //imgd.alt=image.width+"×"+image.height; } } }