
function initStatLyr() {
	var statLyr = new Glider("glideDiv",875,105,null,null,0,-1);
  statLyr.show();
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.id; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' doit contenir une adresse email.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' doit contenir des chiffres.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' est vide.\n'; }
  } if (errors) alert('Attention:\n'+errors);
  document.MM_returnValue = (errors == '');
}
function o(id)
	{
		if(document.getElementById)	return document.getElementById(id);
		else if(document.all)		return document.all[id];
		else if(document.layers)	return document.layers[id];
	}

function cherche_systeme() {

// on crée la variable qui accueillera le nom du système d'exploitation
var systeme = "";

// on teste si on trouve la mention '95' dans le nom du navigateur
if ( navigator.userAgent.indexOf('95') != -1 ) { systeme = 'Windows 95'; }

// on teste si on trouve la mention '98' dans le nom du navigateur
else if ( navigator.userAgent.indexOf('98') != -1 ) { systeme = 'Windows 98'; }
else if ( navigator.userAgent.indexOf('NT') != -1 ) { systeme = 'Windows NT'; }
else if ( navigator.userAgent.indexOf('Mac') != -1 ) { systeme = 'Mac OS'; }

// si rien n'a été reconnu...
else { systeme = 'Inconnu'; }

// on affecte la variable 'systeme' au formulaire
return (systeme);
}

	function renvoietolist(){
	o('renvoietolist').submit();
	}


var ns6=document.getElementById&&!document.all

function restrictinput(maxlength,e,placeholder){
if (window.event&&event.srcElement.value.length>=maxlength)
return false
else if (e.target&&e.target==eval(placeholder)&&e.target.value.length>=maxlength){
var pressedkey=/[a-zA-Z0-9\.\,\/]/ 
if (pressedkey.test(String.fromCharCode(e.which)))
e.stopPropagation()
}
}

function countlimit(maxlength,e,placeholder){
var theform=eval(placeholder)
var lengthleft=maxlength-theform.value.length
var placeholderobj=document.all? document.all[placeholder] : document.getElementById(placeholder)
if (window.event||e.target&&e.target==eval(placeholder)){
if (lengthleft<0)
theform.value=theform.value.substring(0,maxlength)
placeholderobj.innerHTML=lengthleft
}
}

function displaylimit(thename, theid, thelimit){
var theform=theid!=""? document.getElementById(theid) : thename
var limit_text='Il vous reste <b><span id="'+theform.toString()+'">'+thelimit+'</span></b> caractères disponibles.'
if (document.all||ns6)
document.write(limit_text)
if (document.all){
eval(theform).onkeypress=function(){ return restrictinput(thelimit,event,theform)}
eval(theform).onkeyup=function(){ countlimit(thelimit,event,theform)}
}
else if (ns6){
document.body.addEventListener('keypress', function(event) { restrictinput(thelimit,event,theform) }, true); 
document.body.addEventListener('keyup', function(event) { countlimit(thelimit,event,theform) }, true); 
}
}
function initStatLyr() {
	var statLyr = new Glider("glideDiv",875,105,null,null,0,-1);
  statLyr.show();
}



function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //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=MM_preloadImages.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 ajouteinfo(liste, elem){

if(document.getElementById(liste).options[document.getElementById(liste).selectedIndex].value=="autre")
{
//alert("mais de quel droit tu te permets \nde changer le nom de \nla VOITURE	");	
document.getElementById(elem).style.visibility="visible";
}	

if(document.getElementById(liste).options[document.getElementById(liste).selectedIndex].value!="autre")
{
//alert("mais de quel droit tu te permets \nde changer le nom de \nla VOITURE	");	
document.getElementById(elem).style.visibility="hidden";
}

}
function afficheVignette(cheminVignette,cheminMaxi)
	{
	document.write('<A HREF="javascript:afficheMaxi(\''+cheminMaxi+'\')"><IMG SRC="'+cheminVignette+'" HSPACE=0 VSPACE=0 BORDER=0 ALT="cliquez ici pour voir en grand"></A>');
	}
