function PreloadImg() { //v3.0
  var d=document;
	if(d.images){
  	if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=PreloadImg.arguments;
   for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ 
    	d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];
    	}
    }
}

function afficheDate(){
jour = new Array ("Dimanche","Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi");
mois = new Array ("Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Août","Septembre","Octobre","Novembre","Décembre");
date=new Date();
datejour=date.getDate();
heure=date.getHours();
minute=date.getMinutes();
if (date.getDate()<10) datejour="0"+datejour; 
if (heure<10) heure="0"+heure;
if (minute<10) minute="0"+minute;
document.getElementById("texteDate").innerHTML=jour[date.getDay()]+" "+datejour+" "+mois[date.getMonth()]+", il est "+heure+"h"+minute+" ";
setTimeout("afficheDate()", 1000);
}
function resizePopUp(img) { 
	w = window.open('','chargement','width=400,height=400, top=180, left=190, toolbar=no, menubar=no, location=no, resizable=yes, scrollbars=no, status=no');
	w.document.write( "<html>\n" );
	w.document.write( "<head>\n" );
	w.document.write( "<title>L'Agapanthe</title>\n" );
	w.document.write( "<script type='text/javascript'>\n" );
	w.document.write( "\n" );
	w.document.write( "function resizeWinTo() {\n" );
	w.document.write( "Ix=document.images['toto']\n" );
	w.document.write( "Iy=document.images['tata']\n" );
	w.document.write( "if( !document.images.length ) {\n" );
	w.document.write( "Ix = document.layers[0].images['toto']; \n" );
	w.document.write( "}\n" );
	w.document.write( "var oH = Ix.height, oW = Ix.width;\n" );
	w.document.write( "if( !oH || window.doneAlready ) { return; }\n" );
	w.document.write( "window.doneAlready = true;\n" );
	w.document.write( "var x = window; x.resizeTo( oW + 200, oH + 200 );\n" );
	w.document.write( "var myW = 0, myH = 0, d = x.document.documentElement, b = x.document.body;\n" );
	w.document.write( "if( x.innerWidth ) {\n" );
	w.document.write( "myW = x.innerWidth; myH = x.innerHeight; }\n" );
	w.document.write( "else if( d && d.clientWidth ) { \n" );
	w.document.write( "myW = d.clientWidth; myH = d.clientHeight; \n" );
	w.document.write( "}\n" );
	w.document.write( "else if( b && b.clientWidth ) {\n" );
	w.document.write( "myW = b.clientWidth; myH = b.clientHeight; \n" );
	w.document.write( "}\n" );
	w.document.write( "if( window.opera && !document.childNodes ) {\n" );
	w.document.write( "myW += 16; \n" );
	w.document.write( "}\n" );
	w.document.write( "x.resizeTo( oW = oW + ( ( oW + 200 ) - myW ), oH = oH + ( (oH + 200 ) - myH ) );\n" );
	w.document.write( "var scW = screen.availWidth ? screen.availWidth : screen.width;\n" );
	w.document.write( "var scH = screen.availHeight ? screen.availHeight : screen.height;\n" );
	w.document.write( "if( !window.opera ) {\n" );
	w.document.write( "x.moveTo(Math.round((scW-oW)/2),Math.round((scH-oH)/2)); \n" );
	w.document.write( "}\n" ); 
	w.document.write( "Iy.width=Ix.width;\n" );
	w.document.write( "Iy.height=Ix.height;\n" );
	w.document.write( "}\n" );
	w.document.write( "</script>\n" );
	w.document.write( "</head>\n" );
	w.document.write( "<body background-color= #000000 leftmargin=0 topmargin=0 marginwidth=0 marginheight=0 onload='resizeWinTo();'>\n" );
	w.document.write( "<img src='"+img+"' name='toto'>\n" );
	w.document.write( "<div style='position: absolute; width: 10px; height: 10px; z-index: 1; left: 0px; top: 0px;' id='couche1'>\n" );
	w.document.write( "<a href='javascript:window.close();'><img border='0' src='images/rien.gif' alt='Cliquez pour fermer' name='tata'></a>\n" );
	w.document.write( "</div>\n" );
	w.document.write( "</body>\n" );
	w.document.write( "</html>\n" );
	w.document.close();
} 

function redim() { 
	tmt_Resize_WindowX = 850;
	tmt_Resize_WindowY = 600;
	self.resizeTo(tmt_Resize_WindowX,tmt_Resize_WindowY);//tmtC_Resize_WindowEnd
	self.moveTo(0,0)
	}

// Defaults
var ebnumdots= 5;
var ebimg= "images/lierre";
var ebHTML= null;
var ebwidth= 17;
var ebheight= 17;
var ebseglength= 10;
var ebspringk= 10;
var ebmass= 1;
var ebgravity= 50;
var ebresistance= 10;
var ebbounce= 0.75;
var ebzindex= 50;

// Private variables
var ebmousex=0, ebmousey=0;
var ebdeltat=0.02;
var ebdots= new Array();

// Browser detection

// Global variables
var browserversion=0.0;
var browsertype=0; // 0: unknown; 1:MSIE; 2:NN

// Return true if MSIE or NN detected
function browserdetect() {
  var agt= navigator.userAgent.toLowerCase();
  var appVer= navigator.appVersion.toLowerCase();
  browserversion= parseFloat(appVer);
  var iePos= appVer.indexOf('msie');
  if (iePos!=-1) browserversion= parseFloat(appVer.substring(iePos+5, appVer.indexOf(';',iePos)));
  var nav6Pos = agt.indexOf('netscape6');
  if (nav6Pos!=-1) browserversion= parseFloat(agt.substring(nav6Pos+10))
  browsertype= (iePos!=-1) ? 1 : (agt.indexOf('mozilla')!=-1) ? 2 : 0;
  return(browsertype>0);
}

