var ie = /MSIE/.test(navigator.userAgent);
var moz = !ie && navigator.product == "Gecko";
var csch = "/";
var $=function(id){return document.getElementById(id);};

if (moz) {
    	HTMLElement.prototype.__defineGetter__("children", function() {
			var arr = new Array(), i = 0, l = this.childNodes.length;
			for ( i = 0; i < l; i++ ) {
				if ( this.childNodes[ i ].nodeType == 1 ) {
					arr.push( this.childNodes[ i ] );
				}
			}
			return arr;
		});
		HTMLElement.prototype.__defineGetter__("firstChild", function() {
			var node = this.childNodes[ 0 ];
			while (node.nodeType != 1) node = node.nextSibling;
			return node;
		});
		HTMLElement.prototype.__defineGetter__("lastChild", function() {
			var node = this.childNodes[ this.childNodes.length - 1 ];
			while (node.nodeType != 1) node = node.previousSibling;
			return node;
		});
}




//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
//          contrôle de surface                         ::::::::::::::::::::::::::::::::::::::::::::::::


function checkEmail(text)
{

    var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
    var check=/@[\w\-]+\./;
    var checkend=/\.[a-zA-Z]{2,4}$/;
    if (((text.search(exclude) != -1)||(text.search(check)) == -1)||(text.search(checkend) == -1))
    {
        return false;
    }
    return true;
}


function trim(string)
{ 
	return string.replace(/(^\s*)|(\s*$)/g,''); 
}


function checkEmailMultiple(text)
{

    arrayOfStrings = text.split(",");
	//alert(arrayOfStrings.length);
	for (var i=0; i < arrayOfStrings.length; i++) {
      if (trim(arrayOfStrings[i])!='' && !checkEmail(trim(arrayOfStrings[i]))){
      alert(trim(arrayOfStrings[i]));
      	return false;
      }
   	}
   	return true;
}

// Function to check field value
function ValidateField(strFieldName)
{
    if (strFieldName.value.length>0) return true;
	return false;
}


function ValidateCodePostal(codePostal)
{
	if (isNaN(codePostal)) return false;
	if (codePostal.length!=5) return false;
	return true;
}

function CheckNum(num)
{
	if (num.length>=0) {
		if (isNaN(num)) return false;
	}
	return true;
}




//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
//             Mail                    ::::::::::::::::::::::::::::::::::::::::::::::::


function mail(page)
{
     if (page!=''){
         page_url='annuaire_mail.php?page='+page;
     } else {
         page_url='annuaire_mail.php';
     }
     var pTemp=window.open(page_url, 'mail', 'left=330, top=80, width=400, height=558, toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,scrollbars=no');
	 pTemp.document.close();
     pTemp.focus();
}

function quickMail()
{
     page_url='annuaire.php';
     var pTemp=window.open(page_url, 'quickMail', 'left=330, top=80, width=400, height=558, toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,scrollbars=no');
     pTemp.document.close();
     pTemp.focus();
}


function annuaire(elmt){
     if (elmt!=''){
         page_url='annuaire.php?id='+elmt;
     } else {
         page_url='annuaire.php';
     }

     var pTemp=window.open(page_url, 'annuaire', 'left=330, top=80, width=410, height=558, toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,scrollbars=no');
   	 pTemp.document.close();
     pTemp.focus();
}

function resizePopUp(monImage, monTitre)
{
  w = window.open('','chargement','width=1,height=1');
  w.document.write( "<html><head><title>"+monTitre+"</title>\n" );
  w.document.write( "<script language='JavaScript'>\n");
  w.document.write( "IE5=NN4=NN6=false;\n");
  w.document.write( "if(document.all)IE5=true;\n");
  w.document.write( "else if(document.getElementById)NN6=true;\n");
  w.document.write( "else if(document.layers)NN4=true;\n");
  w.document.write( "function autoSize() {\n");
  w.document.write( "if(IE5) self.resizeTo(document.images[0].width+10,document.images[0].height+31)\n");

  w.document.write( "else window.resizeTo(document.images[0].width+2,document.images[0].height+45)\n");
  w.document.write( "self.focus();\n");
  w.document.write( "}\n</script>\n");
  w.document.write( "</head><body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0 onLoad='javascript:autoSize();'>" );
  w.document.write( "<a href='javascript:window.close();'><img src='"+monImage+"' border=0 alt='"+monTitre+"'></a>" );
  w.document.write( "</body></html>" );
  w.document.close();
}



function annonce(){

     var pTemp=window.open('recrutement_annonce.php', 'annonce', 'left=330, top=100, width=417, height=600,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,scrollbars=yes');
   	 pTemp.document.close();
     pTemp.focus();
}

function annonce_validation(elmt){

     page_url='recrutement_validation.php?id='+elmt;
     var pTemp=window.open(page_url, 'annonce_validation', 'left=330, top=100, width=417,height=600,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,scrollbars=yes');
   	 pTemp.document.close();
     pTemp.focus();
}


function connexion(elmt){

     if (elmt==1){
       page_url='connexion.php';
     } else if (elmt==2){
       page_url='connexion.php?cas=1';
     }  else if (elmt==3){
       page_url='http://www.france-orchestres.com/connexion.php?cas=1';
     }
     var pTemp=window.open(page_url, 'connexion', 'left=330, top=100, width=400, height=558, toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,scrollbars=no');
   	 pTemp.document.close();
     pTemp.focus();
}

