// JavaScript Document

function checkMail(str) {
	var verif = /^[a-zA-Z0-9\-\_]{1,}[a-zA-Z0-9\.\-\_]*[a-zA-Z0-9\-\_]{1,}@[a-zA-Z0-9]{1,}[a-zA-Z0-9\.\-\_]*[a-zA-Z0-9]{1,}[.][a-zA-Z]{2,4}$/;
	if(verif.test(str)) return true;
	else return false;
}

/* VALID FORM */
function submitform(f){
	var errors = 'Attention :\n';
	var areErrors = true;
	

	if(f['nom'].value == '') {
		errors += "\n- votre nom n'est pas renseigné.";
		areErrors = false;
	}
	if(f['prenom'].value == '') {
		errors += "\n- votre prénom n'est pas renseigné.";
		areErrors = false;
	}
	if(f['societe'].value == '') {
		errors += "\n- votre société n'est pas renseignée.";
		areErrors = false;
	}
	if(f['email'].value == '') {
		errors += "\n- votre email n'est pas renseigné.";
		areErrors = false;
	}else if(!checkMail(f['email'].value)) {
		errors += "\n- votre email n'est pas valide.";
		areErrors = false;
	}
	if(f['objet'].value == '') {
		errors += "\n- votre objet n'est pas renseigné.";
		areErrors = false;
	}
	if(f['message'].value == '') {
		errors += "\n- votre message n'est pas renseigné.";
		areErrors = false;
	}

	//
	if(!areErrors){
		alert(errors);
		return false;
	}else{
		return true;
	}
}

/* FONCTION DETERMINANT LA HAUTEUR DES DIV "OMBRE" */

iens6=document.all

function heightOmbre(idDivSup, idDivInf, divModif){
	var topDiv = document.getElementById(idDivSup).offsetTop + document.getElementById(idDivSup).offsetHeight;
	var bottomDiv = document.getElementById(idDivInf).offsetTop + document.getElementById(idDivInf).offsetHeight;
	
	if(divModif == "ombreL"){
		if (iens6){
			var height = bottomDiv - topDiv + 11;
		}else{
			var height = bottomDiv - topDiv - 3;
			
		}
	}else if(divModif == "ombreR"){
		if (iens6){
			var height = bottomDiv - topDiv - 44;
		}else{
			var height = bottomDiv - topDiv - 41;
			
		}
	}
	
	document.getElementById(divModif).style.height = height+"px";
}

function heightOmbre2(idDivSup, idDivInf, divModif){
	var topDiv = document.getElementById(idDivSup).offsetTop + document.getElementById(idDivSup).offsetHeight;
	var bottomDiv = document.getElementById(idDivInf).offsetTop + document.getElementById(idDivInf).offsetHeight;
	
	if(divModif == "ombreL2"){
		if (iens6){
			var height = bottomDiv - topDiv + 6;
		}else{
			var height = bottomDiv - topDiv - 9;
			
		}
	}else if(divModif == "ombreR2"){
		if (iens6){
			var height = bottomDiv - topDiv - 45;
		}else{
			var height = bottomDiv - topDiv - 48;
			
		}
	}
	
	document.getElementById(divModif).style.height = height+"px";
}

function heightOmbre3(idDivSup, idDivInf, divModif){
	var topDiv = document.getElementById(idDivSup).offsetTop + document.getElementById(idDivSup).offsetHeight;
	var bottomDiv = document.getElementById(idDivInf).offsetTop + document.getElementById(idDivInf).offsetHeight;
	
	if(divModif == "ombreL3"){
		if (iens6){
			var height = bottomDiv - topDiv + 6;
		}else{
			var height = bottomDiv - topDiv - 9;
			
		}
	}else if(divModif == "ombreR3"){
		if (iens6){
			var height = bottomDiv - topDiv - 45;
		}else{
			var height = bottomDiv - topDiv - 48;
			
		}
	}
	
	document.getElementById(divModif).style.height = height+"px";
}


/* ROLL OVER */

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 MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


/* FONCTION DE DÉFINITION DES CALQUES */
function NameDiv(id){
	if(document.all){ doc = document.all[id]; }
	if(document.getElementById){ doc = document.getElementById(id);}
	return doc;
}

/* FONCTION D'AFFICHAGE/MASQUAGE DES ELEMENTS */
// id : id de l'élement
// prop : propriété du display (none, block, inline)
function SetObjDisplay(id, prop){
	NameDiv(id);
	doc.style.display=prop;
}


/* FONCTION D'AFFICHAGE/MASQUAGE CHIFFRES CLES */
var Chiffrescle = 3;
var idchiffres;
function ShowChiffres(idchiffres){
	for(i = 0; i<Chiffrescle; i++){
		if(i == idchiffres){
			NameDiv("Chiffres"+i).style.display = "block";
		} else {
			NameDiv("Chiffres"+i).style.display = "none";
		}
	}
}

/* FONCTION D'AFFICHAGE/MASQUAGE FLUX RSS */
var activpack=0;
var sens;

function AfficheRSS(sens){
	activpack=sens+activpack;
	for(i=0; i<nbpack; i++){
		if(i==activpack){
			firstnew = 	pack*activpack;
			lastnew = (firstnew+pack)-1;
			for(j=0; j<window.nb; j++){
				if(j>=firstnew && j<= lastnew){
					NameDiv("rss"+j).style.display = "block";
				} else{
					NameDiv("rss"+j).style.display = "none";
				}
			}
		}
		if(activpack == 0){
			NameDiv("prev").style.display = "none";
		} else{
			NameDiv("prev").style.display = "inline";
		}
		if(activpack == nbpack-1){
			NameDiv("next").style.display = "none";
		} else{
			NameDiv("next").style.display = "inline";
		}
	}
}

function openMentions() {
	window.open('mentions.php', 'mentions', 'width=450, height=500', 'resizable=no');
}