function afficheMaxi(chemin)
	{
	i1 = new Image;
	i1.src = chemin;
	html = '<HTML><HEAD><TITLE>4x4Live.com - Photos</TITLE></HEAD><BODY LEFTMARGIN=0 MARGINWIDTH=0 TOPMARGIN=0 MARGINHEIGHT=0 bgcolor=#000000><CENTER><IMG SRC="data/SmallJPEGCache.php?im=../'+chemin+'&maxsize=800" BORDER=0 NAME=imageTest onLoad="window.resizeTo(document.imageTest.width+14,document.imageTest.height+32)"></CENTER></BODY></HTML>';
	popupImage = window.open('','_blank','toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=1');
	popupImage.document.open();
	popupImage.document.write(html);
	popupImage.document.close()
	};
	
	
function afficheVignette2(cheminVignette,cheminMaxi)
	{
	document.write('<A HREF="javascript:afficheMaxi2(\''+cheminMaxi+'\')"><IMG SRC="'+cheminVignette+'" HSPACE=0 VSPACE=0 BORDER=0 ALT="cliquez ici pour voir en grand"></A>');
	}
function afficheMaxi2(chemin)
	{
	i1 = new Image;
	i1.src = chemin;
	html = '<HTML><HEAD><TITLE>4x4Live.com - Photos</TITLE></HEAD><BODY LEFTMARGIN=0 MARGINWIDTH=0 TOPMARGIN=0 MARGINHEIGHT=0 bgcolor=#000000><CENTER><IMG SRC="data/SmallJPEGCache.php?im='+chemin+'&maxsize=800" BORDER=0 NAME=imageTest onLoad="window.resizeTo(document.imageTest.width+14,document.imageTest.height+32)"></CENTER></BODY></HTML>';
	popupImage = window.open('','_blank','toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=1');
	popupImage.document.open();
	popupImage.document.write(html);
	popupImage.document.close()
	};
	


function MultiSelector( list_target, max ){

	// Where to write the list
	this.list_target = list_target;
	// How many elements?
	this.count = 0;
	// How many elements?
	this.id = 0;
	// Is there a maximum?
	if( max ){
		this.max = max;
	} else {
		this.max = -1;
	};
	
	/**
	 * Add a new file input element
	 */
	this.addElement = function( element ){

		// Make sure it's a file input element
		if( element.tagName == 'INPUT' && element.type == 'file' ){

			// Element name -- what number am I?
			element.name = 'file_' + this.id++;

			// Add reference to this object
			element.multi_selector = this;

			// What to do when a file is selected
			element.onchange = function(){

				// New file input
				var new_element = document.createElement( 'input' );
				new_element.type = 'file';

				// Add new element
				this.parentNode.insertBefore( new_element, this );

				// Apply 'update' to element
				this.multi_selector.addElement( new_element );

				// Update list
				this.multi_selector.addListRow( this );

				// Hide this: we can't use display:none because Safari doesn't like it
				this.style.position = 'absolute';
				this.style.left = '-1000px';

			};
			// If we've reached maximum number, disable input element
			if( this.max != -1 && this.count >= this.max ){
				element.disabled = true;
			};

			// File element counter
			this.count++;
			// Most recent element
			this.current_element = element;
			
		} else {
			// This can only be applied to file input elements!
			alert( 'Error: not a file input element' );
		};

	};

	/**
	 * Add a new row to the list of files
	 */
	this.addListRow = function( element ){

		// Row div
		var new_row = document.createElement( 'div' );

		// Delete button
		var new_row_button = document.createElement( 'input' );
		new_row_button.type = 'button';
		new_row_button.value = 'Effacer';

		// References
		new_row.element = element;

		// Delete function
		new_row_button.onclick= function(){

			// Remove element from form
			this.parentNode.element.parentNode.removeChild( this.parentNode.element );

			// Remove this row from the list
			this.parentNode.parentNode.removeChild( this.parentNode );

			// Decrement counter
			this.parentNode.element.multi_selector.count--;

			// Re-enable input element (if it's disabled)
			this.parentNode.element.multi_selector.current_element.disabled = false;

			// Appease Safari
			//    without it Safari wants to reload the browser window
			//    which nixes your already queued uploads
			return false;
		};

		// Set row value
		new_row.innerHTML = element.value;

		// Add button
		new_row.appendChild( new_row_button );

		// Add it to the list
		this.list_target.appendChild( new_row );
		
	};

};