function infopratique(elmt){

     var pTemp=window.open('info.php', 'infopratique', 'left=330, top=100, width=400, height=558, toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,scrollbars=no');
   	 pTemp.document.close();
     pTemp.focus();
}

function plansite(elmt){

     var pTemp=window.open('plan.php', 'plansite', 'left=330, top=100, width=400, height=558, toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,scrollbars=no');
   	 pTemp.document.close();
     pTemp.focus();
}


function avantages_membres(){

     var pTemp=window.open('avantages_membres.php', 'avantages_membres', 'left=330, top=100, width=729, height=570, toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,scrollbars=no');
   	 pTemp.document.close();
     pTemp.focus();
}


function annonce_edition(elmt){

     page_url='recrutement_edition.php?id='+elmt;
     var pTemp=window.open(page_url, 'annonce_edition', 'left=330, top=100, width=417, height=600,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,scrollbars=yes');
   	 pTemp.document.close();
     pTemp.focus();
}

function annonce_subcription(elmt){

     if (elmt!=''){
         page_url='recrutement_subscription.php?id='+elmt;
     } else {
         page_url='recrutement_subscription.php';
     }

     var pTemp=window.open(page_url, 'annonce_subscription', 'left=330, top=100, width=400, height=610, toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,scrollbars=yes');
   	 pTemp.document.close();
     pTemp.focus();
}

   function checkAnnuaire(elmtItem){

            if (!elmtItem.checked){                   // retrait de l'item

             var elmt=elmtItem.parentNode.parentNode.parentNode.parentNode;
             if (elmtItem.className=="choix-M"){
                  // si le membre est le dernier de l'orchestre alors retrait de l'orchestre

                      LJ=elmtItem.parentNode.parentNode.parentNode.parentNode;
                      bool = true;
                      for(j=0; j < LJ.children.length; j++){
                         if (LJ.children[j].className=="search-M"){
                           if (LJ.children[j].children[0].children[0].children[0].checked){
                               bool = false;
                           }
                         }
                      }
                      if (bool){
                        elmt.children[0].children[0].children[0].children[0].checked=false;
                      }


             } else if (elmtItem.className=="choix-O"){
                LJ=elmt.children;
                for(i=0; i < LJ.length; i++){
                   if (LJ[i].className=="search-M"){
                     //  retrait de tous les membres de l'orchestre
                     LJ[i].children[0].children[0].children[0].checked=false;
                   }
                }
             }

         } else {           // sélection de l'item

             var elmt=elmtItem.parentNode.parentNode.parentNode.parentNode;
             if (elmtItem.className=="choix-M"){

                //alert (elmt.children[0].children[0].children[0].children[0].className);
                if (!elmt.children[0].children[0].children[0].children[0].checked){
                   elmt.children[0].children[0].children[0].children[0].checked=true;
                }
             } else if (elmtItem.className=="choix-O"){
                LJ=elmt.children;
                for(i=0; i < LJ.length; i++){
                   if (LJ[i].className=="search-M"){
                     //alert (LJ[i].children[0].children[0].children[0].className);
                     LJ[i].children[0].children[0].children[0].checked=true;
                   }
                }
             }
         }
    }

    function checkAllMail(){

      //field=document.mailForm.choix-M;
      field=document.mailForm;

        for (i = 0; i < field.length; i++) {
           field[i].checked = true;
        }
    }

    function checkAnnuaireMail(){


        msg = '';
        bool = false;
        field=document.mailForm;
        var elmtTemp = document.getElementById('membres');
        elmtTemp.value='';

        for (i = 0; i < field.length; i++) {
           if (field[i].checked == true && field[i].className == "choix-M"){
               bool = true;
               if (elmtTemp.value==''){
                    elmtTemp.value=field[i].value.substring(0);
               } else {
                    elmtTemp.value=elmtTemp.value+","+field[i].value.substring(0);
               }
             }
        }
        
        if (bool == false){
      	   msg += 'Sélectionnez au moins une personne\n';
           alert(msg);
        }
        return bool;

        msg = '';
  	    bool = true;
    }



        function checkNewsletterForm(){

        msg = '';
        bool = false;

        field=document.newsletterForm;
        var elmtTemp = document.getElementById('membres');
        elmtTemp.value='';

        elmtTab = new Array();

        for (i = 0; i < field.length; i++) {
           if (field[i].checked == true && field[i].className == "choix-M"){
               bool = true;
               if (field[i].value.substring(0)!=''){
                   if (elmtTemp.value==''){
                       // elmtTemp.value=field[i].value.substring(0);
                       elmtTab[0]=field[i].value.substring(0);
                       j=0;
    
                   } else {
                       j+=1;
                       // elmtTemp.value=elmtTemp.value+","+field[i].value.substring(0);
                       elmtTab[j]=field[i].value.substring(0);
                   }
                }
           }
           elmtTemp.value = elmtTab;
        }

        if (bool == false){
      	   msg += 'Sélectionnez au moins une personne\n';
           alert(msg);
        }
        return bool;

        msg = '';
  	    bool = true;
    }

        function checkFlashForm(){

        msg = '';
        bool = false;

        field=document.flashForm;
        var elmtTemp = document.getElementById('membres');
        elmtTemp.value='';

        elmtTab = new Array();

        for (i = 0; i < field.length; i++) {
           if (field[i].checked == true && field[i].className == "choix-M"){
               bool = true;
               if (field[i].value.substring(0)!=''){
                   if (elmtTemp.value==''){
                       elmtTab[0]=field[i].value.substring(0);
                       j=0;
    
                   } else {
                       j+=1;
                       elmtTab[j]=field[i].value.substring(0);
                   }
                }
           }
           elmtTemp.value = elmtTab;
        }

        if (bool == false){
      	   msg += 'Sélectionnez au moins une personne\n';
           alert(msg);
        }
        return bool;

        msg = '';
  	    bool = true;
    }



