// PNG transparent sous internet Explorer
function IE_CorrectAlpha_PNG(){ 
	for(i=0; i<document.images.length; i++){ 
		img    = document.images[i]; 
		imgExt  = img.src.substring(img.src.length-3, img.src.length); 
		imgExt  = imgExt.toUpperCase(); 
		if (imgExt == "PNG"){ 
			imgID    = (img.id) ? "id='" + img.id + "' " : ""; 
			imgClass= (img.className) ? "class='" + img.className + "' " : ""; 
			imgTitle= (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "; 
			imgStyle= "display:inline-block;" + img.style.cssText; 
			if (img.align == "left") { 
				imgStyle = "float:left;"  + imgStyle; 
			} else if (img.align == "right"){ 
				imgStyle = "float:right;" + imgStyle; 
			} 
			if (img.parentElement.href) { 
				imgStyle = "cursor:hand;" + imgStyle; 
			}        
			strNewHTML    = '<span '+imgID+imgClass+imgTitle+' style="width:'+img.width+'px; height:'+img.height+'px;'+imgStyle+';'+'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+img.src+'\', sizingMethod=\'scale\');"></span>'; 
			img.outerHTML = strNewHTML; 
			i = i-1; 
		}
	}
} 
window.attachEvent("onload", IE_CorrectAlpha_PNG)

function chargePage(page) {
	top.location.href=page+".php";
}

function favoris() {
	if ( navigator.appName != 'Microsoft Internet Explorer' ){ 
		window.sidebar.addPanel("Artéis","http://www.agoravita.net/",""); 
	}
	else { 
		window.external.AddFavorite("http://www.agoravita.net/","Artéis"); 
	} 
}

function afficheOnglet(qui){
	document.getElementById("ent1").style.display="none";
	document.getElementById("ent2").style.display="none";
	document.getElementById("ent3").style.display="none";
	document.getElementById("ent4").style.display="none";
	document.getElementById("ent5").style.display="none";
	document.getElementById("ent6").style.display="none";
	document.getElementById(qui).style.display="block";
}

function votreMagasin(id) {
	top.location.href="arteis-"+id+".htm";
}

function encodeMailto(a,b){
	var tg="<";
	var name=a;
	var at="@";
	var host=b;
	var text="Email direct";
	document.write(tg+"a hr"+"ef=mai"+"lto:"+name);
	document.write(at+host+">"+text+tg+"/a>");
}

function PopupImage(img) {
	titre="Agrandissement";
	w=open("popup-agrandissement.php?img="+img,"image","width=400,height=400,toolbar=no,scrollbars=no,resizable=no,top=0,left=0");
	w.document.close();
}

function PopupVideo() {
	titre="Visiter un magasin Arteis";
	var top=(screen.height-300)/2;
	var left=(screen.width-450)/2;
	w=open("popup-video.php","Magasin","top="+top+",left="+left+",width=450,height=300,toolbar=no,scrollbars=no,resizable=no,");
	w.document.close();
}

/* contact */
function valider()
{
	//variable contenant le message d'erreur
	var erreur="";
	
	//variable permettant de savoir si il on a rencontré une erreur
	var erreur2;
	
	erreur2=true;
	
	//test du nom
	if(document.getElementById('leNom').value.length==0)
	{
		erreur+="Veuillez renseigner votre nom.\n";
		erreur2=false;			
	}	
	if(document.getElementById('leNom').value.length>55)
	{
		erreur+="Votre nom est trop long.\n";
		erreur2=false;	
	}
	
	//test du prenom
	if(document.getElementById('lePrenom').value.length==0)
	{
		erreur+="Veuillez renseigner votre prénom.\n";
		erreur2=false;			
	}	
	if(document.getElementById('lePrenom').value.length>55)
	{
		erreur+="Votre prénom est trop long.\n";
		erreur2=false;	
	}
	
	//test du mail
	if(document.getElementById('lAdresseDeMessagerie').value.length>55)
	{
		erreur+="Votre E-mail est trop long.\n";
		erreur2=false;	
	}
	if(document.getElementById('lAdresseDeMessagerie').value.length==0)
	{
		erreur+="Veuillez renseigner votre E-mail.\n";	
		erreur2=false;
	}
	var res=arobaceok(document.getElementById('lAdresseDeMessagerie').value)
	if(res==false)
	{
		erreur+="Votre E-mail n'est pas correct.\n";
		erreur2=false;	
	}	
	
	//si aucune erreur on submit le formulaire
	if(erreur2==true)
	{
		document.formulaire.submit();
	}
	else
	{
		//sinon affichage des erreurs
		alert(erreur);
		return false;
	}
}
//test si le champ mail contient un @
function arobaceok(email)
{
	var a=document.forms[0].lAdresseDeMessagerie.value;
	var test="" + a;
	for(var k = 0; k < test.length;k++)
	{
		var c = test.substring(k,k+1);
		if(c == "@")
		{
			return true;
		}
	}
	return false;
}

function confirmSupDoc(id_actu)
{
	if(confirm("Voulez-vous vraiment supprimer le document ?"))
	{
		document.location.href = 'espace-actu.php?sup_doc=1&id_actu=' + id_actu ;
	}	
}

function confirmSupImg(id_actu)
{
	if(confirm("Voulez-vous vraiment supprimer l'image ?"))
	{
		document.location.href = 'espace-actu.php?sup_img=1&id_actu=' + id_actu ;
	}	
}