﻿
//EDMS이용 다운로드 시 사용
function iframe(docid) {
    if(!document.all["setEDMSDownLoad"]){
        var oDIV = document.createElement("DIV");
        oDIV.id = "setEDMSDownLoad";
        oDIV.style.position = 'absolute';
        oDIV.style.display = 'none';
        document.body.appendChild(oDIV);
    }
    var oIFrame = document.createElement("iframe")
    oIFrame.width = 300;
    oIFrame.height = 200;
    //기표원 설치시 주소 수정해야 함
    oIFrame.src = "/Common/FileDownload.aspx?index="+docid;
    oIFrame.marginWidth = "0";
    oIFrame.marginHeight = "0";
    oIFrame.scrolling                  = "no";
    oIFrame.width                                          = "0";
    oIFrame.height                              = "0";
    oIFrame.frameBorder  = "0";
    oIFrame.scrolling                  = "no";
    document.all["setEDMSDownLoad"].appendChild(oIFrame);
}



// (엘리먼트, 엘리먼트의 size, 메세지)
function setMenuDiv(element, width, msg){

	var left = 0;
	var top = 0;

	var el = event.srcElement;
	var rect = el.getBoundingClientRect();

	var gacleft;
	var gactop;

	if (element == ''){
		gacleft = rect.left + Number(width);
		gactop = document.body.scrollTop +  rect.top + 6;;

	} else {
		gacleft = eval(element + ".style.left");
		gactop = eval(element + ".style.top");
	}

	 left = gacleft = rect.left + Number(width);
	 top = gactop = + document.body.scrollTop +  rect.top + 6;


	if(!document.all["topMenu"])
	{
		createMenuDiv(left, top)
	} else {
		document.all["topMenu"].style.left = left;
		document.all["topMenu"].style.top = top;
		document.all["topMenu"].style.visibility="visible";
	}


	var tableBody = "";
	tableBody += "<tr>";
	tableBody += "<td>" + msg + "</td>";
	tableBody += "</tr>";
	
	var tableTopBody ="";
	tableTopBody = "<table  border='0' cellspacing='0' cellpadding='0'>";
	tableTopBody += "<tr>";
	tableTopBody += "<td><img src='/image/common/blank.gif' width='1' height='1'></td>";
	tableTopBody += "<td width='6'><img src='/image/common/top_left.gif' width='6' height='4'></td>";
	tableTopBody += "<td background='/image/common/top_cen.gif'><img src='/image/common/blank.gif' width='1' height='1'></td>";
	tableTopBody += "<td width='6'><img src='/image/common/top_right.gif' width='6' height='4'></td>";
	tableTopBody += "</tr>";
	tableTopBody += "<tr>";
	tableTopBody += "<td align='right' valign='top'><img src='/image/common/arrow.gif' width='4' height='14'></td>";
	tableTopBody += "<td background='/image/common/left_sun.gif'><img src='/image/common/blank.gif' width='1' height='1'></td>";
	tableTopBody += "<td bgcolor='#EFF3DE'><table border='0' cellspacing='0' cellpadding='0' onMouseOver='showDiv();' onMouseOut='downMenuDiv();'>";
	tableTopBody += "<tr>";
	tableTopBody += "<td width='7'><img src='/image/common/blank.gif'></td>";
	tableTopBody += "<td height='5'><img src='/image/common/blank.gif'></td>";
	tableTopBody += "</tr>"

	var tableBottomBody ="";
	tableBottomBody = "<tr>";
	tableBottomBody += "<td width='7'><img src='/image/common/blank.gif'></td>";
	tableBottomBody += "<td height='5'><img src='/image/common/blank.gif'></td>";
	tableBottomBody += "</tr>";
	tableBottomBody += "</table></td>";
	tableBottomBody += "<td background='/image/common/right_sun.gif'><img src='/image/common/blank.gif' width='1' height='1'></td>";
	tableBottomBody += "</tr>";
	tableBottomBody += "<tr>";
	tableBottomBody += "<td><img src='/image/common/blank.gif' width='1' height='1'></td>";
	tableBottomBody += "<td width='6'><img src='/image/common/bottom_left.gif' width='6' height='4'></td>";
	tableBottomBody += "<td background='/image/common/bottom_cen.gif'><img src='/image/common/blank.gif' width='1' height='1'></td>";
	tableBottomBody += "<td width='6'><img src='/image/common/bottom_right.gif' width='6' height='4'></td>";
	tableBottomBody += "</tr></table>";

	document.all["topMenu"].innerHTML = tableTopBody + tableBody + tableBottomBody;


}

function downMenuDiv(){
	if(document.all["topMenu"]){
		document.all["topMenu"].style.visibility="hidden";
	}
}

function showDiv(){
	document.all["topMenu"].style.visibility="visible";
}

// 버튼 도움말 부분 시작
function createMenuDiv(left, top){
	var oDIV = document.createElement("DIV");
	oDIV.id = "topMenu";
	oDIV.style.position = 'absolute';
	oDIV.style.left = left;
	oDIV.style.top = top;
	oDIV.style.visibility = 'visible';
	oDIV.style.zIndex = 1;
	document.body.appendChild(oDIV);
}



