var isDOM=document.getElementById?1:0;
var isIE=document.all?1:0;
var isNS4=navigator.appName=='Netscape'&&!isDOM?1:0;
var isIE4=isIE&&!isDOM?1:0;
var isOp=window.opera?1:0;
var isDyn=isDOM||isIE||isNS4;

// convert all characters to lowercase to simplify testing
var agt=navigator.userAgent.toLowerCase();

// *** BROWSER VERSION ***
// Note: On IE5, these return 4, so use is_ie5up to detect IE5.
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);

var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_ie3    = (is_ie && (is_major < 4));
var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
var is_ie4up  = (is_ie && (is_major >= 4));
var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);



/* --------------------------------------------------
	Simule un clic sur un lien
*/
function goToURL(u, targetName)
{
	if (typeof(u)=="undefined" || u==null || u=="")
		return true;

	if (u.indexOf("javascript:")==0)
	{
		var jscode = u.substring(11);
		if (eval(jscode))
			return true;
		else
			return false;
	}

	if (typeof(targetName)!="undefined" && targetName!=null){
		var w = window.open(u, targetName);
		w.focus();
	} else {
		if (is_ie5up) {
			eval("try { window.location.href=u; } catch(e) {}");
		}
		else
			window.location.href=u;
   }
}


function showLanguages() {
	document.all["langues"].style.visibility="visible";
	return true;
}

function hideLanguages() {
	document.all["langues"].style.visibility="hidden";
	return true;
}

/* --------------------------------------------------
	Recherche un objet DHTML d'ID donné et le renvoit (ou null si inexistant)
*/
function getObj(id) {
	if (isDOM && document.getElementById(id)!=null) {
		return document.getElementById(id);
	}
	
	// on cherche dans document.layers (Netscape)
	if (document.layers && eval("document."+id)!=null) {
		return eval("document."+id);
	}
	
	// on cherche dans document.all
	if (isIE && eval("typeof(document.all[id])")!="undefined") {
		return document.all[id];
	}

	
	// sinon on cherche dans les formulaires
	for(var i=0; i<document.forms.length; i++) {
		if (eval("typeof(document.forms[i]."+id+")")!="undefined")
			return eval("document.forms[i]."+id);
	}

	// sinon on cherche dans les frames
	if (typeof(document.frames)!="undefined") {
		for(var i=0; i<document.frames.length; i++) {
			if (eval("typeof(document.frames[i]."+id+")")!="undefined")
				return eval("document.frames[i]."+id);
		}
	}

	// sinon on cherche dans les images
	for(var i=0; i<document.images.length; i++) {
		if (eval("typeof(document.images[i]."+id+")")!="undefined")
			return eval("document.images[i]."+id);
	}

	// pas trouvé !!
	return null;
}




/* --------------------------------------------------
	Ouvre une fenêtre de taille donnée, centrée sur l'écran
*/
function openCenteredWindow(name, url, w, h, notResizable, noScrollBars)
{
	var features = ",directories=no,location=no,status=no,toolbar=no";
	if (notResizable)
		features += ",resizable=no";
	else
		features += ",resizable=yes";

	if (noScrollBars)
		features += ",scrollbars=no";
	else
		features += ",scrollbars=yes";


	var w = window.open(url, name, getCenteringWinPos(w,h)+features, true);
	if (typeof(w)!="undefined" && w!=null)
		w.focus();
	return w;
}

function getCenteringWinPos(w,h){
    var sW = parseInt(screen.availWidth, 10);
    var sH = parseInt(screen.availHeight, 10);
    if (sW / sH > 2)    // si double ecran
        sW = Math.round(sW/2);

    var x = Math.round((sW - w)/2);
    var y = Math.round((sH - h)/2);

    return "width="+w+",height="+h+",top="+y+",left="+x;
}

