
var gbooBrowserIE = navigator.appName.indexOf("Microsoft");
var gbooBrowserNs = navigator.appName.indexOf("Netscape");
var gstrLoginURL = "";

var gbooRaccourcis = 0;
var gnbKeyCode = -1;
var gbooCallKeyDownSpec = -1;

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;
 }

 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;
     }
 }

 if(gnbKeyCode == 116 && 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') {
        console.debug('commonload ajax');
        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) {
        if(lForm.gstrCSVData[0]) {
            for(var i=0;i<lForm.gstrCSVData.length;i++) {
                lForm.gstrCSVData[i].value = fctTrim(fctHtmlToText(lForm.gstrCSVData[i].value));
            }
        }
        else
            lForm.gstrCSVData.value = fctTrim(fctHtmlToText(lForm.gstrCSVData.value));

        lForm.submit();
    }

    return false;
}

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);
}