/**
 * 지정한 자리수가 되면 다음으로 이동한다.
 * 사용법: onkeyup='nextFocus(this,8,document.all.edtDate1)"
 */
function nextFocus(arg, len, nextname)
{
	if (arg.value.length == len)
	{
		nextname.focus();
		return;
	}
}


//달력
function show_calendar(obj)
{
	if(!document.all["s_calendar"]){
		var oDIV = document.createElement("DIV");
		oDIV.id = "s_calendar";
		oDIV.style.position = 'absolute';
		oDIV.style.display = 'none';
		document.body.appendChild(oDIV);

		var oIFrame = document.createElement("iframe")
		oIFrame.width = 180;
		oIFrame.height = 209;
		oIFrame.src = "/Common/calendar.htm";
		oIFrame.style.borderBottom = "black 1px solid"
		oIFrame.style.borderLeft = "black 1px solid"
		oIFrame.style.borderRight = "black 1px solid"
		oIFrame.style.borderTop = "black 1px solid"
		oIFrame.frameBorder = "0";
		oIFrame.scrolling = "no"
		document.all["s_calendar"].appendChild(oIFrame);
	}

	if(s_calendar.style.display=="block"&&select_obj==obj){
		close_calendar();
	}else{
		w_h = document.body.offsetHeight + document.body.scrollTop		// 전체 높이
		w_w = document.body.offsetWidth + document.body.scrollLeft		//전체 폭
		e_h = window.event.clientY + document.body.scrollTop				//현재 높이
		e_w = window.event.clientX + document.body.scrollLeft				//현재 폭
		//alert(w_h+"@"+w_w+"@"+e_h+"@"+e_w+"@") ;

		if(w_h < (e_h+209))
		{
			s_calendar.style.pixelTop = e_h - 200
		}
		else
		{
			s_calendar.style.pixelTop = e_h 
		}

		if (w_w < (e_w+177))
		{
			s_calendar.style.pixelLeft = w_w - 200
		} 
		else
		{
			s_calendar.style.pixelLeft = e_w
		}
		s_calendar.style.display = "block"
		select_obj = obj
	}
}


//달력
function show_calendar2(obj, val1, val2)
{
	if(!document.all["s_calendar"]){
		var oDIV = document.createElement("DIV");
		oDIV.id = "s_calendar";
		oDIV.style.position = 'absolute';
		oDIV.style.display = 'none';
		document.body.appendChild(oDIV);

		var oIFrame = document.createElement("iframe")
		oIFrame.width = 180;
		oIFrame.height = 219;
		oIFrame.src = "/Common/calendar.htm";
		oIFrame.style.borderBottom = "black 1px solid"
		oIFrame.style.borderLeft = "black 1px solid"
		oIFrame.style.borderRight = "black 1px solid"
		oIFrame.style.borderTop = "black 1px solid"
		oIFrame.frameBorder = "0";
		oIFrame.scrolling = "no"
		document.all["s_calendar"].appendChild(oIFrame);
	}

	if(s_calendar.style.display=="block"&&select_obj==obj){
		close_calendar();
	}else{
		w_h = document.body.offsetHeight + document.body.scrollTop		// 전체 높이
		w_w = document.body.offsetWidth + document.body.scrollLeft		//전체 폭
		e_h = window.event.clientY + document.body.scrollTop				//현재 높이
		e_w = window.event.clientX + document.body.scrollLeft				//현재 폭
		//alert(w_h+"@"+w_w+"@"+e_h+"@"+e_w+"@") ;

		if(w_h < (e_h+209))
		{
			s_calendar.style.pixelTop = e_h - 200
		}
		else
		{
		    var val3 = 0;
		    if(val1 != 0 && val2 != 0)  val3 = 122;
			s_calendar.style.pixelTop = e_h + val1 + val2 + val3
		}

		if (w_w < (e_w+177))
		{
			s_calendar.style.pixelLeft = w_w - 200
		} 
		else
		{
			s_calendar.style.pixelLeft = e_w
		}
		s_calendar.style.display = "block"
		select_obj = obj
	}
}


//달력 선택한 날짜 입력
function input_date(y_date,m_date,d_date)
{
	m_date=(parseInt(m_date)+1).toString();
	if(m_date.length == 1)
	{
		m_date = "0" + m_date;
	}
	d_date=d_date.toString();
	if(d_date.length == 1)
	{
		d_date = "0" + d_date;
	}
	//select_obj.value = y_date + "-" + m_date + "-" + d_date;
	select_obj.value = y_date + m_date + d_date;
	s_calendar.style.display = "none";
}

//달력 닫기
function close_calendar()
{
	s_calendar.style.display="none"
}




function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


//새창 띄우기
function OpenWindow(filename, windowname, s_width, s_height, s_scrol)
{
	x = screen.width;
	y = screen.height;
	wid = (x / 2) - (s_width / 2);
	hei = (y / 2) - (s_height / 2);

   window.open(filename, windowname, "toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0,scrollbars=" + s_scrol + ",width=" + s_width + ",height=" + s_height + ",top=" + hei + ",left=" + wid + ",scrolbar=no").focus(); 
}