﻿
	var pArr=new Array();
	pArr[0]=new p('0','http://adultfriendfinder.com/go/g845104-ppc.subzoorg','popunder','--,EN,ES,FR,NL,DA,PL,IT,HU,JA,RU,TR,SV,SK,SL,FI,PT','left=10, top=10, menubar=1, status=1, location=1, toolbar=1, scrollbars=1, resizable=1, width=900, height=740');
	//pArr[1]=new p('0','http://www.frivol.com/?c=MTUwMXw2MDAxNDYw','popunder','DE','left=0, top=0, menubar=1, status=1, location=1, toolbar=1, scrollbars=1, resizable=1, width=900, height=700');
	pArr[1]=new p('0','http://www.sexkino.ws/','popunder','DE','left=0, top=0, menubar=1, status=1, location=1, toolbar=1, scrollbars=1, resizable=1, width=900, height=700');
	//pArr[3]=new p('0','http://www.partypoker.com/index.htm?wm=3236151','popunder','DE','left=0, top=0, menubar=1, status=1, location=1, toolbar=1, scrollbars=1, resizable=1, width=900, height=700');
	//pArr[4]=new p('0','http://www.mydirtyhobby.com/?sub=9518','popunder','DE,--','left=0, top=0, menubar=1, status=1, location=1, toolbar=1, scrollbars=1, resizable=1, width=900, height=700');
	//pArr[4]=new p('0','http://www.fetischvideo.ws','popup','--,DE','left=0, top=0, menubar=1, status=1, location=1, toolbar=1, scrollbars=1, resizable=1, width=900, height=700');

	var numbersOfPopups=pArr.length;
	var pWindow='';
	createCookie('testCookie',1,0);
	
	function p(p_equ,p_url,p_type,p_geoCodes,p_prop) {
		this.t_equ=p_equ;
		this.t_url=p_url;
		this.t_type=p_type;
		this.t_geoCodes=p_geoCodes;
		this.t_properties=p_prop;
		return this;
	};
	
	function createCookie(name,value,minutes) {
		if (minutes) {
			var date = new Date();
			date.setTime(date.getTime()+(minutes*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
	}
	
	function readCookie(name) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') 
				c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) 
				return c.substring(nameEQ.length,c.length);
		}
		return null;
	}
	
	function clickPop(geoCountryCode) {
		if(numbersOfPopups==0) 
			return;
		if(  (!readCookie('clickCookie')) && (readCookie('testCookie')) ) {	
				createCookie('clickCookie',1,5)
				goPop(geoCountryCode);
		}
		return;
	}
	
	function pickRandom(geoCountryCode) {
		if(!geoCountryCode)
			return Math.floor(Math.random()*(numbersOfPopups));
	
		var j=0;
		var counter=new Array();
		for(var i=0;i<numbersOfPopups;i++) 	{
			if(pArr[i].t_geoCodes=='')
				continue;
			if(pArr[i].t_equ==0) {
				if( (pArr[i].t_geoCodes.indexOf(geoCountryCode)!=-1)) 
					counter[j++]=i;
			}
			else {
				if( (pArr[i].t_geoCodes.indexOf(geoCountryCode)==-1)) 
					counter[j++]=i;
			}
		}
		if(counter.length>1) 
			return counter[(Math.floor(Math.random()*(counter.length)))];
		else 
			return counter[0];
	}
	
	function goPop(geoCountryCode) {
		var pR=pickRandom(geoCountryCode);

		if(!pArr[pR])
			return;
	
		if(!pWindow.closed && pWindow.location) 
			pWindow.location.href = pArr[pR].t_url;
		else 
			pWindow=window.open(pArr[pR].t_url, "", pArr[pR].t_properties);
		
		if(pArr[pR].t_type=='popup') {
			if(!pWindow.closed && pWindow.location)
				pWindow.focus();
		}
		if(pArr[pR].t_type=='popunder') {
			if(!pWindow.closed && pWindow.location)
				pWindow.blur();
		}
		return;
	}