
var gbooBrowserIE = navigator.appName.indexOf("Microsoft");
var gbooBrowserNs = navigator.appName.indexOf("Netscape");
var gstrLoginURL = "";

var gbooRaccourcis = 0;
var gnbKeyCode = -1;
var gbooCallKeyDownSpec = -1;
var gnbFormTabIndex = 0;

var gnbScreenX;
var gnbScreenY;

var gnbPageX; // variable qui met à jour les coord x de la souris par rapport à la page
var gnbPageY; // variable qui met à jour les coord y de la souris par rapport à la page

var gbooaltKey;
var gstrALT="Alt";
var gbooctrlKey;
var gstrCTRL="Ctrl";
var gbooshiftKey;
var gstrSHFT="Shft";
var gstrINSER="Inser";
var gstrSUPPR="Suppr";

//Transitions
var gbooTRANS = true;

var gbooMsgRedef = 1;
var gbooModeDebugTrans = 0;

//session
var session;

//initialise httpXmlRequest
var xmlhttp = false;
var boolxmlhttp = false;

if (window.XMLHttpRequest) {
   xmlhttp = new XMLHttpRequest();
   boolxmlhttp = true;
}
else if (window.ActiveXObject) {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   boolxmlhttp = true;
}

// on essaie de créer l'objet si ce n'est pas déjà fait
if (!boolxmlhttp && typeof XMLHttpRequest != 'undefined')
{
 try
 {
    xmlhttp = new XMLHttpRequest();
    boolxmlhttp = true;
 }
 catch (e)
 {
    boolxmlhttp = false;
    xmlhttp = false;
 }
}

var lbooExistURL = false;

//gestion CSV
gstrCSVSep = ';';
gstrCSVRep = ',';

document.onkeydown = fctNSKeyDown;
document.onmousemove = fctNSMouseMove;

function fctNSKeyDown(pEvent){
 if (gbooBrowserIE == -1){
     if (pEvent) {
         gnbKeyCode = pEvent.which;
         gbooaltKey = pEvent.altKey;
         gbooctrlKey = pEvent.ctrlKey;
         gbooshiftKey = pEvent.shiftKey;
     }
 }
 else {
     gnbKeyCode = event.keyCode;
     gbooaltKey = event.altKey;
     gbooctrlKey = event.ctrlKey;
     gbooshiftKey = event.shiftKey;
 }
 //console.debug(gnbKeyCode);

 if (self.name != "GWINTRANS")
 {
     var ldivTRANS = document.getElementById("gdivTRANS");
     if (ldivTRANS) {
         if (ldivTRANS.style.visibility == "visible")
            return;
     }
 }

 gbooRaccourcis = 1;
 fctKDRetourner();

 if (gbooCallKeyDownSpec != -1) {
    fctKeyDownSpec();
 }
 gbooRaccourcis = 0;

 if(gbooctrlKey && gbooshiftKey && gnbKeyCode >= 69 && gnbKeyCode <= 90) {
     if (gbooBrowserIE != -1) {
         self.event.returnValue = false;
     }
     else {
         return false;
     }
 }
 //codes pour raffraichir la page
 // F5 (116), CTRL+R
 // codes pour retourner
 // back (8)
 if((gnbKeyCode == 116 || gnbKeyCode == 8 || (gbooctrlKey && gnbKeyCode == 82)) && gstrAjaxEnable == 'O' && session){
    session.onClickLink();
 }
}

function fctNSMouseMove(pEvent){
 if (gbooBrowserIE == -1) {
     if (pEvent) {
         gnbScreenX = pEvent.screenX;
         gnbScreenY = pEvent.screenY;
         gnbPageX = pEvent.pageX;
         gnbPageY = pEvent.pageY;
     }
 }
 else {
     gnbScreenX = event.screenX;
     gnbScreenY = event.screenY;
 	 //gnbPageX = event.x+document.body.scrollLeft;
 	 //gnbPageY = event.y+document.body.scrollTop;
 	 gnbPageX = event.x;
 	 gnbPageY = event.y;
 }

 if(gstrAjaxEnable == 'O' && session) {
    session.setActive();
 }
}

function fctAlert(strMsg, strOpt){

    strMsg = strMsg.toString();

    if(gbooBrowserIE != -1){//IE

        //decoupe la chaine dans un tableau par rapport a la chaine de saut de ligne (\n)
        var tmpMaxLg = 0;
        var tabMessage = fctDecoupe(strMsg, '\n');
        if(tabMessage.length){
            for(var i=0;i<tabMessage.length;i++)
            {
                if(tmpMaxLg < tabMessage[i][1].length)
                    tmpMaxLg = tabMessage[i][1].length;
            }
            tmpModLg = 300;
        }
        else
            tmpModLg =  strMsg.length;

        if(tmpMaxLg > 25)
            tmpModLg = 300 + (tmpMaxLg - 25)*6; //calcul largeur optimale

        var tmpModHt = 125;
        if(tabMessage.length > 1)
            tmpModHt = 125 + (tabMessage.length - 1)*10; //calcul hauteur optimale

        var tabParam = new Array;
        tabParam[0] = new Array;

        switch(strOpt)
        {
            case "WARNING" : tabParam[0][0] = "ICONE";
                tabParam[0][1] = "WARNING";
                break;
            case "ERROR" : tabParam[0][0] = "ICONE";
                tabParam[0][1] = "ERROR";
                break;
            case "INFORMATION" : tabParam[0][0] = "ICONE";
                tabParam[0][1] = "INFORMATION";
                break;
            default : tabParam[0][0] = "ICONE";
                tabParam[0][1] = "WARNING";
                break;
        }

        tabParam[1] = new Array;
        tabParam[1][0] = "TYPE";
        tabParam[1][1] = "BUTTON";
        tabParam[2] = new Array;
        tabParam[2][0] = "LIB1";
        tabParam[2][1] = "Fermer";
        tabParam[3] = new Array;
        tabParam[3][0] = "VALUE1";
        tabParam[3][1] = null;
        tabParam[4] = new Array;
        tabParam[4][0] = "CANCEL";
        tabParam[4][1] = "NO";
        tabParam[5] = new Array;
        tabParam[5][0] = "MESSAGE";
        tabParam[5][1] = fctReplace(strMsg, "\n", "<br>");


        var usrOption = showModalDialog(gstrImagesRep+"gstrModalDialog", tabParam, "dialogWidth:"+tmpModLg+"px;dialogHeight:"+tmpModHt+"px;status:0;center:1;scroll:0;help:0;");
        return usrOption;
    }
    else
        alert(strMsg);
}

function fctConfirm(strMsg){

    strMsg = strMsg.toString();

    if(gbooBrowserIE != -1){//IE

        var tmpMaxLg = 0;
        var tabMessage = fctDecoupe(strMsg, '\n');
        if(tabMessage.length){
            for(var i=0;i<tabMessage.length;i++)
            {
                if(tmpMaxLg < tabMessage[i][1].length)
                    tmpMaxLg = tabMessage[i][1].length;
            }
            tmpModLg = 400;
        }
        else
            tmpModLg =  strMsg.length;

        if(tmpMaxLg > 25)
            tmpModLg = 400 + (tmpMaxLg - 25)*6; //calcul largeur optimale

        var tmpModHt = 125;
        if(tabMessage.length > 1)
            tmpModHt = 125 + (tabMessage.length - 1)*10; //calcul hauteur optimale

        var tabParam = new Array;
        tabParam[0] = new Array;
        tabParam[0][0] = "ICONE";
        tabParam[0][1] = "QUESTION";
        tabParam[1] = new Array;
        tabParam[1][0] = "TYPE";
        tabParam[1][1] = "BUTTON";
        tabParam[2] = new Array;
        tabParam[2][0] = "LIB1";
        tabParam[2][1] = "Oui";
        tabParam[3] = new Array;
        tabParam[3][0] = "VALUE1";
        tabParam[3][1] = true;
        tabParam[4] = new Array;
        tabParam[4][0] = "LIB2";
        tabParam[4][1] = "Non";
        tabParam[5] = new Array;
        tabParam[5][0] = "VALUE2";
        tabParam[5][1] = false;
        tabParam[6] = new Array;
        tabParam[6][0] = "CANCEL";
        tabParam[6][1] = "NO";
        tabParam[7] = new Array;
        tabParam[7][0] = "MESSAGE";
        tabParam[7][1] = fctReplace(strMsg, "\n", "<br>");

        return usrOption = showModalDialog(gstrImagesRep+"gstrModalDialog", tabParam, "dialogWidth:"+tmpModLg+"px;dialogHeight:"+tmpModHt+"px;status:0;center:1;scroll:0;help:0;");
        //return false;
    }
    else
        return confirm(strMsg);
}

