
function image_auto_resize(this_s, width, height) {

	// 그림의 width , height가 있고 width가 	지정한 값보다 작다면 리사이징 제외 by kkh 10.11.04
	if(this_s.width > 0 && this_s.height > 0 && this_s.width < width){
		return;
	}
	
	var isIE6 = (navigator.appVersion.indexOf("MSIE 6") != -1) ? true : false;
	if (isIE6) {
		if (this_s.width > width) {
			this_s.width = width;
		}
	} else {
	
		var ta_image = new Image();
		ta_image.src = this_s.src;
		if (!width) {
			this_s.removeAttribute("width");
			this_s.style.width = "auto";
		} else {
			if (width < ta_image.width) {
				this_s.width = width;
			} else {
				this_s.width = ta_image.width;
			}
		}
		if (!height) {
			this_s.removeAttribute("height");
			this_s.style.height = "auto";
		} else {
			if (height < ta_image.height) {
				this_s.height = height;
			} else {
				this_s.height = ta_image.height;
			}
		}
	}
}
function image_auto_resize_inarea(this_s, width, height, view) {
	 //this_s안의 모든 이미지는 자동 리사이즈 된다.
	 //alert(this_s.childNodes.length);
	if (!view) {
		view = true;
	}
	if (!this_s) {
		return;
	}
	if (this_s.nodeType != 1) {
		return;
	}
	for (var i = 0, m = this_s.childNodes.length; i < m; i++) {
		var ta = this_s.childNodes[i];
		if (ta.nodeName == "IMG") {
		//ta.style.border='1px solid #333333'; 
			image_auto_resize(ta, width, height);
			if (view) {
				/*----------------------------------------------------------
		     -- 1. 모든 게시판 내용의 이미지를 클릭시 팝업 화면 뜨지 않도록 함.
		     -- 2. 마우스 오버시 title tooltip이 뜨지 않도록 함. 
		     -- 2007.10.4 Jeong Ju Ho
		     ----------------------------------------------------------
		   if(!ta.title){ta.title=ta.src;}
		   if(!ta.onclick){
		   ta.style.cursor='pointer';
		   ta.onclick=function(){js_image_view(this);}
		   }
		   */
				if (!ta.onload) {
					ta.onload = function () {
						image_auto_resize(this, width, height);
					};
				}
		   //if(!ta.onmouseover)
		   //ta.onmouseover=function(){image_auto_resize(this,width,height);}
			}
		}
		if (ta.childNodes.length > 0) {
			image_auto_resize_inarea(ta, width, height);
		}
	}
	return;
}
function js_image_view(obj) {
	window.open(obj.src, "VIEW_IMAGE");
}


