var expDays = 1;
// Number of days the cookie should last
var expHours = 1;
// Number of hours the cookie should last
var expMins = 1;
var urlpage = "http://www.bombamateur.com/top/ttt-out.php?link=pop";
var uri = urlpage;
var qs = new Querystring();
var windowprops = "toolbar=1,location=1,directories=0,status=1,menubar=1,width=800,height=600,scrollbars=1,resizable=1,top=0,left=0";

function GetCookie (name)
{
   var arg = name + "=";
   var alen = arg.length;
   var clen = document.cookie.length;
   var i = 0;
   while (i < clen)
   {
      var j = i + alen;
      if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
      i = document.cookie.indexOf(" ", i) + 1;
      if (i == 0)
      break;
   }
   return null;
}
function SetCookie (name, value)
{
   var argv = SetCookie.arguments;
   var argc = SetCookie.arguments.length;
   var expires = (argc > 2) ? argv[2] : null;
   var path = (argc > 3) ? argv[3] : null;
   var domain = (argc > 4) ? argv[4] : null;
   var secure = (argc > 5) ? argv[5] : false;
   document.cookie = name + "=" + escape (value) +
   ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
   ((path == null) ? "" : ("; path=" + path)) +
   ((domain == null) ? "" : ("; domain=" + domain)) +
   ((secure == true) ? "; secure" : "");
}
function DeleteCookie (name)
{
   var exp = new Date();
   exp.setTime (exp.getTime() - 1);
   var cval = GetCookie (name);
   document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
var exp = new Date();
// exp.setTime(exp.getTime() + (expDays * 24 * 60 * 1 * 1000));
// exp.setTime(exp.getTime() + (3600 * expHours));
exp.setTime(exp.getTime() + (60000 * 60 * 6));
function amt()
{
   var count = GetCookie('bombacount')
   if(count == null)
   {
      SetCookie('bombacount', '1')
      return 1
   }
   else
   {
      var newcount = parseInt(count) + 1;
      DeleteCookie('bombacount')
      SetCookie('bombacount', newcount, exp)
      return count
   }
}
function getCookieVal(offset)
{
   var endstr = document.cookie.indexOf (";", offset);
   if (endstr == - 1)
   endstr = document.cookie.length;
   return unescape(document.cookie.substring(offset, endstr));
}

var exit = true;

function bombapopunder()
{
    //alert(uri);
   var count = GetCookie('bombacount');
   if (count == null)
{
count = 1;
SetCookie('bombacount', count, exp);

window.open('http://www.bombamateur.com/top/ttt-out.php?link=clickpop','pop','toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=0,copyhistory=0,menuBar=0,width=30000,height=30000,');
window.focus(); // supprimez ces 2 lignes si vous voulez un popup
pop.blur(); // laissez les pour un popunder
   }
   else
   {
      count ++ ;
      SetCookie('bombacount', count, exp);
   }
}

function Querystring(qs)
{
   // optionally pass a querystring to parse
   this.params = new Object()
   this.get = Querystring_get

   if (qs == null)
   qs = location.search.substring(1, location.search.length)

   if (qs.length == 0) return

   // Turn < plus > back to < space >
   // See : http : // www.w3.org / TR / REC - html40 / interact / forms.html#h - 17.13.4.1
   qs = qs.replace(/\+/g, ' ')
   var args = qs.split('&') // parse out name / value pairs separated via &

   // split out each name = value pair
   for (var i = 0; i < args.length; i ++ )
   {
      var value;
      var pair = args[i].split('=')
      var name = unescape(pair[0])

      if (pair.length == 2)
      value = unescape(pair[1])
      else
      value = name

      this.params[name] = value
   }
}

function Querystring_get(key, default_)
{
   // This silly looking line changes UNDEFINED to NULL
   if (default_ == null) default_ = null;

   var value = this.params[key]
   if (value == null) value = default_;

   return value
}

function checkXPSP2()
{
   isXPSP2 = (navigator.userAgent.indexOf("SV1") != - 1);
}
function process_pop()
{
   if ( ! popedWindow )
   {
      // alert(uri);
      openedWindow = open(uri, "bomba", "scrollbars=1,resizable=1,menubar=1,location=1,top=0,left=0,width=" + winWidth + ",height=" + winHeight);

      if(openedWindow)
      {
         popedWindow = true;
         self.focus();
      }
   }
}

function process_clickpop()
{
   if ( ! popedWindow )
   {
      if( ! isXPSP2)
      {
         // alert(uri);
         openedWindow = open(uri, "bomba", "scrollbars=1,resizable=1,menubar=1,location=1,top=0,left=0,width=" + winWidth + ",height=" + winHeight);

         self.focus();
         if(openedWindow)
         {
            popedWindow = true;
         }
      }
   }

   if( ! popedWindow)
   {
      if( window.Event)
      document.captureEvents(Event.CLICK);

      document.onclick = process_pop;
      self.focus();
   }
}