function fctPrompt(strMsg,strVal){

    if(!strVal) strVal = "";

    strMsg = strMsg.toString();

    if(gbooBrowserIE != -1){//IE

        var tmpMaxLg = 0;
        var tabMessage = fctDecoupe(strMsg, '\n');
        if(tabMessage.length){
            for(var i=0;i<tabMessage.length;i++)
            {
                if(tmpMaxLg < tabMessage[i][1].length)
                    tmpMaxLg = tabMessage[i][1].length;
            }
            tmpModLg = 400;
        }
        else
            tmpModLg =  strMsg.length;

        if(tmpMaxLg > 25)
            tmpModLg = 400 + (tmpMaxLg - 25)*6; //calcul largeur optimale

        var tmpModHt = 125;
        if(tabMessage.length > 1)
            tmpModHt = 125 + (tabMessage.length - 1)*10; //calcul hauteur optimale

        var tabParam = new Array;
        tabParam[0] = new Array;
        tabParam[0][0] = "ICONE";
        tabParam[0][1] = "INFORMATION";
        tabParam[1] = new Array;
        tabParam[1][0] = "TYPE";
        tabParam[1][1] = "INPUT";
        tabParam[2] = new Array;
        tabParam[2][0] = "MESSAGE";
        tabParam[2][1] = fctReplace(strMsg, "\n", "<br>");
        tabParam[3] = new Array;
        tabParam[3][0] = "VALUE";
        tabParam[3][1] = strVal;

        return usrOption = showModalDialog(gstrImagesRep+"gstrModalDialog", tabParam, "dialogWidth:"+tmpModLg+"px;dialogHeight:"+tmpModHt+"px;status:0;center:1;scroll:0;help:0;");
        //return false;
    }
    else
        return prompt(strMsg);
}

function fctCommonLoad(pbooMenu,pbooRowNoted,pbooTrans,pbooMsgRedef)
{
    if(gstrAjaxEnable == 'O') {
        dojo.addOnLoad(function(){
            sylogis.gen.event.fctCommonLoad(pbooMenu,pbooRowNoted,pbooTrans,pbooMsgRedef);
        });
        return;
    }
    if (self.document.GFORMREDIRECTLOGIN)
    {
        fctVerouille(
            self.document.GFORMREDIRECTLOGIN.hidRdrLoginPRMID.value,
            self.document.GFORMREDIRECTLOGIN.hidRdrLoginMNPID.value,
            self.document.GFORMREDIRECTLOGIN.hidRdrLoginPROC.value
        );
    }
    //if(pbooTrans != 0)
        reinitTrans();

    if ((pbooTrans != 0) && (self.name != "GWINTRANS"))
    {
        fctTransitions();
        gbooTRANS = true;
    }
    else
    {
        gbooTRANS = false;
        if ((pbooTrans == 0) && (document.getElementById("gdivTRANS")))
            fctSetPositionsTRANS(0);
    }

    //ajoute prmid aux formulaires avec submit
    fctSetPrmidActionAllForms();

    if (pbooRowNoted != 0)
        fctSelRowNoted();

    if (pbooMenu != 0 && (document.getElementById("divMenu0")))
        fctonloadMenu();

    if(pbooMsgRedef == 0)
        gbooMsgRedef = pbooMsgRedef;

        //redefinition de : alert, confirm, prompt pour Internet Explorer
    if(gbooBrowserIE != -1 && gbooMsgRedef != 0){
        window.alert = fctAlert;
        window.confirm = fctConfirm;
        window.prompt = fctPrompt;
    }

}

function fctSelRowNoted()
{
    var ltabForm = self.document.forms; // tableau de formulaires de la page
    for (var SelRowNoted = 0;SelRowNoted < ltabForm.length ;SelRowNoted++)
    {
        if(ltabForm[SelRowNoted].name.indexOf("FormSel") != -1) // si le nom du formulaire est formsel
        {
            var idxSel = ltabForm[SelRowNoted].name.substring(7,ltabForm[SelRowNoted].name.length); // numero du formsel ex : FormSelN ou N est le index du formaulaire (N {null,1..N)
            eval("var lFormSel = self.document." + ltabForm[SelRowNoted].name + ".hidSelTRIdx.value"); // evaluation de la ligne du formulaire selectionné ou pas
            var tabletbl = "TblTBM" + idxSel;
            if(lFormSel != -1) // ligne selectionné
            {
                // alors il y a au moins une ligne selectionné dans le cas des tbx
                if (eval("self.document.FORMTBMXFld" + idxSel)) {
                    for(var noted=0;noted < ltabForm[SelRowNoted].length; noted++) // boucle sur le formulaire formsel
                    {
                        if(ltabForm[SelRowNoted][noted].name.indexOf("hidSelTRIdx") != -1 && ltabForm[SelRowNoted][noted].name != "hidSelTRIdx")
                        {
                            eval("var lFormSelNoted = self.document." + ltabForm[SelRowNoted].name + "." + ltabForm[SelRowNoted][noted].name);
                            if(lFormSelNoted.value != -1)
                            {
                                var lFormSel2 = eval("self.document." + ltabForm[SelRowNoted].name + "." + ltabForm[SelRowNoted][noted].name + ".value");
                                lFormSelNoted.value = -1;
                                var lSelTR2 = self.document.getElementById(tabletbl).rows[lFormSel2];
                                eval("hdlonclickhidSelection" + idxSel + "(lSelTR2)");
                            }
                        }
                    }
                }
                else {
                    var lSelTR = self.document.getElementById(tabletbl).rows[lFormSel];
                    eval("self.document." + ltabForm[SelRowNoted].name + ".hidSelTRIdx.value = -1");
                    eval("fctSelectRow"+ idxSel + "(lSelTR)"); // selectionne la ligne
                }
            }
            else if(!eval("self.document.FORMTBMXFld" + idxSel)) {
//                if (gbooBrowserIE != -1 && self.document.getElementById(tabletbl) && (self.document.getElementById(tabletbl).rows.length == 2))
                if (self.document.getElementById(tabletbl) && (self.document.getElementById(tabletbl).rows.length == 2))
                {
                    if (self.document.getElementById(tabletbl).rows[1].onclick != null)
                        self.document.getElementById(tabletbl).rows[1].onclick();
//                        fctSelectRow(self.document.getElementById(tabletbl).rows[1]);
                }
            }
        }
    }
    if(gstrAjaxEnable == 'O'){
        var lsels = dojo.query('.selHid');
        for(var i=0;i<lsels.length;i++){
            if(lsels[i].value != '-1')
                dijit.byId(lsels[i].parentNode.parentNode.id).selectRowFromIdx(lsels[i].value);
        }
    }
}

function fctSetPrmidActionAllForms(){
    var ltabForms = self.document.forms;
    for (var lIdx=0; lIdx < ltabForms.length; lIdx++)
    {
        var lForm = ltabForms[lIdx];
        if(lForm.action != "") {
            var boofoundprmid=0;
            if(lForm.action.toLowerCase().indexOf("wprmid") != -1) {
                return;
            }
            for(var i=0;i<lForm.elements.length && boofoundprmid == 0;i++){
                if(lForm.elements[i].name.toLowerCase() == "wprmid"){
                    boofoundprmid = 1;
                    if(lForm.action.indexOf("?") != -1) {
                        lForm.action = lForm.action + "&" + lForm.elements[i].name + "=" + lForm.elements[i].value;
                    }
                    else {
                        lForm.action = lForm.action + "?" + lForm.elements[i].name + "=" + lForm.elements[i].value;
                    }
                    lForm.elements[i].disabled = true;
                }
            }
        }
    }
}

//Raccourcis pour Retourner
function fctRetourner(){
 if (self.document.FORMRETOURNER) {
     fctRetour(parseInt(self.document.FORMRETOURNER.hidRetournerMode.value,10),self.document.FORMRETOURNER.hidRetournerURL.value);
 }
 return false;
}

