﻿function hideDiv(Name) {
    if (document.getElementById) {
        var div = document.getElementById(Name);
        if (div) {
            div.style.display = 'none';
        }
    }
}                
function showDiv(Name) {
    if (document.getElementById) {
        var div = document.getElementById(Name);
        if (div) {
            div.style.display = 'block';
        }
    }
}    

function changeClass(Name, Class) {
    if (document.getElementById) {
        var el = document.getElementById(Name)
        if (el) {
            el.setAttribute('class', Class); 
            el.setAttribute('className', Class); 
        }
    }
}

function addBold(Name){
    if (document.getElementById) {
        document.getElementById(Name).style.fontWeight = 'bold';
    }
}            

function removeBold(Name){
    if (document.getElementById) {
        document.getElementById(Name).style.fontWeight = 'normal';
    }
}     

function loadCombo(Name, Elements, Default, Parent1Name, Parent2Name) {
    if (document.getElementById) {
        var ID1;
        var ID2;
        
        if (Parent1Name) { 
            var parent = document.getElementById(Parent1Name);
            if (parent) { 
                ID1 = parent.options[parent.selectedIndex].value;
            }
        }
        if (Parent2Name) { 
            var parent = document.getElementById(Parent2Name);
            if (parent) { 
                ID2 = parent.options[parent.selectedIndex].value;
            }
        }
        if (ID1 == 0) return;
        var cbo = document.getElementById(Name);
        if (cbo) {
            var prev;
            if (cbo.selectedIndex >= 0) {
                prev = cbo.selectedIndex;
            }
            cbo.options.length = 0;

            cbo.options[0] = new Option(Default, "0");
            var j = 1;
            for (var i = 0; i < Elements.length; i++) {
                if ((!ID2  || ID2 == 0 || (Elements[i][3] == ID2)) && (!ID1 || ID1 == 0 || ( Elements[i][2] == ID1)))
                {
                    cbo.options[j++] = new Option(Elements[i][1], Elements[i][0]);
                }
            }
            cbo.selectedIndex = prev;
        }
    }
}

function GetClientId(strid)
{
     var count=document.forms[0].length;
     var i=0;
     var eleName; 
     var strEleNameToReturn = 'IMPOSSIBLEITEMTOFINDONPAGE';
     for (i=0; i < count; i++ )
     {
       eleName=document.forms[0].elements[i].id; 
       pos=eleName.indexOf(strid);
       if(pos>=0) 
       {
            strEleNameToReturn = eleName;
            break;
       }
     }
     return strEleNameToReturn;
    
}

function openWindowPopup (strLien, strNomFenetre)
{
    window.open(strLien,strNomFenetre,'width=300,height=450,toolbar=no,menubar=no,location=no');
}

function openWindowPopupSurMesure (strLien, strNomFenetre, intLargeur, intHauteur)
{
    window.open(strLien,strNomFenetre,'width=' + intLargeur + ',height=' + intHauteur + ',toolbar=no,menubar=no,location=no');
}

function popupWin(popupName,url,popupWidth,popupHeight) { 
            popupDef = window.open(url, popupName,"width=" + popupWidth + ",height=" + popupHeight + ",resizable=no,scrollbars=no,toolbar=no,status=no,location=no,directories=no"); 
            return false; 
} 