// Delivery rate configuration - special setup for forum, very low delivery rate; also cookie domain and path are changed
var TC_PUN_Odds=0.15; // likelihood that a link will have the onclick property
var TC_PUN_Delay=2*60*60*1000; // milliseconds minimum between pun displays
var TC_PUN_Odds_adjust=0.10; // how much less likely to show PUN if cookies disabled
// end of configuration

var TC_PUN_URL='http://futures.tradingcharts.com/showpun-forum.php'; // just for testing
var TC_Window_Options='width=700,height=400,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes';
var TC_PUN_cookiename='TCPUNShownbw7';
var TC_PUN_Shown=0;

function TC_configlinks(){
  var dc=document.cookie;
  if(!dc){
    var newcookie = 'TC_CC_accepted=1';
    TC_PUN_Odds=TC_PUN_Odds*TC_PUN_Odds_adjust;
  }
  if(dc.indexOf(TC_PUN_cookiename)<0){ // cookie not set
    for (var x = 0; x < document.links.length; x++) {
      if((Math.random()<TC_PUN_Odds) && (document.links[x].protocol=='http:') && (document.links[x].target!='wmark_lpwin')){ // no pun on watermark links
        document.links[x].onclick = TC_show_pun;
      }
    }
  }
}
function Create_TC_PopUnder_Win(){
  var expires = new Date();
  expires.setTime(expires.getTime() + TC_PUN_Delay);
  var newcookie = TC_PUN_cookiename + "=shown; expires=" + expires.toGMTString() + "; path=/forum/";
  document.cookie=newcookie;
  TC_PUN_Shown=1;
  var TC_Win_Hdl = eval("window.open (TC_PUN_URL, 'TC_PUN_Window', TC_Window_Options)");
  if (window.focus){
    self.focus();
  }
}
function TC_show_pun(){
  var dc=document.cookie;
  if((TC_PUN_Shown==0) && (dc.indexOf(TC_PUN_cookiename)<0)){ // cookie not set and pun not shown
    Create_TC_PopUnder_Win();
  }
}
