var announceId;
var announceUrl;
var winWidth = '1024'; //pop under window width
var winHeight = '768'; //pop under window height
var cd = 720; //Duration of the cookie in hour ( pop under is not open during the life time of the cookie).If null, the cookie is delete at the of the browser session.
//
var Width=0;
var Height=0;

if (screen.availWidth && screen.availHeight) { 
	Width = screen.availWidth; Height = screen.availHeight;
} else { 
	Width = screen.width; Height = screen.height;
}

function showPopWin_i() { 
	if (!window.popped) {
		w = window.open('about:blank','','width='+winWidth+', height='+winHeight+', scrollbars=1, resizable=1, toolbar=1, location=1, menubar=1, status=1, directories=0');
		if (w!=null) { 
			w.moveTo(0,0); 
			w.moveBy((Width-winWidth)/2,(Height-winHeight)/2); 
			w.location = announceUrl;
			w.blur();
			window.focus();
			setTimeout('window.focus();', 500);
			window.popped = true;
		}
	} 
}
function convertAnchor_i() {
	var tags = document.getElementsByTagName('a');
	for (var ind = 0; ind < tags.length; ++ind)
		if (tags[ind].onclick == undefined && tags[ind].target == '') 
			tags[ind].onclick = showPopWin_i;
}

function Render_i() {
	showPopWin_i();
	if (!window.popped) 
		setInterval(convertAnchor_i, 250);
}


// Donner à la variable compteur la valeur du cookie
function AfficheSite(nom_site)
{
	announceId = nom_site;
	if (nom_site=="rugbykids")
	{
		announceUrl = "http://www.madeinrugby.net/redirect.php";
	}
	if (nom_site=="foot4fun")
	{
		announceUrl = "http://www.madeinnews.com";
	}
	
	if (nom_site=="madeinmotorsport")
	{
		announceUrl = "http://www.madeinmotorsport.com/fr/";
	}
	
	if (nom_site=="madeinrugby")
	{
		announceUrl = "http://www.madeinrugby.com";
	}

	if (nom_site!="no")
	{
		compteur_affiche=LireCookie("CookieSite_Under");
		if (compteur_affiche==null)
			compteur_affiche=1; 
		else 
			compteur_affiche++; 

		// Ecrire le cookie, valide 3 heures
		var expDays = cd;
		var date = new Date();
		date.setTime(date.getTime() + (expDays*60*60*1000));
		EcrireCookie("CookieSite_Under", compteur_affiche, date);
		
		if (compteur_affiche==1)
			setTimeout('Render_i();', 500);
		//else
		//{
		//	document.write('<scr'+'ipt language=JavaS'+'cript type=text/java'+'script src=http://ad.advertstream.com/adjs_r.php?what=zone:10927&inf=no></scr'+'ipt>');
		//}

	}
	else
	{
		document.write('<scr'+'ipt language=JavaS'+'cript type=text/java'+'script src=http://ad.advertstream.com/adjs_r.php?what=zone:10927&inf=no></scr'+'ipt>');
	}
}

