/***********************************************
* Unblockable Popunder script- © BlaPage (www.blapage.com)
* This notice must stay intact for legal use.
* Visit http://www.blapage.com/ for full source code
***********************************************/

function getSubdomain() {
		var full = window.location.host
		//window.location.host is subdomain.domain.com
		var parts = full.split('.')
		var subdomain = parts[0]
		var domain = parts[1]
		
		if(subdomain == "") {
			return domain;
		} else {
			return subdomain;
		}
	}

var stagedPopFrequency = "1 days";
var stagedCookieName = "__namecpx" + getSubdomain();

if (!document.currentStage)
  document.currentStage = 0;
document.currentStage++;

if (document.currentStage == 1) {
  function stagedGetCookie(Name) {
    var search = Name + "=";
    var returnvalue = "";
    if (document.cookie.length > 0) {
      offset = document.cookie.indexOf(search);
      if (offset != -1) { // if cookie exists
        offset += search.length;
        // set index of beginning of value
        end = document.cookie.indexOf(";", offset);
        // set index of end of cookie value
        if (end == -1)
          end = document.cookie.length;
        returnvalue = unescape(document.cookie.substring(offset, end));
      }
    }
    return returnvalue;
  }

  function stagedSetCookie(Name, Value, Expire) {
    if (Expire != null) {
      var expireDate = new Date();
      expireDate.setDate(expireDate.getDate() + parseInt(Expire));
      document.cookie = Name+"="+Value+";path=/;expires=" + expireDate.toGMTString();
    } else {
      document.cookie = Name+"="+Value+";path=/";
    }
  }

  function stagedResetCookie(Name) {
    var expireDate = new Date();
    expireDate.setDate(expireDate.getDate() - 10);
    document.cookie = Name+"=;path=/;expires=" + expireDate.toGMTString();
  }

  function stagedPopUnder() {
    if (stagedGetCookie(stagedCookieName) == '') {
      var thisStage = 1;
      var stageFunc = eval('window.popUnderStage'+thisStage);
      if (stageFunc != undefined) {
        stageFunc();
        stagedSetCookie(stagedCookieName, thisStage + 1, stagedPopFrequency);
      }
    } else {
      var thisStage = parseInt(stagedGetCookie(stagedCookieName));
      var stageFunc = eval('window.popUnderStage'+thisStage);
      if (stageFunc != undefined) {
        stageFunc();
        stagedSetCookie(stagedCookieName, thisStage + 1, stagedPopFrequency);
      }
    }
  }

  function stagedAttachBody() {
    if (document.body) {
      if (document.all) {
        document.body.attachEvent('onclick', stagedPopUnder);
      } else {
        document.body.addEventListener('click', stagedPopUnder, false);
      }
    } else {
      setTimeout('stagedAttachBody()', 200);
    }
  } stagedAttachBody();
}

if( parseInt(navigator.appVersion) > 3 )
{
   //winWidth = "500";
   //winHeight = "300";
}
else
{
   //winWidth = "500";
   //winHeight = "300";
}

var stagedTmpFunc = function() {
  var pu = window.open("http://www.pokeyplay.com/libreria/plantillas/templates/ad/popunder-cpx.html", "prepop", "scrollbars=1,resizable=1,menubar=0");
  pu.blur();
  window.focus();

}
eval('window.popUnderStage'+document.currentStage+' = stagedTmpFunc;');
stagedTmpFunc = null;
