function filtreByMarque(val)
{
  document.location.href='index.php?mode=0&search=1&categorie=0&motcles=&marque='+val;
}
//Affichage d'une image plein écran
function zoomImage(chemin)
{
  nomPage="zoomimage.php";
  nomPage=nomPage+"?nomimage="+chemin;
  window.open(nomPage,'','width=680,height=500,toolbar=0,location=0,directories=0,menuBar=0,scrollbars=yes,resizable=yes,left=2,top=2');   
}
//Poster une alerte sur un prix
function postAlert(annonce) 
{
  nomPage="postalert.php";
  if ( annonce ) nomPage=nomPage+"?annonce="+annonce;
  window.open(nomPage,'','width=600,height=400,toolbar=0,location=0,directories=0,menuBar=0,scrollbars=yes,resizable=yes,left=100,top=100'); 
}
//Recommander le site
function recommander(annonce) 
{
  nomPage="envoipage.php";
  if ( annonce ) nomPage=nomPage+"?annonce="+annonce;
  window.open(nomPage,'','width=600,height=600,toolbar=0,location=0,directories=0,menuBar=0,scrollbars=yes,resizable=yes,left=100,top=100'); 
}
//Question sur une annonce
function questionannonce(annonce) 
{
  nomPage="questionannonce.php";
  if ( annonce ) nomPage=nomPage+"?annonce="+annonce;
  window.open(nomPage,'','width=540,height=490,toolbar=0,location=0,directories=0,menuBar=0,scrollbars=yes,resizable=yes,left=100,top=100'); 
}
//Question sur une annonce
function questionannoncevirtuel(annonce) 
{
  nomPage="questionannoncevirtuel.php";
  if ( annonce ) nomPage=nomPage+"?annonce="+annonce;
  window.open(nomPage,'','width=540,height=540,toolbar=0,location=0,directories=0,menuBar=0,scrollbars=yes,resizable=yes,left=100,top=100'); 
}
//Affiche la charte e-depot
function charteedepot() 
{
  nomPage="charteedepot.htm";
  window.open(nomPage,'','width=680,height=590,toolbar=0,location=0,directories=0,menuBar=0,scrollbars=yes,resizable=yes,left=100,top=100'); 
}
//Conditions générales des e-dépôts
function conditionsedepot() 
{
  nomPage="conditions_depots.htm";
  window.open(nomPage,'','width=680,height=590,toolbar=0,location=0,directories=0,menuBar=0,scrollbars=yes,resizable=yes,left=100,top=100'); 
}
//Affiche des infos pour les expéditioons
function infosExpeditions() 
{
  nomPage="infosexpeditions.htm";
  window.open(nomPage,'','width=680,height=280,toolbar=0,location=0,directories=0,menuBar=0,scrollbars=yes,resizable=yes,left=100,top=100'); 
}

//Affiche la charte e-depot
function infosPrivilege() 
{
  nomPage="privilege.htm";
  window.open(nomPage,'','width=700,height=500,toolbar=0,location=0,directories=0,menuBar=0,scrollbars=yes,resizable=yes,left=100,top=100'); 
}

//Affiche la fenêtre des avis
function avisdepot(val) 
{
  document.location.href='index.php?mode=70&annonce='+val;
}

//Affiche la charte e-depot
function filDepot() 
{
  nomPage="page.php?mode=6";  
  window.open(nomPage,'','width=540,height=360,toolbar=0,location=0,directories=0,menuBar=0,scrollbars=yes,resizable=yes,left=100,top=100'); 
}

//Affichage des fenêtre d'aides
function fenetreAide(val) 
{
  nomPage=val;
  window.open(nomPage,'','width=540,height=240,toolbar=0,location=0,directories=0,menuBar=0,scrollbars=yes,resizable=yes,left=100,top=100'); 
}

