/*
  »õ·Î¿î ÆË¾÷Ã¢À» ¶ç¿ó´Ï´Ù.
  String url : ÆË¾÷¹®¼­ÀÇ °æ·Î
  String name : ÆË¾÷Ã¢ÀÇ ÀÌ¸§
  int w : ÆË¾÷Ã¢À» Æø
  int h : ÆË¾÷Ã¢ÀÇ ³ôÀÌ
  int x : ÆË¾÷Ã¢ÀÇ ÁÂÃø »ó´ÜÀÇ xÁÂÇ¥
  int y : ÆË¾÷Ã¢ÀÇ ÁÂÃø »ó´ÜÀÇ yÇ¥Ç¥
  String s : ÆË¾÷Ã¢¿¡ ½ºÅ¬·Î¹Ù Ç¥½Ã¿©ºÎ('no' : Ç¥½Ã¾ÈÇÔ, 'yes' : Ç¥½ÃÇÔ)
*/
function popup(url, name, w, h, x, y, s) {
	var opt = ',menubar=0,status=0,resizable=0,directories=0,toolbar=0,location=0,';
	window.open(url, name,
		'width=' + w + ',height=' + h + ',left=' + x + ',top=' + y + ',scrollbars=' + s + opt);
}

/*
  ÄíÅ°ÀÇ Á¸Àç¿©ºÎ¿¡ µû¶ó popupÃ¢À» ¶ç¿ó´Ï´Ù.
  String c_name : ÄíÅ°¸í
  String url : ÆË¾÷¹®¼­ÀÇ °æ·Î
  String name : ÆË¾÷Ã¢ÀÇ ÀÌ¸§
  int w : ÆË¾÷Ã¢À» Æø
  int h : ÆË¾÷Ã¢ÀÇ ³ôÀÌ
  int x : ÆË¾÷Ã¢ÀÇ ÁÂÃø »ó´ÜÀÇ xÁÂÇ¥
  int y : ÆË¾÷Ã¢ÀÇ ÁÂÃø »ó´ÜÀÇ yÇ¥Ç¥
  String s : ÆË¾÷Ã¢¿¡ ½ºÅ¬·Î¹Ù Ç¥½Ã¿©ºÎ('no' : Ç¥½Ã¾ÈÇÔ, 'yes' : Ç¥½ÃÇÔ)
*/
function popupByCookie(c_name, url, name, w, h, x, y, s) {
    var cookie = getCookie(c_name);
    if(!cookie) popup(url, name, w, h, x, y, s);
}

/*
  ÄíÅ° »ý¼º ÇÔ¼ö
  String name : ÄíÅ°¸í
  String value : ÄíÅ° °ª
  int day : ÄíÅ°¸¸·á ±â°£(ÀÏ ´ÜÀ§)
*/
function setCookie(name, value, day) {
    var expDays = day;                // ¸¸·á ³¯Â¥ ¼ÂÆÃ
    var exp = new Date();
    exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
    var expire_date = new Date(exp);
    document.cookie = name + "=" + escape(value) + "; expires=" + expire_date.toGMTString()+ "; path=/";
}

/*
  ÄíÅ° ¼Ò¸ê ÇÔ¼ö
  String name : ¼Ò¸ê½ÃÅ³ ÄíÅ°¸í
*/
function clearCookie(name) {
    var today = new Date()
    //¾îÁ¦ ³¯Â¥¸¦ ÄíÅ° ¼Ò¸ê ³¯Â¥·Î ¼³Á¤ÇÑ´Ù.
    var expire_date = new Date(today.getTime() - 60*60*24*1000)
    document.cookie = name + "= " + "; expires=" + expire_date.toGMTString()
}

/*
  ÄíÅ°¸¦ °¡Á®¿À´Â ÇÔ¼ö
  String name : ÄíÅ°¸í
*/
function getCookie(name) {
   var from_idx = document.cookie.indexOf(name+'=');
   if (from_idx != -1) {
      from_idx += name.length + 1
      to_idx = document.cookie.indexOf(';', from_idx)

      if (to_idx == -1) {
            to_idx = document.cookie.length
      }
      return unescape(document.cookie.substring(from_idx, to_idx))
   }
}

/*
  Ã¼Å© »óÅÂ¿¡ µû¶ó ÄíÅ° »ý¼º°ú ¼Ò¸êÀ» Á¦¾îÇÏ´Â ÇÔ¼ö
  checkboxÀÇ Event HandlerÀÎ onClickÀÌº¥Æ®¿¡ µî·ÏÇØ¼­ »ç¿ëÇÕ´Ï´Ù.
  ex) <input type="checkbox" onClick="controlCookie(this, 'cName')">
  Form.checkbox frmObj : input typeÀÌ 'checkbox'ÀÎ Form Object
*/
function controlCookie(frmObj, name, day) {
    if (frmObj.checked) {
        //Ã¼Å© ¹Ú½º¸¦ ¼±ÅÃÇßÀ» °æ¿ì ÄíÅ° »ý¼º ÇÔ¼ö È£Ãâ
        setCookie(name,"true", day);
        self.close();
    }
    else {
        //Ã¼Å© ¹Ú½º¸¦ ÇØÁ¦ÇßÀ» °æ¿ì ÄíÅ° ¼Ò¸ê ÇÔ¼ö È£Ãâ
        clearCookie(name);
    }
    return
}





