var time = new Date();
var ordval = time.getTime();

vis = "visible";
hid = "hidden";
format = 0;
adDisplayed = false;

autoCloseTimeout = 0;
multi = 'http://www.multimania.fr/';
mimg = multi + 'general/pub/dpop/';
mim2 = multi + 'general/pub/' + dpop_num + '/';

function placeAd() {
	var x, x1;
	x = document.body.clientWidth - 16;


	document.all.dpop.style.left = x - pop_w;
	document.all.pub_o.style.left = x - 489;
	document.all.pub_f.style.left = x - 19;
	x1 = x - 108;
	document.all.titremm.style.left = x1; 
	document.all.menumm.style.left = x1;
	x1 = x - 240;
	document.all.titreperso.style.left = x1;
	document.all.menuperso.style.left = x1; 
}

function chFormat(f) {
	if (autoCloseTimeout > 0) {
		clearTimeout(autoCloseTimeout);
		autoCloseTimeout = -1;
	}

	switch(f) {
		case 0:
			display(hid, hid, hid);
			break;
		case 1:
			display(vis, vis, hid);
			break;
		case 2:
			display(vis, hid, vis);
			break;
	}
	format = f;
}

function setVis(z, v) {
	if (document.all[z].style.visibility != v) {
		if ((z == "menuperso") || (z == "menumm"))
			if (v == vis)
				if (format != 1)
					chFormat(1);
		document.all[z].style.visibility = v;
	}
}

function display(a, b, c) {
	setVis('dpop', a);
	setVis('titremm', a);
	setVis('titreperso', a);
	setVis('pub_f', b);
	setVis('pub_o', c);
}

function setAutoClose(oneMore) {
	placeAd();
	chFormat(2);
	autoCloseTimeout = setTimeout('chFormat(1)', 15000);
}