//Saisie des cotes
function saisieCotes(doc) 
{
  param="tmp_cotea="+doc.getElementById('tmp_cotea').value;
  param=param+"&tmp_coteb="+doc.getElementById('tmp_coteb').value;
  param=param+"&tmp_cotec="+doc.getElementById('tmp_cotec').value;
  param=param+"&tmp_coted="+doc.getElementById('tmp_coted').value;
  
  nomPage="saisiecotes.php?"+param;
  window.open(nomPage,'','width=390,height=340,toolbar=0,location=0,directories=0,menuBar=0,scrollbars=yes,resizable=yes,left=100,top=100'); 
}

function kelkooStart(doc)
{
  if ( doc.getElementById('selectmarque').value==""  ) 
   {
     alert("Indiquer la marque et le modèle");
   }
  else
   {
	  param="marque="+doc.getElementById('selectmarque').value;
	  param=param+"&modele="+doc.getElementById('tmp_modele').value;
	  param=param+"&cate="+doc.getElementById('tmp_categorie').value;
	  nomPage="page.php?mode=17&"+param;
	  window.open(nomPage,'','width=640,height=240,toolbar=0,location=0,directories=0,menuBar=0,scrollbars=yes,resizable=yes,left=100,top=100'); 
   }
}
function kelkooStartC(param)
{
   nomPage="page.php?mode=17&"+param;
   window.open(nomPage,'','width=640,height=240,toolbar=0,location=0,directories=0,menuBar=0,scrollbars=yes,resizable=yes,left=100,top=100'); 
}
//Voir les cotes
function voirLesCotes(annonce) 
{
  nomPage="page.php?mode=13&annonce="+annonce;
  window.open(nomPage,'','width=380,height=340,toolbar=0,location=0,directories=0,menuBar=0,scrollbars=yes,resizable=yes,left=100,top=100'); 
}
//Affiche la charte e-depot
function top10Visu() 
{
  nomPage="page.php?mode=11";
  window.open(nomPage,'','width=540,height=430,toolbar=0,location=0,directories=0,menuBar=0,scrollbars=yes,resizable=yes,left=100,top=100'); 
}
//Affiche les utilisateurs de connectés de la journée
function connectedUser() 
{
  nomPage="page.php?mode=12";
  window.open(nomPage,'','width=540,height=430,toolbar=0,location=0,directories=0,menuBar=0,scrollbars=yes,resizable=yes,left=100,top=100'); 
}
//Affiche les détails d'un annonceur
function detailAnnonceur(usr) 
{
  nomPage="page.php?mode=7&user="+usr;
  window.open(nomPage,'','width=640,height=300,toolbar=0,location=0,directories=0,menuBar=0,scrollbars=yes,resizable=yes,left=100,top=100'); 
}
//Mode de livraison
function modelivraison()
{
  window.open('modelivraison.htm','','width=540,height=560,toolbar=0,location=0,directories=0,menuBar=0,scrollbars=yes,resizable=yes,left=100,top=100'); 
}
//Conditions générales de vente
function conditions()
{
  window.open('conditions.htm','','width=640,height=500,toolbar=0,location=0,directories=0,menuBar=0,scrollbars=yes,resizable=yes,left=100,top=100'); 
}
//Etat des commandes
function etatcommande()
{
  window.open('etatcommande.htm','','width=540,height=540','toolbar=0,location=0,directories=0,menuBar=0,scrollbars=yes,resizable=1,left=100,top=100'); 
}
//Coordonnées
function coordonnees()
{
  window.open('lescoordonnees.htm','','width=540,height=240','toolbar=0,location=0,directories=0,menuBar=0,scrollbars=1,resizable=1,left=100,top=100'); 
}
//Paiement sécurisé
function paiement()
{
  window.open('paiement.htm','','width=740,height=600,toolbar=0,location=0,directories=0,menuBar=0,scrollbars=yes,resizable=yes,left=100,top=100'); 
}
//Zone de login
function verifie_login(user,pwd)
{
  if ( user.length<1 )
   {
     alert('Indiquez votre nom utilisateur.');
	 return false;
   }
  if ( pwd.length<1 )
   {
     alert('Indiquez votre mot de passe.');
	 return false;
   }   
  return true;
}
//Zone de recherche
function verifie_recherche(val,cat,marq)
{
return true;
}
function verifie_email(email)
{
  if ( !arobaceok(email) ) 
   {
	 return false;
   }
  return true;
}
//Controle saisie infos newsletter
function verifie_newsletter()
{
  var email = document.newsletter.tmp_email.value;
  if ( !arobaceok(email) || email == "Votre adresse e-mail" ) 
   {
	 return false;
   }
 
  var inscription=true;
      
  if ( inscription==true )
   {
	 var intvtt=document.newsletter.intvtt.checked;
	 var introute=document.newsletter.introute.checked;
	 var intbmx=document.newsletter.intbmx.checked;
   
	 if ( !intvtt && !introute && !intbmx  )
	   {
		 alert('Sélectionnez au moins un centre d\'intêret pour personnaliser vos newsletter.');
		 return false;
	   }    
   }
  return true;
}
//Controle de l'adresse email
function arobaceok(M)
{
if ((M.indexOf(' '))>-1)
{
alert ('Taper l\'adresse email sans espace...');
return false;
}
else
M1=M.substring(0,M.indexOf ('@'));
if (M1.length<2)
{
alert ('l\'adresse email n\'est pas correcte...');
return false;
}
else
M2=M.substring(M.indexOf ('@')+ 1);
M3=M2.substring(M2,M2.indexOf ('.'));
if (M3.length<1)
{
alert ('l\'adresse email n\'est pas correcte...');
return false;
}
else
M4=M2.substring(M2.indexOf ('.')+ 1);
if (M4.length<2)
{
alert ('l\'adresse email n\'est pas correcte...');
return false;
}
return true;
}
//Controle si format numérique
function isNumeric(Data,flg)
{
    if ( !Data.length ) return true;
    Data=trim(Data);
   
	numChars = ".0123456789,";
	var isNum = true;
	var index = 0;
	while ((index < Data.length) && (isNum))
		 {
		 isNum = (numChars.indexOf(Data.charAt(index)) != -1);
		 index ++;
		 }
	if (!isNum)
		 {
		 if ( flg )
		  {
		    alert("Saisissez un format numérique");
		  }
		 return false;
		 }
  return true;		 
}
//Supprime les espace à gauche et droite
function trim(str) 
{
   while (str.substring(0,1) == ' ') str = str.substring(1);
   while (str.substring(str.length-1,str.length) == ' ') str = str.substring(0,str.length-1);
   return(str);
}

