// Pop - Up Controller

// For AdultAdWorld.com

// Written by Joe 12 / 25 / 2005

// joe@adworldmedia.com

// www.adultadworld.com

// Updated by Joe 8 / 27 / 2006

// EDITED AND BOROWED BY Nextri

<!-- Begin

var uri = "";

var expDays = 1;

// Number of days the cookie should last

var expHours = 1;

// Number of hours the cookie should last

var expMins = 1;

// Number of minutes the cookie should last

var urlpage = "http://www.celebpunani.com"; //url to pop under page

var urlcodes_end = "";

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('your cookie name')

   if(count == null)

   {

      SetCookie('your cookie name', '1')

      return 1

   }

   else

   {

      var newcount = parseInt(count) + 1;

      DeleteCookie('your cookie name')

      SetCookie('your cookie name', 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 nextripop()

{

	   uri = urlpage;

    //alert(uri);

   var count = GetCookie('your cookie name');

   if (count == null)

   {

      count = 1;

      SetCookie('your cookie name', count, exp);



      if (exit)

      {

         window_handle = window.open(uri, "", windowprops);

         if(window_handle)

         {

            // popped worked

            window_handle.blur();

         }

         else

         {

            // not popped, use alternative method

            // alert("Alternative Pop Method");



            isXPSP2 = false;

            openedWindow = null;



            if( typeof(popedWindow) == "undefined" )

            {

               popedWindow = false

            }

            ;



            if( parseInt(navigator.appVersion) > 3 )

            {

               winWidth = screen.availWidth;

               winHeight = screen.availHeight

            }



            if( window.SymRealWinOpen )

            {

               open = SymRealWinOpen;

            }



            if( window.NS_ActualOpen )

            {

               open = NS_ActualOpen;

            }



            checkXPSP2();



            if( ! isXPSP2)

            {

               process_pop();

            }

            else

            {

               if(window.Event)

               document.captureEvents(Event.CLICK);



               document.onclick = process_clickpop;

            }

            self.focus();

            process_clickpop();



         }

      }



   }

   else

   {

      count ++ ;

      SetCookie('your cookie name', 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, "AAW0012342432", "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, "AAW0012342432", "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();

   }

}

//  End -->

