// JavaScript Document
//控制图片大小
var flag=false; 
function DrawImage(ImgD,awidth,aheight){ 
var image=new Image(); 
image.src=ImgD.src; 
if(image.width>0 && image.height>0){ 
  flag=true; 
  if(image.width/image.height>= awidth/aheight){ 
   if(image.width>awidth){
    ImgD.width=awidth; 
    ImgD.height=(image.height*aheight)/image.width; 
   }else{ 
    ImgD.width=image.width;
    ImgD.height=image.height; 
   }
   /*ImgD.alt="bigpic"  */
  } 
  else{ 
   if(image.height>aheight){
    ImgD.height=aheight; 
    ImgD.width=(image.width*awidth)/image.height; 
   }else{ 
    ImgD.width=image.width;
    ImgD.height=image.height; 
   } 
    /*ImgD.alt="bigpic"  */ 
  } 
}
}



/*/
function init(){
var pic=document.getElementsByTagName("IMG");
	 if(pic){
for(i=0;i<pic.length;i++){
alert(pic[i].src);
}
}else{
	alert("ko");
}
}

window.onload=init();
/*/


var flags=false; 
function DrawImage_wd(ImgD,awidth,aheight){ 
var image=new Image(); 
image.src=ImgD.src; 
if(image.width>0 && image.height>0){ 
  flags=true; 
  if(image.width/image.height>= awidth/aheight){ 
   if(image.width>awidth){
    ImgD.width=awidth; 
    ImgD.height=(image.height*aheight)/image.width; 
	ImgD.title="在新窗口打开图片";
	ImgD.style.cursor="pointer";
	ImgD.onclick=function(e){window.open(this.src)}
   }else{ 
    ImgD.width=image.width;
    ImgD.height=image.height; 
   }
  } 
  else{ 
   if(image.height>aheight){
    ImgD.height=aheight; 
    ImgD.width=(image.width*awidth)/image.height;
	ImgD.title="在新窗口打开图片";
	ImgD.style.cursor="pointer";
	ImgD.onclick=function(e){window.open(this.src)}
   }else{ 
    ImgD.width=image.width;
    ImgD.height=image.height; 
   } 
  } 
}
}
function control_img(cid,cwidth,cheight){
var id=cid;
var arr=document.getElementById(id);
 if(arr==null) return;
 var wh=cwidth;
 var ct=cheight;
 var arr=arr.getElementsByTagName("IMG");
 for(var i=0;i<arr.length;i++){
  DrawImage_wd(arr[i],wh,ct);
}
}

window.onload=function(){
 control_img("content_wd","550","800");
}
