// ========= AFFICHAGE DES FLASH

function afficheFlash(version,nom,largeur,hauteur){
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+version+',0,0,0" width='+largeur+' height='+hauteur+'>\n');
	document.write('<param name="allowScriptAccess" value="sameDomain" />\n');
	document.write('<param name="movie" value='+nom+' />\n');
	document.write('<param name="quality" value="high" />\n');
	document.write('<param name="wmode" value="transparent" />\n');
	document.write('<embed src='+nom+' quality="high" wmode="transparent" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" width='+largeur+' height='+hauteur+'></embed>\n');
	document.write('</object>\n');
}	

// ========= AFFICHAGE DES FLASH



// ========= AFFICHAGE PLAYER FLV

function affichePlayer(fichier,nom,largeur,hauteur){
	document.write('<object type=\"application/x-shockwave-flash\" height='+hauteur+' width='+largeur+' data="flash/player_flv_maxi.swf">\n');
	document.write('<param value=\"flash/player_flv_maxi.swf\" name=\"movie\" />\n');
	document.write('<param value=\"true\" name=\"allowFullScreen\" />\n');
	document.write('<param value=\"flv=../images/para/'+nom+'&amp;startimage=images/para/'+fichier+'&amp;margin=0&amp;width='+largeur+'&amp;height='+hauteur+'&amp;showplayer=always&amp;autoplay=1\" name=\"FlashVars\" />\n');
	document.write('</object>\n');
}	

// ========= AFFICHAGE PLAYER FLV

function survolLigne(ligne){ // permet le survol des lignes du tableau
		document.getElementById(ligne).style.backgroundColor="#e7e7e7";
}
	
function sortieSurvolLigne(ligne){ // permet d'arrêter le survol des lignes du tableau
		document.getElementById(ligne).style.backgroundColor="#ffffff";
}

function afficheSsmenu(listeMenu,parentMenu){
	document.getElementById(listeMenu).style.display="block";
	parentMenu.style.backgroundColor="#c0e6fd";
}

function cacheSsmenu(listeMenu,parentMenu){
	document.getElementById(listeMenu).style.display="none";
	parentMenu.style.backgroundColor="#9ed2f2";
}

// AJAX par idweb
var http_request = false; 
function makeRequest(url)
{
	if (window.XMLHttpRequest) http_request = new XMLHttpRequest(); 
	else if (window.ActiveXObject) http_request = new ActiveXObject("Microsoft.XMLHTTP"); 
	http_request.onreadystatechange = alertContents; 
	http_request.open('GET', url, true); 
	http_request.send(null); 
} 

function alertContents()
{ 
	if (http_request.readyState == 4) 
	{ 
		if (http_request.status == 200) eval(http_request.responseText); 
		else alert('Erreur de chargement!'); 
	} 
} 

function change_div(nom,valeur)
{
	if (document.getElementById) document.getElementById(nom).innerHTML = valeur;
	else if (document.all) document.all[nom].innerHTML = valeur;
}
// AJAX par idweb


function nb_modele()
{
	var mid=document.monform.MARQUE.options[document.monform.MARQUE.selectedIndex].value;
	var modid=document.monform.MODELE.options[document.monform.MODELE.selectedIndex].value; 
	var mid=document.monform.MARQUE.options[document.monform.MARQUE.selectedIndex].value; 
	var prix=document.monform.PRIX.options[document.monform.PRIX.selectedIndex].value; 
	var ener=document.monform.ENERGIE.options[document.monform.ENERGIE.selectedIndex].value; makeRequest('ajax-nb-occasion.php?MID='+mid+'&MODID='+modid+'&PRIX='+prix+'&ENERGIE='+ener);
}

function verif(monform)
{
	n=0;
	for (var i=0;i<document.comp.elements['ID[]'].length;i++)
	{
		if (document.comp.elements['ID[]'][i].checked) n++;
	}
	if (n<2)
	{
		alert('Vous devez sélectionner 2 ou 3 occasions pour les comparer');
		return false;
	}
	if (n>3)
	{
		alert('Vous devez sélectionner 2 ou 3 occasions pour les comparer');
		return false;
	}
	return true;
}

function verifConditions(monform)
{
	if(monform.accepteConditions.checked==false)
	{
		alert("Vous devez lire et accepter les conditions générales de vente \n pour poursuivre votre commande");
		return false;
	}
	return true;
}

