/* ---------------------------- */
/* --- DETECTEUR DE BROWSER --- */
/* ---------------------------- */

var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;
if (checkIt('konqueror'))
	{
	browser = "Konqueror";
	OS = "Linux";
	}
else if (checkIt('safari')) browser = "Safari"
else if (checkIt('omniweb')) browser = "OmniWeb"
else if (checkIt('opera')) browser = "Opera"
else if (checkIt('webtv')) browser = "WebTV";
else if (checkIt('icab')) browser = "iCab"
else if (checkIt('msie')) browser = "Internet Explorer"
else if (!checkIt('compatible'))
	{
	browser = "Netscape Navigator"
	version = detect.charAt(8);
	}
else browser = "An unknown browser";
if (!version) version = detect.charAt(place + thestring.length);
if (!OS)
	{
	if (checkIt('linux')) OS = "Linux";
	else if (checkIt('x11')) OS = "Unix";
	else if (checkIt('mac')) OS = "Mac"
	else if (checkIt('win')) OS = "Windows"
	else OS = "an unknown operating system";
	}
function checkIt(string)
	{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
	}
	
/* -------------------------------- */
/* --- FiN DETECTEUR DE BROWSER --- */
/* -------------------------------- */	

// Ajouter aux favoris
function AjoutFavoris(theURL, theTITLE) {
	if (window.external) {
		/* Internet Explorer 4+, et ses dérivés (Crazy Browser, Avent Browser ...) */
		window.external.AddFavorite(theURL, theTITLE);
	}
	else if (window.sidebar) {
		/*Netscape 6+ ; Mozilla, FireFox et compagnie (K-Meleon ...) */
		window.sidebar.addPanel(theTITLE,theURL,'');
	}
}


// roll over des images du menu en javascript non intrusif
window.addEvent('domready', function()
{
	// menu principal
   var nav = document.getElementById('menu');
   var lis = nav.getElementsByTagName('li');
   var monimg = nav.getElementsByTagName('img');
		
   for (var i=0;i<monimg.length;i++) {
      if (lis[i].className != 'select')
	  {
		var ii= i+1;
		monimg[i].setAttribute('id','menu'+ii);
		
		// pour rechercher la version
  		chaine = "menu_fr";		
		reg = new RegExp(chaine,'g');
		texte = monimg[i].src;
		// retourne la position de la chaine
		//alert(texte.search(reg));
		
			// si version fr sinon c'est la version anglaise
			if (texte.search(reg) > 0)
			{		
				monimg[i].onmouseover = function() { var monitem = this.attributes.getNamedItem('id').value+'_over.gif';this.src='template/affichem/img/menu_fr/'+monitem; };
				monimg[i].onmouseout = function() { var monitem = this.attributes.getNamedItem('id').value+'.gif';this.src='template/affichem/img/menu_fr/'+monitem;  };
				
			}
			else
			{
				monimg[i].onmouseover = function() { var monitem = this.attributes.getNamedItem('id').value+'_over.gif';this.src='template/affichem/img/'+monitem; };
				monimg[i].onmouseout = function() { var monitem = this.attributes.getNamedItem('id').value+'.gif';this.src='template/affichem/img/'+monitem;  };
			}

	  }
   }
});

/* gestion des png automatique */
if (browser == "Internet Explorer")
{
window.addEvent('domready', function()
{
	// correctly handle PNG transparency in Win IE 5.5 or higher.
	for(var i=0; i<document.images.length; i++)
    {
     var img = document.images[i]
     var imgName = img.src.toUpperCase()
     if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
     {
       var imgID = (img.id) ? "id='" + img.id + "' " : ""
       var imgClass = (img.className) ? "class='" + img.className + "' " : ""
       var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
       var imgStyle = "display:inline-block;" + img.style.cssText
       if (img.align == "left") imgStyle = "float:left;" + imgStyle
       if (img.align == "right") imgStyle = "float:right;" + imgStyle
       if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle      
       var 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
     }
    }
});
}
