/**
* 라디오 하나도 선택안했을시 메시지 출력
* @ obj
* @return  라디오 박스가 하나라도 선택 되었을시 true
*/
function radioChk(obj) {
 var radiolength = obj.length; //라디오 버튼 개수를 알아냄
 if (!radiolength) radiolength=1; //라디오 버튼이 하나라면

 for (i=0; i<radiolength; i++) {
  if (obj[i].checked) break;
  if (radiolength==(i+1)) { //라디오 갯수만큼 루프를 다 돌때까지도 선택된 사항이 없다면
   alert("Please choose a "+obj[i].title);
   obj[0].focus();
   return false;
  }
 }
 return true;
}

function radioChk2(obj, str) {
 var radiolength = obj.length; //라디오 버튼 개수를 알아냄
 if (!radiolength) radiolength=1; //라디오 버튼이 하나라면

 for (i=0; i<radiolength; i++) {
  if (obj[i].checked) break;
  if (radiolength==(i+1)) { //라디오 갯수만큼 루프를 다 돌때까지도 선택된 사항이 없다면
   alert("Please choose a "+str);
   obj[0].focus();
   return false;
  }
 }
 return true;
}

//라디오값
function radioValue(obj) {
	var str;
	var radiolength = obj.length; 
	if (!radiolength) radiolength=1; 

	for (i=0; i<radiolength; i++) {
		if (obj[i].checked) {
			str = obj[i].value;
			break;
		}
	}
	return str;
}

// 첨부이미지사이즈체크
function FnImgSize(obj)
{
	var objImg = new Image();
	obj = eval(obj);
	objImg.src = obj.value;
	var nFileSize = objImg.fileSize;
	
	return nFileSize;
}

// 팝업창 가운데 위치에 띄우기
function NewWindow(mypage, myname, w, h, opt)  
{
	var winl = (screen.width - w) / 2; 
	var wint = (screen.height - h) / 2 - 100; // 정가운데보다 조금 위에
	if(opt=="") opt = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no";
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+','+opt;
	win = window.open(mypage, myname, winprops);
	if (parseInt(navigator.appVersion) >= 4) {
		win.window.focus();
	}
}

// 팝업창 위치조정
function NewWindow2(mypage, myname, w, h, left, opt)  
{
	//var winl = (screen.width - w) / 2; 
	var winl = left; 
	var wint = (screen.height - h) / 2 - 100; // 정가운데보다 조금 위에
	if(opt=="") opt = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no";
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+','+opt;
	win = window.open(mypage, myname, winprops);
	if (parseInt(navigator.appVersion) >= 4) {
		win.window.focus();
	}
}

/**
* '숫자'만 허용하기
* 입력값이 숫자가 아닐경우 입력문자를 취소하고 메시지를 출력함
* onKeyPress="fnChkNum()" --> 올바른 적용을 위해 다음이 필요 style="ime-mode:disabled"
*/
function fnChkNum() {
	if (!((event.keyCode>47)&(event.keyCode<58))) {
		event.returnValue=false;
		alert("숫자만 입력 가능 합니다.");
	}
	
}

// iFrame높이값 계산
function Resize_Frame(name) {
	if ( document.all(name) != null )	{
		var Frame_Body  = document.frames(name).document.body;
		var Frame_name  = document.all(name);

		Frame_name.style.height 
				= Frame_Body.scrollHeight + (Frame_Body.offsetHeight-Frame_Body.clientHeight);
	}
}

// 큰이미지 사이즈 제한 로딩
function imageSize(obj, max) {
  var width1 = obj.width;
  if(width1 > max){
    obj.width = max;
  }
}

// 세로제한 & 가로제한
function imageSize2(obj, w, h) {
  
	var width  = obj.width;
	var height = obj.height;
	var tmp;

	if ( height > h ) {
		tmp = width/(height / h);

		if( tmp > w ) {
			obj.width = w;
		} else {
			obj.width = tmp;
		}
	}
	else if( width > w) {
		obj.width = w;
	}
}


// 세로제한 & 가로제한
function imgSize3(which,w,h){
    var obj = eval("document."+which);
	var width  = obj.width;
	var height = obj.height;
	var tmp;

	if ( height > h ) {
		tmp = width/(height / h);

		if( tmp > w ) {
			obj.width = w;
		} else {
			obj.width = tmp;
		}
	}
	else if( width > w) {
		obj.width = w;
	}
}

