

function unicode(attention)
{
    do
    {
        debut=attention.indexOf("&#");

        if((debut>0) || ((debut==0) && (attention.indexOf("#")==1)))
        {
            fin=attention.indexOf(";");
            caractere=attention.substring(debut,fin+1);
            code=attention.substring(debut+2,fin);
            attention =attention.replace(caractere,String.fromCharCode(code));
        }

    }
    while((debut>=0))

    return attention;
}


function goHome(param,uid)
{
    var indefini;

    if(top.opener)
    {
        var fract = top.opener.parent.parent.location.href.split("/");

        if(fract[4]==indefini)
        {
            var fract2 = top.opener.location.href.split("/");

            if(fract2[4]=="FrmBas.php#") top.opener.parent.frames[2].frames[1].location.href='index.php?uid='+uid;
            else top.opener.location.href='index.php?uid='+uid;
        }
        else
        {
            top.opener.parent.location.href='index.php?uid='+uid;
        }

        top.window.close();
    }
    else
    {
         //Niveau titre site et pied site
         if(parent.location.href==parent.parent.location.href)
         {
             var fract = parent.location.href.split("/");

               if(fract[4]==indefini)
                {
                    parent.frames[2].frames[1].location.href='/index.php?uid='+uid;
                }
                else
                {
                	if(window.location.href.indexOf('rescue-abdeurope.com')!=-1) sDomain='http://telecommande.info.rescue-abdeurope.com';
                	else sDomain='http://www.telecommande.info';

                    window.open(sDomain,'_blank','resizable=1,toolbar=1,location=1,status=1,menubar=1,scrollbars=0,top=0,left=0,width=800,height=600');
                }
         }
         else //Niveau barre de navigation
         {
            if(param==1) parent.parent.location.href='index.php?uid='+uid;
            else if(param==2) parent.location.href='index.php?uid='+uid;
            else parent.location.href='index.php?uid='+uid;
         }
    }
}

function right(e)
{
    var msg = "Please, respect Copyright laws.";
    if (navigator.appName == 'Netscape' && e.which == 3)
    {
        alert(msg);
        return false;
    }
    else if (navigator.appName == 'Microsoft Internet Explorer' && event.button==2)
    {
        alert(msg);
        return false;
    }
    return true;
}

function bloqueTouche()
{//alert("");
  if(event.ctrlKey) //Touche Ctrl enfoncée
    if((event.keyCode == 78) || (event.keyCode == 104)) //touche n ou N enfoncée
      event.returnValue = false;
  if (event.keyCode == 122){ //touche F11 enfoncée
      event.keyCode=0;return false;}
}


function storeCaret (textEl)
{
    if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();

}

function insertAtCaret (textEl, textDeb, textFin)
{
    if (textEl.createTextRange && textEl.caretPos)
    {
        var caretPos = textEl.caretPos;
        if(textFin) caretPos.text = textDeb + textEl.caretPos.text + textFin;
        else caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? textDeb + ' ' : textDeb;
    }
    else textEl.value  = textDeb;
}

function dynamicText(calque,crit1,crit2,crit3,crit4,crit5,crit6,uid)
{
    var ns4=document.layers?1:0
    var ie4=document.all?1:0
    var ns6=document.getElementById&&!document.all?1:0

    var lien="index.php?pageAAfficher=frame.php&uid="+uid+"&action=panier&reference_photo2="+crit6+"&nom_marque="+crit1+"&nombre_touche="+crit2+"&type_batterie="+crit3+"&codage_switch="+crit4+"&inscription_quartz="+crit5;

    if(ie4)
    {
        parent.parent.Frm_Menu.document.all.critere.href=lien;
        parent.parent.Frm_Menu.document.all.critere2.href=lien;
    }
    if(ns4)
    {
        parent.parent.Frm_Menu.document.critere.href=lien;
        parent.parent.Frm_Menu.document.critere2.href=lien
    }
    if(ns6)
    {
        parent.parent.Frm_Menu.document.getElementById('critere').href=lien;
        parent.parent.Frm_Menu.document.getElementById('critere2').href=lien;
    }
    //alert(parent.parent.Frm_Menu.getElementById('critere').innerHTML=texte);
    //nom_marque=".$nom_marque."&nombre_touche=".$nombre_touche."&type_batterie=".$type_batterie."&codage_switch=".$codage_switch."&inscription_quartz=".$inscription_quartz."

}

var checkflag=false;
function checkAll(form,champ)
{
    nombreElements=eval("document."+form+".elements.length;");

    if(checkflag)
    {
        for(i=0;i<nombreElements;i++) if(eval("document."+form+".elements[i].type")=="checkbox") eval("document."+form+".elements[i].checked=false;");

        checkflag=false;
    }
    else
    {
        for(i=0;i<nombreElements;i++) if(eval("document."+form+".elements[i].type")=="checkbox") eval("document."+form+".elements[i].checked=true;");

        checkflag=true;

    }
}