//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
//             fonctions   OVER                 ::::::::::::::::::::::::::::::::::::::::::::::::


function profilOver(elmtProfil)
    {

        var elmt = elmtProfil;
        if (elmt.parentNode.className == "collapse"){
          if (elmt.className == "puce-a"){
              elmt.className = "puce-a-over";
          } else if (elmt.className == "puce-a-over"){
              elmt.className = "puce-a";
          } else if (elmt.className == "puce-b"){
              elmt.className = "puce-b-over";
          } else if (elmt.className == "puce-b-over"){
              elmt.className = "puce-b";
          } else if (elmt.className == "puce-c"){
              elmt.className = "puce-c-over";
          } else if (elmt.className == "puce-c-over"){
              elmt.className = "puce-c";
          }
        }
    }
    


function newsOver(elmtNews)
    {

        var elmt = elmtNews;
        if (elmt.parentNode.className == "collapse"){
          if (elmt.className == "puce"){
              elmt.className = "puceOver";
          } else {
              elmt.className = "puce";
          }
        }
    }
    

function liMenuOver(elmtLi)
    {

        var elmt = elmtLi;
        if (elmt.className == "liMenuOut"){
            elmt.className = "liMenuOver";
        } else {
            if (GetCookie("rubrique")!=elmtLi.id){
                 elmt.className = "liMenuOut";
            }
        }
    }

function liMenuClic(elmtLi)
    {
          elmt = elmtLi.parentNode;
          SetCookie("rubrique",elmt.id);
    }
  
  function liAdminOver(elmtLi)
    {

        var elmt = elmtLi;
        if (elmt.className == "liAdminOut"){
            elmt.className = "liAdminOver";
        } else {
            if (GetCookie("rubrique_admin")!=elmtLi.id){
                 elmt.className = "liAdminOut";
            }
        }
    }

function liAdminClic(elmtLi)
    {
        elmt = elmtLi.parentNode;
        SetCookie("rubrique_admin",elmt.id);
    }


function flecheDetail (elmtFleche)
    {

        var elmt = elmtFleche.parentNode.parentNode;
        if (elmt.children[0].className == "fleche"){
            elmt.children[0].className = "flecheOver";
        } else {
            elmt.children[0].className = "fleche";
        }
    }
    
function deconnexion()
    {
          SetCookie("menu","id000");
          SetCookie("rubrique","id000");
          window.location.href="index.php";
    }


//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
//             fonctions   REDUCTION                 ::::::::::::::::::::::::::::::::::::::::::::::::


function SetCookie (name, value)
{
    // un cookie a besoin d'un nom, d'une valeur, d'un nom de domaine, d'une date d'expiration
    //
    var argv=SetCookie.arguments;
    var argc=SetCookie.arguments.length;
    var expires=(argc > 2) ? argv[2] : null;
    var path=(argc > 3) ? argv[3] : null;
    var domain=(argc > 4) ? argv[4] : null;
    var secure=(argc > 5) ? argv[5] : false;
    document.cookie=name+"="+escape(value)+
        ((expires==null) ? "" : ("; expires="+expires.toGMTString()))+
        ((path==null) ? "" : ("; path="+path))+
        ((domain==null) ? "" : ("; domain="+domain))+
        ((secure==true) ? "; secure" : "");
}

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 getCookieVal (j);
        i=document.cookie.indexOf(" ",i)+1;
        if (i==0) break;
    }
    return null;

}


