// popup.js ÀÚ¹Ù ½ºÅ©¸³Æ® ÇÔ¼ö ÆÄÀÏ

function getCookie(key)
{
  var cook = document.cookie + ";";
  var idx =  cook.indexOf(key, 0);
  var val = "";

  if(idx != -1)
  {
    cook = cook.substring(idx, cook.length);
    begin = cook.indexOf("=", 0) + 1;
    end = cook.indexOf(";", begin);
    val = unescape( cook.substring(begin, end) );
  }

  return val;
}

function setCookie( name, value, expiredays )
{
  var today = new Date();
  today.setDate( today.getDate() + expiredays );
  document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + today.toGMTString() + ";"
}
	
// ÇÏ·íµ¿¾È Ã¢ ¾È¿­±â + ÇöÀç Ã¢ ´Ý±â
function CloseToday(name)
{
  setCookie(name, "sleep", 1);
  
  window.close();
}

// ÇÏ·íµ¿¾È Ã¢ ¾È¿­±â
function endToday(name, obj)
{
	if(obj.checked)
	  setCookie(name, "sleep", 1);
	else
	  setCookie(name, "sleep", 0);
}

// ÄíÅ° °Ë»çÇÑ ´ÙÀ½ ÆË¾÷À» ¶ç¿î´Ù.
function Popup(url, name, left, top, width, height, scrollbar)
{
  if (getCookie(name) != "sleep") {
    open_window(url, name, left, top, width, height, false, false, false, scrollbar, false);
  }
//   else
//   		alert( getCookie(name) );
}

// ºÎ¸ðÃ¢À» strURL·Î ÀÌµ¿ÇÏ°í ÇöÀçÃ¢ ´Ý±â
function CloseGoto(strURL)
{
	opener.location.href = strURL;
	
	window.close();
}

// ¹Ì¸®º¸±â ¿ëµµ·Î ÆË¾÷À» ¶ç¿î´Ù.
function previewPopup(url, name, left, top, width, height, scrollbar)
{
    open_window(url, name, left, top, width, height, false, false, false, scrollbar, false);
}

// À©µµ¿ì »ý¼º À§Ä¡ÀÎ left, topÀÇ °ªÀÌ 0 º¸´Ù ÀÛÀ» °æ¿ì ¸¶¿ì½º À§Ä¡·Î ÀÚµ¿ Ãâ·Â
function open_window(url, name, left, top, width, height, toolbar, menubar, statusbar, scrollbar, resizable)
{
	var param;
	
  toolbar_str = toolbar ? 'yes' : 'no';
  menubar_str = menubar ? 'yes' : 'no';
  statusbar_str = statusbar ? 'yes' : 'no';
  scrollbar_str = scrollbar ? 'yes' : 'no';
  resizable_str = resizable ? 'yes' : 'no';
  
  if(left < 0) left = event.screenX - (width / 2);
  if(top < 0) top = event.screenY - (height / 2);

  param = 'left='+left+',top='+top+',width='+width+',height='+height+',toolbar='+toolbar_str+',menubar='+menubar_str+',status='+statusbar_str+',scrollbars='+scrollbar_str+',resizable='+resizable_str;

  window.open(url, name, param);
}