function fctKDRetourner(){
 if(fctKeyDownRetourner()) {
     return fctRetourner();
 }
}

function fctReload(){
 if(gstrAjaxEnable == 'O' && session){
    session.onClickLink();
 }
 self.location.reload(true);
 if (gbooBrowserIE != -1) {
     self.event.returnValue = false;
 }
 else {
     return false;
 }
}

function fctReplaceAccents(pstrSTR){
    var lstrRes = pstrSTR;
    lstrRes = lstrRes.replace(/â/g, "%E2");
    lstrRes = lstrRes.replace(/æ/g, "%E6");
    lstrRes = lstrRes.replace(/à/g, "%E0");
    lstrRes = lstrRes.replace(/Â/g, "%C2");
    lstrRes = lstrRes.replace(/Æ/g, "%C6");
    lstrRes = lstrRes.replace(/À/g, "%C0");
    lstrRes = lstrRes.replace(/ç/g, "%E7");
    lstrRes = lstrRes.replace(/Ç/g, "%C7");
    lstrRes = lstrRes.replace(/é/g, "%E9");
    lstrRes = lstrRes.replace(/ê/g, "%EA");
    lstrRes = lstrRes.replace(/è/g, "%E8");
    lstrRes = lstrRes.replace(/É/g, "%C9");
    lstrRes = lstrRes.replace(/Ê/g, "%CA");
    lstrRes = lstrRes.replace(/È/g, "%C8");
    lstrRes = lstrRes.replace(/î/g, "%EE");
    lstrRes = lstrRes.replace(/Î/g, "%CE");
    lstrRes = lstrRes.replace(/ô/g, "%F4");
    lstrRes = lstrRes.replace(/Ô/g, "%D4");
    lstrRes = lstrRes.replace(/û/g, "%FB");
    lstrRes = lstrRes.replace(/Û/g, "%DB");
    lstrRes = lstrRes.replace(/ù/g, "%F9");
    lstrRes = lstrRes.replace(/Ù/g, "%D9");
    return lstrRes;
}

function fctReplaceAllAccents(pstrSTR){
    var lstrRes = pstrSTR;
    lstrRes = lstrRes.replace(/â/g, "A");
    lstrRes = lstrRes.replace(/æ/g, "A");
    lstrRes = lstrRes.replace(/à/g, "A");
    lstrRes = lstrRes.replace(/Â/g, "A");
    lstrRes = lstrRes.replace(/Æ/g, "A");
    lstrRes = lstrRes.replace(/À/g, "A");
    lstrRes = lstrRes.replace(/ç/g, "C");
    lstrRes = lstrRes.replace(/Ç/g, "C");
    lstrRes = lstrRes.replace(/é/g, "E");
    lstrRes = lstrRes.replace(/ê/g, "E");
    lstrRes = lstrRes.replace(/è/g, "E");
    lstrRes = lstrRes.replace(/É/g, "E");
    lstrRes = lstrRes.replace(/Ê/g, "E");
    lstrRes = lstrRes.replace(/È/g, "E");
    lstrRes = lstrRes.replace(/î/g, "I");
    lstrRes = lstrRes.replace(/Î/g, "I");
    lstrRes = lstrRes.replace(/ô/g, "O");
    lstrRes = lstrRes.replace(/Ô/g, "O");
    lstrRes = lstrRes.replace(/û/g, "U");
    lstrRes = lstrRes.replace(/Û/g, "U");
    lstrRes = lstrRes.replace(/ù/g, "U");
    lstrRes = lstrRes.replace(/Ù/g, "U");
    return lstrRes;
}

function fctURL(pstrURL,pbooForceIsURLTRANS){
 if(gstrAjaxEnable == 'O') {
    sylogis.gen.url.fctURL(pstrURL,pbooForceIsURLTRANS);
    return;
 }
 pstrURL=fctReplaceAccents(pstrURL);

 if(pstrURL.indexOf("?") == -1) pstrURL += "?";

 fctXMLURL(pstrURL,pbooForceIsURLTRANS);
}

function fctExecURL(pstrURL,pbooForceIsURLTRANS){

 if ((gbooTRANS == 1) && ((pbooForceIsURLTRANS == 1) || (fctIsURLTRANS(pstrURL))))
 {
    if (self.name == "GWINTRANS")
    {
        parent.fctSetModeTRANS("WAIT");
        parent.GWINTRANS.location.replace(pstrURL);
    }
    else
    {
        fctSetModeTRANS("WAIT");
        GWINTRANS.location.replace(pstrURL);
    }
 }
 else
 {
    if (self.name == "GWINTRANS")
    {
        parent.location = pstrURL;
    }
    else
    {
        self.location = pstrURL;
    }
 }
}

function fctReplaceURL(pstrURL){
 if(gstrAjaxEnable == 'O') {
    sylogis.gen.url.fctReplaceURL(pstrURL);
    return;
 }
 if (fctIsURLTRANS(pstrURL))
 {
    if (self.name == "GWINTRANS")
    {
        parent.fctSetModeTRANS("WAIT");
        parent.GWINTRANS.location.replace(pstrURL);
    }
    else
    {
        fctSetModeTRANS("WAIT");
        GWINTRANS.location.replace(pstrURL);
    }
 }
 else
 {
    if (self.name == "GWINTRANS")
    {
        parent.location.replace(pstrURL);
    }
    else
    {
        self.location.replace(pstrURL);
    }
 }
}

function fctNav(Idx)
{
    var lFormMenu = self.document.FormMenu;
    eval("var lstrURL = lFormMenu.wHIDURL" + Idx.toString() + ".value;");
    fctURL(lstrURL);
}

function fctNavParams(Idx)
{
    var lFormMenu = self.document.FormMenu;
    eval("var lstrURL = lFormMenu.wHIDURL" + Idx.toString() + ".value;");
    sylogis.gen.url.fctURLParams(lstrURL,'HIDURL' + Idx.toString());
}

function fctNewWinURL(pstrURL, pstrWinName){
 var lwidth=(self.screen.availWidth - 50);
 var lheight=(self.screen.availHeight - 100);
 if (gbooBrowserIE != -1) {
     var fen=window.open(pstrURL,pstrWinName,"resizable=yes,status=yes,location=no,toolbar=yes,scrollbars=yes,directories=no,width=" + lwidth + ",height=" + lheight + ",top=5,left=25");
     //BUG: If the following line is omitted the opened window will not have the focus, (when keeped open and reclick on preferences on the main window)
//     var ltempo = fen.name;
//     fen.focus();
 }
 else {
     var fen=window.open(pstrURL,pstrWinName,"width=" + lwidth + ",height=" + lheight + ",scrollbars=1,resizable=0,menubar=0,status=0,top=5,left=25");
     fen.focus();
 }
 return false;
}

function fctPrint(Idx)
{
    var lFormMenu = self.document.FormMenu;
    eval("var lstrURL = lFormMenu.wHIDURL" + Idx.toString() + ".value;");
    fctNewWinURL(lstrURL, 'Edition');
}

function fctNewWinURLSize(pstrURL,pstrWinName,pwidth,pheight,ptop,pleft){
 if (gbooBrowserIE != -1) {
     var fen=window.open(pstrURL,pstrWinName,"resizable=yes,status=yes,location=no,toolbar=no,scrollbars=yes,directories=no,width=" + pwidth + ",height=" + pheight + ",top=" + ptop + ",left=" + pleft);
     //BUG: If the following line is omitted the opened window will not have the focus, (when keeped open and reclick on preferences on the main window)
     var ltempo = fen.name;
     fen.focus();
 }
 else {
     var fen=window.open(pstrURL,pstrWinName,"width=" + pwidth + ",height=" + pheight + ",scrollbars=1,resizable=0,menubar=0,status=0,top=" + ptop + ",left=" + pleft);
     fen.focus();
 }
 return false;
}

