/* ---------------------------------------------------- */
/* ---------------------------------------------------- */
/* POPUP */
function envoiAmi(article_id){
	popup("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 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 />';
}