var ie = /MSIE/.test(navigator.userAgent);
var moz = !ie && navigator.product == "Gecko";
var csch = "/";

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;
		});
}      


function deco(Chemin)
{
    window.open(Chemin + 'deconnexion.aspx', 'DecoVBFrance', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,height=250,width=250');
}

    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 ReducForce(elmtTitre)
    {
        var elmt = elmtTitre.parentNode.parentNode;
            elmt.children[1].className = "contentcollapse";
            elmt.children[0].className = "collapse";
    }

        /// 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));
        }
        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 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 valideformbutton(evt, btn)
{
    if (document.all) {
        if (evt.keyCode==13) 
        {
            evt.keyCode=0;
            document.all[btn].click();
        }
    } else if (document.getElementById) {
        if (evt.keyCode==13) 
        {
            document.getElementById(btn).click();
        }
    } else {
    
    }
}

/* 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;

function setHover(){
  LI = document.getElementById('menu').getElementsByTagName('li');
  for(i=0; i < LI.length; i++){
    LI[i].onmouseover = function(){
      hover(this);
      if (dropdownrech != null)
      {
        document.getElementById(dropdownrech).style.visibility = "hidden"
      }
    }
    LI[i].onmouseout = function(){
      hover(this);
      if (dropdownrech != null)
      {
        document.getElementById(dropdownrech).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; 
}

google_alternate_ad_url = "http://www.dotnet-news.com/adsense-alternative.aspx";
google_ad_channel ="5277633647";
google_ad_type = "text";