function verifNombre(nombre){
	if(isNaN(nombre)){
		return false;
	}else{
		return true;
	}
}
function verifValeur(monMin,monMax,elmt){
	monMin=parseInt(document.getElementById(monMin).value);
	monMax=parseInt(document.getElementById(monMax).value);
	tmp="";
	elmt.className="select-orange";
	var valeurTest=elmt.value.toString();
	if(valeurTest!=""){
		var tailleChar=valeurTest.length;
		for(var i=0;i<tailleChar;i++){
			tmp = tmp + valeurTest.charAt(i);
			if (valeurTest.charAt(i) == ","){
				tmp = tmp.replace(",",".");
			}
		}
	}
	elmt.value=tmp;
	if(verifNombre(elmt.value)==false){
		alert("Le résultats doit être un nombre supèrieur à "+monMin+' et infèrieur à '+monMax);
		elmt.value='';
		elmt.className="";
		return false;
	}
	if(parseInt(elmt.value)<monMin && verifNombre(elmt.value)){
		alert("Le résultats doit être supèrieur à :"+monMin);
		elmt.value='';
		elmt.className="";
		return false;
	}else if(parseInt(elmt.value)>monMax && verifNombre(elmt.value)){
		alert("Le résultats doit être infèrieur à :"+monMax);
		elmt.value='';
		elmt.className="";
		return false;
	}else{
		return true;
	}
	
	
}
function Quantite(id,variation){
	prixbase=document.getElementById('prixbase_'+id);
	prix=document.getElementById('prix_'+id);
	monprix=document.getElementById('monprix_'+id);
	quantite=document.getElementById('quantite_'+id);
	
	if(variation=="+"){
		quantite.value=parseFloat(quantite.value)+1;
	}
	if(variation=="-" && document.getElementById('quantite_'+id).value>1){
		quantite.value=parseFloat(quantite.value)-1;
	}
	prix.value=Math.round((parseFloat(prixbase.value)*quantite.value)*100)/100;
	tab_temp=prix.value.split(".");
	temp="";
	if(tab_temp.length>1){
		if(tab_temp[1].length<2){
			temp=0;
		}
	}
	monprix.value=prix.value+temp+" € TTC";
}


