function inNode(obj, idString){
	var o;
	o= obj
	while(o=o.parentNode){
		if(o.id==idString) return true
	}
	
	return false;
}


function drawImages(idString, width, height){
	if( !document.getElementById(idString) ) return null;
	for(var i=0; i<document.images.length; i++){
		if(  inNode(document.images[i], idString)  ){
			resizeimg(document.images[i], width, height);
		}
	}
}



function resizeimg(ImgD,iwidth,iheight) { 
	var image=new Image(); 
	var isChange= false;
	image.src=ImgD.src; 
 
	if(image.width>0 && image.height>0){ 
		if(image.width/image.height>= iwidth/iheight){ 
			if(image.width>iwidth){ 
				ImgD.width=iwidth; 
				ImgD.height=(image.height*iwidth)/image.width; 
				isChange= true
			}else{ 
				ImgD.width=image.width; 
				ImgD.height=image.height; 
			} 
			ImgD.alt=image.width+"×"+image.height; 
		}else{  
		
			if(image.height>iheight){ 
				ImgD.height=iheight; 
				ImgD.width=(image.width*iheight)/image.height; 
				isChange= true
			}else{ 
				ImgD.width=image.width; 
				ImgD.height=image.height; 
			} 
			ImgD.alt=image.width+"×"+image.height; 
			
		} 
		
		if( isChange ){
			ImgD.style.cursor= "pointer"; //改变鼠标指针 
			ImgD.onclick = function() { 
				var w,h,left,top;
				w= image.width + 40;
				h= image.height+40
//				if(w>=screen.width) w= screen.width
//				if(h>=screen.height - 70) h= screen.height -70
				left= (screen.width -w)/2
				top= (screen.height -h - 50)/2
				window.open(this.src,'_blank','top=' + top + ',left=' + left + ',width=' + w + ',height=' + h + ',menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes');
			} 
			ImgD.title = "放大图片"; 
		}

	} 
}


