// desactivation du F5 refraichisement
document.onkeydown = mykeydown;
document.onhelp = dsble_Help;
ignore_submit = false;
cancel_submit = false;
force_submit = false;
memory_force_submit = false;

function dsble_Help() {
  return false;
}
actif = "info";
function mykeydown(ev) {
  var code;
  var ff = false;
  if (ev) {
    ff = true;
    code = ev.which;
    event = ev;
  } else {
    code = event.keyCode;
  }
  if (code == 10) {
  }
  if (code == 13) {
    if (cancel_submit) {
      window.event.which = 9;
      window.event.returnValue = false;
    } else {
      if (ignore_submit) {
        ignore_submit = false;
        window.event.which = 9;
        window.event.returnValue = false;
      } else {
        if (force_submit) {
          document.forms[actif].submit();
        }
      }
    }
  }
  if (code == 33) {
    if (ok_move() == 1) {
      if (!ff) {
        window.event.keyCode = 97;
        window.event.returnValue = false;
      }
      switch (memnoform) {
        case 1:
          type = document.info.Type.value;
          sous_type = document.info.Sous_Type.value;
          etape = document.info.Etape.value;
          etape = etape - 1;
          novisu = document.info.NoVisu.value;
          noarticle = document.info.NoArticle.value;
          window.location.href =
            "default.php?Type=" +
            type +
            "&Sous_Type=" +
            sous_type +
            "&Etape=" +
            etape +
            "&NoVisu=" +
            novisu +
            "&NoArticle=" +
            noarticle +
            "&Move=UP";
          break;
        case 2:
          type = document.info.Type.value;
          sous_type = document.info.Sous_Type.value;
          etape = document.info.Etape.value;
          etape = etape - 1;
          novisu = document.info.NoVisu.value;
          nochasis = document.info.NoChasis.value;
          window.location.href =
            "default.php?Type=" +
            type +
            "&Sous_Type=" +
            sous_type +
            "&Etape=" +
            etape +
            "&NoVisu=" +
            novisu +
            "&NoChasis=" +
            nochasis +
            "&Move=UP";
          break;
        case 3:
          type = document.info.Type.value;
          sous_type = document.info.Sous_Type.value;
          etape = document.info.Etape.value;
          etape = etape - 1;
          novisu = document.info.NoVisu.value;
          noclient = document.info.NoClient.value;
          window.location.href =
            "default.php?Type=" +
            type +
            "&Sous_Type=" +
            sous_type +
            "&Etape=" +
            etape +
            "&NoVisu=" +
            novisu +
            "&NoClient=" +
            noclient +
            "&Move=UP";
          break;
        case 4:
          type = document.info.Type.value;
          sous_type = document.info.Sous_Type.value;
          etape = document.info.Etape.value;
          etape = etape - 1;
          nocommande = document.info.NoCommande.value;
          window.location.href =
            "default.php?Type=" +
            type +
            "&Sous_Type=" +
            sous_type +
            "&Etape=" +
            etape +
            "&NoCommande=" +
            nocommande +
            "&Move=UP";
          break;
        case 5:
          window.location.href =
            "default.php?Type=" +
            type +
            "&Sous_Type=" +
            sous_type +
            "&jour=" +
            jour_up +
            "&mois=" +
            mois_up +
            "&annee=" +
            annee_up;
          break;
        case 6:
          window.location.href =
            "default.php?Type=" +
            type +
            "&Sous_Type=" +
            sous_type +
            "&jour=" +
            jour_up +
            "&mois=" +
            mois_up +
            "&annee=" +
            annee_up +
            "&Categorie=" +
            Categorie;
          break;
      }
      if (ff) {
        ev.cancelBubble = true;
        return false;
      }
    }
  }
  if (code == 34) {
    if (ok_move() == 1) {
      if (!ff) {
        window.event.keyCode = 97;
        window.event.returnValue = false;
      }
      switch (memnoform) {
        case 1:
          type = document.info.Type.value;
          sous_type = document.info.Sous_Type.value;
          etape = document.info.Etape.value;
          etape = etape - 1;
          novisu = document.info.NoVisu.value;
          noarticle = document.info.NoArticle.value;
          window.location.href =
            "default.php?Type=" +
            type +
            "&Sous_Type=" +
            sous_type +
            "&Etape=" +
            etape +
            "&NoVisu=" +
            novisu +
            "&NoArticle=" +
            noarticle +
            "&Move=DOWN";
          break;
        case 2:
          type = document.info.Type.value;
          sous_type = document.info.Sous_Type.value;
          etape = document.info.Etape.value;
          etape = etape - 1;
          novisu = document.info.NoVisu.value;
          nochasis = document.info.NoChasis.value;
          window.location.href =
            "default.php?Type=" +
            type +
            "&Sous_Type=" +
            sous_type +
            "&Etape=" +
            etape +
            "&NoVisu=" +
            novisu +
            "&NoChasis=" +
            nochasis +
            "&Move=DOWN";
          break;
        case 3:
          type = document.info.Type.value;
          sous_type = document.info.Sous_Type.value;
          etape = document.info.Etape.value;
          etape = etape - 1;
          novisu = document.info.NoVisu.value;
          noclient = document.info.NoClient.value;
          window.location.href =
            "default.php?Type=" +
            type +
            "&Sous_Type=" +
            sous_type +
            "&Etape=" +
            etape +
            "&NoVisu=" +
            novisu +
            "&NoClient=" +
            noclient +
            "&Move=DOWN";
          break;
        case 4:
          type = document.info.Type.value;
          sous_type = document.info.Sous_Type.value;
          etape = document.info.Etape.value;
          etape = etape - 1;
          nocommande = document.info.NoCommande.value;
          window.location.href =
            "default.php?Type=" +
            type +
            "&Sous_Type=" +
            sous_type +
            "&Etape=" +
            etape +
            "&NoCommande=" +
            nocommande +
            "&Move=DOWN";
          break;
        case 5:
          window.location.href =
            "default.php?Type=" +
            type +
            "&Sous_Type=" +
            sous_type +
            "&jour=" +
            jour_down +
            "&mois=" +
            mois_down +
            "&annee=" +
            annee_down;
          break;
        case 6:
          window.location.href =
            "default.php?Type=" +
            type +
            "&Sous_Type=" +
            sous_type +
            "&jour=" +
            jour_down +
            "&mois=" +
            mois_down +
            "&annee=" +
            annee_down +
            "&Categorie=" +
            Categorie;
          break;
      }
      if (ff) {
        ev.cancelBubble = true;
        return false;
      }
    }
  }
  if (code == 112) {
    //alert("F1");
    if (window.event.shiftKey) {
    } else if (window.event.ctrlKey) {
      if (ok_move() == 1) {
        window.location.href = "default.php?Type=1&Sous_Type=10&NoVisu=0";
      }
    } else {
      Vwidth = 800;
      Vheight = 600;
      Vtop = (screen.height - Vheight) / 2;
      Vleft = (screen.width - Vwidth) / 2;
      window.open(
        "fast.php?Type=1",
        "",
        "top=" +
          Vtop +
          ", left=" +
          Vleft +
          ", width=" +
          Vwidth +
          ", height=" +
          Vheight +
          ", resizable=yes, toolbar=no, scrollbars=yes, status=no"
      );
    }
    if (ff) return false;
  }
  if (code == 113) {
    //alert("F2");
    if (window.event.shiftKey) {
    } else if (window.event.ctrlKey) {
    } else {
      Vwidth = 800;
      Vheight = 600;
      Vtop = (screen.height - Vheight) / 2;
      Vleft = (screen.width - Vwidth) / 2;
      window.open(
        "fast.php?Type=2",
        "",
        "top=" +
          Vtop +
          ", left=" +
          Vleft +
          ", width=" +
          Vwidth +
          ", height=" +
          Vheight +
          ", resizable=yes, toolbar=no, scrollbars=yes, status=no"
      );
    }
  }
  if (code == 114) {
    //alert("F3");
    if (!ff) {
      window.event.keyCode = 97;
      window.event.returnValue = false;
    }
    if (window.event.shiftKey) {
    } else if (window.event.ctrlKey) {
    } else {
      Vwidth = 800;
      Vheight = 600;
      Vtop = (screen.height - Vheight) / 2;
      Vleft = (screen.width - Vwidth) / 2;
      window.open(
        "fast.php?Type=3",
        "",
        "top=" +
          Vtop +
          ", left=" +
          Vleft +
          ", width=" +
          Vwidth +
          ", height=" +
          Vheight +
          ", resizable=yes, toolbar=no, scrollbars=yes, status=no"
      );
    }
    if (ff) return false;
  }
  if (code == 115) {
    //alert("F4");
    if (!ff) {
      window.event.keyCode = 97;
      window.event.returnValue = false;
    }
    if (ok_move() == 1) {
      if (window.event.shiftKey) {
        window.location.href = "default.php?Type=4&Sous_Type=103";
      } else if (window.event.ctrlKey) {
      } else {
        window.location.href = "default.php?Type=4&Sous_Type=1";
      }
    }
    if (ff) return false;
  }
  if (code == 116) {
    //alert("F5");
    alert("F5 devient F10");
    if (!ff) {
      window.event.keyCode = 97;
      window.event.returnValue = false;
    }
    if (ok_move() == 1) {
      if (window.event.shiftKey) {
      } else if (window.event.ctrlKey) {
      } else {
        window.location.href = "default.php?Type=5&Sous_Type=2";
      }
    }
    if (ff) {
      //ev.keyCode = 0;
      ev.cancelBubble = true;
      return false;
    }
  }
  if (code == 117) {
    //alert("F6");
    alert("F6 devient F11");
    if (!ff) {
      window.event.keyCode = 97;
      window.event.returnValue = false;
    }
    if (ok_move() == 1) {
      if (window.event.shiftKey) {
        window.location.href = "default.php?Type=5&Sous_Type=1&Categorie=2";
      } else if (window.event.ctrlKey) {
        window.location.href = "default.php?Type=5&Sous_Type=1&Categorie=1";
      } else {
        window.location.href = "default.php?Type=5&Sous_Type=1";
      }
    }
    if (ff) {
      //ev.which = 0;
      //ev.returnValue = false;
      //ev.cancelBubble = true;
      return false;
    }
  }
  if (code == 118) {
    //alert("F7");
    if (ok_move() == 1) {
      if (window.event.shiftKey) {
        window.location.href =
          "default.php?Type=4&Sous_Type=1&NoVisu=0&&Etape=2&New=1&NewType=FD";
      } else if (window.event.ctrlKey) {
        window.location.href = "default.php?Type=4&Sous_Type=104";
      } else {
        window.location.href =
          "default.php?Type=4&Sous_Type=1&Etape=3&Modif=1&New=1&NewType=FD&NoClient=&Nom=&Prenom=&NoChasis=&Marque=&Model=&Km=&NoPlaque=&NoClient2=&Nom2=&Prenom2=";
      }
    }
    if (ff) {
      return false;
    }
  }
  if (code == 119) {
    //alert("F8");
    if (ok_move() == 1) {
      if (window.event.shiftKey) {
        window.location.href =
          "default.php?Type=4&Sous_Type=1&NoVisu=0&Etape=2&New=1&NewType=AM";
      } else if (window.event.ctrlKey) {
      } else {
        window.location.href =
          "default.php?Type=4&Sous_Type=1&Etape=3&Modif=1&New=1&NewType=AM&NoClient=&Nom=&Prenom=&NoChasis=&Marque=&Model=&Km=&NoPlaque=&NoClient2=&Nom2=&Prenom2=";
      }
    }
  }
  if (code == 120) {
    //alert("F9");
    if (ok_move() == 1) {
      if (window.event.shiftKey) {
      } else if (window.event.ctrlKey) {
      } else {
        //window.location.href="default.php?Type=5&Sous_Type=2";
      }
    }
  }
  if (code == 121) {
    //alert("F10");
    if (!ff) {
      window.event.keyCode = 97;
      window.event.returnValue = false;
    }
    if (ok_move() == 1) {
      if (window.event.shiftKey) {
      } else if (window.event.ctrlKey) {
      } else {
        window.location.href = "default.php?Type=5&Sous_Type=2";
      }
    }
  }
  if (code == 122) {
    //alert("F11");
    if (!ff) {
      window.event.keyCode = 97;
      window.event.returnValue = false;
    }
    if (ok_move() == 1) {
      if (window.event.shiftKey) {
        window.location.href = "default.php?Type=5&Sous_Type=1&Categorie=4";
      } else if (window.event.ctrlKey) {
        window.location.href = "default.php?Type=5&Sous_Type=1";
      } else {
        window.location.href = "default.php?Type=5&Sous_Type=1&Categorie=1";
      }
    }
    if (ff) {
      return false;
    }
  }
  if (code == 123) {
    //alert("F12");
    if (ok_move() == 1) {
      if (window.event.shiftKey) {
        window.location.href = "default.php?Type=4&Sous_Type=102&Etape=0";
      } else if (window.event.ctrlKey) {
      } else {
        window.location.href = "default.php?Type=4&Sous_Type=101&Etape=0";
      }
    }
  }
  if (window.event.altKey && !window.event.ctrlKey) {
    if (code != 18 && code != 16) {
      if (window.event.shiftKey) {
        alert("Alt maj " + code);
        if (ok_move() == 1) {
          switch (code) {
            case 65: // A
              break;
            case 66: // B
              break;
            case 67: // C
              break;
            case 68: // D
              break;
            case 69: // E
              break;
            case 70: // F
              break;
            case 71: // G
              break;
            case 72: // H
              break;
            case 73: // I
              break;
            case 74: // J
              break;
            case 75: // K
              break;
            case 76: // L
              break;
            case 77: // M
              break;
            case 78: // N
              break;
            case 79: // O
              break;
            case 80: // P
              break;
            case 81: // Q
              break;
            case 82: // R
              break;
            case 83: // S
              break;
            case 84: // T
              break;
            case 85: // U
              break;
            case 86: // V
              break;
            case 87: // W
              break;
            case 88: // X
              break;
            case 89: // Y
              break;
            case 90: // Z
              break;
          }
        }
      } else {
        if (code == 71) {
          return true;
        }
        //alert("Alt "+code);
        if (ok_move() == 1) {
          switch (code) {
            case 48: // 0
              break;
            case 49: // 1 Articles
              Vwidth = 800;
              Vheight = 600;
              Vtop = (screen.height - Vheight) / 2;
              Vleft = (screen.width - Vwidth) / 2;
              window.open(
                "fast.php?Type=1",
                "",
                "top=" +
                  Vtop +
                  ", left=" +
                  Vleft +
                  ", width=" +
                  Vwidth +
                  ", height=" +
                  Vheight +
                  ", resizable=yes, toolbar=no, scrollbars=yes, status=no"
              );
              break;
            case 50: // 2 V�hicules
              //Vwidth=800;
              //Vheight=600;
              //Vtop=(screen.height-Vheight)/2;
              //Vleft=(screen.width-Vwidth)/2;
              //window.open('fast.php?Type=2', '', 'top='+Vtop+', left='+Vleft+', width='+Vwidth+', height='+Vheight+', resizable=yes, toolbar=no, scrollbars=yes, status=no');
              return true; // touche @
              break;
            case 51: // 3 Clients
              Vwidth = 800;
              Vheight = 600;
              Vtop = (screen.height - Vheight) / 2;
              Vleft = (screen.width - Vwidth) / 2;
              window.open(
                "fast.php?Type=3",
                "",
                "top=" +
                  Vtop +
                  ", left=" +
                  Vleft +
                  ", width=" +
                  Vwidth +
                  ", height=" +
                  Vheight +
                  ", resizable=yes, toolbar=no, scrollbars=yes, status=no"
              );
              break;
            case 52: // 4
              break;
            case 53: // 5
              break;
            case 54: // 6
              break;
            case 55: // 7
              break;
            case 56: // 8 Achat sans fournisseur
              window.location.href =
                "default.php?Type=4&Sous_Type=1&Etape=3&Modif=1&New=1&NewType=AM&NoClient=&Nom=&Prenom=&NoChasis=&Marque=&Model=&Km=&NoPlaque=&NoClient2=&Nom2=&Prenom2=";
              break;
            case 57: // 9 Achat avec fournisseur
              window.location.href =
                "default.php?Type=4&Sous_Type=1&NoVisu=0&Etape=2&New=1&NewType=AM";
              break;
            case 65: // a Calendrier atelier
              window.location.href = "default.php?Type=5&Sous_Type=2&NoVisu=0";
              break;
            case 66: // b
              break;
            case 67: // c Commandes ouvertes
              window.location.href = "default.php?Type=4&Sous_Type=103";
              break;
            case 68: // d
              break;
            case 69: // e Encaissement rapide
              window.location.href =
                "default.php?Type=4&Sous_Type=101&NoVisu=0";
              break;
            case 70: // f Nouvelle facture d�taill�e
              window.location.href =
                "default.php?Type=4&Sous_Type=1&NoVisu=0&&Etape=2&New=1&NewType=FD";
              break;
            case 71: // g
              return true; // Ce cas est particulier pour MAC la touche ALT + g est le charctere @ est donc de doit pas �tre ignor�
              break;
            case 72: // h
              break;
            case 73: // i
              break;
            case 74: // j
              break;
            case 75: // k
              break;
            case 76: // l Calendrier - Location
              window.location.href = "default.php?Type=5&Sous_Type=1";
              break;
            case 77: // m Calendrier - Motos
              window.location.href =
                "default.php?Type=5&Sous_Type=1&Categorie=1";
              break;
            case 78: // n
              break;
            case 79: // o Opportunit�s
              window.location.href = "default.php?Type=3&Sous_Type=11&NoVisu=0";
              break;
            case 80: // p
              break;
            case 81: // q
              break;
            case 82: // r : recherche commande/facture
              window.location.href = "default.php?Type=4&Sous_Type=1";
              break;
            case 83: // s Calendrier - Scooters
              window.location.href =
                "default.php?Type=5&Sous_Type=1&Categorie=4";
              break;
            case 84: // t Nouvelle facture sans client
              window.location.href =
                "default.php?Type=4&Sous_Type=1&Etape=3&Modif=1&New=1&NewType=FD&NoClient=&Nom=&Prenom=&NoChasis=&Marque=&Model=&Km=&NoPlaque=&NoClient2=&Nom2=&Prenom2=";
              break;
            case 85: // u
              break;
            case 86: // v
              break;
            case 87: // w
              break;
            case 88: // x
              break;
            case 89: // y
              break;
            case 90: // z
              break;
          }
        }
      }
      return false;
    }
  }
}
// fin desactivation du F5 refraichisement