///
var count = 0;
var defaultWidth  = 580;
var defaultHeight = 420;

// popup( url, <name>, <features>, width, height, top, left )
function popup( url, width, height, top, left, name, features )
{
 if( width == null )  width  = defaultWidth;
 if( height == null ) height = defaultHeight;

 if( document.all )
 {
  availWidth  = window.screen.availWidth;
  availHeight = window.screen.availHeight;

  if( top  == null ) top  = ",top="  + ( availHeight / 2 - height / 2 ); else top  = ",top=" + top;
  if( left == null ) left = ",left=" + ( availWidth  / 2 - width  / 2 ); else left = ",left="+ left;
 }
 else
 {
  if( top  == null ) top  = (screen.height) ? ",screenY=" + (screen.height / 2 - height / 2 ) : ""; else top  = ",screenX="+ top;
  if( left == null ) left = (screen.width)  ? ",screenX=" + (screen.width  / 2 - width  / 2 ) : ""; else left = ",screenY="+ left;
 }

 tmp = "";
 if( features != null && typeof( features ) == "string" ) {
  tmp = "toolbar=" + ( features.indexOf("toolbar") > - 1 ? "yes" : "no" ) + ",";
  tmp += "scrollbars=" + ( features.indexOf("scrollbar") > - 1 ? "yes" : "no" ) + ",";
  tmp += "menubar=" + ( features.indexOf("menubar") > - 1 ? "yes" : "no" ) + ",";
  tmp += "resizable=" + ( features.indexOf("resizable") > - 1 ? "yes" : "no" ) + ",";
  tmp += "status=" + ( features.indexOf("status") > - 1 ? "yes" : "no" ) + ",";
  tmp += "location=" + ( features.indexOf("location") > - 1 ? "yes" : "no" ) + ",";
  tmp += "directories=" + ( features.indexOf("directories") > - 1 ? "yes" : "no" ) + ",";
  features = tmp+"width="+ width +",height="+ height + top + left;
 } else {
  features = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,"
           + "resizable=no,width="+ width +",height="+ height + top + left;
 }

 // alert( features );
 if( name == null ) {
  id = count + Math.floor( Math.random() * 8192 );
  name = "Win"+id;
 }

 win = window.open( url, name, features);
 count++;

 if( win ) {
  win.focus();
 }
}