function OpenMenu()
  {

     var menu=GetCookie("menu");

      if (menu!=""){
        var elmtParent = document.getElementById('id001');

        LI = elmtParent.children;
        for (i=0; i<LI.length; i++){
            elmt=LI[i];
            if (elmt.className == "M"){
              if (elmt.children[0].id==menu){
                  elmt.children[2].className = "end";
                  elmt.children[1].className = "content";
                  elmt.children[0].className = "expand";

                  var rubrique=GetCookie("rubrique");
                  LJ = elmt.children[1].children[0].children;
                  for (j=0; j<LJ.length; j++){
                      if (LJ[j].id==rubrique){
                        LJ[j].className = "liMenuOver";
                      }
                  }
              }
            }
        }
      }
  }

  function OpenAdmin()
  {

        var elmtParent = document.getElementById('id101');

        LI = elmtParent.children;
        for (i=0; i<LI.length; i++){
            elmt=LI[i];
            if (elmt.className == "M"){

                  var rubrique=GetCookie("rubrique_admin");
                  LJ = elmt.children[1].children[0].children;
                  for (j=0; j<LJ.length; j++){
                      if (LJ[j].id==rubrique){
                        LJ[j].className = "liAdminOver";
                      }
                  }
            }
      }
  }

  function SetMenuHome(elmtMenu)
    {

        // menu précédent
        var elmt = elmtMenu.parentNode;
        SetCookie("menu",elmt.id);
        
        if (elmt.id=="id001-1"){

          SetCookie("rubrique","id002-1");
        } else if (elmt.id=="id001-2"){
          
          SetCookie("rubrique","id003-0");
        } else if (elmt.id=="id001-3"){

          SetCookie("rubrique","id004-2");
        } else if (elmt.id=="id001-4"){

          SetCookie("rubrique","id005-0");
        }
    }

  function SetMosaiqueHome(rub)
    {

        if (rub=="id004-5" || rub=="id004-3" || rub=="id004-2"){
             SetCookie("menu","id001-3");
             SetCookie("rubrique",rub);
        } else if (rub.substring(0,5)=="id003"){
             SetCookie("menu","id001-2");
             SetCookie("rubrique",rub);
        } else if (rub.substring(0,5)=="id0b3"){
             SetCookie("menu","id001-1");
             SetCookie("rubrique","id003"+rub.substring(5));
        } else if (rub=="id002-1"){
             SetCookie("menu","id001-1");
             SetCookie("rubrique",rub);
        } else {
             SetCookie("menu","");
             SetCookie("rubrique","");
        }
    }

   function PlanSiteClic(rub)
    {

        if (rub=="id004-1" || rub=="id004-2" || rub=="id004-3" || rub=="id004-4" || rub=="id004-5"){
             SetCookie("menu","id001-3");
             SetCookie("rubrique",rub);
        } else if (rub=="id005-1"){
             SetCookie("menu","id001-4");
             SetCookie("rubrique","");
        } else if (rub=="id003-0"){
             SetCookie("menu","id001-2");
             SetCookie("rubrique",rub);
        } else if (rub=="id002-1" || rub=="id002-2" || rub=="id002-5"){
             SetCookie("menu","id001-1");
             SetCookie("rubrique",rub);
        } else if (rub.substring(0,5)=="id003"){
             SetCookie("menu","id001-2");
             SetCookie("rubrique",rub);
        } else if (rub.substring(0,5)=="id0b3"){
             SetCookie("menu","id001-1");
             SetCookie("rubrique","id003"+rub.substring(5));
        } else {
             SetCookie("menu","");
             SetCookie("rubrique","");
        }
    }


function SetMenu(elmtMenu)
    {
        // menu précédent
        var elmt = elmtMenu.parentNode.parentNode.parentNode;
        LI = elmt.children;
        for (i=0; i<LI.length; i++){
           if (elmt.children[i].className == "M"){
              if (elmt.children[i].children[0].className == "expand"){
                 elmt.children[i].children[2].className = "endcollapse";
                 elmt.children[i].children[1].className = "contentcollapse";
                 elmt.children[i].children[0].className = "collapse";
              }
           }
        }

        // menu courant
        var elmt = elmtMenu.parentNode.parentNode;

        if (elmtMenu.parentNode.id=="id001-4"){
              SetCookie("menu","id001-4");
              SetCookie("rubrique","id005-0");
        } else {
          if (elmt.children[0].className == "expand"){
              elmt.children[2].className = "endcollapse";
              elmt.children[1].className = "contentcollapse";
              elmt.children[0].className = "collapse";
  
          } else {
              elmt.children[2].className = "end";
              elmt.children[1].className = "content";
              elmt.children[0].className = "expand";
              SetCookie("menu",elmt.children[0].id);
          }
        }
    }


function Reduc(elmtTitre)
    {
        var elmt = elmtTitre.parentNode.parentNode;
        if (elmt.children[0].className == "expand")
        {
            elmt.children[1].className = "contentcollapse";
            elmt.children[0].className = "collapse";
            //SetCookie(elmt.id,"collapse");
        }
        else
        {
            elmt.children[1].className = "content";
            elmt.children[0].className = "expand";
            //SetCookie(elmt.id,"expand");
        }
    }


function ReducBib(elmtId)
    {
        var elmt__Id='content'+elmtId;

        var elmt = document.getElementById(elmt__Id);
        if (elmt.children[0].className == "expand")
        {
            elmt.children[1].className = "contentcollapse";
            elmt.children[0].className = "collapse";
        }
        else
        {
            elmt.children[1].className = "content";
            elmt.children[0].className = "expand";
        }
    }


function ReducForce(elmtTitre)
    {
        var elmt = elmtTitre.parentNode.parentNode;
            elmt.children[1].className = "contentcollapse";
            elmt.children[0].className = "collapse";
    }


//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
//             fonctions                    ::::::::::::::::::::::::::::::::::::::::::::::::