function validationForm(monform) // validation des formualires
		{
			var reg_email = /^[A-Za-z0-9\.\-_]+[@][A-Za-z0-9\-\.]+[\.][A-Za-z][A-Za-z][A-Za-z]?$/;
			if(monform.email)
			{
				monform.email.style.backgroundColor="";
			}
			if(monform.mdp)
			{
				monform.mdp.style.backgroundColor="";
			}
			if(monform.nom)
			{
				monform.nom.style.backgroundColor="";
			}
			if(monform.prenom)
			{
				monform.prenom.style.backgroundColor="";
			}
			if(monform.adresse)
			{
				monform.adresse.style.backgroundColor="";
			}
			if(monform.cp)
			{
				monform.cp.style.backgroundColor="";
			}
			if(monform.ville)
			{
				monform.ville.style.backgroundColor="";
			}
			if(monform.pays)
			{
				monform.pays.style.backgroundColor="";
			}
			if(monform.tel)
			{
				monform.tel.style.backgroundColor="";
			}
			if(monform.nomAmi)
			{
				monform.nomAmi.style.backgroundColor="";
			}
			if(monform.prenomAmi)
			{
				monform.prenomAmi.style.backgroundColor="";
			}
			if(monform.emailAmi)
			{
				monform.emailAmi.style.backgroundColor="";
			}
			if(monform.marque)
			{
				monform.marque.style.backgroundColor="";
			}
			if(monform.modele)
			{
				monform.modele.style.backgroundColor="";
			}
			if(monform.km)
			{
				monform.km.style.backgroundColor="";
			}
			if(monform.date)
			{
				monform.date.style.backgroundColor="";
			}
			if(monform.nom)
			{
				if (monform.nom.value=='')
				{
					alert("Veuillez indiquer votre nom");
					monform.nom.style.backgroundColor="#FFE400";
					monform.nom.focus();
					return false;
				}
			}
			if(monform.prenom)
			{
				if (monform.prenom.value=='')
				{
					alert("Veuillez indiquer votre prénom");
					monform.prenom.style.backgroundColor="#FFE400";
					monform.prenom.focus();
					return false;
				}
			}
			if(monform.adresse)
			{
				if (monform.adresse.value=='')
				{
					alert("Veuillez indiquer votre adresse");
					monform.adresse.style.backgroundColor="#FFE400";
					monform.adresse.focus();
					return false;
				}
			}
			if(monform.cp)
			{
				if (monform.cp.value=='')
				{
					alert("Veuillez indiquer votre code postal");
					monform.cp.style.backgroundColor="#FFE400";
					monform.cp.focus();
					return false;
				}
			}
			if(monform.ville)
			{
				if (monform.ville.value=='')
				{
					alert("Veuillez indiquer votre ville");
					monform.ville.style.backgroundColor="#FFE400";
					monform.ville.focus();
					return false;
				}
			}
			if(monform.pays)
			{
				if (monform.pays.options[monform.pays.selectedIndex].value=='0')
				{
					alert("Veuillez indiquer votre pays");
					monform.pays.style.backgroundColor="#FFE400";
					monform.pays.focus();
					return false;
				}
			}
			if(monform.tel)
			{
				if (monform.tel.value=='')
				{
					alert("Veuillez indiquer votre téléphone");
					monform.tel.style.backgroundColor="#FFE400";
					monform.tel.focus();
					return false;
				}
				else{
					if (monform.tel.value.length!=10 || isNaN(monform.tel.value))
					{
						alert("Le numéro de téléphone entré n'est pas valide (10 chiffres)");
						monform.tel.style.backgroundColor="#FFE400";
						monform.tel.focus();
						return false;
					}
				}
			}
			if(monform.email)
			{
				if (monform.email.value=='')
				{
					alert("Veuillez indiquer votre adresse email");
					monform.email.style.backgroundColor="#FFE400";
					monform.email.focus();
					return false;
				}
				if(!reg_email.test(monform.email.value))
				{
					alert("Le format de votre adresse email est invalide");
					monform.email.style.backgroundColor="#FFE400";
					monform.email.focus();
					return false;
				}
			}
			if(monform.mdp)
			{
				if (monform.mdp.value=='')
				{
					alert("Veuillez indiquer votre mot de passe");
					monform.mdp.style.backgroundColor="#FFE400";
					monform.mdp.focus();
					return false;
				}
			}
			if(monform.mdp2)
			{
				if (monform.mdp2.value!=monform.mdp.value)
				{
					alert("Les mots de passe entrés ne correspondent pas");
					monform.mdp2.style.backgroundColor="#FFE400";
					monform.mdp2.focus();
					return false;
				}
			}
			if(monform.nomAmi)
			{
				if (monform.nomAmi.value=='')
				{
					alert("Veuillez indiquer le nom de votre ami");
					monform.nomAmi.style.backgroundColor="#FFE400";
					monform.nomAmi.focus();
					return false;
				}
			}
			if(monform.prenomAmi)
			{
				if (monform.prenomAmi.value=='')
				{
					alert("Veuillez indiquer le prénom de votre ami");
					monform.prenomAmi.style.backgroundColor="#FFE400";
					monform.prenomAmi.focus();
					return false;
				}
			}
			if(monform.emailAmi)
			{
				if (monform.emailAmi.value=='')
				{
					alert("Veuillez indiquer l'adresse email de votre ami");
					monform.emailAmi.style.backgroundColor="#FFE400";
					monform.emailAmi.focus();
					return false;
				}
				if(!reg_email.test(monform.emailAmi.value))
				{
					alert("Le format de l'adresse email de votre ami est invalide");
					monform.emailAmi.style.backgroundColor="#FFE400";
					monform.emailAmi.focus();
					return false;
				}
			}
			if(monform.marque)
			{
				if (monform.marque.value=='')
				{
					alert("Veuillez indiquer la marque de votre véhicule");
					monform.marque.style.backgroundColor="#FFE400";
					monform.marque.focus();
					return false;
				}
			}
			if(monform.modele)
			{
				if (monform.modele.value=='')
				{
					alert("Veuillez indiquer le modèle de votre véhicule");
					monform.modele.style.backgroundColor="#FFE400";
					monform.modele.focus();
					return false;
				}
			}
			if(monform.km)
			{
				if (monform.km.value=='')
				{
					alert("Veuillez indiquer le kilométrage de votre véhicule");
					monform.km.style.backgroundColor="#FFE400";
					monform.km.focus();
					return false;
				}
			}
			if(monform.date)
			{
				if (monform.date.value=='')
				{
					alert("Veuillez indiquer la date de mise en circulation de votre véhicule");
					monform.date.style.backgroundColor="#FFE400";
					monform.date.focus();
					return false;
				}
			}
			return true;
		}

		/* oubli de mot de passe */
		function validationForm2(monform)
		{
			var reg_email = /^[A-Za-z0-9\.\-_]+[@][A-Za-z0-9\-\.]+[\.][A-Za-z][A-Za-z][A-Za-z]?$/;
			
			if (monform.emailOubli.value=='')
			{
				alert("Veuillez indiquer votre adresse email");
				return false;
			}
			if(!reg_email.test(monform.emailOubli.value))
			{
				alert("Le format de votre adresse email est invalide");
				return false;
			}
			return true;
		}
		
		/* filleul */
		function validFilleul(monform)
		{
			var reg_email = /^[A-Za-z0-9\.\-_]+[@][A-Za-z0-9\-\.]+[\.][A-Za-z][A-Za-z][A-Za-z]?$/;
			
			if (monform.email_filleul.value=='')
			{
				alert("Veuillez indiquer une adresse email");
				return false;
			}
			if(!reg_email.test(monform.email_filleul.value))
			{
				alert("Le format de l'adresse email est invalide");
				return false;
			}
			return true;
		}

		// ================================================ ANIMATION FONDU PHOTOS GALERIE
	var Animation = function(imageAnimee)
	{
		this.nomImage=imageAnimee; // nom de l'image pour faire l'animation
		this.listeImage=new Array; // liste des images pour chaque anime
		this.interval=0; 
		this.j=0; // variable utilisée pour indiquer le rang de l'image en cours
		
		this.ajoutImage = function(nomVisuel) // fonction permettant d'ajouter une image dans la liste
		{
			this.listeImage.push(nomVisuel);
		}
		
		this.ajoutVitesse = function(valeurVitesse) // fonction permettant d'indiquer la vitesse de défilement
		{
			this.vitesse = valeurVitesse;
		}
		
		this.ajoutDuree = function(valeurDuree) // fonction permettant d'indiquer la durée du fadding
		{
			this.duree = valeurDuree;
		}
		
		this.runSlide = function() // fonction pour l'animation
		{
			if (document.all)
			{
				
				if(navigator.userAgent.indexOf("Opera")!=-1)
				{
					
				}
				else
				{
					document.getElementById(this.nomImage).style.filter="blendTrans(duration=2)"; // indication du filtre à utiliser pour le fading des images
					document.getElementById(this.nomImage).style.filter="blendTrans(duration=this.duree)";
					document.getElementById(this.nomImage).filters.blendTrans.Apply();
				}
			}
			var p = this.listeImage.length; // variable indiquant le nombre d'images de l'anime
			
			document.getElementById(this.nomImage).src = this.listeImage[this.j]; // indique le nom de l'image
			if (document.all)
			{
				if(navigator.userAgent.indexOf("Opera")!=-1)
				{
					
				}
				else
				{
					document.getElementById(this.nomImage).filters.blendTrans.Play() // actionne le filtre pour l'image
				}
			}
			this.j++; // incrémente le rang de l'image en cours (pour passer à la suivante
			if (this.j > (p-1)) this.j=0 // si le rang de l'image en cours est supérieure au nombre d'images de l'anime on retourne à la première image
			
			var thisObj = this; // permet de récupérer le nom de l'occurence de l'objet
			this.interval = setTimeout(function(){ thisObj.runSlide() }, this.vitesse) // permet de changer l'image en fonctin de la vitesse choisie 
		}
		
		this.stopSlide = function() // permet de stopper le défilement des images (sur un évènement onclick, onmouseover par exemple)
		{
			clearTimeout(this.interval);
		}
	}
// ================================================ ANIMATION FONDU PHOTOS GALERIE
