
function largeur_fenetre()
{
 if (window.innerWidth) return window.innerWidth;
 else if (document.body && document.body.offsetWidth) return document.body.offsetWidth;
 else return 0;
}

function hauteur_fenetre()
{
 if (window.innerHeight) return window.innerHeight  ;
 else if (document.body && document.body.offsetHeight) return document.body.offsetHeight;
 else return 0;
}

function escapeHTML (str)
{
   var div = document.createElement('div');
   var text = document.createTextNode(str);
   div.appendChild(text);
   return div.innerHTML;
}; 

/* definition de l'objet*/
function FdcPopup(varDst,largeur,hauteur,IDpopup,create){
    this.close=false;
    this.InMove=false;
    this.objtitre="";
    this.objcontenu="";
    this.largeur=0;
    this.height=0;
    this.obj;
    this.move;
    this.VitesseDep=1;
    this.pasDep=7;
    this.varDst=varDst;
    this.marge=new Array();	
    balise="script";
    if(create){
	    //On utilise la divstandard
	    fondlargeur=largeur;
	    fondhauteur=hauteur;
	    menuhauteur=15;
	    tablelargeur=largeur;
	    tablehauteur=hauteur;
	    repimg='http://www.acheter-fute.com/test/bleu/';
	    lien='#';
	    lienpub='#'
	    couleurfond="#777777";
	    this.txt="<div id='"+IDpopup+"'  style='display:none;position:absolute;z-index:1000;z-index:100;left:1px;top:1px;width:"+tablelargeur+"px;height=1px;'   > <style type='text/css'>.popupoff{padding:0px;border-width:0px;border-spacing: 0;margin:0px;}.popupvisu{padding : 0px;margin: 0;border-width: 2px;border-style: solid;border-color: #000000;}</style><div id='"+IDpopup+"_titre'>"+"</div><div  >"+'<TABLE width='+tablelargeur+' height='+tablehauteur+' cellpadding=0 cellspacing=0 valign="top" align="left" class="popupoff">'+'<TR><TD rowspan=5 valign=top class="popupvisu">'+"<DIV  id='"+IDpopup+"_contenu'>"+'<A HREF="'+lien+'" id="liencontenu" target="_blank"><IMG SRC="'+repimg+'transp.gif" width="'+fondlargeur+'" height="'+fondhauteur+'" style="border:0px;padding:0px;margin:0px;display:inline;vertical-align:baseline;" id="fondimgcontenu"></A></DIV></TD><TD valign=top width="14" height="14" class="popupoff"><A HREF="#" onClick="__Fdc__'+IDpopup+'.close();return false"><IMG SRC="'+repimg+'croix.gif" width="14" height="14" style="border:0px;padding:0px;margin:0px;display:inline;vertical-align:baseline;"></A><A HREF="#" onClick="__Fdc__'+IDpopup+'.RangeBordGauche();return false"><IMG SRC="'+repimg+'gauche.gif" width="14" height="12" style="border:0px;padding:0px;margin:0px;display:inline;vertical-align:baseline;"></A><A HREF="#" onClick="__Fdc__'+IDpopup+'.ouvreBordGauche();return false"><IMG SRC="'+repimg+'droite.gif" width="14" height="11" style="border:0px;padding:0px;margin:0px;display:inline;vertical-align:baseline;"></A><A href="'+lienpub+'"><IMG SRC="'+repimg+'titre.gif" width="14" height="52" style="border:0px;padding:0px;margin:0px;display:inline;vertical-align:baseline;"></A></td></tr><tr><td valign="top" width="14" height='+menuhauteur+' class="popupoff"></td></tr>'+"</TABLE></DIV></DIV>";
         document.write(this.txt);
  	//document.write( escapeHTML(this.txt)); //permet d'afficher le code
    }
    document.write("<"+balise+" type='text/javascript' language='javascript'>var __Fdc__"+IDpopup+"</"+balise+">");
    this.nom="__Fdc__"+IDpopup;
    this.obj=document.getElementById(IDpopup);
    this.Contenuobj=document.getElementById(IDpopup+'_contenu');
    function getPix(v){if(isNaN(v)){return parseInt(v.substr(0,v.length-2));}}
    this.GetX= function GetX(){	return getPix(this.obj.style.left); } 
    this.GetY= function GetY(){	return getPix(this.obj.style.top);  }

    this.X= function X(v){	if(!isNaN(v)){this.obj.style.left=(v)+"px";} }
    this.Y= function Y(v){	if(!isNaN(v)){this.obj.style.top=(v)+"px";}}
    this.InitMarge=function InitMarge(x,y){
	this.marge[0]=x;
	this.marge[1]=y;
    }
    this.startmove=function startmove(e) {
	/* fonction d'initialisation du déplacement  */
	if (! this.close) {					
	// on stocke la position relative du clic	
		this.InMove=true;
		this.InitMarge((e.offsetX) ? e.offsetX:e.layerX,(e.offsetY) ? e.offsetY:e.layerY);
		if (this.obj.style.zIndex<maxzFlottant) {
			// on place le flottant "au dessus" des autres
			maxzFlottant++;
			this.obj.style.zIndex=maxzFlottant;
		}
		this.defmove();//comme la variable est effacee on la recrée
		window.onmousemove=this.move;	
		window.onmouseup=this.stop;	
	}
	this.objDebug.innerHtml+=("margeX="+this.marge[0]);
	this.objDebug.innerHtml+="margeY="+this.marge[1];
    }
    this.stop=function stop(e){this.InMove=false;}
    this.defmove=function defmove(){
	//comme la variable est effacee on la recrée
	this.move=function move(e) {
	/* fonction de déplacement d'un flottant */
	// on calcule sa position relative
          if(this.InMove){
		x=(e.x) ? e.x:e.pageX;
		y=(e.y) ? e.y:e.pageY;
		// par rapport à la position du clic
		this.X(x-this.marge[0]);
		this.Y(y-this.marge[1]);
		this.objDebug.innerHtml+="X="+(x-this.marge[0]);
		this.objDebug.innerHtml+="Y"+(y-this.marge[1]);
	   }
	}
    }
    this.MoveDroite=function MoveDroite(obj,dst,pas){
	if(dst[0]>obj.GetX()){
		obj.X(obj.GetX()+pas);

	}
	if(dst[1]>obj.GetY()){
		obj.Y(obj.GetY()+pas);
	}
	if(dst[1]<=obj.GetY() && dst[0]<=obj.GetX()){
		clearInterval(obj.Interval);
	}
    }	
    this.MoveGauche=function MoveGauche(obj,dst,pas){
	if(dst[0]<obj.GetX()){
		obj.X(obj.GetX()-pas);
	}
	if(dst[1]<obj.GetY()){
		obj.Y(obj.GetY()-pas);
	}
	if(dst[1]>obj.GetY() && dst[0]>obj.GetX()){
		clearInterval(obj.Interval);
	}
    }
    this.RangeBordGauche=function RangeBordGauche(){

	if(this.Interval){clearInterval(this.Interval);}
	posAbsolue=-2;
	this.Interval=setInterval(this.MoveGauche+"MoveGauche("+this.varDst+",new Array(0-"+this.largeur+"+"+posAbsolue+","+this.GetY()+"),"+this.pasDep+");",this.VitesseDep);
    }
    this.ouvreBordGauche=function ouvreBordGauche(){
	if(this.Interval){clearInterval(this.Interval);}
	this.Interval=setInterval(this.MoveDroite+"MoveDroite("+this.varDst+",new Array(0,"+this.GetY()+"),"+this.pasDep+");",this.VitesseDep);
    }

    this.affiche=function affiche(){this.obj.style.display='inline';}
    this.close=function close(){this.obj.style.display='none';}
    this.contenu=function contenu(txt){this.Contenuobj.innerHTML=txt;}
    this.popunder=function popunder(lien){
      fenpopunder=window.open(lien);
      window.focus();
}

    if(!this.obj){return false;
	}
    else{
	eval("__Fdc__"+IDpopup+"=this;");
	this.objcontenu=document.getElementById(IDpopup+"_contenu");
	///this.objDebug=this.objcontenu;
	//this.objDebug.innerHtml+="start";
	if(this.largeur==0){ this.largeur=getPix(this.obj.style.width)};
	if(this.height==0){this.height=getPix(this.obj.style.height)};
	}
	this.defmove();
return this;
}