//var lockOutils=0;
var mail = /^[\w\-]+(\.[\w\-]+)*@[\w\-]+(\.[\w\-]+)*\.[\w\-]{2,}$/;
function Sur(url){
	sur=confirm("Etest-vous certains de vouloir effectuer cette opération?");
	if(sur && url!=''){
		window.location=url;
	}else if(sur){
		return true;
	}
}
function estCeUnMail(champs) {
	reponse=mail.test(champs.value);
	if (reponse) {
		return true;
	}else {
		return false;
	}
} 
function VerificationEmail(elm){
	if (elm.value.indexOf("@") != "-1" &&elm.value.indexOf("@") != "0" && elm.value.indexOf(".") != "-1" && elm.value.indexOf(".") != "0" && elm.value != ""){
		elm.style.backgroundColor="";
		return true;
	}
	elm.style.backgroundColor="#D0C775";
	complete=0;
	return complete;
}
function VerificationCompte(){
	monform=document.creation_compte;
	/*if(monform.acceptation.checked!=1){
		alert("Vous devez accepter la charte du site avant de vous enregister ou modifier votre compte");
		return false;
	}
	*/
	if(monform.civilite[0].checked!=true && monform.civilite[1].checked!=true && monform.civilite[1].checked!=true){
		alert("Veuillez choisir la civilité");
		return false;
	}
	if(monform.nom.value==""){
		alert("Veuillez entrer votre nom");
		monform.nom.focus();
		return false;
	}
	if(monform.prenom.value==""){
		alert("Veuillez entrer votre prénom");
		monform.prenom.focus();
		return false;
	}
	if(!estCeUnMail(monform.email)){
		alert("Veuillez entrer une adresse e-mail valide");
		monform.email.focus();
		return false;
	}
	if((monform.password.value=="" || monform.password.value.length<6) && monform.maj.value!=1){
		alert("Veuillez entrer votre mot de passe de plus de 6 caractères");
		monform.password.focus();
		return false;
	}
	if(monform.password.value!=monform.password_conf.value && monform.maj.value!=1){
		alert("Attention, le mot de passe de confirmation ne correspond pas");
		monform.password.focus();
		return false;
	}
	monform.submit();
}
function VerifAdresse(){
	monform=document.carnet_modif;
	/*if(monform.acceptation.checked!=1){
		alert("Vous devez accepter la charte du site avant de vous enregister ou modifier votre compte");
		return false;
	}
	*/
	if(monform.nom_carnet.value==""){
		alert("Veuillez entrer votre nom pour cette adresse");
		monform.nom.focus();
		return false;
	}
	if(monform.civilite[0].checked!=true && monform.civilite[1].checked!=true && monform.civilite[1].checked!=true){
		alert("Veuillez choisir la civilité");
		return false;
	}
	if(monform.nom.value==""){
		alert("Veuillez entrer votre nom");
		monform.nom.focus();
		return false;
	}
	if(monform.prenom.value==""){
		alert("Veuillez entrer votre prénom");
		monform.prenom.focus();
		return false;
	}
	if(monform.adresse.value==""){
		alert("Veuillez entrer une adresse");
		monform.adresse.focus();
		return false;
	}
	if(monform.cp.value==""){
		alert("Veuillez entrer un code podtal");
		monform.cp.focus();
		return false;
	}
	if(monform.ville.value==""){
		alert("Veuillez entrer une ville");
		monform.ville.focus();
		return false;
	}
	monform.submit();
}
function setActiveStyleSheet(title) {
   	var i, a, main;
	
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
	if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
	   if(a.getAttribute("title") == title){
		   if(a.disabled == true){
				a.disabled = false;
			}else{
				a.disabled = true;
			}
		}
     }
   }
}

function AfficheComm(index){
	//celui avant
	i=0;
	while(document.getElementById('com'+i)){
		com='com'+(i);
		if(i==index){
			document.getElementById(com).className='';
		}else{
			document.getElementById(com).className='Invisible';
		}
		i++;
	}
}
function Ecrit(texte){
	document.write(texte);
}
function RunObject(texte,emplacement){
	if(emplacement){
		document.getElementById(emplacement).innerHTML=texte;
	}else{
		document.write(texte);
	}
}

function AfficheBlocVideo(id){
	object=document.getElementById(id);
	aff_commentaires=document.getElementById('aff_commentaires');
	bloc_ami=document.getElementById('bloc_ami');
	info_texte=document.getElementById('info_texte');
	bloc_commentaire=document.getElementById('bloc_commentaire');
	if(id=="bloc_commentaire"){
			aff_commentaires.className='';
			info_texte.className='Invisible';
			bloc_commentaire.className='bloc3';
			bloc_ami.className='Invisible';
	}
	if(id=="bloc_ami"){
			bloc_ami.className='bloc3';
			bloc_commentaire.className='Invisible';
			info_texte.className='';
			aff_commentaires.className='Invisible';
	}
	if(id=="info_texte"){
			info_texte.className=''
			bloc_commentaire.className='bloc3';
			aff_commentaires.className='Invisible';
			bloc_ami.className='Invisible';
	}
}
function Limit(){
	doc=document.getElementById('info_saisie');
	if(doc.value.length>800){
		alert('800 caractères maximum');
		doc.value=doc.value.substr(0,800);
	}
	document.getElementById('compteur').value=doc.value.length;
	limit_test=setTimeout("Limit()",500);
}
function LimitComm(){
	doc=document.getElementById('info_saisie_comm');
	if(doc.value.length>400){
		alert('400 caractères maximum');
		doc.value=doc.value.substr(0,400);
	}
	document.getElementById('compteur_comm').value=doc.value.length;
	limit_comm=setTimeout("LimitComm()",500);
}