function popupWindow(url, width, height)
{
 window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width='+width+',height='+height+',screenX=150,screenY=150,top=150,left=150')
}


var ie = document.all?1:0;
var w3c = document.getElementById?1:0;
var ns4 = document.layers?1:0;

var smallWidth, smallHeight, smallLeft, smallTop;
var leftClip, rightClip, topClip, bottomClip;
var largeWidth, largeHeight;
var lensWidth, lensHeight;
var detailLeft, detailTop;
var zoomx, zoomy;
var loading, lens, mouseX = 0, mouseY = 0, X, Y;

function loadmagnifier(smallid, magnifyid, largeurl, largex, largey, loadingid, loadingtext) {

 // Opera ab Version 7 ermitteln - unabhaengig von der eingestellten Identifizierung
 if((window.opera) && !(navigator.userAgent.indexOf("7")!=-1))
    { return; }

   windowwidth = (ie) ? document.body.offsetWidth : window.innerWidth;
  windowheight = (ie) ? document.body.offsetHeight : window.innerHeight;

   pageOffsetX = document.body.scrollLeft;
   pageOffsetY = document.body.scrollTop;

   smallWidth = document.getElementById(smallid).width;
  smallHeight = document.getElementById(smallid).height;	// Breite und Hoehe der kleinen Grafik
   largeWidth = largex;
  largeHeight = largey;	// Breite und Hoehe der kleinen Grafik
    smallLeft = findPosX(document.getElementById(smallid));
     smallTop = findPosY(document.getElementById(smallid));	// Position der kleinen Grafik

    distanceToLeft = smallLeft;
   distanceToRight = windowwidth-smallLeft-smallWidth;
     distanceToTop = smallTop-pageOffsetY;
  distanceToBottom = windowheight-smallTop-smallHeight+pageOffsetY;

   maxdistancex = Math.max(distanceToLeft, distanceToRight);
   maxdistancey = Math.max(distanceToTop, distanceToBottom);

/*
   dragmarginx = windowwidth  - document.body.clientWidth  + 5;
   dragmarginy = windowheight - document.body.clientHeight + 5;
*/

   ((dragmarginx = windowwidth  - document.body.clientWidth)  > 0) ? dragmarginx+=5 : dragmarginx = 0;
   ((dragmarginy = windowheight - document.body.clientHeight) > 0) ? dragmarginy+=5 : dragmarginy = 0;

    lensWidth = Math.min(smallWidth, maxdistancex);
   lensHeight = Math.min(smallHeight, maxdistancey);
   // Minimale Lupengröße
    lensWidth = Math.max(lensWidth, 200);
   lensHeight = Math.max(lensHeight, 150);
   // Maximale Lupengröße
    lensWidth = Math.min(largex/2, lensWidth);
   lensHeight = Math.min(largey/2, lensHeight);
    lensWidth -= dragmarginx;
   lensHeight -= dragmarginy;


   detailLeft = smallLeft+smallWidth/2-lensWidth/2;
    detailTop = smallTop+smallHeight;	// Position des Rahmen-Layers

  zoomx = largeWidth/smallWidth;
  zoomy = largeHeight/smallHeight;

     lens = (ie)?document.all[magnifyid].style:(w3c)?document.getElementById(magnifyid).style:document[magnifyid];
  loading = (ie)?document.all[loadingid]:(w3c)?document.getElementById(loadingid):document[loadingid];


  if (loading.innerHTML == 'undefined' || loading.innerHTML == '') // Moz = undefined, IE = ''
     { loading.innerHTML = loadingtext; }

  var img = new Image();
  img.onload = function()
               {
                lens.backgroundImage = "url('" + largeurl + "')";
                loading.innerHTML = ' ';
               }
  img.src = largeurl;

  loading = loading.style;
  loading.backgroundColor = "#FFFFFF";
  loading.width = lensWidth + "px";
  loading.height = lensHeight + "px";

  lens.width = lensWidth + "px";
  lens.height = lensHeight + "px";
  lens.display = "block";

  if (distanceToRight >= lensWidth && distanceToTop >= 10 && distanceToBottom >= 10) // rechts Platz
     {
      lensx = smallLeft+smallWidth ;
      lensy = smallTop+smallHeight/2-lensHeight/2;
     }
  else if (distanceToLeft >= lensWidth) // links Platz
     {
      lensx = smallLeft-lensWidth;
      lensy = smallTop+smallHeight/2-lensHeight/2;
     }
  else if (distanceToBottom >= lensHeight) // unten Platz
     {
      lensx = smallLeft+smallWidth/2-lensWidth/2;
      lensy = smallTop+smallHeight;
     }
  else if (distanceToTop >= lensHeight) // oben Platz
     {
      lensx = smallLeft+smallWidth/2-lensWidth/2;
      lensy = smallTop-lensHeight;
     }
  else
     {
      lens.display = "none";
      loading.display = "none";
      return;
     }

  lens.left = lensx + "px";
  lens.top  = lensy + "px";

  loading.left = lensx;
  loading.top = lensy;
  loading.visibility = 'visible';

  if(ns4) {
   document.captureEvents(Event.MOUSEMOVE);
  }
  setInterval("cut()", 15);
  document.onmousemove = pos;

}



