/**
 * form.field를 매개변수로 하여 
 * 해당하는 필드에 체크된 radio버튼 혹은 checkbox가 있다면 true를
 * 없다면 false를 반환한다.
 * @param {Object} field_obj
 */
function hasChecked(field_obj) {
    if (field_obj.length > 1) {
        for (var idx = 0; idx < field_obj.length; idx++) {
            if (field_obj[idx].checked) return true;
        }
    } else {
        if (field_obj.checked) return true;
    }
    return false;
}
function hasCheckedValue(field_obj) {
    if (field_obj.length > 1) {
        for (var idx = 0; idx < field_obj.length; idx++) {
            if (field_obj[idx].checked) return field_obj[idx].value;
        }
    } else {
        if (field_obj.checked) return field_obj[idx].value;
    }
    return field_obj[idx].value;
}
function openWindow(url, name, width, height)   {
    var top  = screen.height / 2 - height / 2 - 50;
    var left = screen.width / 2 - width / 2 ;
    var win =
        open(url,
            name,
            'width=' + width + ', height=' + height + ', top=' + top +
            ', left=' + left + ', resizable=no, status=yes, toolbar=no, menubar=no, scrollbars=auto');
    win.focus();
    return win;
}

/**
 * top display
 */

function displaySubMenu(id_name,targer_menu_seq,total) {
    var target_menu = id_name+targer_menu_seq;
    for(i=1 ; i<=total ; i++) {
		if (document.getElementById(id_name + i)) {
			document.getElementById(id_name + i).style.display = "none";
		}
    }
	if (document.getElementById(target_menu)) {
		document.getElementById(target_menu).style.display = "block";
	}
}

function change_subMenuImage(id_name,targer_menu_seq,total) {
    var target_menu = id_name+targer_menu_seq;
    for(i=1 ; i<=total ; i++) {
        var re = /on\./g;
        imgName = document.getElementById(id_name+i).src;
        document.getElementById(id_name+i).src = imgName.replace(re,"off.");
    }
    imgName = document.getElementById(target_menu).src;
    var re = /off\./g;
	document.getElementById(target_menu).src = imgName.replace(re,"on.");
}

/**
 * 이미지 스왑
 */
function chImg(img) {
	imgName = img.src;
	if( imgName.indexOf("on.") > -1 ) {
		var re = /on\./g;
		img.src = imgName.replace(re,"off.");
	} else {
		var re = /off\./g;
		img.src = imgName.replace(re,"on.");
	}
} 


var iZoomPercent = 0;

function jsZoom(param)
{
    if(navigator.userAgent.toLowerCase().indexOf("msie")!=-1)
    {
        if(document.body.style.zoom==null||document.body.style.zoom=="") iZoomPercent = 100;

        if(param=="in")
            iZoomPercent = iZoomPercent + 10;
        else
            iZoomPercent = iZoomPercent - 10;

        if (iZoomPercent > 150) {
			alert("최대크기입니다.");
			iZoomPercent = 150;
		}      

        if(iZoomPercent < 50){
			iZoomPercent = 50;
			alert("최소크기입니다.");
		} 
         
        document.body.style.zoom = iZoomPercent +"%";
    }
}
 



/** 페이지 로딩 완료시 수행*/
function addLoadEvents( func )
{
  var oldonload = window.onload;
  if ( typeof window.onload != 'function' ){
    window.onload = func;
  } else {
    window.onload = function()
    {
      oldonload();
      func();
    }
  }
}

/***********************************
/ 이미지 사이즈에 맞게 새창띄우기
/***********************************/
function OpenImage(s){
 //
 // 변수 정의
 //
 srcImg = new Image();
 clientWidth = screen.width;
 clientHeight = screen.height;
 srcImg.src = s.src;
 //
 // 열려는 파일을 이름
 //
 var srcFileName = srcImg.src.substr(srcImg.src.lastIndexOf("/")+1, srcImg.src.length);
 //
 // 새창 띄우고 이미지 삽입
 //
 win = window.open("","","width=15,height=15,scrollbars=no,resizable=no,left="+(clientWidth/2-15)+",top="+(clientHeight/2-15)+"");
 win.document.writeln("<html>");
 win.document.writeln("<head>");
 win.document.writeln("<title>"+document.title+" ["+srcFileName+"]</title>");
 win.document.writeln("</head>");
 win.document.writeln("<body style='margin:0px;' bgcolor='#333333'>");
 win.document.writeln("<table border='0' cellpadding='0' cellspacing='0' style='cursor:hand' onclick='self.close()'>");
 win.document.writeln(" <tr>");
 win.document.writeln("  <td align='center'><img src="+s.src+" name='winImg' style='cursor:hand' onclick='self.close()' alt='클릭하면 사라집니다'></td>");
 win.document.writeln(" </tr>");
 win.document.writeln("</table>");
 win.document.writeln("</body>");
 win.document.writeln("</html>");

 srcImg = win.document.winImg;
 //
 // 이미지가 모두 로딩될때까지 기다림
 //
 while(true)
 if(srcImg.readyState == "complete")
 break;
 
 //
 // 새창의 크기 설정
 //
 var winWidth = srcImg.width+10;
 var winHeight = srcImg.height+29;
 //
 // 새창이 띄워질 위치 설정
 //
 var left = (clientWidth/2)-(srcImg.width/2);
 var top = (clientHeight/2)-(srcImg.height/2);
 //
 // 이미지의 크기 overflow 확인후 새창의 크기와 위치 재설정
 //
 if(clientWidth <= srcImg.width){
  winWidth = clientWidth;
  left = 0;
  win.document.body.scroll = "auto";
 }
 if(clientHeight <= srcImg.height){
  winHeight = clientHeight-30;
  top = 0;
  win.document.body.scroll = "auto";
 }
 //
 // 이미지로딩이 끝났음으로 이미지의 크기를 사용할수 있다.
 // 해당 이미지의 사이즈에 맞게 윈도우를 재설정한다.
 win.moveTo(left, top);
 win.resizeTo(winWidth, winHeight);
}
//-->

