// les fonctions génériques ============================ js/_gen.js ===
//	un getElementsByClassName
document.getElementsByClassName = function(clsName){
    var retVal = new Array();
    var elements = document.getElementsByTagName("*");
    for(var i = 0;i < elements.length;i++){
        if(elements[i].className.indexOf(" ") >= 0){
            var classes = elements[i].className.split(" ");
            for(var j = 0;j < classes.length;j++){
                if(classes[j] == clsName)
                    retVal.push(elements[i]);
            }
        }
        else if(elements[i].className == clsName)
            retVal.push(elements[i]);
    }
    return retVal;
}
	// la meme en syntaxe rapide
		function getClass(classname){return document.getElementsByClassName(classname);}
// en méthode de l'objet Element
function opacite(opa_){ 
	if(document.all && !window.opera){ 
		this.style.filter = "alpha(opacity=" + opa_ + ");" 
	}else{ 
		var Val = opa_/100; 
		this.style.setProperty( "-moz-opacity", Val, ""); 
		this.style.setProperty( "-khtml-opacity", Val, ""); 
		this.style.setProperty( "opacity", Val, ""); 
	} 
}
Element.prototype.opacite=opacite;
// <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
function elmt_on_off(){
	var set;
	etat=this.style.display;
	if(etat=="block"){set='none';}
	if(etat=="none"){set='block';}
	this.style.display=set;
}
Element.prototype.elmt_on_off=elmt_on_off;
function nln_on_off(){
	var set;
	var etat=this.style.display;
	if(etat=="inline"){set='none';}
	if(etat=="none"){set='inline';}
	this.style.display=set;
}
Element.prototype.nln_on_off=nln_on_off;
// <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
function setCursor(etat){
	this.onmouseover=function(){document.body.style.cursor=etat;};
	this.onmouseout=function(){document.body.style.cursor='auto';};
}
Element.prototype.setCursor=setCursor;
//	le split sur un caractère qui retourne un tableau 
//	bug peut-être si le caractère recherché est présent à l'index 0
function split(car){
	var tab = new Array();
	var deb;
	var fin=0;
	var i=0;
	var test;
	while(test!=-1){
		deb=fin;
		fin=this.indexOf(car,deb+1);
		test=fin;
		if(fin==-1){fin=this.length;}
		if(deb!=0){deb+=car.length;}
		tab[i]=this.substring(deb,fin);
		i++;
	}
	return tab;
}
String.prototype.split = split;
//	pour définir une instance d'objet requete asynchrone
function getXhr(){
	if(window.XMLHttpRequest){return new XMLHttpRequest();}
	else if(window.ActiveXObject){
		try{return new ActiveXObject("Msxml2.XMLHTTP");}
		catch (e){return new ActiveXObject("Microsoft.XMLHTTP");}
	}else{alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest, veuillez le mettre à jour");
    return false;
	}
}
// WMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWM
function showCdDirs(dir){
	this.onmouseover=function(){
		dir.set_screenPlace(0,this.offsetWidth);
		dir.style.display="block";
	}
	this.onmouseout=function(){
		dir.style.display='none';
	}
}
Element.prototype.showCdDirs=showCdDirs;
// WMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWM
function OfstLeft(){
	if(this.offsetParent){
		return ( this.offsetLeft + this.offsetParent.offsetLeft );
	}else{
		return (this.offsetLeft);
	}
}
Element.prototype.OfstLeft=OfstLeft;
// WMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWM
function OfstTop(){
	if(this.offsetParent){
		return ( this.offsetTop + this.offsetParent.offsetTop );
	}else{
		return (this.offsetTop);
	}
}
Element.prototype.OfstTop=OfstTop;
// WMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWM
function set_screenPlace(top,left){
	var parent=this.parentNode;
	if(top==undefined){top=0;}
	if(left==undefined){left=0;}
	this.style.top=(parent.OfstTop()+top)+'px';
	this.style.left=(parent.OfstLeft()+left)+'px';
}
Element.prototype.set_screenPlace=set_screenPlace;
// WMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWM
function center(){
    var wo=this.offsetWidth;
    var we=document.body.parentNode.offsetWidth;
    this.style.left=(we/2)-(wo/2)+"px";
    var ho=this.offsetHeight;
    var sTop=document.body.parentNode.scrollTop;
    var he=document.body.offsetHeight;
    this.style.top=sTop+210+"px"; // (he/2)-(ho/2)+sTop+"px";
}
Element.prototype.center=center;
// WMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWM
function set_la_bulle(){
	var add_bulle=document.getElementsByClassName('add_bulle');
	var la_bulle=document.getElementsByClassName('la_bulle');
	// et pour chaque
	if(add_bulle!=null){
		for(i=0;i<add_bulle.length;i++){
			add_bulle[i].showBulle(la_bulle[i]);
			la_bulle[i].style.display='none';
		}
	}
}
// ....................................................................
function close_bulle(){
	var bulle=document.getElementsByClassName('la_bulle');
	if(bulle!=null){
	    for(i=0;i<bulle.length;i++){
		bulle[i].style.display="none";
	   }
	}
}
// ....................................................................
function showBulle(bulle){
//	alert(this.offsetWidth);
	this.onmouseover=function(){
		bulle.set_screenPlace(0,this.offsetWidth);
		bulle.style.display="block";
	}
	this.onmouseout=function(){
		bulle.style.display='none';
	}
}
Element.prototype.showBulle=showBulle;
// WMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWM
function toogle_div(obj1,obj2){
	this.onclick=function(){
		obj1.elmt_on_off();
		obj2.elmt_on_off();
	};
	this.setCursor('pointer');
}
Element.prototype.toogle_div=toogle_div;
// WMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWM
function toogle_span(sp1,sp2){
	this.onclick=function(){
		sp1.nln_on_off();
		sp2.nln_on_off();
	};
	this.setCursor('pointer');
}
Element.prototype.toogle_span=toogle_span;
// WMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWM
function setDivHtml( id, html ){
	var div=document.getElementById( id );
	if(div==null || div==undefined){alert("'"+id+"' n'existe pas");return;}
	div.innerHTML=html;
}
// WMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWM
function verifEmail(email) { // vérif validité email par REGEXP
	var reg = /^[a-z0-9._-]+@[a-z0-9.-]{2,}[.][a-z]{2,3}$/;
  	return (reg.exec(email)!=null);
}