function ConfirmDelete()
{
if(!confirm('Etes-vous sûr de vouloir effacer cette entree?'))
	return(false);
else
	return (true);
}
		

function verif_agenda_membres()
{
	var go=1;

 if(document.form.type.value == "")  {
   alert("Vous devez choisir un type d'événement.");
   return false;
    go=0;
    }

 if(document.form.pays.value == "")  {
   alert("Si l'événement ne se déroule pas en France vous devez choisir un pays.");
   return false;
    go=0;
    }

 if(document.form.day.value == "")  {
   alert("Vous devez choisir le jour de départ de votre évenement.");
   return false;
    go=0;
    }

if(document.form.month.value == "")  {
   alert("Vous devez choisir le mois de départ de votre événement.");
   return false;
    go=0;
    }

 if(document.form.year.value == "")  {
   alert("Vous devez choisir l'année de départ de votre événement.");
   return false;
    go=0;
    }

 if(document.form.day2.value == "")  {
   alert("Vous devez choisir le jour de fin de votre événement.");
   return false;
    go=0;
    }

 if(document.form.month2.value == "")  {
   alert("Vous devez choisir le mois de fin de votre événement.");
   return false;
    go=0;
    }

 if(document.form.year2.value == "")  {
   alert("Choisissez l'année de fin de votre événement.");
   return false;
    go=0;
    }

 if(document.form.titre.value == "")  {
   alert("Vous n'avez pas donné de titre à votre événement.");
   return false;
    go=0;
  }

 if(document.form.description.value == "")  {
   alert("Vous n'avez pas décrit votre événement.");
   return false;
    go=0;
    }

 if(document.form.organisateur.value == "")  {
   alert("Vous devez nommer l'organisateur.");
   return false;
    go=0;
    }
 if(document.form.telephone.value == "")  {
   alert("Vous devez indiquer un numéro de téléphone.");
   return false;
    go=0;
    }

if(isNaN(parseInt(document.form.telephone.value))){
	   alert("Champ téléphone : n'inscrivez que des chiffres.");
   return false;
    go=0;
}
	
 if((document.form.telephone.value == "") && (document.form.mail.value == "") && (document.form.fax.value == "") && (document.form.site.value == "")) {
   alert("Vous devez indiquer, au moins, un moyen de vous contacter.");
   return false;
    go=0;
    }



if ( go == 1)
{
document.form.submit();
}

}


 function verif()
    {
     // le champs commentaire ne doit pas etre vide
     if (document.addannonce.id_marque.value.length <1)
       {
        alert('Vous devez sélectionner une marque');
        return false;
		       }
			   }