function afficherPopup(elmtTitre)
    {

         var elmt = elmtTitre.parentNode.parentNode.parentNode;
//       alert(elmt.id);
         LI = elmt.children;
       //alert(LI.length);
         for (i=0; i<LI.length; i++){
// alert(elmt.children[i].className);
             if (elmt.children[i].className == "R"){
                 LJ=elmt.children[i].children;
//                 alert(elmt.children[i].children);

                 for (j=0; j<LJ.length; j++){
                     if (elmt.children[i].children[j].id.indexOf("contenu") != -1){
                        //alert(elmt.children[i].children[j].id);
                        if (elmt.children[i].children[j].id=="contenu"+elmtTitre.value){

                           elmt.children[i].children[j].className = "content";
                        } else {
                           elmt.children[i].children[j].className = "collapse";
                        }
                     }
                 }
             }
         }
    }

    function IncNbFichiers(idDos,n)
    {
         var elmt=document.getElementById("dossier"+idDos);
         elmtE=elmt.value.split(" ");
         elmt.value=parseInt(elmtE[0])+n;

         if ( elmt.value >1 ){
           elmt.value=elmt.value+" documents";
         } else {
           elmt.value=elmt.value+" document";
         }
    }



    function showMembre(n)
    {
         var elmt=document.getElementById("tmp_membres"+n);
         window.location.href="membre.php?id="+elmt.options[elmt.selectedIndex].value;
    }


    function fermerCategorie(elmtTitre)
    {
        var elmt = elmtTitre.parentNode.parentNode;
        elmt.className = "collapse";

    }

    function checkItem(elmtItem,h){

         var elmtTemp = document.getElementById('dossiers');
         var elmtId = elmtItem.id.substring(5);


         if (!elmtItem.checked){                   // retrait de l'item

            // retrait du tampon
            if (h){                                // retrait hiérarchiquement descendant
              var LId = elmtTemp.value.split("$");
              elmtTemp.value='';
              for(i=0; i < LId.length; i++){
                 if (LId[i]!=elmtId){
                   if (elmtTemp.value==''){
                     elmtTemp.value=LId[i];
                   } else {
                     elmtTemp.value=elmtTemp.value+"$"+LId[i];
                   }
                 }
              }
            }

            var elmt=elmtItem.parentNode.parentNode;
            LI=elmt.children[1].children;
            alert(LI.length);
            var i;
            for(i=0; i < LI.length; i++){
              alert(i);
              if (LI[i].className == "C"){               // ===DIV du dossier fils
                 LJ=LI[i].children[0].children[1];
                 if (LJ.id.indexOf("choix") != -1){   // ===balise du checkbox fils
                    if (LJ.checked){
                        LJ.checked=false;
                        //checkItem(LJ,true);
                    }
                 }
               }
           }
         } else {           // sélection de l'item
             var elmt=elmtItem.parentNode.parentNode.parentNode.parentNode;

             // alimentation du tampon
             if (h){
               if (elmtTemp.value==''){
                 elmtTemp.value=elmtId;
               } else {
                 elmtTemp.value=elmtTemp.value+"$"+elmtId;
               }
             }

             if (elmt.className == "C"){              // ===DIV du dossier parent
                 LJ=elmt.children[0].children[1];
                 if (LJ.id.indexOf("choix") != -1){   // ===balise du checkbox parent
                    if (!LJ.checked){
                       LJ.checked=true;
                       checkItem(LJ,false);
                    }
                 }
             }
         }
    }



    function li_multiple_InOut(elmtButton) {

    var elmtOut=elmtButton.parentNode.parentNode.children[0].children[0];
    var elmtIn=elmtButton.parentNode.parentNode.children[2].children[0];

		if (elmtButton.name=="ajout" && elmtOut.value) {

            var inrow=elmtIn.length;
            for (row=0;row<elmtOut.length;row++) {
                if (elmtOut.options[row].selected){
                  elmtIn[inrow] = new Option(elmtOut.options[row].text,elmtOut.options[row].value);
                  inrow++;
                }
            }

            var newrow=0;
			newvalue = new Array();
			newtext = new Array();
            for (row=0;row<elmtOut.length;row++) {
				if (!elmtOut.options[row].selected) {
					newvalue[newrow]= elmtOut.options[row].value;
					newtext[newrow]=elmtOut.options[row].text;
					newrow++;
				}
			}

			newlen=newvalue.length;
            elmtOut.options.length=0;
			for (row=0;row<newlen;row++) {
				elmtOut[row] = new Option(newtext[row],newvalue[row]);
            }
		} else if (elmtButton.name=="retrait" && elmtIn.value) {

            var outrow=elmtOut.length;
            for (row=0;row<elmtIn.length;row++) {
                if (elmtIn.options[row].selected){
                  elmtOut[outrow] = new Option(elmtIn.options[row].text,elmtIn.options[row].value);
                  outrow++;
                }
            }

            var newrow=0;
			newvalue = new Array();
			newtext = new Array();
            for (row=0;row<elmtIn.length;row++) {
				if (!elmtIn.options[row].selected) {
					newvalue[newrow]= elmtIn.options[row].value;
					newtext[newrow]=elmtIn.options[row].text;
					newrow++;
				}
			}

			newlen=newvalue.length;
            elmtIn.options.length=0;
			for (row=0;row<newlen;row++) {
				elmtIn[row] = new Option(newtext[row],newvalue[row]);
            }
		}
	}


   function li_multiple_UpDown(elmtButton) {

       var elmt=elmtButton.parentNode.parentNode.parentNode.children[0];

		if (elmtButton.name=="up" && elmt.selectedIndex!=-1) {

           if (elmt.selectedIndex>0){
              var rowid=elmt.selectedIndex;
  			  tmpid = rowid-1;

              rowtext=elmt.options[rowid].text;
              rowvalue=elmt.options[rowid].value;
              tmptext=elmt.options[tmpid].text;
              tmpvalue=elmt.options[tmpid].value;

              elmt.options[tmpid].text=rowtext;
              elmt.options[tmpid].value=rowvalue;
              elmt.options[rowid].text=tmptext;
              elmt.options[rowid].value=tmpvalue;
              
              elmt.selectedIndex=tmpid;
           }

		} else if (elmtButton.name=="down" && elmt.selectedIndex!=-1) {

           if (elmt.selectedIndex<elmt.length-1){
              var rowid=elmt.selectedIndex;
  			  tmpid = rowid+1;

              rowtext=elmt.options[rowid].text;
              rowvalue=elmt.options[rowid].value;
              tmptext=elmt.options[tmpid].text;
              tmpvalue=elmt.options[tmpid].value;

              elmt.options[tmpid].text=rowtext;
              elmt.options[tmpid].value=rowvalue;
              elmt.options[rowid].text=tmptext;
              elmt.options[rowid].value=tmpvalue;
              
              elmt.selectedIndex=tmpid;
           }
		}
	}


