function Afficher(lien, varwidth, varheight){
    var Left=(window.screen.width)/2;
    var Top=window.screen.height/2;
    //Videment faut modifier la config!!
    var Configuration="'toolbar=no, menubar=no, location=no, directories=no, status=no, scrollbars=1, resizable=yes,   width="+ varwidth +", height=" + varheight + ", left=" + Left + ", top=" + Top + "'";

	window.open(lien,'_blank',Configuration);
}

function Supprimer(lien, sujet){

if (confirm(sujet))
	window.location =  lien ;

	
}
 

function Question(lien, sujet){

if (confirm(sujet))
	window.location =  lien ;

	
}

function Lien_site(lien)
	{
	window.location =  lien ;
	}
	
	
function chiffres(event) {
	// Compatibilité IE / Firefox
	if(!event&&window.event) {
		event=window.event;
	}
	// IE
	
	if( event.keyCode != 13 && (event.keyCode < 48 || event.keyCode > 57))
		{
		event.returnValue = false;
		event.cancelBubble = true;
		}
	// DOM
	if(event.which != 13 && (event.which < 48 || event.which > 57))
		{
		event.preventDefault();
		event.stopPropagation();
		}	
}


function changeliste(groupe)
{
	choix = document.getElementById("indice_" + groupe).value;
	
	t='';
	i=0;
	nbrcol = 3 ;
	if (choix==0)
	{
		t ='<table style="width:100%" cellspacing="0" cellpadding="0" border="0">';
		
		while(i<liste[groupe].length)
		{
			t += "<tr style='height:20px;'>" ;
			t += "<td style='width:5%;' align='right'>" ;
			if (i==(liste[groupe].length)-nbrcol)
				t += "<img  src='images/tree_end.gif' style='width:16px;height:16px;border:0px' >" ;
			else
				t += "<img  src='images/tree_split.gif' style='width:16px;height:16px;border:0px' >" ;
			t += "</td>"
			
			t += "<td style='width:5%;' align='right'>" ;
				t += "<img src='images/" + liste[groupe][(i+2)] + "' style='width:16px;height:16px;border:0px'>" ;
			t += "</td>"
			
			t += "<td style='width:90%;' align='left'>" ;
			t += "<a class='linksite' style='border:0px;' href='../" + liste[groupe][(i+1)] + "'>&nbsp;&nbsp;"+liste[groupe][i] + "</a>";
			
			t += "</td>"
			t += "</tr>" ;
			i= i+ nbrcol ;
		}
			t += "<tr height='16'>" ;
			t += "<td colspan='3'>" ;
			t += "&nbsp;" ;
			t += "</td>"
			t += "</tr>" ;
			t +='</table>';
			
	}
	document.getElementById("liste_" + groupe).innerHTML = t ;

	if (choix==0)
		t =   '&nbsp;&nbsp;<img src="images/tree_collapse.gif" style="width:16px; height:16px; border:0px" >';
	else
		t =   '&nbsp;&nbsp;<img src="images/tree_expand.gif" style="width:16px; height:16px; border:0px" >' ;	
	
	document.getElementById("entete_" + groupe).innerHTML = t ;
	
	
	if (choix==0)
		document.getElementById("indice_" + groupe).value = 1 ;
	else
		document.getElementById("indice_" + groupe).value = 0 ;
}




function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false
		 }

 		 return true					
	}





function totalitezz() {
	var inputList = document.forms['form_new_module'].elements;
	var alertTxt = "";
		for (i = 0; i < inputList.length; i++) {
        	var inputElement = inputList[i];
			if(inputElement.type=="text"&&inputElement.value.length==0){
				alertTxt += "Le champ \"" + inputElement.id + "\" n'a pas été rempli \n";
			}
			else if(inputElement.type=="file"&&inputElement.value==""){
				alertTxt += "Le champ \"" + inputElement.id + "\" n'a pas été rempli \n";
			}
		}
	if (alertTxt != ""){
		alert(alertTxt);
		return false;	
	}
	return true;
}

function controle_nbre_caractere(cp, nbre)
   {
    nbchar = cp.length;
    if (nbchar != nbre)
    	ctrl = false ;
	else
		ctrl = true ;
    	
return ctrl ;
   }
   
   
