// Pop »ý¼º
var openPop = new Array();

function woongjapopup(e){
   if(openPop.length > 0){
		for(i = 0; i < openPop.length; i++){
			try{
				if(typeof(openPop[i])!='defined' && openPop[i].closed == false){
					openPop[i].focus();
				}else {
					openPop[i] = '';
				}
			}catch(e){}
		}
   }else {
      if(document.addEventListener){
         //ns
         document.removeEventListener("focus", woongjapopup, true);
      }else if(document.detachEvent){
         //ie
         document.detachEvent("onmousedown", woongjapopup);
         window.detachEvent("onfocus", woongjapopup);
      }
   }
}


var current = new Date();

function date_input(year_start, year_end, inputYear, inputMonth, inputDay, inputHour, inputMinute, inputSecond, returnVar, disable)
{
   //inputHour=inputHour*1;
   if(disable == 'disable')
   {
	  disable = 'disabled';
   }
   else 
   {
	  disable = '';
   }
   if(inputYear != 'N')
   {
	  document.write("<SELECT name='" + returnVar + "[year]' onChange=makeDay('" + returnVar + "'); class='form' " + disable + " id='" + returnVar + "[year]'>");
	  if(year_start >= year_end)
	  {
		 for(var i = year_start; i >= year_end; i--)
		 {
			selected =(i == inputYear) ? 'selected' : '';
			document.write("<option value=" + i + " " + selected + ">" + i + "</option>");
		 }
	  }
	  else 
	  {
		 for(var i = year_start; i < year_end; i++)
		 {
			selected =(i == inputYear) ? 'selected' : '';
			document.write("<option value=" + i + " " + selected + ">" + i + "</option>");
		 }
	  }
	  document.write("</SELECT> ³â &nbsp;&nbsp;");
   }
   if(inputMonth != 'N')
   {
	  document.write("<SELECT name='" + returnVar + "[month]' onChange=makeDay('" + returnVar + "'); class=form " + disable + " id='" + returnVar + "[month]'>");
	  for(var i = 0; i < 12; i++)
	  {
		 if(i < 9)
		 var j = "0" +(i + 1);
		 else 
		 var j = i + 1;
		 checkedH =(j == current.getHours()) ? 'selected' : '';
		 document.write("<option value=" + j + " " + checkedH + ">" + j);
	  }
	  document.write("</SELECT> ¿ù &nbsp;&nbsp;");
   }
   if(inputDay != 'N')
   {
	  document.write("<SELECT name='" + returnVar + "[day]' class=form " + disable + " id='" + returnVar + "[day]'>" + "<script\ language=javascript>setDateValue('" + returnVar + "')</script\> ");
	  document.write("</select> ÀÏ &nbsp;&nbsp;");
   }
   if(inputHour != 'N')
   {
	  document.write("<select name='" + returnVar + "[hour]' class=form " + disable + " id='" + returnVar + "[hour]'>");
	  document.write("<script\ language=javascript>setHourValue('" + returnVar + "')</script\>");
	  document.write("</select> ½Ã &nbsp;&nbsp;");
   }
   if(inputMinute != 'N')
   {
	  document.write("<select name='" + returnVar + "[minute]' class=form " + disable + " id='" + returnVar + "[minute]'>");
	  document.write("<script\ language=javascript>setMinuteValue('" + returnVar + "')</script\>");
	  document.write("</select> ºÐ &nbsp;&nbsp;");
   }
   if(inputSecond != 'N')
   {
	  document.write("<select name='" + returnVar + "[second]' class=form " + disable + " id='" + returnVar + "[second]'>");
	  document.write("<script\ language=javascript>setSecondValue('" + returnVar + "')</script\>");
	  document.write("</select> ÃÊ ");
   }
   if(inputMonth != 'N')
   {
	  try
	  {
		 document.getElementById(returnVar+'[month]').options[inputMonth-1].selected=true;
	  }
	  catch(e)
	  {
	  }
   }
   if(inputDay != 'N')
   {
	  try{
	   document.getElementById(returnVar+'[day]').options[inputDay-1].selected=true;
	  }catch(e){}
   }
   if(inputHour && inputHour != 'N')
   {
	  try{
		document.getElementById(returnVar+'[hour]').options[inputHour].selected=true;
	  }catch(e){}
   }
   if(inputMinute && inputMinute != 'N')
   {
	   try{
			document.getElementById(returnVar+'[minute]').options[inputMinute].selected=true;
	   }catch(e){}
   }
   if(inputSecond && inputSecond != 'N')
   {
	   try{
			document.getElementById(returnVar+'[second]').options[inputSecond].selected=true;
	   }catch(e){}
   }
}