// ******************************************************************
// Macromedia image swap management
// ******************************************************************

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0

  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}



////////////////////////////////////////////////////////////////////////////////////////////////////////////////








        /// mode : - 0 si onglet et le button
        ///        - autre si c'est l'id du parent des onglets
        function OngletChange(onglet, number,mode){
            var elmt;
            if (mode == 0) elmt = onglet.parentNode.parentNode.parentNode;
            else elmt = document.getElementById(onglet);
            LI = elmt.firstChild.getElementsByTagName("a");
            for(i=0; i < LI.length; i++){
                if (i == number) LI[i].className = "Actif";
                else LI[i].className = "";
            }
           var i=0;
           node = elmt.children[ 1 ];
           while (node != null){ 
           if (node.nodeType == 1){
            var nodeTitre = node.children[ 0 ];
            var b = false;
            while (!(nodeTitre == null || b))
            {
                if(nodeTitre.nodeType == 1) {nodeTitre.style.display = "none";nodeTitre.style.visibility = "hidden";b=true;}
                nodeTitre = nodeTitre.nextSibling;
            }
            if (i == number) {node.style.display = "block"; node.style.visibility = "visible" }
            else {node.style.display = "none";node.style.visibility = "hidden"}
            i++;}
           node = node.nextSibling; }
        }
        
  function OngletLoad(id)
  {
    var elmtOnglet = document.getElementById(id);
    var Onglets = new Array();
        node = elmtOnglet.children[ 0 ];
        var i =0;
        while (node != null)
        { 
           if (node.nodeType == 1)
           {
                var nodeTitre = node.children[ 0 ];
                var b = false;
                while (!(nodeTitre == null || b ))
                {
                    if(nodeTitre.nodeType == 1) 
                    {
                        Onglets[i] = nodeTitre.innerHTML;
                        b=true;
                    }
                    nodeTitre = nodeTitre.nextSibling;
                }
           i++;
           }
           node = node.nextSibling; 
        }
    var tmpOngletContent = elmtOnglet.innerHTML;
    elmtOnglet.innerHTML = '';
    for (var i=0; i < Onglets.length; i++ )
    {
        var Onglet = '<li';
        if(i==0)
            Onglet += ' class="first"';
        Onglet += '> <a href="javascript:void(0);" onclick="OngletChange(this,' + i + ',0)">';
        Onglet += Onglets[i] ;
        Onglet += '</a></li>';
        elmtOnglet.innerHTML += Onglet;
    }
     elmtOnglet.innerHTML = '<ul class="Onglet">' + elmtOnglet.innerHTML+ '</ul>' + tmpOngletContent;
     OngletChange(id, 0, 1);
  }
  
  function getTitreFromIdBloc(id)
  {
    return "Titre";
  }

        // Déclaration des variables 'domaine' et 'date d'expiration'
        var pathname=location.pathname;
        var myDomain=pathname.substring(0,pathname.lastIndexOf('/')) +'/';
        var date_exp = new Date();
        date_exp.setTime(date_exp.getTime()+(365*24*3600*1000)); 
        
        function getCookieVal(offset) {
            var endstr=document.cookie.indexOf (";", offset);
            if (endstr==-1)
                    endstr=document.cookie.length;
            return unescape(document.cookie.substring(offset, endstr));
        }




/* Gestion des notes */
var agent = navigator.userAgent.toLowerCase(); 
var AllowOpacity = (agent.indexOf('opera') == -1 )

var DefaultNote = 5;
var AlreadyVote = false;
var LowOpacity = 40;
var MediumOpacity = 60;
var HighDensity = 100;

function Note_event(n)
{
	try
	{
		for (var i=1; i < 11; i++ )
		{
				SetOpacity(document.getElementById("Note").getElementsByTagName("img")[i - 1], LowOpacity);
        }
        

        if (AlreadyVote)
            n = DefaultNote;
		if (n == null && AlreadyVote == false)
			for (var j=1; j < DefaultNote + 1; j++ )
				SetOpacity(document.getElementById("Note").getElementsByTagName("img")[j - 1], MediumOpacity);
		else
			for (var j=1; j < n + 1; j++ )
				SetOpacity(document.getElementById("Note").getElementsByTagName("img")[j - 1], HighDensity);
	}
	catch(ex)
	{
			//alert("Il y a une erreur : \n Surement à cause du browser qui accepte pas l'opacité \n\n" + ex);
	}
}

function SetOpacity(elmt, opacity)
{
	if(document.all)
	{
		elmt.style.filter = "alpha(opacity=" + opacity + ");"
	}
	else
	{
		elmt.style.setProperty("-moz-opacity", opacity/100, "");
		elmt.style.setProperty("-khtml-opacity", opacity/100, "");
		elmt.style.setProperty("opacity", opacity/100, "");
	}
}

var LAnote = 0;
var LEChemin = "/";
var LECID = 0;
var LL = true;
var TT = "code";

