function getElementLeft(Elem) {
xPos = Elem.offsetLeft;
tempEl = Elem.offsetParent;
while (tempEl != null) {
xPos += tempEl.offsetLeft;
tempEl = tempEl.offsetParent;
}
return xPos;
}
function getElementTop(Elem) {
yPos = Elem.offsetTop;
tempEl = Elem.offsetParent;
while (tempEl != null) {
yPos += tempEl.offsetTop;
tempEl = tempEl.offsetParent;
}
return yPos;
}
var growTimeoutId;
var randTimeoutId;
var startWidth = 120;
var startHeight = 90;
var growWidth = 135;
var growHeight = 100;
var extraWidth = 15;
var extraHeight = 10;
var curWidth;
var curHeight;
var curLeft;
var curTop;
var baseWidth;
var baseHeight;
var baseLeft;
var baseTop;
var cLeft;
var cRight;
var cTop;
var cBottom;
var growTimeoutId;

function enlargeThumb(imgObj) {
var cDiv = document.getElementById("container");
var otDiv = document.getElementById("overThumbDiv");
if (!cDiv || !otDiv)
return false;

var otImg = otDiv.getElementsByTagName("img")[0];
var otLink1 = otDiv.getElementsByTagName("a")[0];
var otLink2 = imgObj.parentNode;

cLeft = getElementLeft(cDiv);
cRight = cLeft + 882;
cTop = getElementTop(cDiv);
cBottom = cTop + 989;

baseWidth = imgObj.width;
baseHeight = imgObj.height;
baseLeft = getElementLeft(imgObj);
baseTop = getElementTop(imgObj);

curWidth = startWidth;
curHeight = startHeight;
curLeft = baseLeft - ((curWidth - baseWidth) / 2);
curTop = baseTop - ((curHeight - baseHeight) / 2);

if (curLeft < cLeft) curLeft = cLeft;
if (curLeft + curWidth > cRight) curLeft = cRight - curWidth;
if (curTop < cTop) curTop = cTop;
if (curTop + curHeight > cBottom) curTop = cBottom - curHeight;

otDiv.style.left = curLeft+'px';
otDiv.style.top = curTop+'px';
otDiv.style.width = curWidth+'px';
otDiv.style.height = curHeight+'px';
otImg.style.width = otDiv.style.width;
otImg.style.height = otDiv.style.height;
otLink1.href = otLink2.href;
otLink1.target = otLink2.target;
otLink1.title = otLink2.title;
otLink1.onclick = otLink2.onclick;

otImg.src = "";
otImg.src = imgObj.src;
showThumb();
growTimeoutId = window.setTimeout('growThumb()', 10);
}

function growThumb() {
otDiv = document.getElementById("overThumbDiv");
otImg = otDiv.getElementsByTagName("img")[0];

window.clearTimeout(growTimeoutId);

if (curWidth < growWidth + extraWidth || curHeight < growHeight + extraHeight) {
curWidth += Math.round(((growWidth + extraWidth) - curWidth) / 2);
curHeight += Math.round(((growHeight + extraHeight) - curHeight) / 2);
curLeft = baseLeft - ((curWidth - baseWidth) / 2);
curTop = baseTop - ((curHeight - baseHeight) / 2);
growTimeoutId = window.setTimeout('growThumb()', 25);
} else {
curWidth = growWidth;
curHeight = growHeight;
curLeft = baseLeft - ((curWidth - baseWidth) / 2);
curTop = baseTop - ((curHeight - baseHeight) / 2);
}
if (curLeft < cLeft) curLeft = cLeft;
if (curLeft + curWidth > cRight) curLeft = cRight - curWidth;
if (curTop < cTop) curTop = cTop;
if (curTop + curHeight > cBottom) curTop = cBottom - curHeight;

otDiv.style.left = curLeft+'px';
otDiv.style.top = curTop+'px';
otDiv.style.width = curWidth+'px';
otDiv.style.height = curHeight+'px';
otImg.style.width = otDiv.style.width;
otImg.style.height = otDiv.style.height;
}

function hideThumb() {
window.clearTimeout(growTimeoutId);
window.clearTimeout(randTimeoutId);

document.getElementById("overThumbDiv").style.display = "none";
randTimeoutId = window.setTimeout("popRandom()", 500);
}

function showThumb() {
window.clearTimeout(randTimeoutId);
document.getElementById("overThumbDiv").style.display = "inline";
}
var thumbs = new Array();

function collectThumbs() {
var divs = document.getElementsByTagName("div");
var counter = 0;
for (var i=0; i<divs.length; i++) {
var thisClass = divs[i].getAttribute("class");
if (!thisClass)
thisClass = divs[i].getAttribute("className");

if (thisClass == 'thumb') {
thumbs[counter] = divs[i];
counter++;
}
}
}

function popRandom() {
if (!thumbs)
return false;

var rand = Math.round(Math.random() * thumbs.length);
var thumbDiv = thumbs[rand];

if (!thumbDiv)
return false;

var thumbImg = thumbDiv.getElementsByTagName("img")[0];
if (thumbImg != null)
enlargeThumb(thumbImg);

window.clearTimeout(randTimeoutId);
randTimeoutId = window.setTimeout("hideThumb()", 3000);
}
var text_timer;
var text_visible = 1;
var text_tmp;

function blink()
{
   if (text_visible)
	 {
	    text_tmp = document.formulaire.mot.value;
			document.formulaire.mot.value = '';
			text_visible = false;
	 }
   else
	 {
	    document.formulaire.mot.value = text_tmp;
			text_visible = true;
	 }
}

function start_blink()
{
   if (document.formulaire.mot.value=='votre recherche ici')
	 {
	    text_timer = setInterval('blink()', 500);
	 }
}

function stop_blink()
{
   if (text_timer)
    {
	    clearInterval(text_timer);
	 }
 }

function mot_focus()
{
   stop_blink();
	 e = document.formulaire.mot;
	 if (e.value == 'votre recherche ici') e.value = '';
}
function mot_blur()
{
   e = document.formulaire.mot;
	 if (e.value == 'votre recherche ici' || e.value == '')
	 {
	    e.value = 'votre recherche ici';
	    start_blink();
	 }
}

if (window.addEventListener) window.addEventListener("load", start_blink, false);
else if (window.attachEvent) window.attachEvent("onload", start_blink);
else if (document.getElementById) window.onload=start_blink;
