  
  /* 
    
    VERSION 2.050819 
    
  */
  
  
  
  function subscriptionsClass() { 
    
    /* pop window sizes and locations ... */ 
    this.exitingPopPath="/nocount/exiting.html"; 
    this.exitingPopHeight=350; 
    this.exitingPopWidth=500; 
    this.arrivalPopPath="/nocount/arrival.html"; 
    this.arrivalPopHeight=350; 
    this.arrivalPopWidth=500; 
    
    /* offsets for pop windows from center ...*/ 
    this.arrivalLeftOffset=-50; 
    this.arrivalTopOffset=-50; 
    this.exitingLeftOffset=50; 
    this.exitingTopOffset=50; 
	
	/* pop window names ... */ 
    this.exitingPopName="exitingpop"; 
    this.arrivalPopName="arrivalpop"; 
	
	/* cookie duraation time ... */ 
    this.duration=0.5; /* hours */ 
	
	/* delay for arrival pop */ 
	this.delay=3; /* seconds delay between click and unload */ 
	
	/* set the workarea domain ... */ 
	this.workarea="advance"; 
	
	/* switches ... */ 
    this.turnOffStaging=true; /* SET TO TRUE */ 
    this.turnOnExitingPop=false; /* SET TO FALSE */ 
    
    /* cookie names ...*/ 
    this.exitingCookieName="ExitingCookie"; 
    this.arrivalCookieName="ArrivalCookie"; 
    
    /* keys and gift variables ... */ 
    this.path=""; 
    this.giftPath=""; 
    this.keys=new Object(); 
    this.gift=new Object(); 
    this.links=new Object(); 
    
  } /* end  */ 
  
  var subscriptionPops=new subscriptionsClass(); /* LEGACY  */ 
  var subscriptions=new subscriptionsClass(); 
  
  
  /* undefined variable */ 
  var undefined;  
  
  
  
  
  
  
  /*
  
    assigns keys to subscription links ... 
    
    REQUIRES keys.js ... 
    
    name each link in html document ... 
    insert specific name in name AND href attributes ...
    define path  ... 
    assign keys to each link in keys.js ... 
    execute subscriptions.assign() method at bottom of page ... 
    
    
    FOR EXAMPLE ... in keys.js ... 
   
    subscriptions.path="https://lnasfsf.com/jlasfsdn?whatever=something&key="; 
    subscriptions.keys["alpha"]="zeta"; 
    subscriptions.keys["gamma"]="zeta";  
    subscriptions.keys["epsilon"]="zeta"; 
	
	and ... 
	
    subscriptions.giftPath="https://lnasfsf.com/jlasfsdn?whatever=somethingelse&key="; 
    subscriptions.gifts["eta"]="zeta"; 
	
	or simply ... 
	
    subscriptions.links["beta"]="http://awlfawelel.com/asjfsdakljf"; 
  
  */ 
  
  
  /* assign links by name (or by href) ... */ 
  function assignLinks() { 
    for( var i=0; i<document.links.length; i++ ) { 
      var name=""; 
      if( typeof document.links[i].name=="string" ) { 
	    name=document.links[i].name; /* works only in newer browsers !!! */ 
	  } 
      else { name=document.links[i].href; }/* for older browsers !!! */ 
      if( name == null ) { continue; } 
      if( typeof name != "string" ) { continue; } 
      if( name.length < 5 ) { continue; } 
      if( name.indexOf('javascript') != -1 ) { continue; } 
      if( typeof name == "string" ) { 
        name=name.substring( name.lastIndexOf('/')+1 ); 
        if( typeof this.links[name] == "string" ) { 
          document.links[i].href=this.links[name]; 
          document.links[i].target="_blank"; 
        } 
        else if( typeof this.keys[name] == "string" ) { 
          document.links[i].href=this.path+this.keys[name]; 
          document.links[i].target="_blank"; 
        } 
        else if( typeof this.gift[name] == "string" ) { 
          document.links[i].href=this.giftPath+this.gift[name]; 
          document.links[i].target="_blank"; 
        } 
      } 
    } 
  } /* end */ 
  subscriptionsClass.prototype.assign=assignLinks; 
  
  
  
  
  
  
  
  
  
  /* 
    
    1) pops window for subscriptions offers on arrival 
    2) cookies viewer for specified duration on arrival 
    3) checks and pops exiting window if unloading window to new domain 
	4) assumes all links to other sites open new windows so does not check these 
    
  */ 



  /* arrival subscription pop ...  */ 
  function arrivalSubscriptionPop() { 
    
	/*don't display popup if suppressed*/ 
	noArrivalPop = typeof(noArrivalPopFlag) != 'undefined' && noArrivalPopFlag;
	if(noArrivalPop) { return; } 
	
	/* check for cookie */ 
    var cookie=this.getCookie(this.arrivalCookieName); 
    if(cookie == true) { return; } 
	
	/* set exiting cookie */ 
    this.setArrivalCookie(); 
	
    var domain=location.host.toString(); 
    var referrer=document.referrer.toString(); 
    
    /* prevents triggering when loading new page on site */ 
    if(typeof referrer == "string" && referrer != "" && typeof domain == "string" && domain != "") { 
	
	  if(domain.indexOf("www") > -1) { domain=domain.substring(domain.indexOf("www.")+5); } 
	  if(domain.indexOf("boards") > -1) { domain=domain.substring(domain.indexOf("boards.")+8); } 
	  
	  if(referrer.indexOf("http") != -1) { referrer=referrer.substring(referrer.indexOf("http://")+8); } 
	  if(referrer.indexOf("boards") != -1) { referrer=referrer.substring(referrer.indexOf("boards.")+8); } 
	  if(referrer.indexOf("www") != -1) { referrer=referrer.substring(referrer.indexOf("www.")+5); } 
	  if(referrer.indexOf("/") != -1) { referrer=referrer.substring(0,referrer.indexOf("/")); } 
	  
      if(referrer.indexOf(domain) != -1) { return; } 
      if(domain.indexOf(referrer) != -1) { return; } 
	  
    } 
	
    /* prevents functioning on development servers */ 
	var workarea=(domain.indexOf(this.workarea) != -1); 
    if(workarea && this.turnOffStaging) { return; } 
	
	/* pop window */ 
	var duration=this.duration*1000; 
    setTimeout("subscriptions.arrivalAction()",duration); /* LEAVE AS "SUBSCRIPTIONS" */ 
    
  } /* end */ 
  subscriptionsClass.prototype.arrival=arrivalSubscriptionPop; 
  


  /* arrival subscription pop ...  */ 
  function arrivalSubscriptionPopAction() {     
    var options="height="+this.arrivalPopHeight;
    options+=",width="+this.arrivalPopWidth; 
    if(screen.height) { 
      options+=",top="+(screen.height/2-this.arrivalPopHeight/2+this.arrivalTopOffset); 
      options+=",left="+(screen.width/2-this.arrivalPopWidth/2+this.arrivalLeftOffset); 
    } 
    var pop=window.open(this.arrivalPopPath,this.arrivalPopName,options); 
    pop.focus(); 
  } /* end */ 
  subscriptionsClass.prototype.arrivalAction=arrivalSubscriptionPopAction; 





  /* exiting subscription pop ...  */ 
  function engageExitingPop() { 
    this.turnOnExitingPop=true; 
  } /* end */ 
  subscriptionsClass.prototype.exiting=engageExitingPop; 
  
  
  
  /* exiting subscription pop ...  */ 
  function exitingSubscriptionPop() {  
    
	/*don't display popup if suppressed */ 
	noExitingPop = typeof(noExitingPopFlag) != 'undefined' && noExitingPopFlag;
	if(noExitingPop) { return; }
	
	/* check if exiting pop is engaged */ 
    if(!this.turnOnExitingPop) { return; } 
    
	/* check for cookie */ 
    var cookie=this.getCookie(this.exitingCookieName); 
    if(cookie == true) { return; } 
    
	/* set exiting cookie */ 
    this.setExitingCookie(); 
    
    /* prevents functioning on development servers */ 
    var domain=location.host.toString(); 
	var workarea=(domain.indexOf(this.workarea) != -1); 
    if(workarea && this.turnOffStaging) { return; } 
	
	/* pop window */ 
	this.exitingAction(); 
      
  } /* end */ 
  subscriptionsClass.prototype.popExiting=exitingSubscriptionPop; 
  


  /* arrival subscription pop ...  */ 
  function exitingSubscriptionPopAction() {     
    var options="height="+this.exitingPopHeight;
    options+=",width="+this.exitingPopWidth; 
    if(screen.height) { 
      options+=",top="+(screen.height/2-this.exitingPopHeight/2+this.exitingTopOffset); 
      options+=",left="+(screen.width/2-this.exitingPopWidth/2+this.exitingLeftOffset); 
    } 
    var pop=window.open(this.exitingPopPath,this.exitingPopName,options); 
    pop.focus(); 
  } /* end */ 
  subscriptionsClass.prototype.exitingAction=exitingSubscriptionPopAction; 




  /* check exiting and engage exiting pop ...  */ 
  var clicked=0;
  function checkExiting(e) { 
    
    if(!subscriptions.turnOnExitingPop) { return; } 
  
    var activity=null; 
	if(e == undefined) { e=window.event; }
	activity=e.type; 
	
	/* alert(activity); */ 
	
	var source=null; 
    if(activity && activity == "click") { 
	  clicked=1;
	  if(e.target != undefined) { source=e.target; } 
	  else if(e.srcElement != undefined) { source=e.srcElement; } 
	
	  /* SAFARI BUG FIX */ 
	  if(source.nodeType && source.nodeType == 3) { source=source.parentNode; } 
	  
	  if(typeof source.href == "string") { 
	    source=source.href; 
	    if(source.indexOf("javascript") > -1) { return; }  
        var domain=location.host.toString(); 
	    if(domain.indexOf("www") > -1) { domain=domain.substring(5); } 
	    if(domain != "" && source.indexOf(domain) > -1) { return; }  
        subscriptions.popExiting(); /* LEAVE AS "SUBSCRIPTIONS" !!! */ 
	  } 
	  return; 
	} 
	
	/* if just clicked return */ 
    if(clicked == 1) { clicked=0; return; } 
	
	/* if unloading from location pop */ 
    subscriptions.popExiting(); /* LEAVE AS "SUBSCRIPTIONS" !!! */ 
	  
  } /* end */ 
  document.onclick=checkExiting; /* checks clicks */ 
  window.onunload=checkExiting; /* checks changes in address */ 


  
  
  

  /* set cookie for variable duration ... */ 
  function setSubscriptionPopCookie(name) { 
    var domain=location.host.toString(); 
    var date=new Date( (new Date()).getTime() + this.duration*3600000 ); 
    var current=name+"="+escape(name)+"; "; 
    current+="expires="+date.toGMTString()+"; "; /* set expiry date */ 
    current+="path=/; "; /* set path to top directory */ 
    /*current+="domain="+domain+"; "; /* set domain */ 
    document.cookie=current; 
  } /* end */ 
  subscriptionsClass.prototype.setCookie=setSubscriptionPopCookie; 
  
  /* set cookie for variable duration ...*/ 
  function setArrivalSubscriptionPopCookie() { 
    this.setCookie(this.arrivalCookieName); 
  } /* end */ 
  subscriptionsClass.prototype.setArrivalCookie=setArrivalSubscriptionPopCookie; 

  /* set cookie for variable duration ... */ 
  function setExitingSubscriptionPopCookie() { 
    this.setCookie(this.exitingCookieName); 
  } /* end */ 
  subscriptionsClass.prototype.setExitingCookie=setExitingSubscriptionPopCookie; 



  /* returns cookie ... */ 
  function getSubscriptionPopCookie(name) { 
	var cookie=unescape(document.cookie); 
	if(document.cookie.indexOf(name) > -1) { return true; } 
    return false; 
  } /* end */ 
  subscriptionsClass.prototype.getCookie=getSubscriptionPopCookie; 



  /* delete cookie ... */ 
  function deleteSubscriptionPopCookie(name) { 
    var domain=location.host.toString();
    var current=name+"="+escape(name)+"; "; 
    current+="expires=Fri, 02-Jan-1970 00:00:00 GMT; "; /* set expiry date */ 
    current+="path=/; "; /* set path to top directory */ 
    /*current+="domain="+domain+"; "; /* set domain */ 
    document.cookie=current; 
  } /* end */ 
  subscriptionsClass.prototype.deleteCookie=deleteSubscriptionPopCookie; 

  /* delete cookie ... */ 
  function deleteExitingSubscriptionPopCookie(name) { 
    this.deleteCookie(this.exitingCookieName); 
  } /* end */ 
  subscriptionsClass.prototype.deleteExitingCookie=deleteExitingSubscriptionPopCookie; 

  /* delete cookie ... */ 
  function deleteArrivalSubscriptionPopCookie(name) { 
    this.deleteCookie(this.arrivalCookieName); 
  } /* end */ 
  subscriptionsClass.prototype.deleteArrivalCookie=deleteArrivalSubscriptionPopCookie; 
  
  
  
  