function fctNewWinURLSizeWthOpt(pstrURL,pstrWinName,pwidth,pheight,ptop,pleft,pOption){
 if (gbooBrowserIE != -1) {
     var fen=window.open(pstrURL,pstrWinName,pOption + ",width=" + pwidth + ",height=" + pheight + ",top=" + ptop + ",left=" + pleft);
     //BUG: If the following line is omitted the opened window will not have the focus, (when keeped open and reclick on preferences on the main window)
     var ltempo = fen.name;
     fen.focus();
 }
 else {
     var fen=window.open(pstrURL,pstrWinName,"width=" + pwidth + ",height=" + pheight + "," + pOption + ",top=" + ptop + ",left=" + pleft);
     fen.focus();
 }
 return false;
}

function fctNewWinURLWH(pstrURL,pstrWinName,pwidth,pheight){
 if (gbooBrowserIE != -1) {
     var fen=window.open(pstrURL,pstrWinName,"resizable=yes,status=yes,location=no,toolbar=no,scrollbars=yes,directories=no,width=" + pwidth + ",height=" + pheight);
     //BUG: If the following line is omitted the opened window will not have the focus, (when keeped open and reclick on preferences on the main window)
     //var ltempo = fen.name;
     fen.focus();
 }
 else {
     var fen=window.open(pstrURL,pstrWinName,"width=" + pwidth + ",height=" + pheight + ",scrollbars=1,resizable=0,menubar=0,status=0");
     fen.focus();
 }
 return false;
}

function fctNewCenterWinURL(pstrURL,pwidth,pheight,poptions)
{
  if(poptions == '')
    poptions = "resizable=yes,status=yes,location=no,toolbar=no,scrollbars=yes,directories=no";

  var top=(screen.height-pheight)/2;
  var left=(screen.width-pwidth)/2;
  window.open(pstrURL,"","top="+top+",left="+left+",width="+pwidth+",height="+pheight+","+poptions);
}

function fctSubmit(pstrWinName){
 var lwidth=(self.screen.availWidth - 50);
 var lheight=(self.screen.availHeight - 50);
 if (gbooBrowserIE != -1) {
     var fen=window.open("",pstrWinName,"resizable=yes,status=no,location=no,toolbar=no,scrollbars=yes,directories=no,width=" + lwidth + ",height=" + lheight + ",top=5,left=25");
     fen.focus();
 }
 else {
     var fen=window.open("",pstrWinName,"width=" + lwidth + ",height=" + lheight + ",scrollbars=1,resizable=0,menubar=0,status=0,top=5,left=25");
     fen.focus();
 }
}

function fctRetour(pNbMode,pstrURL){
 var lstrURL = pstrURL;

 if (self.name != "GWINTRANS")
 {
     if ((pNbMode == 0) || (pNbMode == 4)) {
         self.close();
         if(opener)
         {
            if (gbooBrowserIE == -1)
            {
                opener.focus();
            }
            else
            {
                if (!opener.closed)
                {
                    opener.focus();
                }
            }
         }
     }
     if (pNbMode == 1) {
         history.back();
     }
     if (pNbMode == 2) {
         fctURL(lstrURL);
     }
     if (pNbMode == 3) {
         lstrURL = fctGetCookie(pstrURL);
         fctURL(lstrURL);
     }
     if (pNbMode == 5) {
         lstrURL = gstrLoginURL;
         if (!opener) {
             fctURL(lstrURL);
         }
         else {
             opener.location = lstrURL;
             opener.focus();
             self.close();
         }
     }
 }
 else
 {
     if (pNbMode == 1)
     {
         parent.fctSetModeTRANS("INIT");
     }
     if (pNbMode == 2) {
         fctURL(lstrURL);
     }
     if (pNbMode == 5)
     {
         lstrURL = gstrLoginURL;
         if (!parent.opener)
             parent.location = lstrURL;
         else
         {
             parent.opener.location = lstrURL;
             parent.opener.focus();
             parent.close();
         }
     }
 }
 if (gbooBrowserIE != -1)
    self.event.returnValue = false;
 else
    return false;
}

function fctVerouille(pVerPRMID,pVerMNPID,pVerPROC){
 fctSetCookie("SYLOVERRPRMID",pVerPRMID.toString(),null,"/");
 fctSetCookie("SYLOVERRMNPID",pVerMNPID,null,"/");
 fctSetCookie("SYLOVERRPROC",pVerPROC,null,"/");
 var lstrURL = "PK_SECURE_HTML8.PR_LOGIN_MAIN";
 fctURL(lstrURL);
 return false;
}