function pos(e) { // Mausposition und Clipping-Werte berechnen

 if(!e) e = window.event; // Event-Definition fuer IE
 mouseX = ((ns4)?e.pageX:e.clientX) + document.body.scrollLeft - smallLeft; // Mausposition innerhalb der
 mouseY = ((ns4)?e.pageY:e.clientY) + document.body.scrollTop - smallTop;  // kleinen Grafik ermitteln

 X = Math.round(mouseX * zoomx); // Umrechnen der Mausposition
 Y = Math.round(mouseY * zoomy); // auf grosse Grafik

 // Overscan verhindern - zuerst links/oben, dann rechts/unten
 if (X < lensWidth/2)
    { X = lensWidth/2; }
 if (Y < lensHeight/2)
    { Y = lensHeight/2; }
 if (X+lensWidth/2 > largeWidth)
    { X = largeWidth-lensWidth/2; }
 if (Y+lensHeight/2 > largeHeight)
    { Y = largeHeight-lensHeight/2; }

 leftClip = X - lensWidth /2; // Clipping-Werte
 topClip = Y - lensHeight /2; // fuer die grosse Grafik
// rightClip = X + lensWidth /2;
// bottomClip = Y + lensHeight /2;
}


function cut() {

 if(mouseX > 0 && mouseX < smallWidth && mouseY > 0 && mouseY < smallHeight)
   {
    lens.visibility = "visible";
    lens.backgroundPosition = -leftClip + "px " + -topClip + "px";
   }
 else
   {
    loading.visibility = "hidden";
    lens.visibility = "hidden";
   }
}

function closemagnifier()
{
 lens.visibility = 'hidden';
 lens.display = 'none';
 loading.visibility = 'hidden';
 loading.display = 'none';
}


function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}
function showHideCtrl(idctrl)
{
 ctrl=document.getElementById(idctrl);
 if ( ctrl==null ) return;
 if ( ctrl.style.display=="none" ) ctrl.style.display="";
 else ctrl.style.display="none";  
}

function hideCtrl(idctrl)
{
 ctrl=document.getElementById(idctrl);
 if ( ctrl==null ) return;
 ctrl.style.display="none";  
}
function showCtrl(idctrl)
{
 ctrl=document.getElementById(idctrl);
 if ( ctrl==null ) return;
 ctrl.style.display="";  
}

function tabnav_active(val)
{
  for ( i=1;i<6;i++)
   {
     hideCtrl('tabnav'+i);
   }
  showCtrl('tabnav'+val);
}
