//		fonctions IHM


// donne la résolution de l'écran
function resolution() 
{
	var fenetre = new Array(screen.height,screen.height);
	return (fenetre);
}

// retourne le navigateur utilisé
function getNavigateur()
{
	Navigateur = navigator.appName;
	if (Navigateur == 'Netscape') return ('NS')
	else if (Navigateur == 'Microsoft Internet Explorer') return ('IE')
}



//        Montre/ou cache un element en fonction de l'ID passée en paramètre
function montre_cache(element)
{
		if (document.getElementById(element)!=null)
		{
			var elem=document.getElementById(element);
	
			if (elem.style.display=="none") //table fermée
			{
					elem.style.display="block";
			}
			else //table ouverte
			{
					elem.style.display="none";
			}
		}
}


function montre(element)
{
        var elem=document.getElementById(element);
        elem.style.display="block";
}

function cache(element)
{
        var elem=document.getElementById(element);
        elem.style.display="none";
}


//val1 = valeur cochée
//val2 = valeur non cochée
function _switch(id,val1,val2)
{
	var elem = 	document.getElementById(id);
//	alert(elem.checked);
	if (elem.checked==true)
	{
		elem.value = val1;
	}
	else
	{
		elem.value = val2;
	}
//	alert(elem.checked);
}



// génération de popup
function popup(contenu)
{
	var w=open("",'popup','width=600,height=450,toolbar=no,scrollbars=no,resizable=yes');
	w.document.write("<body>");
	w.document.write(contenu);
	w.document.write("<BODY>");
	w.document.close();
}



// lien d'ouverture de popup
function open_popup (a_dest, a_width, a_height, a_left, a_top, a_features)
{					
	var featur = "";
									  
	if (a_features) 		featur+=a_features;
	else 				featur+='toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no'
	
        featur+= ',width='+a_width+',height='+a_height;
		if (a_left)	 featur+= ', left='+a_left;
		if (a_top)	 featur+= ', top='+a_top;
        zoom = window.open (a_dest, 'popup', featur );
}


        
//change the opacity for different browsers
function changeOpac(opacity, id, end) {
	var object = document.getElementById(id).style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
	if (opacity==end)
	{
			//alert('end');
			window.clearTimeout(fnc);
			document.getElementById(id).style.display="none";
			initOpac(id);
	}
}



//initie the opacity for different browsers
function initOpac(id) {
	var object = document.getElementById(id).style;
	object.opacity = 100;
	object.MozOpacity = 100;
	object.KhtmlOpacity = 1;
	object.filter = "alpha(opacity=" + 100 + ")";
}




