/* ---------------------------------------------------- */
/* ---------------------------------------------------- */
function plan(){
	if (document.getElementById("planContainer").style.display!="block"){
		_hide("visuel");
		_show("planContainer");
		map.checkResize();
		map.setCenter(mapcenter, zoom);
	}else{
		exitplan();
	}
}

function exitplan(){
	_show("visuel");
	_hide("planContainer");
}


/* ---------------------------------------------------- */
/* ---------------------------------------------------- */
/* Coche ou decoche une liste de checkbox               */
/* la fonction reçoit l'id de la forme                  */

function selectAllCheckbox(id) {
	var o = document.getElementById(id) ;
	var oTaille = o.length ;
	for(var i=0 ; i<oTaille; i++) {
		if(o[i].type =='checkbox') {
			o[i].checked = true ;
		}
	}
}

function unSelectAllCheckbox(id) {
	var o = document.getElementById(id) ;
	var oTaille = o.length ;
	for(var i=0 ; i<oTaille; i++) {
		if(o[i].type =='checkbox') {
			o[i].checked = false ;
		}
	}
}


/* ---------------------------------------------------- */
/* ---------------------------------------------------- */
/* affiche un message avec une decoration particuliere  */

function afficheMessage(id, colorEnd) {
	// apparition en fadeur
	$(id).appear({ duration: 1.5 }); 		
	// une fois le fadeur finit morphing color
	$(id).morph('background:#'+colorEnd+'; ', {delay:1.5},{ queue: 'end' });	
}

/* ---------------------------------------------------- */
/* ---------------------------------------------------- */
/* Change l'image  */

function SwitchImg(id,img) {
	document.getElementById(id).src = img
}
/* ---------------------------------------------------- */




/* ---------------------------------------------------- */
/* ---------------------------------------------------- */
/* Change l'image pour les onglets */

function changeImg(id, img) {
	temp = id.split('onglet_img')
	if(document.getElementById("l"+temp[1]).className != 'active') {
		document.getElementById(id).src = img ;
	}

}

/* ---------------------------------------------------- */
/* ---------------------------------------------------- */
/* Affiche l'onglet au clique */
function tab(id,PremiereId,nbr,imgON,univers) {

	for(var i=PremiereId; i<(parseInt(nbr)+parseInt(PremiereId)); i++) {
	//alert("onglet_img"+i+"=img/t"+i+"-1.gif")
		if( i != id) {
			document.getElementById('t'+i).style.display='none' ;
			document.getElementById('onglet_img'+i).src = "images/col_d/T"+i+"_"+univers+".gif" ;
			//document.getElementById('onglet_img'+i).style.background = "none" ;			
			document.getElementById('l'+i).className=""
		}
		
	}
	//alert('---onglet_img'+id+'=img/'+imgON)
	document.getElementById('t'+id).style.display='block' ;
	
	document.getElementById('onglet_img'+id).src = "images/col_d/"+imgON ;
	document.getElementById('l'+id).className="active"
	//document.getElementById('onglet_img'+id).style.background = "#ffffff" ;

}



/* ---------------------------------------------------- */
/* ---------------------------------------------------- */
/* POPUP */
function envoiAmi(article_id){
	popup("http://www.revue-etudes.com/envoi_ami.php?article_id="+article_id,400,350,0);
}

function popup(loc,larg,haut,scro){
	nouvelle_fenetre = window.open(loc,"","menubar=0,resizable=1,scrollbars="+scro+",width="+larg+",height="+haut+",top=100,left=100");
	if (parseInt(navigator.appVersion) > 2) { nouvelle_fenetre.focus();}	
}

/* ---------------------------------------------------- */
/* ---------------------------------------------------- */
/* test formulaire */
function isEmail(value){
  var re=/^[a-z0-9_-](\.?[a-z0-9_-])*[@]([a-z0-9_-]+\.)+([a-z]{2,4})$/i;
  return re.test(value)?true:false;
}

function isCpFrance(value){
	var re=/^[0-9]{4,5}$/i;
	return re.test(value)?true:false;
}

function only_space(chaine) {
  if (chaine=="") {return true;}
  if (chaine==" ") {return true;}
  for (var i=0 ; i<chaine.length ; i++) {
    if (chaine.charAt(i)!=" ") {
      return false;
    }
  }
  return true;
}

function isCodePostalFr(value){
	if (!only_space(value)){
		var re = /^[0-9]{4,5}$/i;
		return re.test(value)?true:false;
	}
	return false;
}

/* ---------------------------------------------------- */
/* ---------------------------------------------------- */
/* raccourcis */
/* valeur d'un champs de formulaire par son id */
function valFromId(id){
	try{
		tr = document.getElementById(id).value;	
	}catch(e){
		tr="";
	}
	return tr;
}
/* focus sur un champs de formulaire par son id */
function focusById(id){
	try{
		document.getElementById(id).focus();	
	}catch(e){}
}

/* ---------------------------------------------------- */
/* ---------------------------------------------------- */
/* Affichage des résultats du test de la conbfig (ok / nok) */
function displayResultatTestConfig(res){
	if (res){
		return "<img src='images/ok.png' border=0 alt='OUI' />";//"&rarr; <span class='resultattestconfigok'>OUI</span>";
	}else{
		return "<img src='images/warning.png' border=0 alt='NON' />";//"&rarr; <span class='resultattestconfignok'>NON</span>";
	}
}

/* Affichage des résultats du test de la conbfig (ok / nok) pour un point bloquant */
function displayResultatTestConfigBloquant(res){
	if (res){
		return "<img src='images/ok.png' border=0 alt='OUI' />";//"&rarr; <span class='resultattestconfigok'>OUI</span>";
	}else{
		return "<img src='images/stop.png' border=0 alt='NON' />";//"&rarr; <span class='resultattestconfignok'>NON</span>";
	}
}

/* Test la confi de l'internaute */
function TestConfig() {
	var configTest = new ConfigTest();

	configTest.addBrowser('Safari');
	configTest.addBrowser('Chrome');
	configTest.addBrowser('Firefox', 2);
	configTest.addBrowser('Explorer', 6);

	configTest.addOS('Windows', 'XP');
	configTest.addOS('Windows', 'Vista');
	configTest.addOS('Windows', '2000');
	configTest.addOS('Windows', 'Server 2003');
	configTest.addOS('Mac', 'OS X');

	document.getElementById('tdBrowser').innerHTML = displayResultatTestConfig(configTest.hasMinimumBrowser());
	document.getElementById('tdCookies').innerHTML = displayResultatTestConfig(configTest.hasCookies());
	document.getElementById('tdOS').innerHTML = displayResultatTestConfigBloquant(configTest.hasOS());
	document.getElementById('tdResolution').innerHTML = displayResultatTestConfig(configTest.hasMinimumResolution(1024,768));
	document.getElementById('tdFlash').innerHTML = displayResultatTestConfig(configTest.hasMinimumFlashVersion(9,0,115));
	
	if (!configTest.hasMinimumFlashVersion(9,0,115)){
		document.getElementById('spanFlash').style.display="block";
	}
	if (!configTest.hasMinimumBrowser()){
		document.getElementById('spanBrowser').style.display="block";
	}
	//document.getElementById('resultatdutest').style.display='block';
	try{
		showHide("resultatdutest");
	}catch(e){}
	//outDiv.innerHTML = 'User agent: ' + navigator.userAgent + '<br />';
	//outDiv.innerHTML += 'Screen: ' + screen.width + 'x'+ screen.height + '<br />';
}
