function setCookie(name, value, expire) {
  document.cookie = name + "=" + escape(value) + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()));
}

function getCookie(Name) {
  var search = Name + "=";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search);
    if (offset != -1){
      offset += search.length;

      end = document.cookie.indexOf(";", offset);

      if (end == -1) end = document.cookie.length;
      return unescape(document.cookie.substring(offset, end));
    }
  }
}

// ptype == 1 : top, left
function is_popup_open(url,win_width,win_height,win_scroll,ptype,xx,yy) {
  if(ptype == 1){
    var win2 = window.open(url,'win2','height='+win_height+',width='+win_width+',left='+xx+',top='+yy+',screenX='+xx+',screenY='+yy+',resizable=no,menubar=no,scrollbars='+win_scroll+','+',location=no,status=no');
  }
  else{
  var me_width;
  var me_height;

  me_width = (window.screen.width/2) - (win_width/2);
  me_height = (window.screen.height/2) - (win_height/2);
  me_height = me_height - 30;

  var win2 = window.open(url,'win2','height='+win_height+',width='+win_width+',left='+me_width+',top='+me_height+',screenX='+me_width+',screenY='+me_height+',resizable=no,menubar=no,scrollbars='+win_scroll+','+',location=no,status=no');
  }

  win2.focus();

}

function no_popupopen(){
  var today = new Date();
	var expires = new Date();
	var cookieName = "POPUPVAR";

  var cookieValue = Math.round(today.getTime()/1000);

  expires.setTime(today.getTime() + 1000*60*60*24); //1000*60(ΊΠ)*60(60ΊΠ)*24*365
  setCookie(cookieName,cookieValue, expires);
}