function GiveNote(note, Chemin, CID, L, T)
{
    if (!L)
    {
        alert("Pour donner une note vous devez être authentifié\nveuillez vous authentifier pour donner votre note");
        LL = false;
        showlogin();
    } else {
        if (!AlreadyVote)
        {
            LAnote = note;
            LEChemin = Chemin;
            LECID = CID;
            if (T == "code")
            {
                SendNote(Chemin + "codevote.aspx?n=" + note + "&id=" + CID + "&r=" + escape((new Date()).getTime()))
            } else {
                SendNote(Chemin + "tutovote.aspx?n=" + note + "&id=" + CID + "&r=" + escape((new Date()).getTime()))
            }
        } else {
            alert("Vous avez déjà voté pour ce code");
        }
    }
}

function SendNote(ReqUrl)
{
    if ( window.XMLHttpRequest ) {
        ReqXhttp = new window.XMLHttpRequest();
	} else if ( window.ActiveXObject ) {
		ReqXhttp = new ActiveXObject( 'Microsoft.XMLHTTP' );
	}
	ReqXhttp.onreadystatechange = function() { SendNoteCallBack(); };
	ReqXhttp.open( 'GET', ReqUrl);
	ReqXhttp.send( null );
}

SendNoteCallBack = function()
{
	if ( ReqXhttp.readyState == 4 ) {
		if ( ReqXhttp.status == 200 ) {
			if (ReqXhttp.responseText != "")
			{
			    if (ReqXhttp.responseText == "1")
			    {
			        AlreadyVote = true;
                    DefaultNote = LAnote;
                    LoadNote(LEChemin,LECID, LL, TT);
                    if (TT == "code")
                    {
                        alert("Vous avez assigné la note de " + LAnote + " sur 10 à cette source");
                    } else {
                        alert("Vous avez assigné la note de " + LAnote + " sur 10 à ce tutorial");
                    }
			    } else {
			        alert("Il y a eu une erreur lors de la notation, veuillez réessayer");
			    }
			}
		}
	}
}

function LoadNote(Chemin, CID, L, T)
{
    LL = L;
    TT = T;
	if (AllowOpacity)
	{
		if (T == "code")
		{
    		document.getElementById("Note").innerHTML = '<b>Donnez une note à cette source : </b><br />'
    	} else {
    	    document.getElementById("Note").innerHTML = '<b>Donnez une note à ce tutorial source : </b><br />'
    	}
		for(var i=1; i < 11; i++)
		{
			if (AlreadyVote)
			{
			    if (T == "code")
			    {
				    document.getElementById("Note").innerHTML += '<img src="' + Chemin + 'g/st.gif" alt="' + DefaultNote + ' sur 10" onclick="alert(\' Vous avez déjà vôté pour cette source \')" align="absmiddle" />';
                } else {
                    document.getElementById("Note").innerHTML += '<img src="' + Chemin + 'g/st.gif" alt="' + DefaultNote + ' sur 10" onclick="alert(\' Vous avez déjà vôté pour ce tutorial \')" align="absmiddle" />';
                }
            } else {
                document.getElementById("Note").innerHTML += '<img src="' + Chemin + 'g/st.gif" alt="Assigner la note de ' + i + ' sur 10" onmouseover="Note_event(' + i + ')"  onmouseout="Note_event()" onclick="GiveNote(' + i + ', \'' + Chemin + '\', \'' + CID + '\', ' + L + ', \'' + T + '\')" align="absmiddle" />';
            }
		}
		Note_event();
	}
	else
	{
		document.getElementById("DropDownListNote").options[10 - DefaultNote].selected = true ;
	}
}

function validate_Confirm(txt)
{
	if(confirm(txt))
	{
		return true;
	}else{
		alert('Action annulée');
		return false;
	}
}

function hover(obj){
  if(ie){
    UL = obj.getElementsByTagName('ul');
    if(UL.length > 0){
      sousMenu = UL[0].style;
      if(sousMenu.display == 'none' || sousMenu.display == ''){
        sousMenu.display = 'block';
      }else{
        sousMenu.display = 'none';
      }
    }
  }
}

var dropdownrech = null;
var dropdownrech2 = null;

function setHover(){
  LI = document.getElementById('menu').getElementsByTagName('li');
  for(i=0; i < LI.length; i++){
    LI[i].onmouseover = function(){
      hover(this);
      if (dropdownrech)
        document.getElementById(dropdownrech).style.visibility = "hidden";
      if (dropdownrech2)
        document.getElementById(dropdownrech2).style.visibility = "hidden";
    }
    LI[i].onmouseout = function(){
      hover(this);
      if (dropdownrech)
        document.getElementById(dropdownrech).style.visibility = "visible";
      if (dropdownrech2)
        document.getElementById(dropdownrech2).style.visibility = "visible";
    }
  }
}



function playSound(snd) { snd.Play(); }
function pauseSound(snd) { snd.Pause(); }
function stopSound(snd) { snd.Stop(); }

// Appellé pour chaque element Expandable
function Collapse(id){
    var elmt=document.getElementById(id);
    if (GetCookie(id) == "collapse") 
        {elmt.children[1].className = "contentcollapse";
        elmt.children[0].className = "collapse";}
}

