/*
	v1.01 Copyright (c) 2007 julien
*/
var DHTMLpop = {};
var scrollDiff = 0;
function initDHTMLpop(Obj) 
{
	if (!Obj)
	{
		Obj = {};
		if (!Obj.autorun) Obj.autorun = true;
	}
	if (typeof(Obj.opacity)=="undefined") Obj.opacity = 6;
	if (!Obj.height) Obj.height	= 300;
	if (!Obj.width)	Obj.width = 500;
	if (!Obj.bgcolor) Obj.bgcolor = '#000000';
	if (!Obj.url) Obj.url = 'http://www.google.fr';
	DHTMLpop = Obj;
	if (DHTMLpop.autorun) showHideInnerPopUp();
	return DHTMLpop;
}
function runDHTMLpop(obj) { 
	obj.autorun=true; 
	DHTMLpop = initDHTMLpop(obj); 
	return false;
}
function debugDHTMLpop() {
	var d = dimension_detect();
	var output = 
	' viewW='+d.viewW+' viewH='+d.viewH+' docH='+d.docH+' docW='+d.docW+
	' left='+d.left+' top='+d.top+' scrollDiff='+scrollDiff+'<hr>';
	var bod = document.getElementsByTagName('body')[0];
	if (document.getElementById('debugSpan')) {
		document.getElementById('debugSpan').innerHTML+=output;
	} else {
		var div = document.createElement('div');
		div.id = "debugSpan";
		div.style.position = "absolute";
		div.style.display="block";
		div.style.top="0px";
		div.style.width="500px";
		div.style.backgroundColor='lightgreen';
		div.innerHTML = output;
		bod.appendChild(div);
	}
}
function alwaysInTop() {
	window.scrollTo(0,0);
	setTimeout("alwaysInTop()",1000);	
}
function replaceInnerPopUp(width,height)
{
	window.scrollTo(0,0);
	if (width)	DHTMLpop.width = width;
	if (height) DHTMLpop.height = height;
	var d 		= dimension_detect();
	var newTop 	= (d.viewH-DHTMLpop.height)/2 ;
	var newLeft = (d.viewW-DHTMLpop.width)/2;
	// on repositionne le div au centre de la page
	var innerPopUp = document.getElementById("innerpopup_iframe");
	innerPopUp.allowTransparency = true;
	innerPopUp.style.top 	= parseInt(newTop)+"px";
	innerPopUp.style.left 	= parseInt(newLeft)+"px";
	innerPopUp.style.width 	= DHTMLpop.width+"px";
	innerPopUp.style.height = DHTMLpop.height+"px";
	// on réagrandit le background	
	if (document.body.style.overflow=='hidden') {
		var back = document.getElementById("innerpopup_background");
		back.style.width = (d.docW>d.viewW)?d.docW+'px':d.viewW+'px';
		back.style.height = (d.docH>d.viewH)?d.docH+'px':d.viewH+'px';
		back.style.height = '5000px';
	} else if (document.body.style.overflow=='') {
		var back = document.getElementById("innerpopup_background");
		back.style.width = (d.docW>d.viewW)?d.docW+'px':d.viewW+'px';
		back.style.height = (d.docH>d.viewH)?d.docH+'px':d.viewH+'px';
		back.style.height = '5000px';
	} else {
		var back = document.getElementById("innerpopup_background");
		back.style.width = '1px';
		back.style.height = '1px';
	}
	scrollDiff = d.viewW-d.docW;
	if (scrollDiff<1) document.body.style.width=d.viewW;
};
function showHideInnerPopUp()
{
	alwaysInTop();
	// On applique une opacité
	var back = document.getElementById("innerpopup_background");

	back.style.filter = 'alpha(opacity='+DHTMLpop.opacity*10+')';
	back.style.MozOpacity = DHTMLpop.opacity/100;
	back.style.KHTMLOpacity = DHTMLpop.opacity/100;
	back.style.opacity = DHTMLpop.opacity/10;

	// Chargement du contenu de l'iframe
	var innerpopup_iframe = document.getElementById("innerpopup_iframe");
	frames['innerpopup_iframe'].location.href = DHTMLpop.url;
	innerpopup_iframe.style.width=DHTMLpop.width+'px';
	innerpopup_iframe.style.height=DHTMLpop.height+'px';

	// On vérifie l'etat de l'innerPopUp pour determiner si on doit l'afficher ou la cacher
	var innerpopup = document.getElementById("innerpopup");
	// si caché on affiche
	if (innerpopup.style.visibility == 'hidden' || DHTMLpop.showonly)
	{
		document.getElementById("innerpopup_background").style.backgroundColor=DHTMLpop.bgcolor;
		var os=document.getElementsByTagName('select');
		for (var i=0,o;o=os[i];i++) o.parentNode.style.visibility = 'hidden';
		document.body.style.overflow = 'hidden';
		document.getElementsByTagName('html')[0].style.overflow = 'hidden';
		innerpopup.style.visibility = 'visible';
	// si affiché on cache
	} else {
		innerpopup.style.width='1px';
		var os=document.getElementsByTagName('select');
		for (var i=0,o;o=os[i];i++) o.parentNode.style.visibility = 'visible';
		document.body.style.overflow = 'auto';
		document.getElementsByTagName('html')[0].style.overflow = 'auto';
		innerpopup.style.visibility = 'hidden';
	}
	replaceInnerPopUp();
	if (DHTMLpop.debug) debugDHTMLpop();
}
// Dimension_detect
function dimension_detect(){
	var d={'viewW':0,'viewH':0,'docH':0,'docW':0,'left':0,'top':0};
	if (document.body.scrollHeight>document.body.offsetHeight){
		d.docW=document.body.scrollWidth;
		d.docH=document.body.scrollHeight;
	} else {
		d.docW=document.body.offsetWidth;
		d.docH=document.body.offsetHeight;
	}
	if (self.innerWidth){
		d.viewW=self.innerWidth;
		d.viewH=self.innerHeight;
		d.left=window.pageXOffset;
		d.top=window.pageYOffset;
	} else {
		var ie=(document.compatMode&&document.compatMode!='BackCompat')?document.documentElement:document.body;
		d.viewW=ie.clientWidth;
		d.viewH=ie.clientHeight;
		d.left=ie.scrollLeft;
		d.top=ie.scrollTop;
	}
	return d;
};