browserdetect();

// General utils

// Find object by name or id
function ebobj(id) {
  var i, x;
  x= document[id];
  if (!x && document.all) x= document.all[id];
  for (i=0; !x && i<document.forms.length; i++) x= document.forms[i][id];
  if (!x && document.getElementById) x= document.getElementById(id);
  return(x);
}

// Move object
function ebmove(o, x, y) {
  if (!o) return;
  if (o.style) {
    o.style.left= x+"px";
    o.style.top= y+"px";
  } else {
    o.left= x;
    o.top= y;
  }
}

// Create dots
function ebwrite() {
  var i, img;
  var x=ebwidth/2, y=ebheight/2;

  if (arguments.length==2) {
    x= arguments[0];
    y= arguments[1];
  }
  ebmousex=x; ebmousey=y;

  if (browsertype<0 || browserversion<5) return;

  img= "";
  ebdots[0]= new ebdot(x, y);
  for (i=1; i<=ebnumdots; i++) {
    y+= ebseglength;
    img+= "<div id='ebdot"+i+"' style='position:absolute; left:"+x+"; top:"+y+"; "+
            "height:"+ebheight+"; width:"+ebwidth+"; z-index:"+ebzindex+"'>"+
	    (ebHTML ? ebHTML : "<img src='"+ebimg+i+".gif' height='"+ebheight+"' width='"+ebwidth+"' border='0'>")+ "</div>";
    ebdots[i]= new ebdot(x, y);
  }
  document.write(img);

  for (i=1; i<=ebnumdots; i++) {
    ebdots[i].obj= ebobj("ebdot"+i);
  }

  switch (browsertype) {
    case 1:
      document.onmousemove=ebmousemoveIE;
      break;
    case 2:
      document.captureEvents(Event.MOUSEMOVE);
      document.onmousemove=ebmousemoveNS;
      break;
  }

  setInterval("ebanimate()", 1000*ebdeltat);
}

// Parameters of one dot
function ebdot(x, y) {
  this.x= x;
  this.y= y;
  this.dx= 0;
  this.dy= 0;
  this.obj= null; // unknown
}

// Capture mouse position
function ebmousemoveNS(e) {
  ebmousex= e.pageX;
  ebmousey= e.pageY;
  return(true);
}
function ebmousemoveIE() {
  ebmousex= window.event.clientX + document.body.scrollLeft;
  ebmousey= window.event.clientY + document.body.scrollTop;
}

// Animation
function ebanimate() {

  // Vector object
  function ebvec(X, Y) {
    this.x = X;
    this.y = Y;
  }

  // Add force in x and y direction to spring for ebdot[i] on ebdot[j]
  function ebspring(i, j, spring) {
    var dx= ebdots[i].x-ebdots[j].x;
    var dy= ebdots[i].y-ebdots[j].y;
    var len= Math.sqrt(dx*dx+dy*dy);
    if (len>ebseglength) {
      var springF= ebspringk*(len-ebseglength);
      spring.x+= (dx/len)*springF;
      spring.y+= (dy/len)*springF;
    }
  }

  var winleft= browsertype==2 ? window.scrollX : document.body.scrollLeft;
  var wintop= browsertype==2 ? window.scrollY : document.body.scrollTop;
  var winwidth= browsertype==2 ? window.innerWidth-14 : document.body.clientWidth;
  var winheight= browsertype==2 ? window.innerHeight : document.body.clientHeight;

  ebdots[0].x= ebmousex-winleft;
  ebdots[0].y= ebmousey-wintop;
  for (i=1; i<=ebnumdots; i++) {
    var spring= new ebvec(0, 0);
    ebspring(i-1, i, spring);
    if (i<ebnumdots) {
      ebspring(i+1, i, spring);
    }
    var resist= new ebvec(-ebdots[i].dx*ebresistance, -ebdots[i].dy*ebresistance);
    var accel= new ebvec((spring.x+resist.x)/ebmass, (spring.y+resist.y)/ebmass+ebgravity);
    ebdots[i].dx+= (ebdeltat*accel.x);
    ebdots[i].dy+= (ebdeltat*accel.y);
    ebdots[i].x+= ebdots[i].dx;
    ebdots[i].y+= ebdots[i].dy;
    if (ebdots[i].y>=winheight-ebheight/2-1) {
      if (ebdots[i].dy>0) {
	ebdots[i].dy= -ebbounce*ebdots[i].dy;
      }
      ebdots[i].y= winheight-ebheight/2-1;
    }
    if (ebdots[i].y<ebheight/2) {
      if (ebdots[i].dy<0) {
	ebdots[i].dy= -ebbounce*ebdots[i].dy;
      }
      ebdots[i].y= ebheight/2;
    }
    if (ebdots[i].x>=winwidth-ebwidth/2) {
      if (ebdots[i].dx>0) {
	ebdots[i].dx= -ebbounce*ebdots[i].dx;
      }
      ebdots[i].x= winwidth-ebwidth/2-1;
    }
    if (ebdots[i].x<ebwidth/2) {
      if (ebdots[i].dx<0) {
	ebdots[i].dx= -ebbounce*ebdots[i].dx;
      }
      ebdots[i].x= ebwidth/2;
    }
    ebmove(ebdots[i].obj, winleft+ebdots[i].x-ebwidth/2, wintop+ebdots[i].y-ebheight/2);
  }
}