function fctGetCookie (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 getCookieVal (offset) {
 var endstr = document.cookie.indexOf (";", offset);
 if (endstr == -1)
   endstr = document.cookie.length;
 return unescape(document.cookie.substring(offset, endstr));
 }

function fctSetCookie (name,value,expires,path,domain,secure) {
 document.cookie = name + "=" + escape (value) +
 ((expires) ? "; expires=" + expires.toGMTString() : "") +
 ((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
}

function fctSetPICACookie (name,value,nbjourexpire) {
    var futdate = new Date()
    var expdate = futdate.getTime()
    expdate += 3600*1000*24*nbjourexpire; //expires in 1 hour(milliseconds)
    futdate.setTime(expdate)

    fctSetCookie(name,value,futdate,'/');
}

function fctDeleteCookie (name,path,domain) {
 if (fctGetCookie(name)) {
 document.cookie = name + "=" +
 ((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
"; expires=Thu, 01-Jan-70 00:00:01 GMT";
 }
}


//FONCTIONS : RACCOURCIS
//F7 pour lancer l'interface de recherche
function fctRechercheLib()
 {
 return "Rechercher...";
 }
function fctKeyDownRechercheText()
 {
 return "F7";
 }
function fctKeyDownRecherche()
 {
 if(gnbKeyCode == 118)
   return true;
 return false;
 }

//F8 pour lancer la recherche
function fctRechercherLib()
 {
 return "Rechercher";
 }
function fctKeyDownRechercherText()
 {
 return "F8";
 }
function fctKeyDownRechercher()
 {
 if(gnbKeyCode == 119)
   return true;
 return false;
}

//F9 pour lancer une liste de valeurs
function fctLDVLib()
 {
 return "Liste de valeurs";
 }
function fctKeyDownLDVText()
 {
 return "F9";
 }
function fctKeyDownLDV()
 {
 if(gnbKeyCode == 120)
   return true;
 return false;
}


//CTRL+SHFT+E pour vider des champs
function fctEffacerLib()
 {
 return "Effacer";
 }
function fctKeyDownEffacerText()
 {
 return gstrCTRL + "+" + gstrSHFT + "+E";
 }
function fctKeyDownEffacer()
 {
 if(gbooctrlKey && gbooshiftKey && gnbKeyCode == 69)
   return true;
 return false;
 }

//CTRL+SHFT+A pour lancer l'interface d'ajout
function fctAjoutLib()
 {
 return "Ajouter...";
 }
function fctKeyDownAjoutText()
 {
 return gstrCTRL + "+" + gstrSHFT + "+A";
 }
function fctKeyDownAjout()
 {
 if(gbooctrlKey && gbooshiftKey && gnbKeyCode == 65)
   return true;
 return false;
 }

//CTRL+SHFT+S pour lancer l'interface de suppression
function fctSuppressionLib()
 {
 return "Supprimer...";
 }
function fctKeyDownSuppressionText()
 {
 return gstrCTRL + "+" + gstrSHFT + "+S";
 }
function fctKeyDownSuppression()
 {
 if(gbooctrlKey && gbooshiftKey && gnbKeyCode == 83)
   return true;
 return false;
}

//CTRL+SHFT+M pour lancer l'interface de modification
function fctModificationLib()
 {
 return "Modifier...";
 }
function fctKeyDownModificationText()
 {
 return gstrCTRL + "+" + gstrSHFT + "+U";
 }
function fctKeyDownModification()
 {
 if(gbooctrlKey && gbooshiftKey && gnbKeyCode == 85)
   return true;
 return false;
 }

//CTRL+SHFT+INSER pour lancer l'ajout
function fctAjouterLib()
 {
 return "Ajouter";
 }
function fctKeyDownAjouterText()
 {
 return gstrCTRL + "+" + gstrSHFT + "+J";
 }
function fctKeyDownAjouter()
 {
 if(gbooctrlKey && gbooshiftKey && gnbKeyCode == 74)
   return true;
 return false;
 }

//CTRL+SHFT+SUPPR pour lancer la suppression
function fctSupprimerLib()
 {
 return "Supprimer";
 }
function fctKeyDownSupprimerText()
 {
 return gstrCTRL + "+" + gstrSHFT + "+" + gstrSUPPR;
 }
function fctKeyDownSupprimer()
 {
 if(gbooctrlKey && gbooshiftKey && gnbKeyCode == 46)
   return true;
 return false;
 }

//F12 pour lancer la modification
function fctModifierLib()
 {
 return "Modifier";
 }
function fctKeyDownModifierText()
 {
 return "F12";
 }
function fctKeyDownModifier()
 {
 if(gnbKeyCode == 123)
   return true;
 return false;
 }

//CTRL+SHFT+V pour lancer la validation
function fctValiderLib()
 {
 return "Valider";
 }
function fctKeyDownValiderText()
 {
 return gstrCTRL + "+" + gstrSHFT + "+V";
 }
function fctKeyDownValider()
 {
 if(gbooctrlKey && gbooshiftKey && gnbKeyCode == 86)
   return true;
 return false;
 }

//CTRL+SHFT+W pour lancer (ou fermer) l'interface de ventilation
function fctVentilationLib()
 {
 return "Ventilation...";
 }
function fctKeyDownVentilationText()
 {
 return gstrCTRL + "+" + gstrSHFT + "+W";
 }
function fctKeyDownVentilation()
 {
 if(gbooctrlKey && gbooshiftKey && gnbKeyCode == 87)
   return true;
 return false;
 }

//F9 pour lancer l'interface des valeurs
function fctValeursLib()
 {
 return "Valeurs...";
 }
function fctKeyDownValeursText()
 {
 return "F9";
 }
function fctKeyDownValeurs()
 {
 if(gbooctrlKey && gbooshiftKey && gnbKeyCode == 120)
   return true;
 return false;
 }

//CTRL+SHFT+H pour lancer l'interface du guide utilisateur
function fctAideLib()
{
 return "Guide utilisateur";
}

function fctKeyDownAideText()
 {
 return gstrCTRL + "+" + gstrSHFT + "+H";
 }
function fctKeyDownAide()
 {
 if(gbooctrlKey && gbooshiftKey && gnbKeyCode == 72)
   return true;
 return false;
 }

//CTRL+SHFT+P pour lancer l'interface de personnalisation
function fctPersonnaliserLib()
 {
 return "Personnaliser";
 }
function fctKeyDownPersonnaliserText()
 {
 return gstrCTRL + "+" + gstrSHFT + "+P";
 }
function fctKeyDownPersonnaliser()
 {
 if(gbooctrlKey && gbooshiftKey && gnbKeyCode == 80)
   return true;
 return false;
 }

//CTRL+SHFT+, pour afficher les premiers enregistrements
function fctDetLinksPremierLib()
 {
 return "Premier";
 }
function fctKeyDownDetLinksPremierText()
 {
 return gstrCTRL + "+" + gstrSHFT + "+,";
 }
function fctKeyDownDetLinksPremier()
 {
 if(gbooctrlKey && gbooshiftKey && gnbKeyCode == 188)
   return true;
 return false;
 }

//CTRL+SHFT+; pour afficher les enregistrements précédents
function fctDetLinksPrecedentLib()
 {
 return "Précédent";
 }
function fctKeyDownDetLinksPrecedentText()
 {
 return gstrCTRL + "+" + gstrSHFT + "+;";
 }
function fctKeyDownDetLinksPrecedent()
 {
 if(gbooctrlKey && gbooshiftKey && gnbKeyCode == 190)
   return true;
 return false;
 }

//CTRL+SHFT+: pour afficher les enregistrements suivants
function fctDetLinksSuivantLib()
 {
 return "Suivant";
 }
function fctKeyDownDetLinksSuivantText()
 {
 return gstrCTRL + "+" + gstrSHFT + "+:";
 }
function fctKeyDownDetLinksSuivant()
 {
 if(gbooctrlKey && gbooshiftKey && gnbKeyCode == 191)
   return true;
 return false;
 }

//CTRL+SHFT+! pour afficher les derniers enregistrements
function fctDetLinksDernierLib()
 {
 return "Dernier";
 }
function fctKeyDownDetLinksDernierText()
 {
 return gstrCTRL + "+" + gstrSHFT + "+!";
 }
function fctKeyDownDetLinksDernier()
 {
 if(gbooctrlKey && gbooshiftKey && gnbKeyCode == 223)
   return true;
 return false;
 }

//CTRL+SHFT+R pour faire retourner
function fctRetournerLib()
 {
 return "Retourner";
 }
function fctKeyDownRetournerText()
 {
 return gstrCTRL + "+" + gstrSHFT + "+R";
 }
function fctKeyDownRetourner()
 {
 if(gbooctrlKey && gbooshiftKey && gnbKeyCode == 82)
   return true;
 return false;
}

// CTRL+SHFT+U pour lancer l'interface de duplication
function fctDupliquerLib()
 {
 return "Dupliquer...";
 }
function fctKeyDownDupliquerText()
 {
 return gstrCTRL + "+" + gstrSHFT + "+I";
 }
function fctKeyDownDupliquer()
 {
 if(gbooctrlKey && gbooshiftKey && gnbKeyCode == 73)
   return true;
 return false;
}

// CTRL+SHFT+D pour lancer l'interface de duplication
function fctDetaillerLib()
 {
 return "Détailler...";
 }
function fctKeyDownDetaillerText()
 {
 return gstrCTRL + "+" + gstrSHFT + "+D";
 }
function fctKeyDownDetailler()
 {
 if(gbooctrlKey && gbooshiftKey && gnbKeyCode == 68)
   return true;
 return false;
}

function fctAppliquerLib()
 {
 return "Appliquer";
 }

function fctReplace(pstrchaine, pstrcher, pstrremp) //chaine de base; chacher : chaine a chercher; charemp: chaine de remplacement
{
    var lgc=pstrcher.length; // longueur de la chaine a chercher (pstrcher)
    var lg=pstrchaine.length;   //longueur de la chaine d'entrée (pstrchaine)
    var indd=0, inddc=0, indfc;   //indices
    var tmpdeb, tmpfin; //chaine temporaire : debut et fin
    while((inddc = pstrchaine.indexOf(pstrcher,indd)) != -1)
    {
        tmpdeb=pstrchaine.substr(0,inddc); //on recupere partie gauche jusqua l'indice du debut de la chaine a chercher (pstrcher)
        indfc = inddc+lgc; //itmp : indice de fin de la chaine a chercher
        tmpfin=pstrchaine.substr(indfc,lg);  //on recupere la chaine de la fin de la chaine a chercher jusqua la fin de la chaine
        pstrchaine = tmpdeb + pstrremp + tmpfin; //on reconstruit la chaine avec la chaine de remplacement
        indd = indfc+1;  //on deplace l'indice de debut de recherche pour accelerer la recherche indexOf
    }
    return pstrchaine;
}

//Découper une chaine et retourner un tableau
//Chaque élément du tableau retourné est un tableau à deux entrées (0 : indice du début de la sous-chaîne, 1 : la sous-chaine)
//Remarque : _ Le séparateur n'est pas inclu dans le résultat
//           _ Le séparateur peut être une chaîne de longueur > 1
//           _ faut tester l'existence de "if (larrResultat.length)" avant toute opération
function fctDecoupe(chaine, separateur)
 {
 var i=0;
 var j=0;
 var numval=-1;
 tab=new Array;

 //PREND LES LONGEURS ET VERIFIE SI SEPARATEUR A LA FIN
 var longC=chaine.length;
 var longS=separateur.length;
 var last=chaine.substr(longC-longS,longS);
 //SINON RAJOUTE UN A LA FIN
 if(last!=separateur)
    {
        chaine=chaine+separateur;
        var longC=chaine.length;
    }


 //TANT QUE I EST AVANT LA POSITION DU DEBUT DU DERNIER SEPARATEUR ET DIFFERENT DE -1
 while(j<longC && i!=-1)
     {
         //INDEX DU PROCHAIN SEPARATEUR
         i=chaine.indexOf(separateur,j);

         //SEPARATEURS SE SUIVENT: ON CHERCHE LE SUIVANT
         while(i==j)
            {
            j=j+longS;
            i=chaine.indexOf(separateur,j);
            }

         //PLUS DE SEPARATEUR DANS LA CHAINE
         if(i==-1)
            {
            //AUCUN SEPARATEUR DANS LA CHAINE
            if(numval==-1)
                {
                return false;
                }
            }
         else
            {
             numval++;
             tab[numval]= new Array;
             tab[numval][0]=j;                     //position du premier caractère de la chaine
             tab[numval][1]=chaine.substring(j,i); //valeur de la chaine entre position début et début du séparateur prochain

             j=i+longS;
            }
     }
 return tab;
}

function getCharTabFromString(chaine) {
    var tab = new Array;
    for(var j=0;j<chaine.length;j++) {
        tab.push(chaine.substring(j,j+1));
    }
    return tab;
}

function cleanIEHTML(lstrChaine, debut){
    var deb;
    deb = lstrChaine.indexOf("<", debut);
    if(deb > -1) {
        var fin = lstrChaine.indexOf(">", deb);
        var deb_chaine = lstrChaine.substring(0, deb);
        var sous_chaine = lstrChaine.substring(deb, fin+1);
        var fin_chaine = lstrChaine.substring(fin+1);

        var deb1 = sous_chaine.indexOf('=');
        var deb2 = sous_chaine.indexOf('="');

        if(deb1 > -1 && deb2 == -1) {
            //alors mauvais formattage de IE, on doit ajouter les "
            var lg = sous_chaine.length;
            var new_sous_chaine = addQuoteToHTMLMark(sous_chaine, -1);

            var decal = new_sous_chaine.length - lg;
        }
        else {
            var decal = 0;
            var new_sous_chaine = sous_chaine;
        }

        lstrChaine = deb_chaine + new_sous_chaine + fin_chaine;
        lstrChaine = cleanIEHTML(lstrChaine, fin+decal+1);
    }
	lstrChaine=lstrChaine.replace(/<EM>/gi,"<I>");
	lstrChaine=lstrChaine.replace(/<\/EM>/gi,"</I>");
	lstrChaine=lstrChaine.replace(/<STRONG>/gi,"<B>");
	lstrChaine=lstrChaine.replace(/<\/STRONG>/gi,"</B>");
	lstrChaine=lstrChaine.replace(/&nbsp;/gi," ");

    return lstrChaine;
}

function addQuoteToHTMLMark(chaine, debut) {
    var tabChaine = getCharTabFromString(chaine);

    for(var i=0;i<tabChaine.length;i++) {
        if(tabChaine[i] == "=" && i < (tabChaine.length-1)) {
            if(tabChaine[i+1] != '"') {
                //on va chercher la fin de la valeur de l'zttribut
                var fin = chaine.indexOf(" ",i);
                if(fin == -1) {
                    //cas du dernier attribut
                    fin = chaine.indexOf(">",i);
                }

                var deb_chaine = chaine.substring(0, i+1);
                var sous_chaine = chaine.substring(i+1, fin);
                var fin_chaine = chaine.substring(fin);

                var sous_chaine = '"' + sous_chaine + '"';

                chaine = deb_chaine + sous_chaine + fin_chaine;
                tabChaine = getCharTabFromString(chaine);
                i = fin + 2;
            }
        }
    }
    return chaine;
}

function fctGenTabCSV(ltabIdx){

    if(gstrAjaxEnable == 'O' && dijit.byId("CSV"+ltabIdx)) {
        sylogis.gen.common.fctGenTabCSV(ltabIdx);
        return false;
    }

    eval("var lForm = self.document.FormCSV"+ltabIdx);

    if(lForm) {
        var tab = document.getElementById('TblTBM'+ltabIdx);
        if(tab) { //traitement pour les tbm/tbx
            fctGenCsvDataFromTab(tab,lForm);
        }

        //suppression des csvdata du formulaire
        var csvdatas = cssQuery('input[name="gstrCSVData"]',lForm);
        for(var i=0;i<csvdatas.length;i++){
            csvdatas[i].value = fctTrim(fctHtmlToText(csvdatas[i].value));
        }

        lForm.submit();
    }

    return false;
}

function fctGenCsvDataFromTab(tab,formCsv){

    //suppression des csvdata du formulaire
    var csvdatas = cssQuery('input[name="gstrCSVData"]',formCsv);
    for(var i=0;i<csvdatas.length;i++){
        csvdatas[i].parentNode.removeChild(csvdatas[i]);
    }

    //liste des lignes du teableaux
    var rows = cssQuery('tr',tab);
    for(var i=0;i<rows.length;i++){
        var cssText = [];
        //lignes des cellules de la ligne
        var cels = cssQuery('td',rows[i]);
        for(var j=1;j<cels.length-1;j++){
            //champs saisie texte
            var input = cssQuery('input[type="text"]',cels[j]);
            //champs saisie textearea
            var area = cssQuery('textarea',cels[j]);
            //champs saisie radio
            var radio = cssQuery('input[type="radio"]',cels[j]);
            //champs saisie checkbox
            var check = cssQuery('input[type="checkbox"]',cels[j]);
            //champs saisie select
            var selects = cssQuery('select',cels[j]);
            if(input.length>0) {
                cssText.push(fctCSVReplaceText(input[0].value));
            }
            else if(area.length>0){
                cssText.push(fctCSVReplaceText(area[0].value));
            }
            else if(selects.length>0){
                cssText.push(fctCSVReplaceText(selects[0].value));
            }
            else if(radio.length>0){
                for(var k=0;k<radio.length && !radio[k].checked;k++);
                if(k<radio.length)
                    cssText.push(fctCSVReplaceText(radio[k].value));
                else
                    cssText.push('');
            }
            else if(check.length>0){
                //les checkbox peuvent etre multi cochées, je prend les valeurs de chacune séparées par -
                var vals = '';
                for(var k=0;k<check.length;k++){
                    if(check[k].checked)
                        vals = vals+check[k].value+'-';
                }
                vals = check.substr(0,vals.length-1);
                cssText.push(fctCSVReplaceText(vals));
            }
            else {
                //pas de champ de saisie, je prend la valeur de la cellule (contenu dans l'element font)
                var val = cssQuery('font',cels[j]);
                if(val.length > 0) {
                    cssText.push(fctCSVReplaceText(val[0].innerText));
                }
            }
        }
        //je cree le champ input hidden
        var csvdata = document.createElement('DIV');
        csvdata.innerHTML = '<input type="hidden" name="gstrCSVData" value="'+cssText.join(';')+';">';
        formCsv.appendChild(csvdata);
    }
}

function fctCSVReplaceText(lText) {
    var lNewText = lText;

    lNewText = fctReplace(lNewText, '&nbsp;', ' ');
    lNewText = fctReplace(lNewText, gstrCSVSep, gstrCSVRep);
    lNewText = fctReplace(lNewText, '"', "'");
    return lNewText;
}

function fctVerifyUrl(lstrURL) {
    fctXMLURL(lstrURL);
}

function fctXMLURL(lstrURL,pbooForceIsURLTRANS) {
    fctExecURL(lstrURL,pbooForceIsURLTRANS); return;
}

function fctTrimLeft(pStr){
 var lRes;
 lRes = pStr;
 while (lRes.substring(0, 1) == " ") {
     lRes = lRes.substring(1, lRes.length);
 }
 return lRes;
}

function fctTrimRight(pStr){
 var lRes;
 lRes = pStr;
 while (lRes.substring((lRes.length - 1), lRes.length) == " ") {
     lRes = lRes.substring(0, (lRes.length - 1));
 }
 return lRes;
}

function fctTrim(pStr){
 var lRes;
 lRes = fctTrimLeft(pStr);
 lRes = fctTrimRight(lRes);
 return lRes;
}

function fctHtmlToText(pStr) {
    return pStr.replace(/<[^>]+>/g,"");
}

// This code was written by Tyler Akins and has been placed in the
// public domain.  It would be nice if you left this header intact.
// Base64 code from Tyler Akins -- http://rumkin.com

var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";

function encode64(input) {
   var output = "";
   var chr1, chr2, chr3;
   var enc1, enc2, enc3, enc4;
   var i = 0;

   do {
      chr1 = input.charCodeAt(i++);
      chr2 = input.charCodeAt(i++);
      chr3 = input.charCodeAt(i++);

      enc1 = chr1 >> 2;
      enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
      enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
      enc4 = chr3 & 63;

      if (isNaN(chr2)) {
         enc3 = enc4 = 64;
      } else if (isNaN(chr3)) {
         enc4 = 64;
      }

      output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) +
         keyStr.charAt(enc3) + keyStr.charAt(enc4);
   } while (i < input.length);

   return output;
}

function decode64(input) {
   var output = "";
   var chr1, chr2, chr3;
   var enc1, enc2, enc3, enc4;
   var i = 0;

   // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
   input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

   do {
      enc1 = keyStr.indexOf(input.charAt(i++));
      enc2 = keyStr.indexOf(input.charAt(i++));
      enc3 = keyStr.indexOf(input.charAt(i++));
      enc4 = keyStr.indexOf(input.charAt(i++));

      chr1 = (enc1 << 2) | (enc2 >> 4);
      chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
      chr3 = ((enc3 & 3) << 6) | enc4;

      output = output + String.fromCharCode(chr1);

      if (enc3 != 64) {
         output = output + String.fromCharCode(chr2);
      }
      if (enc4 != 64) {
         output = output + String.fromCharCode(chr3);
      }
   } while (i < input.length);

   return output;
}


function fctViewDiv(ldivname)
{
 var diviframe = self.document.getElementById(ldivname);
 if(diviframe){
     if (diviframe.style.visibility == "visible")
     {
        diviframe.style.visibility = "hidden";
        diviframe.style.display = "none";
        diviframe.style.position = "absolute";
     }
     else
     {
        diviframe.style.visibility = "visible";
        diviframe.style.display = "";
        diviframe.style.position = "relative";
     }
 }
 return false;
}

function fctViewFrmDiv(ldivname,lheight)
{
 var diviframe = self.document.getElementById(ldivname);
 if(diviframe){
     if (diviframe.style.visibility == "visible")
     {
        diviframe.style.visibility = "hidden";
        diviframe.style.position = "absolute";
        diviframe.style.height = '0';
        diviframe.style.display = "none";
     }
     else
     {
        diviframe.style.visibility = "visible";
        diviframe.style.position = "relative";
        diviframe.style.height = lheight;
        diviframe.style.display = "";
     }
 }
 return false;
}

function fctChgViewDiv(ldivname,lvisible)
{
 var diviframe = self.document.getElementById(ldivname);
 if(diviframe){
     if (lvisible == "hidden")
     {
        diviframe.style.visibility = "hidden";
        diviframe.style.position = "absolute";
     }
     else if(lvisible == "visible")
     {
        diviframe.style.visibility = "visible";
        diviframe.style.position = "relative";
     }
 }
 return false;
}

function fctDivIsVisible(ldivname)
{
 var diviframe = self.document.getElementById(ldivname);
 if(diviframe){
    if (diviframe.style.visibility == "visible" || diviframe.style.display != 'none'){
        return true;
    }
    else{
        return false;
    }
 }
 return false;
}

function hidDiv(ldivname) {
 var div = document.getElementById(ldivname);
 if(div){
    div.style.visibility = "hidden";
    div.style.display = "none";
 }
}

function viewDiv(ldivname) {
 var div = document.getElementById(ldivname);
 if(div){
    div.style.display = "";
    div.style.visibility = "visible";
 }
}


function fctArboDiv(ldivname)
{
 var diviframe = self.document.getElementById(ldivname);
 if(diviframe){
    if (diviframe.style.display == "inline")
        diviframe.style.display = "none";
     else
        diviframe.style.display = "inline";
 }
 return false;
}

function fctChangePic(wName,wDivName,wGifNameOpen,wGifNameClose)
{
     var diviframe = self.document.getElementById(wDivName);
     var img = document.getElementById(wName);

     if(diviframe){
         if (diviframe.style.visibility == "hidden" || diviframe.style.display == "none")
         {
            img.src = gstrImagesRep + wGifNameOpen;
         }
         else if(diviframe.style.visibility == "visible" || diviframe.style.display == "inline")
         {
            img.src = gstrImagesRep + wGifNameClose;
         }
     }
}
Array.prototype.remove = function (indx) {
    return (indx>this.length)?false:(this.slice(0,indx).concat(this.slice(indx+1,this.length)));
}
Array.prototype.removeObj = function (obj) {
    var indx = this.getPos(obj);
    if(indx == -1) alert('pb');
    return this.remove(indx);
    //return (indx>this.length)?false:(this.slice(0,indx).concat(this.slice(indx+1,this.length)));
}
Array.prototype.getPos = function (val) {
    for(var j=0;j<this.length && this[j]!=val;j++);
    if(j<this.length) return j;
    else return -1;
}
Array.prototype.indexOf = function (obj) {
	return this.getPos(obj);
};
//Prototypage des Dates pour pouvoir ajouter des jours facilement
Date.prototype.addJours = function(value) {
	this.setDate(this.getDate()+value);
}

/*
	cssQuery, version 2.0.2 (2005-08-19)
	Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/)
	License: http://creativecommons.org/licenses/LGPL/2.1/
*/
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('7 x=6(){7 1D="2.0.2";7 C=/\\s*,\\s*/;7 x=6(s,A){33{7 m=[];7 u=1z.32.2c&&!A;7 b=(A)?(A.31==22)?A:[A]:[1g];7 1E=18(s).1l(C),i;9(i=0;i<1E.y;i++){s=1y(1E[i]);8(U&&s.Z(0,3).2b("")==" *#"){s=s.Z(2);A=24([],b,s[1])}1A A=b;7 j=0,t,f,a,c="";H(j<s.y){t=s[j++];f=s[j++];c+=t+f;a="";8(s[j]=="("){H(s[j++]!=")")a+=s[j];a=a.Z(0,-1);c+="("+a+")"}A=(u&&V[c])?V[c]:21(A,t,f,a);8(u)V[c]=A}m=m.30(A)}2a x.2d;5 m}2Z(e){x.2d=e;5[]}};x.1Z=6(){5"6 x() {\\n  [1D "+1D+"]\\n}"};7 V={};x.2c=L;x.2Y=6(s){8(s){s=1y(s).2b("");2a V[s]}1A V={}};7 29={};7 19=L;x.15=6(n,s){8(19)1i("s="+1U(s));29[n]=12 s()};x.2X=6(c){5 c?1i(c):o};7 D={};7 h={};7 q={P:/\\[([\\w-]+(\\|[\\w-]+)?)\\s*(\\W?=)?\\s*([^\\]]*)\\]/};7 T=[];D[" "]=6(r,f,t,n){7 e,i,j;9(i=0;i<f.y;i++){7 s=X(f[i],t,n);9(j=0;(e=s[j]);j++){8(M(e)&&14(e,n))r.z(e)}}};D["#"]=6(r,f,i){7 e,j;9(j=0;(e=f[j]);j++)8(e.B==i)r.z(e)};D["."]=6(r,f,c){c=12 1t("(^|\\\\s)"+c+"(\\\\s|$)");7 e,i;9(i=0;(e=f[i]);i++)8(c.l(e.1V))r.z(e)};D[":"]=6(r,f,p,a){7 t=h[p],e,i;8(t)9(i=0;(e=f[i]);i++)8(t(e,a))r.z(e)};h["2W"]=6(e){7 d=Q(e);8(d.1C)9(7 i=0;i<d.1C.y;i++){8(d.1C[i]==e)5 K}};h["2V"]=6(e){};7 M=6(e){5(e&&e.1c==1&&e.1f!="!")?e:23};7 16=6(e){H(e&&(e=e.2U)&&!M(e))28;5 e};7 G=6(e){H(e&&(e=e.2T)&&!M(e))28;5 e};7 1r=6(e){5 M(e.27)||G(e.27)};7 1P=6(e){5 M(e.26)||16(e.26)};7 1o=6(e){7 c=[];e=1r(e);H(e){c.z(e);e=G(e)}5 c};7 U=K;7 1h=6(e){7 d=Q(e);5(2S d.25=="2R")?/\\.1J$/i.l(d.2Q):2P(d.25=="2O 2N")};7 Q=6(e){5 e.2M||e.1g};7 X=6(e,t){5(t=="*"&&e.1B)?e.1B:e.X(t)};7 17=6(e,t,n){8(t=="*")5 M(e);8(!14(e,n))5 L;8(!1h(e))t=t.2L();5 e.1f==t};7 14=6(e,n){5!n||(n=="*")||(e.2K==n)};7 1e=6(e){5 e.1G};6 24(r,f,B){7 m,i,j;9(i=0;i<f.y;i++){8(m=f[i].1B.2J(B)){8(m.B==B)r.z(m);1A 8(m.y!=23){9(j=0;j<m.y;j++){8(m[j].B==B)r.z(m[j])}}}}5 r};8(![].z)22.2I.z=6(){9(7 i=0;i<1z.y;i++){o[o.y]=1z[i]}5 o.y};7 N=/\\|/;6 21(A,t,f,a){8(N.l(f)){f=f.1l(N);a=f[0];f=f[1]}7 r=[];8(D[t]){D[t](r,A,f,a)}5 r};7 S=/^[^\\s>+~]/;7 20=/[\\s#.:>+~()@]|[^\\s#.:>+~()@]+/g;6 1y(s){8(S.l(s))s=" "+s;5 s.P(20)||[]};7 W=/\\s*([\\s>+~(),]|^|$)\\s*/g;7 I=/([\\s>+~,]|[^(]\\+|^)([#.:@])/g;7 18=6(s){5 s.O(W,"$1").O(I,"$1*$2")};7 1u={1Z:6(){5"\'"},P:/^(\'[^\']*\')|("[^"]*")$/,l:6(s){5 o.P.l(s)},1S:6(s){5 o.l(s)?s:o+s+o},1Y:6(s){5 o.l(s)?s.Z(1,-1):s}};7 1s=6(t){5 1u.1Y(t)};7 E=/([\\/()[\\]?{}|*+-])/g;6 R(s){5 s.O(E,"\\\\$1")};x.15("1j-2H",6(){D[">"]=6(r,f,t,n){7 e,i,j;9(i=0;i<f.y;i++){7 s=1o(f[i]);9(j=0;(e=s[j]);j++)8(17(e,t,n))r.z(e)}};D["+"]=6(r,f,t,n){9(7 i=0;i<f.y;i++){7 e=G(f[i]);8(e&&17(e,t,n))r.z(e)}};D["@"]=6(r,f,a){7 t=T[a].l;7 e,i;9(i=0;(e=f[i]);i++)8(t(e))r.z(e)};h["2G-10"]=6(e){5!16(e)};h["1x"]=6(e,c){c=12 1t("^"+c,"i");H(e&&!e.13("1x"))e=e.1n;5 e&&c.l(e.13("1x"))};q.1X=/\\\\:/g;q.1w="@";q.J={};q.O=6(m,a,n,c,v){7 k=o.1w+m;8(!T[k]){a=o.1W(a,c||"",v||"");T[k]=a;T.z(a)}5 T[k].B};q.1Q=6(s){s=s.O(o.1X,"|");7 m;H(m=s.P(o.P)){7 r=o.O(m[0],m[1],m[2],m[3],m[4]);s=s.O(o.P,r)}5 s};q.1W=6(p,t,v){7 a={};a.B=o.1w+T.y;a.2F=p;t=o.J[t];t=t?t(o.13(p),1s(v)):L;a.l=12 2E("e","5 "+t);5 a};q.13=6(n){1d(n.2D()){F"B":5"e.B";F"2C":5"e.1V";F"9":5"e.2B";F"1T":8(U){5"1U((e.2A.P(/1T=\\\\1v?([^\\\\s\\\\1v]*)\\\\1v?/)||[])[1]||\'\')"}}5"e.13(\'"+n.O(N,":")+"\')"};q.J[""]=6(a){5 a};q.J["="]=6(a,v){5 a+"=="+1u.1S(v)};q.J["~="]=6(a,v){5"/(^| )"+R(v)+"( |$)/.l("+a+")"};q.J["|="]=6(a,v){5"/^"+R(v)+"(-|$)/.l("+a+")"};7 1R=18;18=6(s){5 1R(q.1Q(s))}});x.15("1j-2z",6(){D["~"]=6(r,f,t,n){7 e,i;9(i=0;(e=f[i]);i++){H(e=G(e)){8(17(e,t,n))r.z(e)}}};h["2y"]=6(e,t){t=12 1t(R(1s(t)));5 t.l(1e(e))};h["2x"]=6(e){5 e==Q(e).1H};h["2w"]=6(e){7 n,i;9(i=0;(n=e.1F[i]);i++){8(M(n)||n.1c==3)5 L}5 K};h["1N-10"]=6(e){5!G(e)};h["2v-10"]=6(e){e=e.1n;5 1r(e)==1P(e)};h["2u"]=6(e,s){7 n=x(s,Q(e));9(7 i=0;i<n.y;i++){8(n[i]==e)5 L}5 K};h["1O-10"]=6(e,a){5 1p(e,a,16)};h["1O-1N-10"]=6(e,a){5 1p(e,a,G)};h["2t"]=6(e){5 e.B==2s.2r.Z(1)};h["1M"]=6(e){5 e.1M};h["2q"]=6(e){5 e.1q===L};h["1q"]=6(e){5 e.1q};h["1L"]=6(e){5 e.1L};q.J["^="]=6(a,v){5"/^"+R(v)+"/.l("+a+")"};q.J["$="]=6(a,v){5"/"+R(v)+"$/.l("+a+")"};q.J["*="]=6(a,v){5"/"+R(v)+"/.l("+a+")"};6 1p(e,a,t){1d(a){F"n":5 K;F"2p":a="2n";1a;F"2o":a="2n+1"}7 1m=1o(e.1n);6 1k(i){7 i=(t==G)?1m.y-i:i-1;5 1m[i]==e};8(!Y(a))5 1k(a);a=a.1l("n");7 m=1K(a[0]);7 s=1K(a[1]);8((Y(m)||m==1)&&s==0)5 K;8(m==0&&!Y(s))5 1k(s);8(Y(s))s=0;7 c=1;H(e=t(e))c++;8(Y(m)||m==1)5(t==G)?(c<=s):(s>=c);5(c%m)==s}});x.15("1j-2m",6(){U=1i("L;/*@2l@8(@\\2k)U=K@2j@*/");8(!U){X=6(e,t,n){5 n?e.2i("*",t):e.X(t)};14=6(e,n){5!n||(n=="*")||(e.2h==n)};1h=1g.1I?6(e){5/1J/i.l(Q(e).1I)}:6(e){5 Q(e).1H.1f!="2g"};1e=6(e){5 e.2f||e.1G||1b(e)};6 1b(e){7 t="",n,i;9(i=0;(n=e.1F[i]);i++){1d(n.1c){F 11:F 1:t+=1b(n);1a;F 3:t+=n.2e;1a}}5 t}}});19=K;5 x}();',62,190,'|||||return|function|var|if|for||||||||pseudoClasses||||test|||this||AttributeSelector|||||||cssQuery|length|push|fr|id||selectors||case|nextElementSibling|while||tests|true|false|thisElement||replace|match|getDocument|regEscape||attributeSelectors|isMSIE|cache||getElementsByTagName|isNaN|slice|child||new|getAttribute|compareNamespace|addModule|previousElementSibling|compareTagName|parseSelector|loaded|break|_0|nodeType|switch|getTextContent|tagName|document|isXML|eval|css|_1|split|ch|parentNode|childElements|nthChild|disabled|firstElementChild|getText|RegExp|Quote|x22|PREFIX|lang|_2|arguments|else|all|links|version|se|childNodes|innerText|documentElement|contentType|xml|parseInt|indeterminate|checked|last|nth|lastElementChild|parse|_3|add|href|String|className|create|NS_IE|remove|toString|ST|select|Array|null|_4|mimeType|lastChild|firstChild|continue|modules|delete|join|caching|error|nodeValue|textContent|HTML|prefix|getElementsByTagNameNS|end|x5fwin32|cc_on|standard||odd|even|enabled|hash|location|target|not|only|empty|root|contains|level3|outerHTML|htmlFor|class|toLowerCase|Function|name|first|level2|prototype|item|scopeName|toUpperCase|ownerDocument|Document|XML|Boolean|URL|unknown|typeof|nextSibling|previousSibling|visited|link|valueOf|clearCache|catch|concat|constructor|callee|try'.split('|'),0,{}))

