function setFavori(titre_fav,url_fav)
{
	if ( navigator.appName != 'Microsoft Internet Explorer' ){
		window.sidebar.addPanel(titre_fav,url_fav,"");
	}else {
		window.external.AddFavorite(url_fav,titre_fav);
	}
}

/*
Mettre dans le code
<!--[if IE]>
<IE:HOMEPAGE ID="oHomePage" />
<![endif]-->

<a href="#" onclick="setAccueil(this)">
*/
function setAccueil(obj,url_fav)
{
	obj.style.behavior='url(#default#homepage)';
	obj.setHomePage(url_fav)
}


// a supprimer (systeme de changement du titre de la fenetre lorsque l'on change
// de page fille : on mete le titre de la page courante dans la page parente)
// parent.document.title=document.title;


function noclick()
{
	if (event.button==2)
	{
		alert('Tous droits réservés');
	}
}

function trap()
{
	if(document.images)
		for(i=0;i<document.images.length;i++)
			document.images[i].onmousedown = noclick;
}
//document.onmousedown=trap;

function trim(string)
{
	return string.replace(/(^\s*)|(\s*$)/g,'');
}



function getValCookie(offset)
{
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1) endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

function getCookie (name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg) return getValCookie(j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return null;
}

function setCookie (name,value,expires,path,domain,secure) {
	document.cookie = name + "=" + escape (value); // escape: important pr les espaces

	if(expires != "null")
		document.cookie += ((expires) ? "; expires=" + expires.toGMTString() : "");
	document.cookie +=	((path) ? "; path=" + path : "") +
						((domain) ? "; domain=" + domain : "") +
						((secure) ? "; secure" : "");
}

function a_voir_calcul_espace_utilisable_fenetre()
{
	var largeur = 0, hauteur = 0;
	if( typeof( window.innerWidth ) == 'number' )
	{
		largeur = window.innerWidth;
	  	hauteur = window.innerHeight;
	}
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
	{
		largeur = document.documentElement.clientWidth;
	  	hauteur = document.documentElement.clientHeight;
	}
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
	{
		largeur = document.body.clientWidth;
	  	hauteur = document.body.clientHeight;
	}
	else
	{
		largeur = -1;
	  	hauteur = -1;
	}
}


function largeur_fenetre()
{

 if (window.innerWidth) return window.innerWidth;
 else if (document.body && document.body.offsetWidth) return document.body.offsetWidth;
 else return 0;
}

function hauteur_fenetre()
{
 if (window.innerHeight) return window.innerWidth;
 else if (document.body && document.body.offsetHeight) return document.body.offsetHeight;
 else return 0;
}

function Browser()
{
	//alert(window.onresize);

    d=document;
    this.agt=navigator.userAgent.toLowerCase();
    this.major = parseInt(navigator.appVersion);
    this.dom=(d.getElementById)?1:0;
    this.ns=(d.layers);
    this.ns4up=(this.ns && this.major >=4);
    this.ns6=(this.dom&&navigator.appName=="Netscape");
    this.op=(window.opera? 1:0);
    this.ie=(d.all);
    this.ie4=(d.all&&!this.dom)?1:0;
    this.ie4up=(this.ie && this.major >= 4);
    this.ie5=(d.all&&this.dom);
    this.ie6=((this.agt.indexOf("msie 6")!=-1));
    this.ie7=((this.agt.indexOf("msie 7")!=-1));
    this.ie8=((this.agt.indexOf("msie 8")!=-1));
    this.win=((this.agt.indexOf("win")!=-1) || (this.agt.indexOf("16bit")!=-1));
    this.mac=(this.agt.indexOf("mac")!=-1);
	this.liste_plugins = "";
	this.largeur_utile = largeur_fenetre(); //screen.availWidth;
	this.hauteur_utile = hauteur_fenetre(); //screen.availHeight;
	this.resolution_x = screen.width;
	this.resolution_y = screen.height;
	this.accepteCookies = (navigator.cookieEnabled) ? true : false;
	if (typeof navigator.cookieEnabled == "undefined" && !cookieEnabled)
	{
 		document.cookie = "petitTest";
  		this.accepteCookies = (document.cookie.indexOf("petitTest") != -1) ? true : false;
  	}

	var pluginlist = "";

	if (this.ie && this.win){
		pluginlist = "";
		pluginlist += detectIE("Adobe.SVGCtl","SVG Viewer");
		pluginlist += detectIE("SWCtl.SWCtl.1","Shockwave Director");
		pluginlist += detectIE("ShockwaveFlash.ShockwaveFlash.1","Shockwave Flash");
		pluginlist += detectIE("rmocx.RealPlayer G2 Control.1","RealPlayer");
		pluginlist += detectIE("QuickTimeCheckObject.QuickTimeCheck.1","QuickTime");
		pluginlist += detectIE("MediaPlayer.MediaPlayer.1","Windows Media Player");
		pluginlist += detectIE("PDF.PdfCtrl.5","Acrobat Reader");
		pluginlist += detectIE("VideoLAN.VLCPlugin","VLC Plugin");
		pluginlist += detectIE("VideoLAN.VLCPlugin.1","VLC Plugin.1");
		pluginlist += detectIE("VideoLAN.VLCPlugin.2","VLC Plugin.2");
	}
	if (this.ns || !this.win){
		nse = "";
		for (var i=0;i<navigator.mimeTypes.length;i++){
			nse += navigator.mimeTypes[ i ].type.toLowerCase();
		}
		pluginlist = "";
		pluginlist += detectNS("image/svg-xml","SVG Viewer");
		pluginlist += detectNS("application/x-director","Shockwave Director");
		pluginlist += detectNS("application/x-shockwave-flash","Shockwave Flash");
		pluginlist += detectNS("audio/x-pn-realaudio-plugin","RealPlayer");
		pluginlist += detectNS("video/quicktime","QuickTime");
		pluginlist += detectNS("application/x-mplayer2","Windows Media Player");
		pluginlist += detectNS("application/pdf","Acrobat Reader");
	}
	if(this.ns6) // firefox
	{
		pluginlist = "";
		for (var i=0;i<navigator.plugins.length;i++){
			pluginlist += navigator.plugins[i].name+',';
		}
	}

	this.liste_plugins = pluginlist;

	function detectIE(ClassID,name){
		result = false;
		//document.write("<SCRIPT LANGUAGE=VBScript> on error resume next  result = IsObject(CreateObject('Adobe.SVGCtl'))</SCRIPT>");
		window.execScript("On Error Resume Next : Set test = CreateObject('"+ClassID+"') : If Err.Number = 0 Then : result = true :Else : result = false : End if", "VBScript");
		if (result){
			return name+',';
		}else{
			return '';
		}
	}

	function detectNS(ClassID,name) { n = ""; if (nse.indexOf(ClassID) != -1) if (navigator.mimeTypes[ClassID].enabledPlugin != null) n = name+","; return n; }

	pluginlist += navigator.javaEnabled() ? "Java," : "";
	if (pluginlist.length > 0) pluginlist = pluginlist.substring(0,pluginlist.length-1);

	//document.write(pluginlist);
	//SAMPLE USAGE- detect "Flash"
	//if (pluginlist.indexOf("Flash")!=-1)
	//document.write("You have flash installed")
};

var navigateur = new Browser();

function resize_browser()
{
	navigateur.largeur_utile = largeur_fenetre();
	navigateur.hauteur_utile = hauteur_fenetre();
	navigateur.resolution_x = screen.width;
	navigateur.resolution_y = screen.height;
}