//¿ù°ú³¯Â¥ º¯°æ

function makeDay(returnVar)
{
   var yearF =  document.getElementById(returnVar+'[year]');//eval("document.all['" + returnVar + "[year]']");
   var monthF = document.getElementById(returnVar+'[month]');//eval("document.all['" + returnVar + "[month]']");
   var dayF = document.getElementById(returnVar+'[day]');//eval("document.all['" + returnVar + "[day]']");
   var YEAR = yearF.options[yearF.selectedIndex].value;
   var MONTH = monthF.options[monthF.selectedIndex].value;
   var daysInMonth = new Date(new Date(YEAR, MONTH, 1) - 86400000).getDate();
   for(var i = 0; i < dayF.length; i++) dayF.options[i] = null;
   for(var j = 0; j < daysInMonth; j++)
   {
	  if(j < 9)
		var k = "0" +(j + 1);
	  else 
		var k = j + 1;
	dayF.options[j] = new Option(k);
	dayF.options[j].value=k;
	}
}
//¿ù¿¡µû¸¥ ³¯Â¥ º¯°æ

function setDateValue(returnVar)
{
   //ÀÌ¹ø´ÞÀÇ ³¯¼ö
   var daysInMonth = new Date(new Date(current.getFullYear(), current.getMonth() + 1, 1) - 86400000).getDate();
   for(var i = 0; i < daysInMonth; i++)
   {
	  if(i < 9)
	  var j = "0" +(i + 1);
	  else 
	  var j = i + 1;
	  document.write("<option value=" + j + ">" + j);
   }
   if(document.all){
		eval("document.all['" + returnVar + "[month]'].options[current.getMonth()].selected = true");
		eval("document.all['" + returnVar + "[day]'].options[current.getDate()-1].selected = true");
   }else{
		document.getElementById(returnVar+'[month]').options[current.getMonth()].selected = true;
		document.getElementById(returnVar+'[day]').options[current.getDate()-1].selected = true;
   }
}
//½Ã

function setHourValue(returnVar)
{
   for(var i = 0; i <= 23; i++)
   {
	  if(i <= 9)
		var j = "0" +(i);
	  else 
		var j = i;
	  checkedH = (j == current.getHours()) ? 'selected' : '';
	  document.write("<option value=" + j + " " + checkedH + ">" + j);
   }
}
//ºÐ

function setMinuteValue(returnVar)
{
   for(var i = 0; i <= 59; i++)
   {
	  if(i < 10)
	  var j = "0" +(i);
	  else 
	  var j = i;
	  checkedH =(j == current.getMinutes()) ? 'selected' : '';
	  document.write("<option value=" + j + " " + checkedH + ">" + j);
   }
}
//ÃÊ

function setSecondValue(returnVar)
{
   for(var i = 0; i <= 59; i++)
   {
	  if(i < 10)
	  var j = "0" +(i);
	  else 
	  var j = i;
	  checkedH =(j == current.getSeconds()) ? 'selected' : '';
	  document.write("<option value=" + j + " " + checkedH + ">" + j);
   }
}

