var flag=false;
function DrawImage(ImgD,imgW,imgH){ 
 var image=new Image(); 
 image.src=ImgD.src; 
 if(image.width>0 && image.height>0){ 
  flag=true; 
  if(image.width/image.height>= imgW/imgH){ 
   if(image.width>imgW){
    ImgD.width=imgW; 
    ImgD.height=(image.height*imgH)/image.width; 
   }else{ 
    ImgD.width=image.width;
    ImgD.height=image.height; 
   } 
  } 
  else{ 
   if(image.height>imgH){
    ImgD.height=imgH; 
    ImgD.width=(image.width*imgH)/image.height; 
   }else{ 
    ImgD.width=image.width;
    ImgD.height=image.height; 
   }  
  } 
 }
}
function ChanageImagesWH(imgName,imgW,imgH)
{
	var imgs = document.getElementsByName(imgName);
	for(var i = 0;i<imgs.length;i++)
	{
			DrawImage(imgs[i],imgW,imgH);
	}
}
function ChanageImage(modelName,targetId)
{
	var imgs = document.getElementsByName(modelName);
	var targetImg = document.getElementById(targetId);
	for(var i = 0 ;i<imgs.length;i++)
	{
		imgs[i].width = 100;
		imgs[i].height=100;
		imgs[i].onclick=function (){targetImg.src = this.src;}
	}
}
