function image_auto_resize(this_s,width,height){
 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){
    if(!ta.title){ta.title=ta.src;}
    if(!ta.onclick){
    //ta.style.cursor='pointer';
    //ta.onclick=function(){js_image_view(this,1);}
    }
    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 imgErrDisp(sname,idx){
	try{
		var idName = sname + "_img_" + idx;
		var obj = document.getElementById(idName);
		obj.style.display = "none";
	}catch(e){}
}


function imgErrDispStar2(sname,idx){
	try{
		var idName = sname + "_img_" + idx;
		var idN = sname + "_msg_" + idx;
		var idName_err = sname+"_err";
		var obj = document.getElementById(idName);
		var obj2 = document.getElementById(idN);
		obj.style.display = "none";
		//obj2.innerHTML = "<div style='padding:10px' id='img_"+idx+"'></div>";
		obj2.innerHTML = "<div style='padding:10px'>이미지 로딩중 오류발생 - 클릭후 이미지를 확인하세요</div>";
	}catch(e){}
}



function imgErrDispStar(sname,idx){
	try{
		var idName = sname + "_img_" + idx;
		var idN = sname + "_msg_" + idx;
		var idName_err = sname+"_err";
		var obj = document.getElementById(idName);
		var obj2 = document.getElementById(idN);
		obj.style.display = "none";
		obj2.innerHTML = "<div style='padding:10px' id='err_msg_"+idx+"'><img id='err_img_"+idx+"' src='http://kinview.co.kr/image_tmp/i.php?i="+encodeURIComponent(obj.src)+"' onload=\"image_auto_resize(this,800,'');\" onmouseover=\"image_auto_resize(this,800,'');\" border=0 onError=\"imgErrDispStar2('err','"+idx+"');\"></div>";
		//obj2.innerHTML = "<div style='padding:10px'>이미지 로딩중 오류발생 - 클릭후 이미지를 확인하세요</div>";
	}catch(e){}
}