function verif_formulaire()
{
var go=1;
/*
 if(document.ajout_annonce.id_produit.value == "")  {
   alert("Veuillez sélectionner un modèle");
   return false;
   go=0;
  }
  
  
   if ( (document.ajout_annonce.id_produit.value == "autre") && (document.ajout_annonce.modele_autre.value == "") )
{
   alert("Veuillez saisir votre modèle ");
   return false;
    go=0;
  } 
  
 
 
if (document.ajout_annonce.version.value == "") 
{
   alert("Veuillez sélectionner la version ");
   return false;
    go=0;
  } 
  
  
  if ( (document.ajout_annonce.version.value == "autre") && (document.ajout_annonce.version_autre.value == "") )
{
   alert("Veuillez saisir votre version ");
   return false;
    go=0;
  } 
  
 
  
  
 
 if(document.ajout_annonce.immatriculation.value == "")  {
   alert("Veuillez saisir l\'immatriculation");
   return false;
    go=0;
  }
 
 
  if(document.ajout_annonce.carburation.value == "")  {
   alert("Veuillez sélectionner l'Energie");
   return false;
    go=0;
  }
 
  if(document.ajout_annonce.km.value == "")  {
   alert("Veuillez saisir le kilométrage");
   return false;
    go=0;
  }
   if(document.ajout_annonce.puissf.value == "")  {
   alert("Veuillez saisir la puissance fiscale");
   return false;
    go=0;
  }
    if(document.ajout_annonce.porte.value == "")  {
   alert("Veuillez saisir le nombre de porte");
   return false;
    go=0;
  }
  if(document.ajout_annonce.prix_annonces.value == "")  {
   alert("Veuillez saisir le prix");
   return false;
    go=0;
  }
  if(document.ajout_annonce.couleur.value == "")  {
   alert("Veuillez saisir la couleur");
   return false;
    go=0;
  }
 // on attribue la valeur de la saisie à une variable pour plus de commodité
var saisie = document.ajout_annonce.aa.value;

// on compare cette variable à '' (vide) ou à ' ' (espace)
if ( saisie == '' || saisie == ' ' ) {

// si la saisie est vide ou égale à un espace on lance ceci :
window.alert('Vous n\'avez pas rempli le champ année de mise en circulation.');
return false;
go=0;
}
if (saisie.length <4)
{

window.alert('Le champ année de mise en circulation nécessite 4 chiffres.');
return false;
go=0;
}
   
  var saisid = document.ajout_annonce.dept.value;

// on compare cette variable à '' (vide) ou à ' ' (espace)
if ( saisid == '' || saisid == ' ' ) {

// si la saisie est vide ou égale à un espace on lance ceci :
window.alert('Vous n\'avez pas rempli le champ département.');
return false;
go=0;
}
 
if (saisid.length <2)
{
window.alert('Le champ année de mise en circulation nécessite 2 chiffres.');
return false;
go=0;
}
   
  */
  
  if ( go == 1)
  {
document.ajout_annonce.submit();
}

}


function verif_formulaire_modif()
{
var go=1;
 
/*
 if(document.modif_annonce.immatriculation.value == "")  {
   alert("Veuillez saisir l\'immatriculation");
   return false;
    go=0;
  }
 
 
  if(document.modif_annonce.carburation.value == "")  {
   alert("Veuillez sélectionner l'Energie");
   return false;
    go=0;
  }
 
  if(document.modif_annonce.km.value == "")  {
   alert("Veuillez saisir le kilométrage");
   return false;
    go=0;
  }
   if(document.modif_annonce.puissf.value == "")  {
   alert("Veuillez saisir la puissance fiscale");
   return false;
    go=0;
  }
    if(document.modif_annonce.porte.value == "")  {
   alert("Veuillez saisir le nombre de porte");
   return false;
    go=0;
  }
  


// on attribue la valeur de la saisie à une variable pour plus de commodité
var saisie = document.modif_annonce.aa.value;

// on compare cette variable à '' (vide) ou à ' ' (espace)
if ( saisie == '' || saisie == ' ' ) {

// si la saisie est vide ou égale à un espace on lance ceci :
window.alert('Vous n\'avez pas rempli le champ année de mise en circulation.');
return false;
go=0;
}
if (saisie.length <4)
{

window.alert('Le champ année de mise en circulation nécessite 4 chiffres.');
return false;
go=0;
}
   
  var saisid = document.modif_annonce.dept.value;

// on compare cette variable à '' (vide) ou à ' ' (espace)
if ( saisid == '' || saisid == ' ' ) {

// si la saisie est vide ou égale à un espace on lance ceci :
window.alert('Vous n\'avez pas rempli le champ département.');
return false;
go=0;
}
 
if (saisid.length <2)
{
window.alert('Le champ département nécessite 2 chiffres.');
return false;
go=0;
}
    
  if(document.modif_annonce.prix_annonces.value == "")  {
   alert("Veuillez saisir le prix");
   return false;
    go=0;
  }
  if(document.modif_annonce.couleur.value == "")  {
   alert("Veuillez saisir la couleur");
   return false;
    go=0;
  }
 */
  
  if ( go == 1)
  {
document.modif_annonce.submit();
}
}