function recup_extension(fichier)
   {
         if (fichier!="")
         {
            nom_fichier=fichier;
            nbchar = nom_fichier.length;
            extension = nom_fichier.substring(nbchar-4,nbchar);
            extension=extension.toLowerCase();
            return extension;
         }
   }

function is_numeric(num)
	{
		var exp = new RegExp('^[0-9-.]+$','g');
		return exp.test(num);
	}

function verif_extension(fichier)
   {
   ext = recup_extension(fichier);
            if(ext==".php"||ext==".txt"){}
            else
            {
               alert("L'extension de ce fichier n'est pas correcte ! \n\n Seules les extensions suivantes sont autorisées : PHP et TXT !");
            }
   }


function retourqte(t)
	{

	ds_element = t;
	
	if (ds_element.value=='')
		ds_element.value = 1 ;
	else
		ds_element.value = (ds_element.value * 1) + 1 ;
	}


//#################################################################################################


function elt_left(el) {
	var tmp = el.offsetLeft;
	el = el.offsetParent ;
	while(el) {
		tmp += el.offsetLeft;
		el = el.offsetParent;
	}
	return tmp;
}


function elt_top(el) {
	var tmp = el.offsetTop;
	el = el.offsetParent ;
	
	while(el) {
		tmp += el.offsetTop;
		el = el.offsetParent;
	}
	
	return tmp;
}


function elt_print_lst(t) {

	var tableau = t.id + "_lst" ;
	//alert(tableau) ;
	document.getElementById(tableau).style.width = t.offsetWidth + 'px';
	document.getElementById(tableau).style.left = elt_left(t) + 'px';
	document.getElementById(tableau).style.top = elt_top(t) + t.offsetHeight + 'px';
	document.getElementById(tableau).style.visibility = "visible";


}


function elt_retour_valeur(t) 
	{
	var element = t.id ;
	//alert(element.substring(0, element.length - 4)) ;
	document.getElementById(t.id).style.visibility ="hidden";
	document.getElementById(element.substring(0, element.length - 4)).value = t.value ;
	document.getElementById(element.substring(0, element.length - 4)).focus() ;
	}	
	
function elt_cache(t) {
	document.getElementById(t.id + "_lst").style.visibility = "hidden";
}
//#################################################################################################

	
	function SearchList(htmlselect,htmltext,caseSensitive)
		{
		this.select=htmlselect;
		this.text=htmltext;
		this.allOptions=new Array();
		for(i=0;i<this.select.options.length;i++)
			{
			this.allOptions[i]=this.select.options[i];
			}
		this.caseSensitive=false;
		if(caseSensitive)
			this.caseSensitive=true;
		
		}

	/*
	*	Vide le contenu de la liste
	*/	
	SearchList.prototype.viderListe=function()
		{
		var length=this.select.options.length;
		for(i=length-1;i>=0;i--)
			{
			this.select.options[i]=null;
			}
		}
	
	/*
	*	Restore le contenu de la liste avec les valeurs initiales
	*/
	SearchList.prototype.restoreListe=function()
		{
		for(i=0;i<this.select.options.length;i++)
			{
			this.select.options[i]=null;
			}
		for(i=0;i<this.allOptions.length;i++)
			{
			this.select.options[i]=this.allOptions[i];
			}
		
		}

	/*
	*	Met à jour le contenu de la liste en fonction
	*	du texte saisie dans le champ
	*/
	SearchList.prototype.MAJListe=function()
		{
		
		var search=this.text.value;
		//alert(search) ;
		if(search=="")
			{
			this.restoreListe();
			return;
			}
		else
			{
			this.viderListe();
			for(i=0;i<this.allOptions.length;i++)
				{
				if(!this.caseSensitive)
					{
					if(this.allOptions[i].text.toUpperCase().indexOf(search.toUpperCase())==0)
						this.select.options[this.select.options.length]=this.allOptions[i];
					}
				else
					{
					if(this.allOptions[i].text.indexOf(search)==0)
						this.select.options[this.select.options.length]=this.allOptions[i];
					}
				}
			}
		}
	
	