function ouvremoi(url,titre,nombox)
{
    window.open(url, nombox, 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,height=250,width=450');
}

function SeulAdmin(){
	alert('Seul les admins peuvent supprimer un commentaire');
}
function howManyChecked(whichCheckBox)
{
	var _countChecked = 0;
	var err = 0;
	if(document.getElementById(whichCheckBox).checked==true)
	{
		_countChecked++;
	}
	if(_countChecked == 0)
		{ alert('Veuillez lire la charte de bonne conduite puis cochez la case comme quoi vous en accepté les termes');
			err = 1;}
	if (err == 1) { 
	    return false; 
    } else {
        return true;
    }
}
function validate_BonneRep()
{
	if(confirm('Etes-vous sûr que cette réponse répond à votre problème ?\nN\'oubliez pas que lorsque vous validez une réponse cela permettra d\'aider un autre visiteur\npour l\'aider à trouver la réponse au même problème que vous alors ne validez que si vous êtes sûr que cela répond bien à votre problème\nMerci de votre participation\n\nNix'))
	{
		return true;
	}else{
		alert('Bonne réponse annulée');
		
		return false;
	}
}


function stopError() {return true;}
window.onerror=stopError;


function CodeFavs(IDCode, chemin)
{
    window.open(chemin + 'codefavajout.aspx?ID=' + IDCode + '&action=1', 'CodeFavAjoutCS', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,height=250,width=450');
}
function LivreFavs(IDCode, chemin)
{
    window.open(chemin + 'livrefavajout.aspx?ID=' + IDCode + '&action=1', 'LivreFavAjoutCS', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,height=250,width=450');
}

CleanHTMLCode = function( inCODE )
{
 var code = "";
 code = inCODE;
 // removes all Class attributes on a tag eg. '<p class=asdasd>xxx</p>' returns '<p>xxx</p>'
 code = code.replace(/<([\w]+) class=([^ |>]*)([^>]*)/gi, "<$1$3");
 // removes all style attributes eg. '<tag style="asd asdfa aasdfasdf" something else>' returns '<tag something else>'
 code = code.replace(/<([\w]+) style="([^"]*)"([^>]*)/gi, "<$1$3");
 // gets rid of all xml stuff... <xml>,<\xml>,<?xml> or <\?xml>
 code = code.replace(/<\\?\??xml[^>]>/gi, "");
 // get rid of ugly colon tags <a:b> or </a:b>
 code = code.replace(/<\/?\w+:[^>]*>/gi, "");
 // removes all empty <p> tags
 code = code.replace(/<p([^>])*>(&nbsp;)*\s*<\/p>/gi,"");
 // removes all empty span tags
 code = code.replace(/<span([^>])*>(&nbsp;)*\s*<\/span>/gi,"");
 return code;
};

function navurl(url, p) { 
    try
    {
        limg = new Image();
        limg.src = p + 'boutiquecnt.aspx?u=' + escape(url) + '&u2=' + escape(window.location) ;
        
    }
    catch(ex)
    {
    }
    window.location = url; 
}

function ShowRechBox(laquelle,divurl,divmots,divgoogle){
  RechBoxSEngine = document.getElementById(divurl);
  RechBoxMots = document.getElementById(divmots);
  RechBoxGoogle = document.getElementById(divgoogle);
  
  if (laquelle == 1)
  {
    RechBoxSEngine.style.visibility = "hidden";
    RechBoxSEngine.style.display = "none";
    RechBoxMots.style.visibility = "visible";
    RechBoxMots.style.display = "inline";
    RechBoxGoogle.style.visibility = "hidden";
    RechBoxGoogle.style.display = "none";

  } else if (laquelle == 0) {
    RechBoxSEngine.style.visibility = "visible";
    RechBoxSEngine.style.display = "inline";
    RechBoxMots.style.visibility = "hidden";
    RechBoxMots.style.display = "none";
    RechBoxGoogle.style.visibility = "hidden";
    RechBoxGoogle.style.display = "none";

  } else if (laquelle == 2) {
    RechBoxSEngine.style.visibility = "hidden";
    RechBoxSEngine.style.display = "none";
    RechBoxMots.style.visibility = "hidden";
    RechBoxMots.style.display = "none";
    RechBoxGoogle.style.visibility = "visible";
    RechBoxGoogle.style.display = "inline";
  }
}

function ShowDotnetRechOptions(divoptions, listboxvalue) {
    if (listboxvalue == 'source')
    {
        //document.getElementById(divoptions).style.visibility = "visible";
        document.getElementById(divoptions).style.display = "block";
    } else {
        //document.getElementById(divoptions).style.visibility = "hidden";
        document.getElementById(divoptions).style.display = "none";
    }
}

function jnu(u) {
    window.location = u;
}

function jnutb(u,winname) { 
    window.open(u, winname);
}

google_alternate_ad_url = "http://www.dotnet-news.com/adsense-alternative.aspx";
google_ad_channel ="5277633647";
google_ad_type = "text";

function stripHTML(txt){
    return txt.replace(/<\S[^><]*>/g, "")
}

function showgglangs(opt, lnklng, divautre)
{
    if (opt == 0)
    {
        document.getElementById(lnklng).href = "javascript:showgglangs(1,'" + lnklng + "','" + divautre + "');";
        document.getElementById(lnklng).innerHTML = "Masquer les autres langages";
        document.getElementById(divautre).style.display = "inline";
        document.getElementById(divautre).style.position = "relative";
        document.getElementById(divautre).style.visibility = "visible";
    } else {
        document.getElementById(lnklng).href = "javascript:showgglangs(0,'" + lnklng + "','" + divautre + "');";
        document.getElementById(lnklng).innerHTML = "Afficher les autres langages";
        document.getElementById(divautre).style.display = "none";
        document.getElementById(divautre).style.position = "relative";
        document.getElementById(divautre).style.visibility = "hidden";
    }
}

