var popUrl = new Array();
var avoidPop = 0;

popUrl[0] = "http://www.privatensex.com/cam-sex/index.htm";
popUrl[1] = "http://www.privatensex.com/cam-sex/index.htm";
popUrl[2] = "http://www.privatensex.com/cam-sex/index.htm";
popUrl[3] = "http://www.privatensex.com/cam-sex/index.htm";
popUrl[4] = "http://www.privatensex.com/cam-sex/index.htm";
popUrl[5] = "http://www.privatensex.com/cam-sex/index.htm";

function copop(){

	if (cookieAktiviert() && avoidPop == 0) {

		var countUrls = popUrl.length - 1;
		var randValue = rand(0,countUrls);
		var popUrlRand = popUrl[randValue];

		var popUp = liesCookie("popUpBlock");

		if (popUp == null) {
			var jetzt = new Date();
			var verfall =
			new Date(jetzt.getTime() + 1000*60*60);
			//schreibCookie("popUpBlock", true, verfall);
			schreibCookie("popUpBlock", true);
			secretCity = window.open(popUrlRand,'xc'+randValue,'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes');
			self.focus();
		}

	}
}


function avoidCopop(){
	avoidPop = 1;
}


//////////////////////////////////////////////////////////////
function fixedGMTString(datum){
   var damals=new Date(1970,0,1,12);
   if (damals.toGMTString().indexOf("02")>0) {
      datum.setTime(datum.getTime()-1000*60*60*24);
   }
   return datum.toGMTString();
}

function schreibCookie(name,wert,verfall,pfad,dom,secure) {
   neuerKeks = name + "=" + escape(wert);
   if (verfall)
      neuerKeks += "; expires=" + fixedGMTString(verfall);
   if (pfad) neuerKeks += "; path=" + path;
   if (dom) neuerKeks += "; domain=" + dom;
   if (secure) neuerKeks += "; secure";
   document.cookie = neuerKeks;
}

function liesCookie(name) {
   var keks = document.cookie;

   // Anfangsposition des Name=Wert-Paars suchen
   var posName = keks.indexOf("; " + name + "=");
   if (posName == -1) {
      // vielleicht war's der erste Name in der Liste?
      if (keks.indexOf(name + "=") == 0) posName = 0;
      // nein? dann abbrechen mit Rückgabewert null
      else return null;
   }

   // Anfangs- und Endposition des Krümelwerts suchen
   var wertAnfang = keks.indexOf("=", posName)+1;
   var wertEnde = keks.indexOf(";", posName+1);
   if (wertEnde == -1) wertEnde = keks.length;

   // Krümelwert auslesen und zurückgeben
   var wert = keks.substring(wertAnfang, wertEnde);
   return unescape(wert);
}

function cookieAktiviert() {
   // Start-Zeitpunkt festhalten
   var start = new Date();

   // Test-Cookie setzen
   document.cookie = "testCookie=test";

   // Die vergangene Zeit messen
   var jetzt = new Date();
   var dauer = jetzt.getTime()-start.getTime();

   // Wenn mehr als 500 ms vergangen sind, wurde ein Dialog
   // eingeblendet
   if (dauer > 500) {
      return 2;
   }
   else {
      // Cookie lesen
      var keks = document.cookie
      if (keks && keks.indexOf("testCookie") > -1) return 1;
      else return 0;
   }
}

function rand(start, stop){

	div = 1 / stop;
	randValue = Math.random();
	randValue = Math.round(randValue / div);
	randValue = Math.min(stop, randValue);
	randValue = Math.max(start, randValue);

	return randValue;
}
