function Set_Cookie( name, value, expires, path, domain, secure ) 
{
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct 
expires time, the current script below will set 
it for x number of days, to make it for hours, 
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
( ( path ) ? ";path=" + path : "" ) + 
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}

function Get_Cookie( name ) {
	
var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
if ( ( !start ) &&
( name != document.cookie.substring( 0, name.length ) ) )
{
return "";
}
if ( start == -1 ) return "";
var end = document.cookie.indexOf( ";", len );
if ( end == -1 ) end = document.cookie.length;
return unescape( document.cookie.substring( len, end ) );
}

function filtreByMarque(val)
{
  document.location.href='index.php?mode=0&search=1&categorie=0&motcles=&marque='+val;
}
//Change une image
function changeImage(img,imgName,x,y)
{
  imgName.src = img; 
  imgName.width=x;
  imgName.height=y; 
}
function fadeIn(img) { 
 var photo = document.images[img];  
 var MSIE = navigator.appName.indexOf('Microsoft'); 
 if (MSIE == 0) { 
     photo.style.visibility='hidden';  
     photo.style.filter='blendTrans(duration=0.2)';  
     photo.filters.blendTrans.Apply();  
     photo.style.visibility='visible';  
     photo.filters.blendTrans.Play();  
 } else {  
     photo.style.visibility='visible';  
 }
}
//Messagerie instantanée
function msginstant(val) 
{
  nomPage="msginstant.php";
  window.open(nomPage,'','width=540,height=490,toolbar=0,location=0,directories=0,menuBar=0,scrollbars=yes,resizable=yes,left=100,top=100'); 
}

//Affichage d'une image plein écran
function zoomImage(chemin,cat)
{
  nomPage="zoomimage.php";
  nomPage=nomPage+"?nomimage="+chemin+"&categorie="+cat;
  window.open(nomPage,'','width=720,height=690,toolbar=0,location=0,directories=0,menuBar=0,scrollbars=yes,resizable=yes,left=2,top=2');   
}
//Affichage d'une image plein écran
function zoomImageGen(chemin)
{
  nomPage=chemin;
  window.open(nomPage,'','width=660,height=520,toolbar=0,location=0,directories=0,menuBar=0,scrollbars=yes,resizable=yes,left=40,top=40');   
}
//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=640,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="tarifscolis.php";
  window.open(nomPage,'','width=680,height=480,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) 
{
  nomPage="page.php?mode=9&annonce="+val;
  window.open(nomPage,'','width=690,height=600,toolbar=0,location=0,directories=0,menuBar=0,scrollbars=yes,resizable=yes,left=100,top=20'); 
}

//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'); 
}

//Affichage des fenêtres génériques
function openWm(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'); 
}
//Création du filtre sur les départements
function filtreDepartements(val) 
{
  nomPage="cartefrance.php?codepostal="+val;
  param="width=490,height=560,left=50,top=50,toolbar=0,location=0,directories=0,menuBar=0,scrollbars=yes,resizable=yes";  
  window.open(nomPage,'',param); 
}
//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=1,resizable=1,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=500','toolbar=0,location=0,directories=0,menuBar=0,scrollbars=1,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;
}
//Controle saisie infos newsletter
function verifie_newsletter()
{
  var email = document.newsletter.tmp_email.value;
  if ( !arobaceok(email) || email == "votreadresse@mail.com" ) 
   {
	 return false;
   }
 
  var inscription=document.newsletter.tmp_fct[0].checked;
      
  if ( inscription==true )
   {
	 var intvtt=document.newsletter.intvtt.checked;
	 var introute=document.newsletter.introute.checked;
	 var intbmx=document.newsletter.intbmx.checked;
	 var inttrial=document.newsletter.inttrial.checked;
	 var intcyclo=document.newsletter.intcyclo.checked;
   
	 if ( !intvtt && !introute && !intbmx && !inttrial && !intcyclo )
	   {
		 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);
}
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 showHideCtrl(idctrl)
{
 ctrl=document.getElementById(idctrl);
 if ( ctrl==null ) return;
 if ( ctrl.style.display=="none" ) ctrl.style.display="";
 else ctrl.style.display="none";  
}
function checkallbox(ctrlcall,name,maxval)
{
  for (i=0;i<maxval;i++)
  {
    ctrl=document.getElementById(name+i);
    if ( ctrl==null ) continue;
    ctrl.checked=(ctrlcall.checked==true)?true:false;
  }
}
function gotoUrl(url)
{
  win=window.open(); win.location.href=url;
}