function popupCheck(n_num)
{
	var form = document.forms[0];
	var n_subject = form.n_subject.value.replace(/^\s*/,'').replace(/\s*$/, '');
	var n_contents = form.n_contents.value.replace(/^\s*/,'').replace(/\s*$/, '');

	var n_start = "";
	n_start = document.getElementById("n_startdate[year]").value+document.getElementById("n_startdate[month]").value+document.getElementById("n_startdate[day]").value
	n_start = n_start+document.getElementById("n_startdate[hour]").value+document.getElementById("n_startdate[minute]").value

	var n_end = "";
	n_end = document.getElementById("n_enddate[year]").value+document.getElementById("n_enddate[month]").value+document.getElementById("n_enddate[day]").value
	n_end = n_end+document.getElementById("n_enddate[hour]").value+document.getElementById("n_enddate[minute]").value

	if (!n_subject)
	{
		alert("Á¦¸ñÀ» ÀÔ·ÂÇÏ¼¼¿ä.");
		form.n_subject.focus();
	}
	else if (parseInt(n_start)>=parseInt(n_end))
	{
		alert("½ÃÀÛÀÏ°ú Á¾·áÀÏÀ» È®ÀÎÇØÁÖ¼¼¿ä.")
	}
	else if (!n_contents)
	{
		alert("³»¿ëÀ» ÀÔ·ÂÇÏ¼¼¿ä.");
		form.n_contents.focus();
	}
	else
	{
		if (!n_num)
		{
			form.action = "woongja_popup_add_process.html";
		}
		else
		{
			form.action = "woongja_popup_modify_process.html";
		}
		form.submit();
	}
}

var openPop = new Array();
var max_z_index = 200;

function show_popup_layer(no,width,height,left,top,scroll){
    
	if(document.getElementById("popup_div_"+no)){
		document.getElementById("popup_div_"+no).parentNode.removeChild(document.getElementById("popup_div_"+no));
	}
	obj = document.createElement("div");
	obj.id = "popup_div_"+no;
	obj.style.zIndex = max_z_index;
	obj.style.position = 'absolute';
	obj.style.left=left+'px';
	obj.style.top=top+'px';
	obj.style.padding = 0;
	obj.style.margin=0;
	iobj = document.createElement('iframe');
	iobj.src='/popup/popup_win.php?n_num='+no;
	iobj.frameBorder=0;
	iobj.marginWidth=0;
	iobj.marginHeight = 0;
	iobj.width=width;
	iobj.height=height;
	iobj.allowtransparency=true;
	iobj.scrolling = scroll;
	obj.appendChild(iobj);
	document.body.appendChild(obj);

}

//À©µµ¿ì ¿ÀÇÂ ÇÔ¼ö
function open_window(href,popup_name, w, h, scroll, x, y,modal)
{
	if (! window.focus)return true;
	var x =(!x) ?(screen.width - w)/2 : x;
	var y =(!y) ?(screen.height - h)/2 : y;
	if(window.showModalDialog && modal==1){
		window.showModalDialog(href,window,"dialogWidth:"+w+"px;dialogHeight:"+h+"px;scroll:"+scroll+";center:yes;resizeable:no;status:no;help:no");
	}else{
		wp = 'height=' + h + ',width=' + w + ',left=' + x + ',top=' + y + ',scrollbars=' + scroll + ',resizable=no,status=no';
		n = openPop.length;
		openPop[n] = window.open(href,'_blank', wp);

		if(openPop.length == 1){
			if(document.addEventListener){
				document.addEventListener("focus", woongjapopup, true);
			}else if(document.attachEvent){
				document.attachEvent("onmousedown", woongjapopup);
				window.attachEvent("onfocus", woongjapopup);
			}
		}
		return openPop[n];
	}
}

//·¹ÀÌ¾î ÇÏÀÌµå
function layerHide(lay){try{document.getElementById(lay).style.display = "none";}catch(e){}}
function layerShow(lay){try{document.getElementById(lay).style.display = "inline";}catch(e){}}