/*---------------------------------------------|
|    COMMON FUNCTIONS                          |
|    BY PASCAL CARDINAL                        |
|    (c)2002 CYBER2000                         |
|    pascal@cyber2000.qc.ca                    |
|---------------------------------------------*/
top.exit = true;
var no=0;
var oldLink = true;
var nbpop = new Number(2);
re = /&amp\;/gi
regexp = /site/gi;
QueryString.replace(regexp, "trace2")
newstr=QueryString.replace(re, "&");    // replace &amp; by &
var SplitString = newstr.substring(1).split("&")    // Split the query string into an array
var defurl=false;
var trace="";

// Resize the browser window to max width and max height
// set the doResize flag to false in case you do not want to resize the window ex .: popup windows
if (doResize==true) {
   parent.moveTo(0,0);
   parent.resizeTo(screen.availWidth,screen.availHeight);
}
// If no resize is needed, align the window in the center of the screen
if (doResize==false){
//   xall = (screen.availWidth / 2);
//   yall = (screen.availHeight / 2);
   self.moveTo(50, 50);
}

// Find out from what site number the visitor came
for (i=0;i<SplitString.length;i++) {
  if (SplitString[i].substring(0,4) == "site") {
     site = SplitString[i].substring(5);
  }
}

// Load a popup window on exit
function ExitPopup(){
   QueryString = "?";
   for (i=0;i<SplitString.length;i++) 
   {
      if (SplitString[i].substring(0,5) == "trace") 
	  {	
	  	trace = SplitString[i].substring(6);
      }
      else if (SplitString[i].substring(0,6) == "popurl") 
	  {	
		defurl = SplitString[i].substring(7);
        if (defurl != "0")
		{
			var the_site = defurl;
			var the_at_is_at = the_site.indexOf("http://");
			if (the_at_is_at == -1)
			{
				defurl = "http://"+defurl;
			}
		}	
		if (defurl.length>7) 
		{
        	popwidth=screen.availWidth;
            popheight=screen.availHeight;
            popresize="yes";
            popstatus="yes";
            popscroll = "yes";
            popmenubar = "yes";
            poplocationbar = "yes";
            poptoolbar = "yes";
            nbpop="-1";

            for (i=0;i<SplitString.length;i++) 
			{
            	if (SplitString[i].substring(0,8) == "popwidth") 
				{
                	popwidth = SplitString[i].substring(9);
               	}
               	else if (SplitString[i].substring(0,9) == "popheight") 
				{
                	popheight = SplitString[i].substring(10);
               	}
               	else if (SplitString[i].substring(0,9) == "popresize") 
				{
                	popresize = SplitString[i].substring(10);
               	}
               	else if (SplitString[i].substring(0,9) == "popstatus") 
				{
                	popstatus = SplitString[i].substring(10);
               	}
               	else if (SplitString[i].substring(0,9) == "popscroll") 
				{
                	popscroll = SplitString[i].substring(10);
               	}
               	else if (SplitString[i].substring(0,7) == "popmenubar") 
				{
                	popmenubar = SplitString[i].substring(8);
               	}
               	else if (SplitString[i].substring(0,14) == "poplocationbar") 
				{
                	poplocationbar = SplitString[i].substring(15);
               	}
               	else if (SplitString[i].substring(0,10) == "poptoolbar") 
				{
                	poptoolbar = SplitString[i].substring(11);
               	}
            }
         }
         else 
		 {
         	defurl=false
         }
      }
      else if (SplitString[i].substring(0,5) == "nbpop") 
	  {
      	oldLink = false;
        nbpop = Number(SplitString[i].substring(6,7));
        nb = eval("/"+nbpop+"/gi");
        nb2 = --nbpop;
        SplitString[i]=SplitString[i].replace(nb, nb2);
      }
      QueryString += SplitString[i] + "&";
   }

   // top.exit flag can be used to block the popup  ex .: Set on member section links
   if ( top.exit==true ) {

      // popup if popups are still remaining to be displayed
      if (nbpop != "-1") {
         // oldLink flag is set to true for compatibility with unexisting query string
         if (oldLink == true) {
            QueryString += "nbpop=1";
         }
         if (QueryString.search('partenaire') == '-1') 
		 {
            if (nbpop == "0")
			{
			}
			else
			{
				siteURL = String(document.location);
            	if (siteURL.search("gay") != "-1")
				{
						if (siteURL.search("gayrotique") != "-1")
						{
							window.open("http://exit.gros-penis.com/?partenaire=9612");
						}
						else if (siteURL.search("gayvirtual") != "-1")
						{
							window.open("http:/www.powereraser.com/?partenaire=9612");
						}
						else if (siteURL.search("corridagay") != "-1")
						{
							window.open("http://exit.agrandatupene.com/?partenaire=9612");
						}
						else if (siteURL.search("gayklub") != "-1")
						{
							window.open("http://exit.penismeister.com/?partenaire=9612");
						}	
            	}
            	else 
				{
						if (siteURL.search("agrandatupene") != "-1")
						{
							window.open("http://www.superborrador.com/?partenaire=9612");
						}
						else if (siteURL.search("penismeister") != "-1")
						{
							window.open("http://www.spurenwischer.com/?partenaire=9612");
						}
						else if (siteURL.search("gros-penis") != "-1")
						{
							window.open("http://access.powereraser.com/cgi-bin/access.asp?site=124&partenaire=9612&type=4&bpromo=191&trace=191");
						}
						else if (siteURL.search("scopatissime") != "-1")
						{
							window.open("http://exit.grandipompini.com/?partenaire=9612");
						}
						else if (siteURL.search("clubcochonnes") != "-1")
						{
							
						}
						else
						{
							window.open("http://access.iawsnetwork.com/cgi-bin/access.asp?trace=&site=272&type=100&partenaire=' + partenaire");
						}
            	}
			 }
         }
		 else if (QueryString.search('partenaire=9612') == '1') 
		 {
			 	siteURL = String(document.location)
			 	if (siteURL.search("gay") != "-1")
				{
						if (siteURL.search("gayrotique") != "-1")
						{
							window.open("http://access.powereraser.com/cgi-bin/access.asp?site=124&partenaire=9612&type=4&bpromo=191&trace=191");
						}
						else if (siteURL.search("gayvirtual") != "-1")
						{
							window.open("http://www.powereraser.com/?partenaire=9612");
						}
						else if (siteURL.search("corridagay") != "-1")
						{
							window.open("http://exit.agrandatupene.com/?partenaire=9612");
						}
						else if (siteURL.search("gayklub") != "-1")
						{
							window.open("http://exit.penismeister.com/?partenaire=9612");
						}	
            	}
            	else 
				{
						if (siteURL.search("agrandatupene") != "-1")
						{
							window.open("http://www.superborrador.com/?partenaire=9612");
						}
						else if (siteURL.search("penismeister") != "-1")
						{
							window.open("http://www.spurenwischer.com/?partenaire=9612");
						}
						else if (siteURL.search("gros-penis") != "-1")
						{
							window.open("http://access.powereraser.com/cgi-bin/access.asp?site=124&partenaire=9612&type=4&bpromo=191&trace=191");
						}
						else if (siteURL.search("scopatissime") != "-1")
						{
							window.open("http://exit.grandipompini.com/?partenaire=9612");
						}
						else if (siteURL.search("clubcochonnes") != "-1")
						{
							
						}
						else
						{
							window.open("http://exit.xxxabusif.com/?partenaire=9612");
						}
            	}
		 }
         else 
		 {
            window.open(popurl + QueryString,nbpop,'scrollbars='+popscroll + ',resizable='+popresize + ',menubar='+popmenubar + ',location='+poplocationbar + ',toolbar='+poptoolbar + ',resize='+popresize + ',status='+popstatus + ',width='+popwidth + ',height='+popheight);
         }
      }
      // if the user defined a URL, the defurl flag will contain the URL to be opened
      else if ( defurl!=false ) 
	  {
         window.open(defurl,'popup','scrollbars='+popscroll + ',resizable='+popresize + ',menubar='+popmenubar + ',location='+poplocationbar + ',toolbar='+poptoolbar + ',resize='+popresize + ',status='+popstatus + ',width='+popwidth + ',height='+popheight);
      }
   }
}