if (!self.getCookie){
  function setCookie(name, value, expires, path, domain, secure) {
  //thanks to Alexandr Alexandorv and Andrew A.Alikberov http://www.citforum.ru/internet/html/cookie.shtml
        var curCookie = name + "=" + escape(value) +
                ((expires) ? "" : "") + //"; expires=" + expires.toGMTString() - it does not work
                ((path) ? "; path=" + path : "") +
                ((domain) ? "; domain=" + domain : "") +
                ((secure) ? "; secure" : "")
        //if (!caution || (name + "=" + escape(value)).length <= 4000) - caution is nto defined
		if ((name + "=" + escape(value)).length <= 4000)
                document.cookie = curCookie
        else
                if (confirm("Cookie exceeds 4KB and will be dropped!"))
                        document.cookie = curCookie
  }

  function deleteCookie(name, path, domain) {
  //thanks to Alexandr Alexandorv and Andrew A.Alikberov http://www.citforum.ru/internet/html/cookie.shtml
    if (getCookie(name)) {
            document.cookie = name + "=" +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
  }

  function getCookie(name) {
        var prefix = name + "="
        var cookieStartIndex = document.cookie.indexOf(prefix)
        if (cookieStartIndex == -1)
                return null
        var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)
        if (cookieEndIndex == -1)
                cookieEndIndex = document.cookie.length
        return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))
  }
}

function showExitPopup(url, width, height, show_count){
  var current_show_count = 0;
  if (getCookie('popup_was_shown')){
    current_show_count = parseInt(getCookie('popup_was_shown'));
  }
  if (current_show_count>show_count){
    show_exit_popup = false
  }
  if (show_exit_popup) {
    setCookie('popup_was_shown', String(current_show_count+1), '', '/', '.hentaikey.com', false)
    window.open(
      url, 
      'exit_popup_window', 
      "directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no,width="+width+",height="+height,
      false
    )
  }
}

function blockExitPopup(){
  show_exit_popup = false
}

/*window.onunload = function () {
  showExitPopup(popup_url, popup_width, popup_height, popup_show_count)
}*/


for (i=0;i<document.links.length;i++){
 if (document.links[i].href.match("hentaikey") || document.links[i].href.match("ccbill")){
   document.links[i].onclick = function (){ blockExitPopup() };
 }
}
