// détection langage de la page
lang='';
if (document.location.href.indexOf("/Fr/")>0) lang='Fr';
if (document.location.href.indexOf("/En/")>0) lang='En';
// détection navigateur
ns4 = false ;
ns6 = false ;
ie4 = false ;
ie5 = false ;
ie6 = false;
switch (navigator.appName)
  {
    case "Microsoft Internet Explorer":
      if (navigator.appVersion.substr(navigator.appVersion.indexOf("MSIE")+5,1)=="4")
        ie4=true;
      if (navigator.appVersion.substr(navigator.appVersion.indexOf("MSIE")+5,1)=="5")
        ie5=true;
      if (navigator.appVersion.substr(navigator.appVersion.indexOf("MSIE")+5,1)=="6")
        ie6=true;
    case "Netscape":
      if (navigator.appVersion.substr(0,1) == "4")
	    ns4 = true;
      if (navigator.appVersion.substr(0,1) == "5") 
	    ns6 = true;
  }
var W3CDOM = (document.createElement && document.getElementsByTagName);
window.onload = init;

function init()
{
  if (!W3CDOM) return;

  var divs = document.getElementsByTagName('DIV');
  for (var i=0;i<divs.length;i++) {
// comportement des objets <div> de classe 'loupe'
	if (divs[i].className=='loupe'){
      divs[i].onmouseover = barreEtatCliquez;
      divs[i].onmouseout = barreEtatReset;
      divs[i].onclick = GrandPetit2;
    }
// comportement des objets <a> des <div> de classe 'document'
	if (divs[i].className=='document'){
      divs[i].onmouseover = barreEtatCliquez;
      divs[i].onmouseout = barreEtatReset;
      if (divs[i].hasChildNodes){
		var enfants=divs[i].childNodes;
		for (var j=0;j<enfants.length;j++){
		  if (enfants[j].tagName=='A'){
            enfants[j].onmouseover = barreEtatCliquez;
            enfants[j].onmouseout = barreEtatReset;
            enfants[j].onclick = GrandPetit3;
		  }
		}
	  }
    }
  }
}

function barreEtatCliquez()
{if (lang=="Fr")
  window.status='Cliquez sur l\'image pour en changer de format';
 else 
  window.status='Click on the image to change its format';
}
function barreEtatReset()
{window.status='';}

function GrandPetit2()   // Click sur une loupe => bascule taille du document associé
{
// positionnement sur le DIV de class 'document' qui précède la loupe
var obj=this;
  do obj=obj.previousSibling;
  while ((obj.nodeName!='DIV'||obj.className!='document')&&obj!=null)
// recherche des enfants de l'objet <DIV>, de type <A>
var enfants=obj.childNodes;
  for (var i=0;i<enfants.length;i++) {
	if (enfants[i].tagName=='A'){
// recherche des enfants de l'objet <A>, de type <IMG>
      var images=enfants[i].childNodes;
      for (var j=0;j<images.length;j++) {
	    if (images[j].tagName=='IMG'){
// changement du src de l'image
          basculeTailleImage(images[j])
    	}
      }
	}
  }
 return true;
}
function GrandPetit3()   // Click sur un document => bascule taille du document
{
// recherche des enfants de l'objet <A>, de type IMG
var enfants=this.childNodes;
  for (var i=0;i<enfants.length;i++) {
	if (enfants[i].tagName=='IMG'){
// changement du src de l'image
      basculeTailleImage(enfants[i])
	}
  }
 return true;
}
function basculeTailleImage(img){
// changement du src de l'image
  var finSrc=img.src.substr(img.src.lastIndexOf("/")+1);
  if (img.src.indexOf("GImages")!=-1)
   {img.src="../PImages/" + finSrc;}
  else 
   {img.src="../GImages/" + finSrc;}
}
// fonction d'ouverture page de présentation d'un document de l'album
var windowid 
function affImage(camp,num,image,page)
{
 var html
 if (lang=='Fr')
   {
   txtTitre='Document philat&eacute;lique';
   txtFermer='Fermer';
   txtAller='Aller vers la page qui contient ce document';
   }
  else
   {
   if (lang=='En')
     {
     txtTitre='Philatelic document';
     txtFermer='Close';
	 txtAller='Go to the page containing this document';
	 }
	else
	 alert("La lange de la page est inconnue !");
   }
 windowid=window.open("","image");
 html="<head><title>"+txtTitre+"</title><link rel='stylesheet' href='../Ress/CampsDoc.css' type='text/css'></head>";
 html=html+"<body>";
 html=html+"<div id='titre'>"+camp+" : document "+num+"</div>";
 html=html+"<div id='document'><img src='../GImages/"+image+"-75.jpg'></div>";
 html=html+"<div id='pied'><a href='#' onclick='window.close();'>"+txtFermer+"</a>";
 if (page!="")
   {
   if (ie4|ie5|ie6)
     {
     html=html+" | <a href='"+page+".html' target='mainframe' onclick='window.close();'>";
	 }
    else
	 {
     html=html+" | <a href='"+page+".html' target='mainframe'>";
	 }
   html=html+txtAller+"</a>";
   }
 html=html+"</div>";
 html=html+"</body>";
 windowid.document.open();
 windowid.document.write(html);
 windowid.document.close();
 windowid.focus();
};
//
function Mail(qui,domaine,sujet) {
var arob="@";
chaine="mailto:"+qui+arob+domaine
if (sujet!=null && sujet.length>0) chaine+="?subject="+sujet;
location.href=chaine;
}
// fonction de gestion de l'affichage des traductions
function EtatTraduc(statut){
  var div = document.getElementById('TraductionStatut');
  div.style.visibility=statut;
}
