// Variables globales

var chemin ="";
var loaded = 0;         // pour le prÈload des images, la variable passe ý "1" si les images sont prÈloadÈes


//---------------------------//
// Detailed Browser Sniffing //
//---------------------------//

function Is()
{
var agent = navigator.userAgent.toLowerCase();
this.major = parseInt(navigator.appVersion);
this.minor = parseFloat(navigator.appVersion);
this.ns = ((agent.indexOf('mozilla')!=-1) && ((agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible') == -1)));
this.ns2 = (this.ns && (this.major == 3));
this.ns3 = (this.ns && (this.major == 3));
this.ns4b = (this.ns && (this.minor < 4.04));
this.ns4 = (this.ns && (this.major >= 4));
this.ns6 = (this.ns && (this.major >= 5));
this.ie = (agent.indexOf("msie") != -1);
this.ie3 = (this.ie && (this.major == 2));
this.ie4 = (this.ie && (this.major >= 4));
this.ie5  = (this.ie && (agent.indexOf("msie 5")!=-1));
this.op3 = (agent.indexOf("opera") != -1);
this.win = (agent.indexOf("win")!=-1);
this.mac = (agent.indexOf("mac")!=-1);
this.unix = (agent.indexOf("x11")!=-1);
}

var is = new Is();

//---------------------------//
// DÈfinit un chemin de base //
//---------------------------//

function defineChemin()
{
chemin = document.domain;
if ((chemin == 'rhea') || (chemin == 'rhea.quaeris.com'))
	{
	chemin = 'http://' + chemin + '/site_tabac/';
	}
else if ((chemin == 'localhost') || (chemin == '127.0.0.1'))
	{
	chemin = 'http://' + chemin + '/site_tabac/';
	}
else
	{
	chemin = "http://" + chemin + "/";
	}
}

//-------------------------------------------------------//
// Initialisation de variables pour manipuler les layers //
//-------------------------------------------------------//

function InitVar()
{
if(is.ns4)
	{
	doc = "document";
	sty = "";
	htm = ".document";
	}
else if(is.ie4)
	{
	doc = "document.all";
	sty = ".style";
	htm = "";
	}
}

//----------------------------------------------//
// PrÈload des images du menu                   //
// Appel : <body ... onLoad="loadImgs();" ...>  //
//----------------------------------------------//

function loadImgs()
{ 
if ((is.ns4) || (is.ie4))
	{
	defineChemin();
	
	fleche = new Image(20,9);  
	fleche.src = chemin + "images/home/fleche_on.gif";
	carredefaut = new Image(20,9);  
	carredefaut.src = chemin + "images/home/fleche_off.gif";
	
	carre_on = new Image(10,8);
	carre_on.src = chemin + "images/nav/carre_on.gif";
	carre_off = new Image(10,8);
	carre_off.src = chemin + "images/nav/carre_off.gif";
	
	carror_on = new Image(23,9);
	carror_on.src = chemin + "images/niveau2/carror_on.gif";
	carror_off = new Image(23,9);
	carror_off.src = chemin + "images/niveau2/carror_off.gif";
	
	carrbleu_on = new Image(23,9);
	carrbleu_on.src = chemin + "images/niveau2/carrbleu_on.gif";
	carrbleu_off = new Image(23,9);
	carrbleu_off.src = chemin + "images/niveau2/carrbleu_off.gif";
	
	carrmar_on = new Image(23,9);
	carrmar_on.src = chemin + "images/niveau2/carrmar_on.gif";
	carrmar_off = new Image(23,9);
	carrmar_off.src = chemin + "images/niveau2/carrmar_off.gif";
	
	carrjaun_on = new Image(23,9);
	carrjaun_on.src = chemin + "images/niveau2/carrjaun_on.gif";
	carrjaun_off = new Image(23,9);
	carrjaun_off.src = chemin + "images/niveau2/carrjaun_off.gif";
	
	carrgris_on = new Image(23,9);
	carrgris_on.src = chemin + "images/niveau2/carrgris_on.gif";
	carrgris_off = new Image(23,9);
	carrgris_off.src = chemin + "images/niveau2/carrgris_off.gif";
	
	home_on = new Image(99,23);
	home_on.src = chemin + "images/nav/home_on.gif";
	home_off = new Image(99,23);
	home_off.src = chemin + "images/nav/home_off.gif";
	
	accessoires_on = new Image(155,23);
	accessoires_on.src = chemin + "images/nav/accessoires_on.gif";
	accessoires_off = new Image(155,23);
	accessoires_off.src = chemin + "images/nav/accessoires_off.gif";
	
	pipe_on = new Image(86,23);
	pipe_on.src = chemin + "images/nav/pipe_on.gif";
	pipe_off = new Image(86,23);
	pipe_off.src = chemin + "images/nav/pipe_off.gif";
	
	inspiration_on = new Image(244,23);
	inspiration_on.src = chemin + "images/nav/inspiration_on.gif";
	inspiration_off = new Image(244,23);
	inspiration_off.src = chemin + "images/nav/inspiration_off.gif";
	
	comportements_on = new Image(175,23);
	comportements_on.src = chemin + "images/nav/comportements_on.gif";
	comportements_off = new Image(175,23);
	comportements_off.src = chemin + "images/nav/comportements_off.gif";
	
	a_on = new Image(151,23);
	a_on.src = chemin + "accessoires/conserver_transporter/images/sous_tit1_on.gif";
	a_off = new Image(151,23);
	a_off.src = chemin + "accessoires/conserver_transporter/images/sous_tit1_off.gif";
	
	b_on = new Image(151,23);
	b_on.src = chemin + "accessoires/conserver_transporter/images/sous_tit2_on.gif";
	b_off = new Image(151,23);
	b_off.src = chemin + "accessoires/conserver_transporter/images/sous_tit2_off.gif";
	
	c_on = new Image(151,23);
	c_on.src = chemin + "accessoires/conserver_transporter/images/sous_tit3_on.gif";
	c_off = new Image(151,23);
	c_off.src = chemin + "accessoires/conserver_transporter/images/sous_tit3_off.gif";
	
	d_on = new Image(151,23);
	d_on.src = chemin + "accessoires/conserver_transporter/images/sous_tit4_on.gif";
	d_off = new Image(151,23);
	d_off.src = chemin + "accessoires/conserver_transporter/images/sous_tit4_off.gif";
	
	e_on = new Image(151,23);
	e_on.src = chemin + "accessoires/conserver_transporter/images/sous_tit5_on.gif";
	e_off = new Image(151,23);
	e_off.src = chemin + "accessoires/conserver_transporter/images/sous_tit5_off.gif";
	
	loaded = 1;
	} 
}

//----------------------------------------------------------------------------------------------------------------------------------------------------------------------//
// Remplace l'image portant le nom "img_source_name" par l'image portant le nom "img_dest_name"                                                                         //
// Arguments : mettre le nom "name" des images                                                                                                          		//
// Appel : <a href="#" onMouseOut="swap_img1_en_img2('general','gp2i')"><img src="images/general_off.gif" width="128" height="30" border="0" name="general"></a>	//
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------//

function swap_img1_en_img2(img_source_name,img_dest_name)
{
if (((is.ns4) || (is.ie4)) && loaded == "1")
        {
        document[img_source_name].src = eval(img_dest_name + ".src");
        }
}

//------------------------------------------------------------------------------------------------------------------------------------------------------//
// Appelle l'image "on" qd la souris passe sur l'image "off"                                                                                            //
// Arguments : mettre le nom "name" des images                                                                                                          //
// Appel : <a href="#" onMouseOver="onlight('general')"><img src="images/general_off.gif" width="128" height="30" border="0" name="general"></a>        //
//------------------------------------------------------------------------------------------------------------------------------------------------------//

function onlight()
{
var nb_arg = onlight.arguments;
if (((is.ns4) || (is.ie4)) && loaded == "1")
        {
        for (var i=0 ; i<nb_arg.length ; i++)
                {
                img_name = nb_arg[i];
                document[img_name].src = eval(img_name + "_on.src");
                }
        }
}

//----------------------------------------------------------------------------------------------//
//----------------------------------------------------------------------------------------------//
// Appelle l'image "off" qd la souris quitte l'image "off"                                      //
//// Arguments : mettre le nom "name" des images                                                  //
//// Appel : <a href="#" onMouseOut="offlight('general')">                                        //
//         <img src="images/general_off.gif" width="128" height="30" border="0" name="general"> //
//         </a>                                                                                 //
//----------------------------------------------------------------------------------------------//

function offlight()
{
var nb_arg = offlight.arguments;
if (((is.ns4) || (is.ie4)) && loaded == "1")
        {
        for (var i=0 ; i<nb_arg.length ; i++)
                {
                img_name = nb_arg[i];
                document[img_name].src = eval(img_name + "_off.src");
                }
        }
}

//----------------------------------------------------------------//
//----------------------------------------------------------------//
// Initialise l'image qui doit Ítre "on" au chargement de la page //
////----------------------------------------------------------------//

function InitOnlight(img_name)
{
if (((is.ns4) || (is.ie4)) && loaded == "1")
	{
	document[img_name].src = eval(img_name + "_on.src");
	}
}

//------------------------------------------------------------//
//------------------------------------------------------------//
// Rendre visible un layer                                    //
//// Arguments :                                                //
////      layer_id(s) : identifiant du ou des layers            //
////------------------------------------------------------------//

function ShowLayer()
{
var nb_arg = ShowLayer.arguments;
InitVar();

for (var i=0 ; i<nb_arg.length ; i++)
        {
        layer_id = nb_arg[i];
        layer_objet = eval(doc + '["' + layer_id + '"]' + sty);

        layer_objet.visibility = "visible";
        }
}

//------------------------------------------------------------//
//------------------------------------------------------------//
// Rendre invisible un layer                                  //
//// Arguments :                                                //
////      layer_id(s) : identifiant du ou des layers            //
////------------------------------------------------------------//

function HideLayer()
{
var nb_arg = HideLayer.arguments;
InitVar();

for (var i=0 ; i<nb_arg.length ; i++)
        {
        layer_id = nb_arg[i];
        layer_objet = eval(doc + '["' + layer_id + '"]' + sty);
        layer_objet.visibility = "hidden";
}
}

//------------------------------------------------------------//
//  reloads the window if Nav4 resize                         //
//------------------------------------------------------------//
function MM_reloadPage(init) {  
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

//------------------------------------------------------------//
//  initialise l'image ý ON au chargement de la page          //
//------------------------------------------------------------//
function init_img(img_name)
{
if (img_name)
	{
	onlight(img_name);
	}
else
	{
	alert("Initialiser l'image onlight !!!");
	}
}

//------------------------------------------------------------------------------------------------------------------------------------------------------//
// CrÈÈ la navigation rubriques de bas de page                                                                                         //
//------------------------------------------------------------------------------------------------------------------------------------------------------//

function nav_basse()
{
defineChemin();
document.write('   <div align="right">\n');
document.write('<table border="0" cellspacing="0" cellpadding="0">\n');
document.write(' <tr class="liennavbas">\n');
document.write('  <td class="liennavbas">\n');
document.write('   <a href="'+ chemin +'bibliographie/index.htm" class="liennavbas">Bibliographie</a>    |    \n');
document.write('   <a href="'+ chemin +'liens/index.htm"class="liennavbas">Liens</a>    |    \n');
document.write('   <a href="'+ chemin +'musees/index.htm"class="liennavbas">Mus&eacute;es</a>    |    \n');
document.write('   <a href="'+ chemin +'galerie/index.htm"class="liennavbas">Galerie</a>    |    \n');
document.write('   <a href="mailto:contact@tabacollector.com"class="liennavbas">Nous &eacute;crire</a>    |    \n');
document.write('   <a href="'+ chemin +'vous/index.htm"class="liennavbas">Formulaire</a>\n');
document.write('  </td>\n');
document.write('  <td class="liennavbas">&nbsp;&nbsp;&nbsp;&nbsp;\n');
document.write('  </td>\n');
document.write('</table>\n');
document.write('   </div>\n');
}

//-------------------------------------------------------//
// Affichage aleatoire des images sur la home           //
//-------------------------------------------------------//

function random_image()
{
// liste des images
tab_img = new Array(
	"images/aleatoire/vesoul.jpg",
	"images/aleatoire/pipe_taulard.jpg",
	"images/aleatoire/pipe_rima.jpg",
	"images/aleatoire/pipe_poilu.jpg",
	"images/aleatoire/briquet_poilu.jpg",
	"images/aleatoire/algerie.jpg",
	"images/aleatoire/helmstadt.jpg",
	"images/aleatoire/saint_cyr2.jpg",
	"images/aleatoire/saint_cyr1.jpg",
	"images/aleatoire/enseigne.jpg",
	"images/aleatoire/marin_ropp.jpg",
	"images/aleatoire/retrouvey.jpg",
	"images/aleatoire/zouave.jpg",
	"images/aleatoire/fage2.jpg",
	"images/aleatoire/fage.jpg",
	"images/aleatoire/pesme.jpg",
	"images/aleatoire/journal.jpg",
	"images/aleatoire/enfant_cafe.jpg",
	"images/aleatoire/enfant_craneur.jpg",
	"images/aleatoire/enfant_bonnaud.jpg",
	"images/aleatoire/frederic.jpg",
	"images/aleatoire/enfants.jpg",
	"images/aleatoire/enfant_ministere.jpg",
	"images/aleatoire/enfant_foulrouge.jpg",
	"images/aleatoire/enfant_jacob.jpg",
	"images/aleatoire/mobile.jpg",
	"images/aleatoire/jeton.jpg",
	"images/aleatoire/enkhuizen.jpg",
	"images/aleatoire/guemene.jpg",
	"images/aleatoire/bb.jpg",
	"images/aleatoire/pranzini.jpg",
	"images/aleatoire/jacquot.jpg",
	"images/aleatoire/jacob.jpg",
	"images/aleatoire/nicolas1er.jpg",
	"images/aleatoire/japon.jpg"
	);
// liste des liens sur les images
tab_link = new Array(
	"comportements/tabac_virilite/vesoul.htm",
	"comportements/pipe_militaire/pipe_taulard.htm",
	"comportements/pipe_militaire/pipe_rima.htm",
	"comportements/pipe_militaire/pipe_poilu.htm",
	"comportements/pipe_militaire/pipe_poilu.htm",
	"comportements/pipe_militaire/pipe_algerie.htm",
	"comportements/pipe_militaire/pipe_prisonnier.htm",
	"comportements/pipe_militaire/saint_cyriens.htm",
	"comportements/pipe_militaire/saint_cyriens.htm",
	"auteur/index.htm",
	"comportements/premiere_pipe/imitation_cp.htm",
	"comportements/tabac_virilite/retrouvey.htm",
	"comportements/tabac_virilite/zouave.htm",
	"comportements/tabac_virilite/fage.htm",
	"comportements/tabac_virilite/fage.htm",
	"comportements/tabac_virilite/pesme.htm",
	"comportements/vie_tabagique/index.htm",
	"comportements/premiere_pipe/imitation_cp.htm",
	"comportements/premiere_pipe/premiere_pipe.htm",
	"comportements/premiere_pipe/tout_chose.htm",
	"comportements/premiere_pipe/frederic.htm",
	"comportements/premiere_pipe/pipe_journal.htm",
	"comportements/premiere_pipe/nouveau_ministere.htm",
	"comportements/premiere_pipe/vomir.htm",
	"comportements/premiere_pipe/bonne_pipe.htm",
	"pipe/autres_materiaux/index.htm",
	"pipe/historique_fabrication/index.htm",
	"accessoires/conserver_transporter/index.htm",
	"accessoires/consommer/index.htm",
	"accessoires/allumer/index.htm",
	"inspiration/modeles/index.htm",
	"inspiration/themes/index.htm",
	"inspiration/figures/index.htm",
	"pipe/terre_cuite/index.htm",
	"pipe/accessoires/index.htm"
	);
// liste des alt sur les images
tab_title = new Array(
	"Fumeur de cigare dans les ateliers d'un photographe de Vesoul. France. Seconde moitiÈ du XIXe siËcle.",
	"Pipe d'un prisonnier. France. PremiËre moitiÈ du XXe siËcle.",
	"Pipe d'un appelÈ d'un RÈgiment d'Infanterie de Marine. France. Seconde moitiÈ du XXe siËcle.",
	"Pipe de poilu. France. Guerre de 14-18. Bataille des frontiËres, 1914.",
	"Briquet de poilu. France. Guerre de 14-18.",
	"pipe d'un appelÈ du contingent durant la Guerre d'AlgÈrie. France. DÈbut des annÈes 60.",
	"Pipe d'un militaire franÁais emprisonnÈ en 1940 en Allemagne.",
	"Pipe de Saint-Cyrien, promotion Alexandre III. France. 1894-1896.",
	"Pipe de Saint-Cyrien, promotion Foch. France. 1928-1930.",
	"Enseigne de vitrine en pl’tre polychromÈ. France. Fin du XXe siËcle.",
	"Ce petit marin fume de l'air dans une pipe en merisier. France. Premier tiers du XXe siËcle.",
	"Tout en faisant ma cigarette je vous envoie mes meilleures amitiÈes. France. DÈbut du XIXe siËcle.",
	"Un zouave goštant aux charmes de l'Orient. France. DÈbut du XIXe siËcle.",
	"L'Ècrivain AndrÈ Fage pose cigarette ý la main. France. DÈbut du XIXe siËcle.",
	"Ecume en main, un ami ou un membre de la famille de l'Ècrivain AndrÈ Fage. France. DÈbut du XIXe siËcle.",
	"Fumeur de cigare dans les ateliers du photographe Pesme ý Paris. France. Seconde moitiÈ du XIXe siËcle.",
	"Achats tabagiques extraits d'un journal de compte d'un bourgeois montpellierain du XIXe siËcle.",
	"Enfant et pipe de CafÈ. Europe centrale. DÈbut du XIXe siËcle.",
	"PremiËre pipe. Carte-postale affranchie le 19 septembre 1903.",
	"AprËs les premiËres bouffÈes Quoiqu'c'est donc j'ai, je m'sent tout chose ! Carte postale affranchie le 3 juin 1918.",
	"La premiËre pipe. Carte postale datÈe du 14 juin 1903",
	"Une bonne pipe et un journal. Carte postale datÈe du 20 novembre 1907",
	"Encore un nouveau ministËre ! Carte postale datÈe du 12 mars 1904 ",
	"Bourrer, allumer, fumer, vomir. Carte-postale affranchie en 1906.",
	"Tout Áa ne vaut pas une bonne pipe. Pas de date d'expÈdition.",
	"BruyËre sculptÈe d'une tÍte de garde mobile, embout en ambre jaune. France. Seconde moitiÈ du XIXe siËcle",
	"Echantillon de cuisson. Manufacture Gambier, Givet, France. Fin XIXe-dÈb XXe siËcle",
	"BoÓte ý tabac en cuivre jaune gravÈe d'une vue du port d'Enkhuizen. Hollande, 1770-1780",
	"GuÈmenÈ-sur-Scorff - La prise - Butun Mad . Pas de date d'expÈdition.",
	"Statuette pyrogËne. SociÈtÈ Bruder-Bloch, Teplice, BohËme, Empire Austro-Hongrois. Fin du XIXe siËcle",
	"Pranzini. Manufacture Fiolet, Saint-Omer, France. Circa 1887",
	"Jacquot scatologique. Manufacture Dutel-Gisclon, Montereau, France. Fin du XIXe siËcle",
	"Jacob. Atelier Tanneveau, Saint-Omer, France",
	"Nicolas 1er, nƒ438. Manufacture CrÈtal-Gallard, Rennes, France. circa 1856",
	"DÈtail d'un ratelier ý pipes en terre, en papier machÈ l’quÈ. France. Milieu du XIXe siËcle"
	);

if ((tab_img.length == tab_link.length) && (tab_img.length == tab_title.length))
	{
	// tirage du nombre aleatoire
	numimage= Math.round(Math.random()*(tab_img.length-1));

	// affichage de l'image, de son lien et de son alt
	document.write('<a href="'+ tab_link[numimage]+'"><img src="'+ tab_img[numimage] +'" width="71" height="96" border="0" title="'+ tab_title[numimage] +'"></a>');
	//alert(tab_img[numimage]+"\n"+tab_link[numimage]+"\n"+tab_title[numimage]);
	}
else
	{
	alert("Il n'y a pas le mÍme nb d'images, de liens et de title !!!");
	}
}

 //--------------------------------------//
 // Ouvre une nouvelle fenÍtre           //
 // ParamËtres :                         //
 //      - nom du fichier ý ouvrir       //
 //      - nom de la fenÍtre ý ouvrir    //
 //      - largeur de la fenÍtre         //
 //      - hauteur de la fenÍtre         //
 //     -  scrollbars=no                 //
 //--------------------------------------//

 function ouvre(page,nom_win,largeur,hauteur)
 {
 var l = largeur;
 var h = hauteur;
 ouvre_win = window.open(page,nom_win,"toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=no,resizable=no,width="+l+",height="+h);
}

 //--------------------------------------//
 // Ouvre une nouvelle fenÍtre           //
 // ParamËtres :                         //
 //      - nom du fichier ý ouvrir       //
 //      - nom de la fenÍtre ý ouvrir    //
 //      - largeur de la fenÍtre         //
 //      - hauteur de la fenÍtre         //
 //     -  scrollbars=yes                 //
 //--------------------------------------//

 function ouvre2(page,nom_win,largeur,hauteur)
 {
 var l = largeur;
 var h = hauteur;
 ouvre2_win = window.open(page,nom_win,"toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=no,width="+l+",height="+h);
}

 //--------------------------------------//
 // Ouvre une nouvelle fenÍtre           //
 // ParamËtres :                         //
 //      - nom du fichier ý ouvrir       //
 //      - nom de la fenÍtre ý ouvrir    //
 //      - largeur de la fenÍtre         //
 //      - hauteur de la fenÍtre         //
 //    	 -  scrollbars=no                 //
 //    	 -  menubars=no                 //
 //--------------------------------------//

 function ouvre3(page,nom_win,largeur,hauteur)
 {
 var l = largeur;
 var h = hauteur;
 ouvre2_win = window.open(page,nom_win,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width="+l+",height="+h);
}


//--------------------------------------------------------------------------------------//
// Fonction fermuture de popup                   			                //
//--------------------------------------------------------------------------------------//

function shutup()
{
parent.close();
}