// fonction de fading avec retard
function opacity(id, opacStart, opacEnd, millisec, retard) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) 
		{
			// retard
			do 
			{
				timer++;
				continue;
			}
			while ((timer)<=retard);
			// effet
			fnc = setTimeout("changeOpac(" + i + ",'" + id + "'," + opacEnd + ")",(timer * speed));
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
		{
			fnc = setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
} 


// récupère l'extension d'un fichier
function getExtension(filename)
{
	var parts = filename.split(".");
	return (parts[(parts.length-1)]);
}




function generepassword(plength)
{
	var keylist="abcdefghijklmnopqrstuvwxyz123456789"
	var passwd=''
	for (i=0;i<plength;i++)
		passwd+=keylist.charAt(Math.floor(Math.random()*keylist.length))
	return passwd
}


// Remplace les caractères accentués
function no_accent(my_string) {
var new_string = String (my_string);
new_string = new_string.replace(RegExp("(\u0040|&#x40|&#064;|@|&commat;|\u0061|&#x61|&#097;|\u00C0|&#xC0|&#192;|À|&Agrave;|\u00C1|&#xC1|&#193;|Á|&Aacute;|\u00C2|&#xC2|&#194;|Â|&Acirc;|\u00C3|&#xC3|&#195;|Ã|&Atilde;|\u00C4|&#xC4|&#196;|Ä|&Auml;|\u00C5|&#xC5|&#197;|Å|&Aring;|\u00E0|&#xE0|&#224;|à|&agrave;|\u00E1|&#xE1|&#225;|á|&aacute;|\u00E2|&#xE2|&#226;|â|&acirc;|\u00E3|&#xE3|&#227;|ã|&atilde;|\u00E4|&#xE4|&#228;|ä|&auml;|\u00E5|&#xE5|&#229;|å|&aring;)","gi"),'a');
new_string = new_string.replace(RegExp("(\u00C7|&#xC7|&#199;|Ç|&Ccedil;|\u00E7|&#xE7|&#231;|ç|&ccedil;)","gi"),'c');
new_string = new_string.replace(RegExp("(\u00D0|&#xD0|&#208;|Ð|&ETH;)","gi"),'d');
new_string = new_string.replace(RegExp("(\u0065|&#x65;|&#101;|\u00C8|&#xC8;|&#200;|È|&Egrave;|\u00C9|&#xC9;|&#201;|É|&Eacute;|\u00CA|&#xCA;|&#202;|Ê|&Ecirc;|\u00CB|&#xCB;|&#203;|Ë|&Euml;|\u00E8|&#xE8;|&#232;|è|&egrave;|\u00E9|&#xE9;|&#233;|é|&eacute;|\u00EA|&#xEA;|&#234;|ê|&ecirc;|\u00EB|&#xEB;|&#235;|ë|&euml;)","gi"),'e');
new_string = new_string.replace(RegExp("(\u0069|&#x69|&#105;|\u00CC|&#xCC|&#204;|Ì|&Igrave;|\u00CD|&#xCD|&#205;|Í|&Iacute;|\u00CE|&#xCE|&#206;|Î|&Icirc;|\u00CF|&#xCF|&#207;|Ï|&Iuml;|\u00EC|&#xEC|&#236;|ì|&igrave;|\u00ED|&#xED|&#237;|í|&iacute;|\u00EE|&#xEE|&#238;|î|&icirc;|\u00EF|&#xEF|&#239;|ï|&iuml;)","gi"),'i');
new_string = new_string.replace(RegExp("(\u006E|&#x6E|&#110;|\u00D1|&#xD1|&#209;|Ñ|&Ntilde;|\u00F1|&#xF1|&#241;|ñ|&ntilde;)","gi"),'n');
new_string = new_string.replace(RegExp("(\u006F|&#x6F|&#111;|\u00D2|&#xD2|&#210;|Ò|&Ograve;|\u00D3|&#xD3|&#211;|Ó|&Oacute;|\u00D4|&#xD4|&#212;|Ô|&Ocirc;|\u00D5|&#xD5|&#213;|Õ|&Otilde;|\u00D6|&#xD6|&#214;|Ö|&Ouml;|\u00F2|&#xF2|&#242;|ò|&ograve;|\u00F3|&#xF3|&#243;|ó|&oacute;|\u00F4|&#xF4|&#244;|ô|&ocirc;|\u00F5|&#xF5|&#245;|õ|&otilde;|\u00F6|&#xF6|&#246;|ö|&ouml;|\u00F8|&#xF8|&#248;|ø|&oslash;)","gi"),'o');
new_string = new_string.replace(RegExp("(\u0075|&#x75|&#117;|\u00D9|&#xD9|&#217;|Ù|&Ugrave;|\u00DA|&#xDA|&#218;|Ú|&Uacute;|\u00DB|&#xDB|&#219;|Û|&Ucirc;|\u00DC|&#xDC|&#220;|Ü|&Uuml;|\u00F9|&#xF9|&#249;|ù|&ugrave;|\u00FA|&#xFA|&#250;|ú|&uacute;|\u00FB|&#xFB|&#251;|û|&ucirc;|\u00FC|&#xFC|&#252;|ü|&uuml;)","gi"),'u');
new_string = new_string.replace(RegExp("(\u0079|&#x79|&#121;|\u00DD|&#xDD|&#221;|Ý|&Yacute;|\u00FD|&#xFD|&#253;|ý|&yacute;|\u00FF|&#xFF|&#255;|ÿ|&yuml;)","gi"),'y');
new_string = new_string.replace(RegExp("(\u00C6|&#xC6|&#198;|Æ|&AElig;|\u00E6|&#xE6|&#230;|æ|&aelig;)","gi"),'ae');
new_string = new_string.replace(RegExp("(\u008C|&#x8C|&#140;|Œ|&OElig;|\u009C|&#x9C|&#156;|œ|&oelig;)","gi"),'oe');
return new_string;
} 