function mm_d_ad() {
	var pn = 'px;visibility:hidden" ';
	var sv = ';return false" onMouseOver="window.status=\'Cliquez pour ouvrir le menu\';return true;" onMouseOut="window.status=\'\';return true;">';
	var ln = '<a target=_blank class=mm href="';
	var im = '<td><img src="';

	document.write('<style>');
	document.write('.mm { font-family: Arial, Helvetica, sans-serif; font-size: 10px; color: black; text-decoration: none }');
	document.write('A.mm:link,A.mm:active,A.mm:visited { font-family: Arial, Helvetica, sans-serif; font-size: 10px; color: black; text-decoration: none }');
	document.write('A.mm:hover { font-family: Arial, Helvetica, sans-serif; font-size: 10px; color: #006699; text-decoration: underline }');
	document.write('</style>');

	document.write('<map name="mm_pub_close"><area coords="472,2,486,16" href="javascript:chFormat(1)"></map>');

	document.write('<div id=dpop style="position:absolute;left:0px;top:0px;visibility:hidden;">');
	document.write('	<img src="' + mim2 + 'haut.gif" width=' + pop_w + ' height=' + pop_h + ' border=0>');
	document.write('	<div style="position:absolute;left:' + pop_l_x + 'px;top:' + pop_l_y + 'px"><a href="' + multi + '" target=_blank><img src="' + mim2 + 'logo.gif" width=' + pop_l_w + ' height=' + pop_l_h + ' border=0></a></div>');
	document.write('	<div style="position:absolute;left:' + pop_r_x + 'px;top:' + pop_r_y + 'px"><table cellspacing=4 cellpadding=0 border=0><tr><form target=_blank method=post action="' + multi + 'explorer/recherche/index.phtml"><td><input type=hidden name=src value=dpop><input class=mm type=text name=query maxlength=60 size=10 value="' + search_query + '"></td><td valign=bottom><input type=image border=0 name=ok src="' + mimg + 'ok.gif" width=19 height=20></td></form></tr></table></div>');
	document.write('	<div style="position:absolute;left:' + pop_f_x + 'px;top:' + pop_f_y + 'px"><a href="" onClick="chFormat(0);return false"><img src="' + mim2 + 'fermer.gif" width=16 height=15 border=0></a></div>');
	document.write('	<div style="position:absolute;left:' + pop_a_x + 'px;top:' + pop_a_y + 'px"><a href="' + multi + 'evenement/popup/" target=_blank><img src="' + mim2 + 'aide.gif" width=16 height=15 border=0></a></div>');
	document.write('</div>');
	document.write('<div id=titreperso style="position:absolute;width:133;height:17;top:' + pop_h + pn + '>');
	if (perso_links != "")
		document.write('<a href="" onClick="setVis(\'menuperso\', vis);setVis(\'menumm\', hid)' + sv + '<img src="' + mimg + 'perso.gif" width=133 height=17 border=0></a>');
	document.write('</div>');
	document.write('<div id=titremm style="position:absolute;width:108;height:17;top:' + pop_h + pn + '>' +
						'<a href="" onClick="setVis(\'menumm\', vis);setVis(\'menuperso\', hid)' + sv + '<img src="' + mimg + 'mmt.gif" width=108 height=17 border=0></a>' +
					'</div>');

	document.write('<div id=pub_o style="position:absolute;top:' + pub_y + 'px;visibility:hidden">');
	document.write('	<img src="' + mimg + 'pub_on.gif" usemap="#mm_pub_close" width=489 height=84 border=0>');
	document.write('	<div style="position:absolute;left:2px;top:2px;width:468;height:60"><iframe src="http://ad.fr.doubleclick.net/adi/popup.mm.net' + category + ';sz=468x60;tile=1;ord=\' + ordval + \'?" width=468 height=60 marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=no><A HREF="http://ad.fr.doubleclick.net/jump/popup.mm.net' + category + ';sz=468x60;tile=1;abr=!ie4;abr=!ie5;ord=\' + ordval + \'?"><IMG src="http://ad.fr.doubleclick.net/ad/popup.mm.net' + category + ';sz=468x60;tile=1;abr=!ie4;abr=!ie5;ord=\' + ordval + \'?" width=468 height=60 border=0></A></iframe></div>');
	document.write('	<div style="position:absolute;left:2px;top:64px;width:468;height:18"><iframe src="http://ad.fr.doubleclick.net/adi/march.mm.net/popup;sz=468x18;ord=\' + ordval + \'?" width=468 height=18 marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=no><A HREF="http://ad.fr.doubleclick.net/jump/march.mm.net' + category + ';sz=468x18;abr=!ie4;abr=!ie5;ord=\' + ordval + \'?"><IMG src="http://ad.fr.doubleclick.net/ad/march.mm.net' + category + ';sz=468x18;abr=!ie4;abr=!ie5;ord=\' + ordval + \'?" width=468 height=18 border=0></A></iframe></div>');
	document.write('</div>');
	document.write('<div id=pub_f style="position:absolute;top:' + pub_y + 'px;visibility:hidden">');
	document.write('	<a href="javascript:chFormat(2)"><img src="' + mimg + 'pub_off.gif" width=19 height=84 border=0></a>');
	document.write('</div>');

	document.write('<div id=menumm style="position:absolute;top:' + pop_h + pn + '>' +
						'<table cellspacing=0 cellpadding=0 border=0>' +
							'<tr><td colspan=3>' +
								'<a href="" onClick="setVis(\'menumm\', hid)' + sv + '<img src="' + mimg + 'mmt.gif" width=108 height=17 border=0></a>' +
							'</td></tr>' +
							'<tr bgcolor="#EA9213">' +
								im + mimg + 'mm_gh.gif" width=8 height=7></td>' +
								im + mimg + 'mm_bande_h.gif" width=92 height=7></td>' +
								im + mimg + 'mm_dh.gif" width=8 height=7></td>' +
							'</tr>' +
							'<tr bgcolor="#EA9213">' +
								'<td background="' + mimg + 'mm_bande_g.gif"><img src="' + multi + 'common/img/vide.gif" width=8 height=2></td>' +
								'<td>' +
									ln + multi + '">Accueil</a><br>' +
									ln + multi + 'communiquer/email/">Email gratuit</a><br>' +
									ln + multi + 'construire/">Pages perso</a><br>' +
									ln + 'http://chat.multimania.fr/">Chat</a><br>' +
									ln + 'http://forums.multimania.fr/">Forums</a><br>' +
									ln + multi + 'explorer/">Annuaire des sites</a><br>' +
									ln + multi + 'ecommerce/">WebShopping</a><br>' +
								'</td>' + 
								'<td background="' + mimg + 'mm_bande_d.gif"><img src="' + multi + 'common/img/vide.gif" width=8 height=2></td>' +
							'</tr>' + 
							'<tr>' + 
								im + mimg + 'mm_gb.gif" width=8 height=8></td>' + 
								'<td bgcolor="#EA9213"><img src="' + mimg + 'mm_bande_b.gif" width=92 height=8></td>' +
								im + mimg + 'mm_db.gif" width=8 height=8></td>' +
							'</tr>' +
						'</table>' +
					'</div>');

	document.write('<div id=menuperso style="position:absolute;width:133;top:' + pop_h + pn + '>');
	if (perso_links != "") {
		document.write('<table cellspacing=0 cellpadding=0 border=0>' +
							'<tr><td colspan=3>' +
								'<a href="" onClick="setVis(\'menuperso\', hid)' + sv + '<img src="' + mimg + 'perso.gif" width=133 height=17 border=0></a>' +
							'</td></tr>' +
							'<tr>' +
								im + mimg + 'site_gh.gif" width=8 height=7></td>' +
								im + mimg + 'site_bande_h.gif" width=117 height=7></td>' +
								im + mimg + 'site_dh.gif" width=8 height=7></td>' +
							'</tr>' +
							'<tr bgcolor="#FFCC00">' +
								'<td background="' + mimg + 'site_bande_g.gif"><img src="' + multi + 'common/img/vide.gif" width=8 height=2></td>' +
								'<td bgcolor="#FFCC00">' + perso_links + '</td>' + 
								'<td background="' + mimg + 'site_bande_d.gif"><img src="' + multi + 'common/img/vide.gif" width=8 height=2></td>' +
							'</tr>' + 
							'<tr>' + 
								im + mimg + 'site_gb.gif" width=8 height=8></td>' + 
								im + mimg + 'site_bande_b.gif" width=117 height=8></td>' +
								im + mimg + 'site_db.gif" width=8 height=8></td>' +
							'</tr>' +
						'</table>');
	}
	document.write('</div>');

	setAutoClose(2);
}

function findTop(w) {
//	try {
		return w.document;
//	} catch (foo) {
//		return findTop(w.frames[0]);
//	}
}		

function checkForDisplay() {
	var wd, ht, sf, mytop;

	if (top == self) {
		if (top.frames.length==0)
			mm_d_ad();
	}
	else {
		mytop = findTop(top);
		sf = mytop.body.clientWidth * mytop.body.clientHeight;
		sf = sf / (self.document.body.clientWidth * self.document.body.clientHeight);

		if (sf < 3) {
			if (!mytop.adDisplayed) {
				mytop.adDisplayed = true;
				mm_d_ad();
			}
		}
	}
}