/* Disclaimer Redirect version DHTML */

if (typeof new_disclaimer == "undefined") var new_disclaimer = {'lg':'fr','opacity':9}

var DHTMLpopParam = {'width':564,'height':377,'url':'http://www.eminencia-conseil.com/new.php?'};



if (typeof(new_disclaimer.opacity)!="undefined") DHTMLpopParam.opacity = new_disclaimer.opacity;
if (new_disclaimer.lg) DHTMLpopParam.url+="&langue="+new_disclaimer.lg;

if (new_disclaimer.dob) DHTMLpopParam.url+="&dob=1";
if (new_disclaimer.id_site) DHTMLpopParam.url+="&id_site="+new_disclaimer.id_site;
if (new_disclaimer.bgcolor) DHTMLpopParam.bgcolor = new_disclaimer.bgcolor;
if (new_disclaimer.showhost) DHTMLpopParam.url+='&showhost=1';
if (new_disclaimer.skin) DHTMLpopParam.url+="&skin="+new_disclaimer.skin;
if (new_disclaimer.noexit==1) DHTMLpopParam.url+="&noexit=1";
if (new_disclaimer.post==1) DHTMLpopParam.url+="&post=1";
if (new_disclaimer.sortir) DHTMLpopParam.url+="&sortir="+escape(new_disclaimer.sortir);

if (new_disclaimer.popunder==1) DHTMLpopParam.url+="&popunder=1";
if (new_disclaimer.popover==1) DHTMLpopParam.url+="&popover=1";
if (new_disclaimer.img) DHTMLpopParam.url+="&disclaimer_img="+escape(new_disclaimer.img);
if (new_disclaimer.popover==1 || new_disclaimer.popunder==1) {
	var d = dimension_detect();
	DHTMLpopParam.url+="&viewH="+d.docH;
	DHTMLpopParam.url+="&viewW="+d.docW;
}
if (new_disclaimer.exitcd) DHTMLpopParam.url+="&exitcd="+new_disclaimer.exitcd;
if (new_disclaimer.timer) DHTMLpopParam.url+="&timer="+new_disclaimer.timer;
if (new_disclaimer.debug) DHTMLpopParam.debug=1;

var exp = /(&|\?)(w|warning)=1/g;
if (exp.test(window.location)) {
	DHTMLpopParam.autorun=true;
	document.cookie = 'dhtmlclaimer=1;path=/;';
} else if (new_disclaimer.preview==1) {
	DHTMLpopParam.autorun=true;
} else if (new_disclaimer.preview===0) {
	DHTMLpopParam.autorun=false;
} else if (document.cookie.indexOf('dhtmlclaimer') == -1) { 
	document.cookie = 'dhtmlclaimer=1;path=/;'; 
	DHTMLpopParam.autorun=true;
}
// Disclaimer disable
var exp = /(&|\?)(w|warning)=0/g;
if (exp.test(window.location)) DHTMLpopParam.autorun=false;

if (DHTMLpopParam.autorun===false && new_disclaimer.popunder==1) window.focus();

// noexit optiony
var exp = /(&|\?)(noexit=1|e=0|md==19)/g;
if (exp.test(window.location)) DHTMLpopParam.url+="&noexit=1";

DHTMLpopParam.url+="&wparent="+escape(window.location);

document.write('<style type="text/css">');
document.write('#innerpopup_iframe { overflow:hidden; z-index:5000; position:absolute; top:0; left:0; border:0; }');
document.write('#innerpopup_background { z-index:4998; position:absolute; top:0; left:0; width:100%; height:100%; }');
if (DHTMLpopParam.autorun===true) {
	document.write('embed,object { display:none; visibility:hidden }');
}
document.write('</style>');
document.write('<div id="innerpopup" style="visibility:hidden;">');
document.write('	<div id="innerpopup_background">&nbsp;</div>');
document.write('	<iframe id="innerpopup_iframe" name="innerpopup_iframe" frameborder="0" scrolling="no" src="about:blank" style="width:5px;height:5px" autocomplete="Off"></iframe>');
document.write('</div>');

var DHTMLdisclaimer = initDHTMLpop(DHTMLpopParam);

if (new_disclaimer.uacct && DHTMLpopParam.autorun===true) {
	var _uacct = new_disclaimer.uacct;
	urchinTracker("/disclaimer");
}

window.onresize=function(){
	var innerpopup = document.getElementById("innerpopup");
	if (innerpopup.style.visibility == 'hidden') return;
	var innerpopup_iframe = document.getElementById("innerpopup_iframe");
	replaceInnerPopUp( 
		parseInt(innerpopup_iframe.style.width,10), 
		parseInt(innerpopup_iframe.style.height,10) 
	);
}; 