var ModuleAdmin = "WA";   //Module Administration
var ModuleInvent = "WI";  //Module Inventaire
var ModuleAssetManag = "WP";    //Module IsiParc
var ModuleHelpDesk = "WH";  //Module HelpDesk
var ModuleCommon = "WC";  //Module commun pour IsiParc et HelpDesk

var bLoadInProgress;

var SEP_MESS = "|";
var bDesign = false;
var IWS_SESSION_ID_URL_PARAM = "IwsId=";

var WAITTIMEOUT = 4000;


var iMaxTimeSpentOnLookingForComponentsToBeLoaded = 10000;
var oParentDocumentOfComponentToInitialize = Array();
var sComponentToWaitFor = Array();
var oValueToSetInComponent = Array();
var asynchroneousTimeout = Array();
var bAddValueToExistingOne = Array();

var bFocusOnTextArea = false;
var bConnexSearch = false;

var gsLastKeyPressed = -1;

var gbAutomaticViewIsLaunch = false;

var nPageDuration = 0;

var closeStartMenu;
var mouseX;
var mouseY;
function ShortCut(aProp) {
this.keyCode = aProp[0];
this.constantKey = aProp[1];
this.action = aProp[2];
this.type = aProp[3];
}

function AppShortCuts() {

function mAdd(oShortCut) {
if (!this.tableau) {
this.tableau = new Array();
}
this.tableau.push(oShortCut);
}

function mGetShortCut(iKeyCode, iConstantKey) {
var i = 0;
var bTrouve = false;

if (this.tableau) {
while (!bTrouve && i < this.tableau.length) {
if ((this.tableau[i].keyCode == iKeyCode) &&
(this.tableau[i].constantKey == iConstantKey)) {
bTrouve = true;
rtnObject = this.tableau[i];
}
++i;
}
}
if (bTrouve) {
return rtnObject;
}
}

function mGetActionsArray(iKeyCode, iConstantKey) {
var i = 0;
var tab = new Array();

if (this.tableau) {
while (i < this.tableau.length) {
if ((this.tableau[i].keyCode == iKeyCode) &&
(this.tableau[i].constantKey == iConstantKey)) {
tab.push(this.tableau[i].action);
}
++i;
}
}
return tab;
}

function mGetElement(iNumber) {
if (this.tableau) {
if (iNumber < this.tableau.length) {
return this.tableau[iNumber];
}
}
return false;
}

function mCount() {
if (this.tableau) { return this.tableau.length; }
return 0;
}

this.add = mAdd;
this.getShortCut = mGetShortCut;
this.getActionsArray = mGetActionsArray;
this.count = mCount;
this.getElement = mGetElement;

this.tableau = new Array();

return this;
}


var colShortCuts = new AppShortCuts();

function iSC(aProp) {
colShortCuts.add(new ShortCut(aProp));
}



document.onkeydown = iws_KeyPressedHandler;

document.onhelp = redirectOnHelp;

document.onclick = iws_MouseClickHandler;



function iws_MouseClickHandler() {
gsLastKeyPressed = -1;
}

function iws_KeyPressedHandler(evt) {

if (!evt) evt = window.event;

var keyCode = evt.keyCode;
var constant_keys = 0;

gsLastKeyPressed = keyCode;


if (bDesign && bFocusOnTextArea == false) {
var bStopNext = iws_moveByKeyboard(evt);
if (bStopNext) return false;
}

if (evt.altKey && !evt.altLeft) { return true; }

if (evt.ctrlKey && !evt.shiftKey && !evt.altLeft &&
(keyCode == 67  // --> On ne catch pas le CTRL + C
|| keyCode == 86  // --> Touche V
|| keyCode == 88  // --> Touche X
|| keyCode == 22  // --> Keycode special CTRL + V (curiosite Javascript)
|| keyCode == 24  // --> Keycode special CTRL + X
|| keyCode == 37  // --> Touche Gauche
|| keyCode == 38  // --> Touche Haut
|| keyCode == 39  // --> Touche Droite
|| keyCode == 40)) // --> Touche Bas
{ return true; }

if (evt.ctrlKey && evt.shiftKey &&
(keyCode == 37  // --> Touche Gauche
|| keyCode == 38  // --> Touche Haut
|| keyCode == 39  // --> Touche Droite
|| keyCode == 40)) // --> Touche Bas
{ return true; }



if ((keyCode == 13
&& bFocusOnTextArea == false
&& document.title != ISI_PRODUCT_NAME
&& document.title != "GLOB010")
|| (keyCode == 27 && window.goIsiSuggestCtrl)) {
if (keyCode == 27) { iws_HideIsiSuggestDiv(); }
try { evt.keyCode = 0; } catch (e) { }
return false;
}
if (keyCode == 13
&& document.title == ISI_PRODUCT_NAME
&& document.getElementById('IsiHLinkEnter_' + LINK_BUTTON) != null) {
__doPostBack('IsiHLinkEnter$LnkBtn', '');
return true;
}

if ((keyCode != 16
&& keyCode != 17
&& keyCode != 18
&& (evt.ctrlKey || (evt.shiftKey && evt.ctrlKey) || (evt.altLeft && (evt.ctrlKey || evt.shiftKey))))
|| (keyCode > 112 && keyCode < 124)
|| (!evt.ctrlKey && !evt.shiftKey && evt.altLeft && (keyCode == 37 || keyCode == 39))) {
if (evt.ctrlKey) constant_keys += 1;
if (evt.shiftKey) constant_keys += 2;
if (evt.altLeft) constant_keys += 4;

try { evt.keyCode = 0; } catch (e) { }

iws_SeekAndLaunchShortCutAction(keyCode, constant_keys);

return false;

}

return true;
}

function iws_SeekAndLaunchShortCutAction(keyCode, constant_keys) {
if (GetShortCutStatus()) {
if (colShortCuts.count() > 0) {

var tabActions = new Array();

activeShortCut = colShortCuts.getShortCut(keyCode, constant_keys);

if (activeShortCut) {
if (activeShortCut.type == "MN" || activeShortCut.type == "MD" || activeShortCut.type == "MA") {
tabActions = colShortCuts.getActionsArray(keyCode, constant_keys);
}
else { tabActions.push(activeShortCut.action); }

iws_LaunchShortCutAction(activeShortCut.type, tabActions);
}
}
}
}



function redirectOnHelp() {
iws_LaunchShortCutAction("MM", ["HELP"]);
return false;
}

function iws_LaunchShortCutAction(sType, actions) {
var bShortCutActive = true;
var sel = document.activeElement;
if (sel) {
sel.removeAttribute("noOnBlur");
sel.fireEvent("onblur");
}

if (sType == "MM") {

try { var menuID = getMenuIDWithTag(igmenu_getItemById("mnuModule"), actions[0]); }
catch (e) { return false; }

if (menuID != false) {
switch (actions[0]) {

case "WEBSITE":
try {
var oItem = igmenu_getItemById(menuID);
window.open(appendSessionId(oItem.getTargetUrl()));
} catch (e) { return false; }
break;

case "CONTACTUS":
try {
var oItem = igmenu_getItemById(menuID);
window.open(appendSessionId(oItem.getTargetUrl()));
} catch (e) { return false; }
break;

case "HOME":
mnuModule_ItemClick("mnuModule", menuID);
break;

case "QUIT":
mnuModule_ItemClick("mnuModule", menuID);
break;

case "HELP":
var oItem = igmenu_getItemById(menuID);
window.navigate(oItem.getTargetUrl());
break;
case "APROPOS":
mnuModule_ItemClick("mnuModule", menuID);
IsiAbout();
break;
case "PANIER":
mnuModule_ItemClick("mnuModule", menuID);
break;
default:
break;
}
}


if (actions[0] == ModuleAdmin || actions[0] == ModuleAssetManag || actions[0] == ModuleHelpDesk || actions[0] == ModuleInvent) {
if (document.getElementById("ihdCurrentItemmnuModule").value != actions[0]) {
SetShortCutStatus(false);
OnclickModule("MODULE", actions[0])
bShortCutActive = GetShortCutStatus();
}
}

}

if (sType == "MN" || sType == "MD" || sType == "MA") {

var visibleMenu = getVisibleMenu();

if (visibleMenu) {
var HTML_ID = getMenuItemIDFromObjectKey(visibleMenu, actions, visibleMenu.id + "_", "LISTBAR");

try {
try {
document.getElementById(visibleMenu.id).focus();
document.getElementById(HTML_ID).focus();
}
catch (e) { }
document.getElementById(HTML_ID).fireEvent("onmousedown");
}
catch (e) { return false; }
bShortCutActive = GetNotSubmitPageOnShortCut();
}
}


if (sType == "MO") {

try {
var oDIV = document.getElementById(DIV_FORMULAIRE);
var oCtrl = document.getElementById(actions[0]);

if (oDIV) {
oDIV.focus();
}
if (oCtrl)
oCtrl.fireEvent("onclick");
}
catch (e) { return false; }

bShortCutActive = true;
}


if ((sType == "S") || (sType.substr(0, sType.indexOf(";", 0)) == "S")) {
var itemTAG = actions[0];
var sURL = sType.substr(sType.indexOf(";", 0) + 1, sType.length);

var isExistingItem = getTargetURLFromTag(igmenu_getItemById("mnuPage"), itemTAG);

if (isExistingItem == true) {
mnuPage_ItemClick("mnuPage", itemTAG);
document.Form1.submit();
bShortCutActive = false;
}
}

if (sType == "BA") {
var oAjax = new IsiAjax("../../Classes/IsiAjax/IsiAjax.aspx");
oAjax.init();
var sResponse;
var key = activeShortCut.keyCode;
var conskey = activeShortCut.constantKey;
if ((actions[0]) && (key) && (conskey)) {
var sDataToSend = "Traitement=IsiSyncRacBandeau";
sDataToSend += "&tRac=" + sType;
sDataToSend += "&nRac=" + actions[0];
sDataToSend += "&iKey=" + key;
sDataToSend += "&iConsKey=" + conskey;
sResponse = oAjax.SyncExecute(sDataToSend, "POST", "TEXT", "TEXT");
if (sResponse) {
var txt = document.getElementById(sResponse + "_" + TEXTBOX);
if (txt) {
var divrac = txt.parentElement.parentElement.parentElement.parentElement.parentElement
if (divrac) {
if (divrac.style.display = "none") {
iws_clickRacBanner("ButtonRac", divrac.id, "DivRacBandeauContener");
}
txt.focus();
}
} else {
var button = document.getElementById(sResponse + "_" + LINK_BUTTON);
if (button) {
button.fireEvent("onclick");
}
}
}
}
}

if (sType == "CS") {
var itemMenu;
var idMnuPage;
var itemTAG = actions[0];
var key = activeShortCut.keyCode;
var conskey = activeShortCut.constantKey;
var oAjax = new IsiAjax("../../Classes/IsiAjax/IsiAjax.aspx");
oAjax.init();
if ((itemTAG) && (key) && (conskey)) {
var sDataToSend = "Traitement=IsiSyncRacBandeau";
sDataToSend += "&tRac=" + sType;
sDataToSend += "&nRac=" + itemTAG;
sDataToSend += "&iKey=" + key;
sDataToSend += "&iConsKey=" + conskey;
itemMenu = oAjax.SyncExecute(sDataToSend, "POST", "TEXT", "TEXT");
if (itemMenu) {
var isExistingItem = getTargetURLFromTag(igmenu_getItemById("mnuPage"), itemMenu);
if (isExistingItem == true) {
idMnuPage = getMenuIDWithTag(igmenu_getItemById("mnuPage"), itemMenu)
mnuPage_ItemClick("mnuPage", idMnuPage);
document.Form1.submit();
bShortCutActive = false;
}
}
}
}

SetShortCutStatus(bShortCutActive);

return true;
}

function getMenuIDWithTag(mainMenu, menuTag) {
if (!mainMenu || !menuTag)
{ return false; }

var oItem = getItemObjetFromTag(mainMenu, menuTag);

if (!oItem) {
return false;
} else {
return oItem.Id;
}
}

function getTargetURLFromTag(mainMenu, menuTag) {
if (!mainMenu || !menuTag)
{ return false; }

var oItem = getItemObjetFromTag(mainMenu, menuTag);

if (!oItem) {
return false;
} else {
return true; //oItem.getTargetUrl();
}
}

function getItemObjetFromTag(mainMenu, menuTag) {
if (!mainMenu || !menuTag)
{ return false; }

var oRtnObject;
var oBackRtnObject;
var tabSsMenu = mainMenu.getItems();
var iCptMenu = 0;

for (iCptMenu = 0; iCptMenu < mainMenu.getItems().length; iCptMenu++) {
var oMenu = tabSsMenu[iCptMenu];

oBackRtnObject = getItemObjetFromTag(oMenu, menuTag);

if (oBackRtnObject) { oRtnObject = oBackRtnObject; }

if (oMenu.getTag() == menuTag) {
oRtnObject = oMenu;
}
}
return oRtnObject;
}


function getMenuItemIDFromObjectKey(mainMenu, itemKeys, ItemClass, ComposantType) {
if (!mainMenu || !itemKeys || !ComposantType || !ItemClass)
{ return false; }

for (iCpt = 0; iCpt < mainMenu.all.length; iCpt++) {

var HTML_Item = mainMenu.all(iCpt);

if (HTML_Item.id.substring(0, 16) == ItemClass + HTML_Item.id.substring(10, 11) + "_Item") {

if (ComposantType == "LISTBAR") {
var oItem = iglbar_getItemById(HTML_Item.id);
}
if (ComposantType == "MENU") {
var oItem = igmenu_getItemById(HTML_Item.id);
}

for (iCpt2 = 0; iCpt2 < itemKeys.length; iCpt2++) {
if (oItem.Key == itemKeys[iCpt2]) {
return HTML_Item.id;
}
}
}
}

return false;
}


function getVisibleMenu() {
var tmpMenu = false;

if (!window.MnuMaster) { } else {
if (MnuMaster.style.visibility == "visible") {
tmpMenu = MnuMaster;
}
}

if (!window.MnuDetail) { } else {
if (MnuDetail.style.visibility == "visible") {
tmpMenu = MnuDetail;
}
}

return tmpMenu;
}



function iws_ChangeWholeCursorStyles(sStyle) {

var oDivForm = document.getElementById(DIV_FORMULAIRE);
var oDivDetail = document.getElementById(DIV_DETAIL);
var oDivEnTete = document.getElementById(DIV_ENTETE);

if (oDivForm) {
oDivForm.style.cursor = sStyle;
}

if (oDivDetail) {
oDivDetail.style.cursor = sStyle;
}

if (oDivEnTete) {
oDivEnTete.style.cursor = sStyle;
}

document.body.style.cursor = sStyle;
}



var ARRAY_SIZE = 1000;
var aDebugTime = new Array(ARRAY_SIZE);
var aDebugFunc = new Array(ARRAY_SIZE);
var aDebugMess = new Array(ARRAY_SIZE);
var aIntervalTime = new Array(ARRAY_SIZE);
var aIntervalNb = new Array(ARRAY_SIZE);
var iDebug = 0;
var iNbIntervals = 0;
var dPrecDate;

function isiDebug_ToTraceRAZ() {

aDebugTime = null; aDebugTime = new Array(ARRAY_SIZE);
aDebugFunc = null; aDebugFunc = new Array(ARRAY_SIZE);
aDebugMess = null; aDebugMess = new Array(ARRAY_SIZE);
aIntervalTime = null; aIntervalTime = new Array(ARRAY_SIZE);
aIntervalNb = null; aIntervalNb = new Array(ARRAY_SIZE);

iDebug = 0;
}

function isiDebug_ToTrace(sFunc, sTxt) {
aDebugTime[iDebug] = new Date();
aDebugFunc[iDebug] = sFunc;
aDebugMess[iDebug++] = sTxt;
}

function isiDebug_ToTraceError(sFunc, sTxt) {
isiDebug_ToTrace(sFunc, "<span style=\"color:red;\">" + sTxt + "</span>");
}

function isiDebug_showTrace() {
ow = window.open("")
var maintenant = new Date();
var _title = "Trace generee le : " + maintenant.getFullYear() + "/"
+ (maintenant.getMonth() + 1) + "/"
+ maintenant.getDate() + " "
+ maintenant.getHours() + ":"
+ maintenant.getMinutes() + ":"
+ maintenant.getSeconds() + "."
+ maintenant.getMilliseconds();

ow.document.write("<h1>" + _title + "</h1>\n");
ow.document.write("<table border=1>");
ow.document.write("<tr><td>Date</td><td>Func</td><td>Txt</td></tr>");
for (var j = 0; j < aDebugFunc.length; ++j) {
if (aDebugTime[j]) {
sTime = aDebugTime[j].getFullYear() + "/"
+ (aDebugTime[j].getMonth() + 1) + "/"
+ aDebugTime[j].getDate() + " "
+ aDebugTime[j].getHours() + ":"
+ aDebugTime[j].getMinutes() + ":"
+ aDebugTime[j].getSeconds() + "."
+ aDebugTime[j].getMilliseconds();
ow.document.write("<tr><td>" + sTime + "</td><td>" + aDebugFunc[j] + "</td><td>" + aDebugMess[j] + "</td></tr>\n");
}
}
ow.document.write("</table>");

}

function asynchroneousInitialisation(pDocument, sComponentName, oValue, bMustBeConcatened) {

if (pDocument && sComponentName) {

oParentDocumentOfComponentToInitialize[oParentDocumentOfComponentToInitialize.length] = pDocument;
sComponentToWaitFor[sComponentToWaitFor.length] = sComponentName;
oValueToSetInComponent[oValueToSetInComponent.length] = oValue;
bAddValueToExistingOne[bAddValueToExistingOne.length] = bMustBeConcatened;
asynchroneousTimeout[asynchroneousTimeout.length] = 0;

asyncInnerManagement();
}
}

function asyncInnerManagement() {

var oComponent;
for (index = 0; index < oParentDocumentOfComponentToInitialize.length; index++) {
if (oParentDocumentOfComponentToInitialize[index] &&
sComponentToWaitFor[index] &&
oValueToSetInComponent[index]) {

if (asynchroneousTimeout[index] < iMaxTimeSpentOnLookingForComponentsToBeLoaded) {

oComponent = oParentDocumentOfComponentToInitialize[index].getElementById(sComponentToWaitFor[index]);
if (oComponent) {
if (bAddValueToExistingOne[index])
oComponent.value += oValueToSetInComponent[index];
else
oComponent.value = oValueToSetInComponent[index];
clearArrays(index);
} else {
asynchroneousTimeout[index] += 200;
setTimeout("asyncInnerManagement();", 200);
}
} else {
clearArrays(index);
alert("Timout (" + asynchroneousTimeout[index] + "/" + iMaxTimeSpentOnLookingForComponentsToBeLoaded + "ms) expired while waiting for initializing '" + sComponentToWaitFor[index] + "'.\nApplication may result in unexpected behavior.");
}
}
}
}

function clearArrays(index) {

if (index > -1 &&
index < oParentDocumentOfComponentToInitialize.length &&
index < asynchroneousTimeout.length &&
index < sComponentToWaitFor.length &&
index < oValueToSetInComponent.length &&
index < bAddValueToExistingOne.length) {

oParentDocumentOfComponentToInitialize[index] = null;
asynchroneousTimeout[index] = 0;
sComponentToWaitFor[index] = null;
oValueToSetInComponent[index] = null;
bAddValueToExistingOne[index] = null;
}
}

function InitOnLoad(bLoadWithDetail, bInhibeDetails) {
var sGridName;
var sValBandeauPanier;
var sID = "ImageCaddy1";

document.stopMessaging = false;

gestDetailsAndDiv(bLoadWithDetail, bInhibeDetails);

sGridName = PutSelectedCell("");
if (IsCtrlDetail(sGridName)) {
SetValueFrame('HiddenFields', 'ihdSetfocusDetail', DIV_DETAIL);
}

if (sGridName != '') {
ActionOnCtrlFocus(sGridName);
}
var navVersion = navigator.appVersion;
if (navVersion.indexOf('MSIE 6.0', 0) != -1) {
document.getElementById("curvLeft").style.backgroundImage = "none";
document.getElementById("curvRight").style.backgroundImage = "url(../../Images/Banner/CurvRight.gif)";
document.getElementById("StartButton").style.backgroundImage = "url(../../Images/Banner/start.gif)";
}
}

function iws_OnUnLoad() {
iws_OnUnLoad_Overridable();

iws_ajax_dispose();
}
function iws_OnUnLoad_Overridable() {
}


function IsCtrlDetail(sIDCtrl) {
var bCtrlDetail = false;
if (sIDCtrl == DIV_DETAIL || sIDCtrl == GRD_HIER + SEP_ENCAPS_GRID + NAME_ISIGRID ||
sIDCtrl == GRD_FLAT + SEP_ENCAPS_GRID + NAME_ISIGRID) {
bCtrlDetail = true;
}
return bCtrlDetail;
}

function EndOnLoad() {
SetValueFrame('HiddenFields', 'ihdSetfocusDetail', '');

iws_ChangeStatusPage(ISI_PRODUCT_NAME);
bNoFocus = false;

SetShortCutStatus(true);
}

function gestDetailsAndDiv(bLoadWithDetail, bInhibeDetails) {
if (bLoadWithDetail) {
if (bInhibeDetails) {
InhibeDetails();
}
else {
LoadPosDetail(true);
}
}
else {
ResizeDiv(false, true, true);
ModifWaitStatus(false, false, '');
}

ResizeGridsToMaxSize();
}

function OnChangeLanguage(oCb) {
parent.frames['HiddenFields'].document.getElementById("ihdNewLanguage").value = oCb.value;
parent.frames['HiddenFields'].SubmitFormulaire();
ModifWaitStatus(true, true, LOADING);
}

function LoadHomePage() {
if (parent.document) {
parent.document.URL = appendSessionId("../../HOMEPAGE.aspx?Action=QUIT&bIsRedirected=YES");
}
}

function OnClickNavigation(oCtrl, oNavID, iCurrentEnreg, iMaxEnreg, sIdTextCurrentEnreg) {
var sCtrlName;
var IdCtrl;
var bSubmit = false;
var pCtrlCurrentValue;
var pCtrlClicked;

if (document.title == "ADM020") {
eraseWorkflow()
}

pCtrlCurrentValue = document.getElementById(sIdTextCurrentEnreg);
if (pCtrlCurrentValue) {
if (iMaxEnreg > 0 && oCtrl) {
IdCtrl = oCtrl.id.replace(oNavID + "_", "");
switch (IdCtrl) {
case IMAGE_BUTTON_FIRST:
case IMAGE_BUTTON_PREV:
if (pCtrlCurrentValue.value > 1 && pCtrlCurrentValue.value <= iMaxEnreg) {
bSubmit = true;
}
else { // sinon on remet l'ancienne valeur
pCtrlCurrentValue.value = iCurrentEnreg;
}
break;
case IMAGE_BUTTON_NEXT:
case IMAGE_BUTTON_LAST:
if (pCtrlCurrentValue.value >= 1 && pCtrlCurrentValue.value < iMaxEnreg) {
bSubmit = true;
}
else { // sinon on remet l'ancienne valeur
pCtrlCurrentValue.value = iCurrentEnreg;
}
break;
case LINK_BUTTON:
if (pCtrlCurrentValue.value >= 1 && pCtrlCurrentValue.value <= iMaxEnreg &&
iCurrentEnreg != pCtrlCurrentValue.value) {
bSubmit = true;
}
else { // sinon on remet l'ancienne valeur
pCtrlCurrentValue.value = iCurrentEnreg;
}
break;
}
}
else { // Si on effectu aucun traitement on remet a 0
pCtrlCurrentValue.value = 0;
}
}

if (bSubmit) {
sCtrlName = oNavID + "_" + NAV_ITEM_CLICK_ID;
pCtrlClicked = document.getElementById(sCtrlName)
if (pCtrlClicked) {
pCtrlClicked.value = IdCtrl;
}

SaveCtrlNameClick(oNavID);
SubmitFormulaire();
}
}

function GetWaitStatus() {
var mbLoadInProgress = false;
if (parent.frames['HiddenFields']) {
if (parent.frames['HiddenFields'].bLoadInProgress) {
mbLoadInProgress = parent.frames['HiddenFields'].bLoadInProgress;
}
}
return mbLoadInProgress;
}

function SetWaitStatus(loadInProgress) {
if (parent.frames['HiddenFields']) {
parent.frames['HiddenFields'].bLoadInProgress = loadInProgress;
}
}

function GetCurrentLib() {
var sCurrentLib = "";
if (parent.frames['HiddenFields']) {
if (parent.frames['HiddenFields'].sCurrentLib) {
sCurrentLib = parent.frames['HiddenFields'].sCurrentLib;
}
}
return sCurrentLib;
}

function SetCurrentLib(sCurrentLib) {
if (parent.frames['HiddenFields']) {
parent.frames['HiddenFields'].sCurrentLib = sCurrentLib;
}
}

function ModifWaitStatus(bVisible, bWait, sCodeLibelleStatus) {
var sLibStatus = "";
var sLibWait = "";
var oAttente = document.getElementById(DIV_ATTENTE);
var pMsgAttente = document.getElementById("DivMsgAttente");
window.status = window.defaultStatus;

if (oAttente) {
if (sCodeLibelleStatus != "") {
sLibStatus = GetMessagesForJavascript(true).GetMessage(sCodeLibelleStatus).L_MESSAGE;
window.status = sLibStatus;
}

if (bVisible == true) {
iws_ChangeWholeCursorStyles("wait");

if (!bLoadInProgress) {
bLoadInProgress = true;
SetCurrentLib(sCodeLibelleStatus);

if (bWait == true) {
oAttente.className = "BlockDivAttente";
pMsgAttente.className = "HideDivAttente";
setTimeout("SetVisibleWaitStatus(true);", WAITTIMEOUT);
} else {
SetVisibleWaitStatus(true);
SetWaitStatus(true);
}

if (pMsgAttente) {
sLibWait = GetMessagesForJavascript(true).GetMessage(WAITING).L_MESSAGE;
if (sLibStatus != "") {
pMsgAttente.innerHTML = sLibWait + '<BR>' + sLibStatus;
} else if (sLibWait.substr(sLibWait - 3, 3) != "...") {
pMsgAttente.innerHTML = sLibWait + "...";
}
}
}
}
else {
iws_ChangeWholeCursorStyles("default");

if (bLoadInProgress) {
bLoadInProgress = false;
SetWaitStatus(false);
SetCurrentLib('');
SetVisibleWaitStatus(false);
}
}
}

}

function SetVisibleWaitStatus(bVisible) {
var oAttente = document.getElementById(DIV_ATTENTE);
var pMsgAttente = document.getElementById("DivMsgAttente");
if (oAttente)
{
if (bVisible)
{
if (bLoadInProgress)
{
SetWaitStatus(true);
if (oAttente)
{
oAttente.className = "DisplayDivAttente";
pMsgAttente.className = "MessageAttente";
}
}
}
else
{
if (oAttente)
{
oAttente.className = "HideDivAttente";
}
}
}
oAttente = null;
}

function ShowModal(sUrl, sArgs, sOptions) {
setTimeout("WaitForComponentToBeLoadedToExecShowModal('" + appendSessionId(sUrl) + "', '" + sArgs + "', '" + sOptions + "');", 200);
}

var iWaitedTimeForComponentToLoad = 0;

function WaitForComponentToBeLoadedToExecShowModal(sUrl, sArgs, sOptions) {

var bComponentLoaded = bIsComponentLoaded();
if (!bComponentLoaded && (iWaitedTimeForComponentToLoad <= iMaxTimeSpentOnLookingForComponentsToBeLoaded)) {
setTimeout("WaitForComponentToBeLoadedToExecShowModal('" + sUrl + "', '" + sArgs + "', '" + sOptions + "');", 200);
iWaitedTimeForComponentToLoad += 200;
} else
ExecShowModal(sUrl, sArgs, sOptions);
}

function bIsComponentLoaded() {

var bIsAwaitedComponentAvailable = false;
var oDocument;
var oComponent;

if (parent.frames['HiddenFields']) {
oDocument = parent.frames['HiddenFields'].document;
} else {
oDocument = document;
}

var oComponent = oDocument.getElementById('shdUrlModal');
if (oComponent) {
bIsAwaitedComponentAvailable = true;
}

return bIsAwaitedComponentAvailable;
}

function ExecShowModal(sUrl, sArgs, sOptions) {
var myArgs;
var sAllUrl;
var sUrlToShow;
var iPosSeconde;
var bOk = (iWaitedTimeForComponentToLoad <= iMaxTimeSpentOnLookingForComponentsToBeLoaded);

if (bOk) {
if (parent.frames['HiddenFields']) {

sAllUrl = parent.frames['HiddenFields'].document.getElementById('shdUrlModal').value;
}
else {
sAllUrl = document.getElementById('shdUrlModal').value;
}
} else {
alert("Unable to find specified document. Timeout occured while waiting the document to load.\nImpossible de trouver le document specifie. Le temps d'attente a ete depasse pendant que la page se chargeait.");
}

if (sAllUrl) {
iPosSeconde = sAllUrl.indexOf(SEP_MESS);
if (iPosSeconde != -1) {
if (parent.frames['HiddenFields']) {
parent.frames['HiddenFields'].document.getElementById('shdUrlModal').value = sAllUrl.substr(iPosSeconde + 1, sAllUrl.length - iPosSeconde);
} else {
document.getElementById('shdUrlModal').value = sAllUrl.substr(iPosSeconde + 1, sAllUrl.length - iPosSeconde);
}

sUrlToShow = sAllUrl.substr(0, iPosSeconde);
} else {
sUrlToShow = sAllUrl;

if (parent.frames['HiddenFields']) {
parent.frames['HiddenFields'].document.getElementById('shdUrlModal').value = "";
} else {
document.getElementById('shdUrlModal').value = "";
}
}
myArgs = new Array(sArgs, sUrlToShow);
}

if (window.showModalDialog && !document.stopMessaging) {
try {
var sResult = window.showModalDialog(appendSessionId(sUrl), myArgs, sOptions);

ExecUserModalChoice(sArgs, sResult);
} catch (e) { }
}
}

function ExecUserModalChoice(sArgs, sResult) {
var oCtrlMemo;

if (sResult) {
switch (sArgs) {
case "DOCOLEPREVIEW":
case "MEMOGLOB011":
case "DOCOLEGLOB014":
if (sResult[3].toString() == '1') {
oCtrlMemo = document.getElementById('ihdC_MEMO_' + HIDDEN);

oCtrlMemo.value = sResult[0].toString();
document.getElementById('imgbtnMemo_' + IMAGE_BUTTON).src = sResult[1].toString();
document.getElementById('imgbtnMemo_' + IMAGE_BUTTON).alt = sResult[2].toString();
}
if (sArgs == "DOCOLEGLOB014" || sArgs == "DOCOLEPREVIEW") {
document.getElementById('ihdReloadForce').value = "yes";
ModifWaitStatus(true, true, LOADING);
poster();
}
break;
case "SELECT_INFOS_GLOB018":
if (sResult[0].toString() == "VALIDATION") {
ModifWaitStatus(true, true, LOADING);
poster();
}
else if (sResult[0].toString() == "CLOSE_CROSS") {
ModifWaitStatus(true, true, LOADING);
poster('RestaurStackGrid');
}
break;
case "GENER_PROCED":
if (sResult[0].toString() == "VALIDATION") {
ModifWaitStatus(true, true, LOADING);
poster();
} else {
document.URL = appendSessionId(sResult[0].toString());
}
break;
case "METIERSUB":
if (sResult[0].toString() != "") {
sResultSubMetier = sResult[0];
}
break;
case "RACCOURCICTRLGLOB023":
if (window.document.getElementById(sResult[0].toString())) {
window.document.getElementById(sResult[0].toString()).value = sResult[1].toString();
}

case "RECUPINSTANCE":
if (sResult[0].toString() != "") {
document.getElementById('ihdItemClickForInstance').value = sResult[0].toString();
}
break;

case "RECUPINSTANCEVT":
document.URL = appendSessionId("../../Pages/Listes/LIST002.aspx?C_ECRAN=" + sResult[0].toString() + "&BREFRESH=False&B_NOT_RESTRICT=False&Action=C");
break;

case "GLOB033_AJOUTER_CANEVAS":
if (sResult[0].toString() != "") {
var value = iwsAllCtrls.getCtrl("icbCanevas").value();
TraitementCombo(value);
}
break;

default:
if (sArgs == "ARCHIVEGLOB007" ||
sArgs == "SUPPRESS" ||
sArgs == "ActionDelete" ||
sArgs == "MVT_OBJ_AFTER_REPLACE" ||
sArgs == "ActionSoumettre" ||
sArgs == "ErrChpObliHELP001" ||
sArgs == "PARC049" ||
sArgs == "HELP001" ||
sArgs == "ObjectsLimit" ||
sArgs == "ERR_DIRECTORY_NOT_EXISTS" ||
sArgs == "DuplicateDetails" ||
sArgs == "DUPLICATION" ||
sArgs == "ModifProced" ||
sArgs == "msgIsiscan" ||
sArgs == "ErrPersoView" ||
sArgs == "INFO_ACTION"
) {
ModifWaitStatus(true, true, LOADING);
document.URL = appendSessionId(sResult[0].toString());
}
else if (sArgs == "SUPPRESSREQUEST" ||
sArgs == "PERSOEXPORTGLOB007" ||
sArgs == "DISSOCIER" ||
sArgs == "ActionDeleteDetail" ||
sArgs == "DARMess" ||
sArgs == "CreationInstance" ||
sArgs == "MSG_INDEX_DESIGN" ||
sArgs == "ADDREQUESTGLOB015" ||
sArgs == "Confirmation" ||
sArgs == "MvtObjet" ||
sArgs == "MOUVEMENT" ||
sArgs == "DuplicationMultiple" ||
sArgs == "DuplicationMsgType") {
ModifWaitStatus(true, true, LOADING);
poster(sResult[0].toString());
}
}
} else {

if (sArgs == "ObjectsLimit" || sArgs == "ErrPersoSQL" || sArgs == "EXCEPTION" || sArgs == "ErrDroitVT") {

if (document.title != 'GLOB000') {
document.stopMessaging = true;
document.URL = appendSessionId("../../Pages/Global/GLOB000.aspx");
}
}
}
iws_reInitIsiCurrentModalPage(sArgs)

}


function iws_reInitIsiCurrentModalPage(sArgs) {
var sDataToSend = "Traitement=IsiAsyncUpdateVariableSessionToNothing&SESSION_VARIABLE_NAME=IsiCurrentModalPage";
if (document.title == ISI_PRODUCT_NAME) {
oAjax = new IsiJavaScriptAjax("./Classes/IsiAjax/IsiAjax.aspx");
}
else {
oAjax = new IsiJavaScriptAjax("../../Classes/IsiAjax/IsiAjax.aspx");
}
oAjax.init();
oAjax.AsyncExecute(sDataToSend, "POST", true, "TEXT", "TEXT");
}



function iws_setFocusOnGLOB(btnId) {
if (!btnId) return;

var btn = document.getElementById(btnId);
document.focus();
if (btn) {
if (btn.disabled == false && btn.style.visibility != "hidden") {
btn.focus();
}
}
}

function poster(pParam) {
if (document.forms.length != 0) {
if (document.Form1) {
if (pParam) {
if (document.Form1.hdParam) {
document.Form1.hdParam.value = pParam;
}
}
else {
pParam = "";
}
__doPostBack("Poster", pParam);
}
}
}


function ResizeGridsToMaxSize() {

var sImageRight = "_ImgRight";
var sMainGrid = NAME_ISIGRID + "_main";

var oGridMain = document.getElementById(GRD_SEARCH + SEP_ENCAPS_GRID + sMainGrid);
var oGridDetail = document.getElementById(GRD_FLAT + SEP_ENCAPS_GRID + sMainGrid);
var oGridHier = document.getElementById(GRD_HIER + SEP_ENCAPS_GRID + sMainGrid);
var oGridExt = document.getElementById(NAME_ISIEXTGRID + SEP_ENCAPS_GRID + sMainGrid);

if (oGridMain || oGridDetail || oGridHier || oGridExt) {

var oDiv;
var oGrid;
var sImageName;

if (oGridMain || oGridExt) {
oDiv = document.getElementById(DIV_FORMULAIRE).style;
if (oGridMain) {
oGrid = oGridMain.style;
sImageName = GRD_SEARCH + sImageRight;
} else {
oGrid = oGridExt.style;
sImageName = NAME_ISIEXTGRID + sImageRight;
}
} else {
oDiv = document.getElementById(DIV_DETAIL).style;
if (oGridDetail) {
oGrid = oGridDetail.style;
sImageName = GRD_FLAT + sImageRight;
} else {
oGrid = oGridHier.style;
sImageName = GRD_HIER + sImageRight;
}
}

if (oDiv && oGrid) {
var iGridLeft = (oGrid.left == "") ? 0 : parseInt(oGrid.left);
var iGridTop = (oGrid.top == "") ? 0 : parseInt(oGrid.top);

var iMaxWidth = parseInt(oDiv.width) - (2 * iGridLeft);
var iMaxHeight = parseInt(oDiv.height) - iGridTop - 23;

if (iMaxWidth < 0) iMaxWidth = parseInt(oGrid.width);
if (iMaxHeight < 0) iMaxHeight = parseInt(oGrid.height);

oGrid.width = iMaxWidth + "px";
oGrid.height = iMaxHeight + "px";


var oGridHeader = document.getElementById('_isiGridHeaderTable_').style;

var iGridHeaderLeft = (oGridHeader.left == "") ? 0 : parseInt(oGridHeader.left);

var iHeaderWidth = iMaxWidth;
var iRightCornerImageLeft = iHeaderWidth + iGridHeaderLeft;

oGridHeader.width = iHeaderWidth + "px";

oGridHeader = null;
}
}
}

function GetShortCutStatus() {
var bResult = false;
if (parent.frames['HiddenFields']) {
if (parent.frames['HiddenFields'].bShortCutActivated) {
bResult = parent.frames['HiddenFields'].bShortCutActivated;
}
}
return bResult;
}

function SetShortCutStatus(bShortCutActivated) {
if (parent.frames['HiddenFields']) {
parent.frames['HiddenFields'].bShortCutActivated = bShortCutActivated;
}
}

function GetNotSubmitPageOnShortCut() {
var bNotSubmitPageOnShortCut = false;
if (parent.frames['HiddenFields']) {
if (parent.frames['HiddenFields'].bNotSubmitPageOnShortCut) {
bNotSubmitPageOnShortCut = parent.frames['HiddenFields'].bNotSubmitPageOnShortCut;
}
}
return bNotSubmitPageOnShortCut;
}

function SetNotSubmitPageOnShortCut(bNotSubmitPageOnShortCut) {
if (parent.frames['HiddenFields']) {
parent.frames['HiddenFields'].bNotSubmitPageOnShortCut = bNotSubmitPageOnShortCut;
}
}


var oTitre;       // On recupere le titre de la page (NOM DE L'ECRAN)
var bRechercheConnexe = false;   // Booleen indiquant si on est dans le cas d'une recherche connexe
var oCritere;       // Variable recuperant la zone de critere pour les VT et les recherches connexes
var oRequete;       // Variable recuperant la liste deroulante contenant les requetes sur les VT

var bIsHierarchique;     // Booleen indiquant si la grille est hierarchique ou non
var classEntete = 'IsiEnteteTop';  // Variable definissant la classe d'entete des grilles sans le trait inferieur
var classEnteteAll = 'IsiEnteteAll'; // Variable definissant la classe d'entete des grilles encradrement total
var classLigne = 'IsiLigneTop';  // Variable definissant la classe des lignes des grilles sans le trait inferieur
var classLigneAll = 'IsiLigneAll';  // Variable definissant la classe des lignes des grilles encradrement total
var classLigneAlternate = 'IsiLigneAlternateTop';  // Variable definissant la classe des lignes alternee des grilles sans le trait inferieur
var classLigneAlternateAll = 'IsiLigneAlternateAll'; // Variable definissant la classe des lignes alternee des grilles encradrement total
var classGroup = 'IsiGroup';   // Variable definissant la classe des groupements des grilles

var sTableau;       // variable utilisee pour la construction de la grille sous forme de tableau
var iRedim = 940;      // variable utilisee pour le redimenssionement de la page (Portrait/Paysage...)
var iNbrTable = 1;      // utilisee pour decouper la grille en table
var iLargEnCours = 0;     // Variable pour calculer la largeur des colones
var iNbrCol = new Array();
iNbrCol[iNbrTable] = 0;    // utilisee pour definir le nombre de colonne par table
var tabEntete = new Array();   // tableau utilise pour stocker l'entete de la grille
var largCol = 0;      // Largeur des colonnes d'une table
var iNbrLigne = 0;      // utilisee pour recuperer le nombre de ligne de la grille
var tabLargeur = new Array();
tabLargeur[iNbrLigne] = new Array(); // largeur de chaque colonne de la grille
var tabElement = new Array();
tabElement[iNbrLigne] = new Array(); // element de chaque Ligne/Colonne de la grille
var iColonne;       // nbr de colonne de la grille
var iLigne = 0;      // indice de la ligne en cours de parcours
var tabCorrespondance = new Array();   // tableau en relation avec les colonnes de la grille pour indiquer si la colonne est visible ou non

var sTabEnteteGroupement;    // utilisee pour fabriquer l'entete des groupements
var iNiveauMaxParcours = 0;   // utilisee en cas de groupement pour definir le nombre de niveau de parcours
var tabColGroupee = new Array();  // tableau en relation avec les colonnes de la grille pour indiquer si elle est groupee ou non
var tabGroupement = new Array();  // recupere les groupements si il y'en a
var tabGroupe = new Array();   // recupere les groupes pour chaque groupements de lignes
var iIndiceGroupe = 1;
tabGroupe[iIndiceGroupe] = '';
var sValeur;

function popImprimer(bParam) {
window.status = 'Veuillez patienter... Chargement des informations en cours...';
oTitre = document.getElementById('lblTitle_Lbl');  // On recupere le titre de la page (NOM DE L'ECRAN)
var oDivForm = document.getElementById(DIV_FORMULAIRE); // On recupere le contenu du div formulaire (information de l'ecran maitre)
var oIdent = document.getElementById('lblIdent_Lbl');  // si oIdent est != "" alors on est sur une page formulaire, ou detail, sinon il s'agit d'une page de recherche ou VT
var oDivDetail = document.getElementById(DIV_DETAIL);  // On recupere le contenu du div detail (information de l'ecran detail) = '' si il n'est pas affiche
var oTitreGrid;

if (oIdent.innerHTML != "") {
if (oDivDetail) {
bIsHierarchique = false;
oTitreGrid = document.getElementById(GRD_FLAT + '_LblTitle'); // Detail
var GrilleHierarchique = document.getElementById(GRD_HIER + SEP_ENCAPS_GRID + NAME_ISIGRID); // GRILLE HIERARCHIQUE ON NE GERE PAS !!
if (GrilleHierarchique) {
oTitreGrid = 'Mode hierarchique non impimable ! ';
bIsHierarchique = true;
}
}
} else {
oTitreGrid = document.getElementById(GRD_SEARCH + '_LblTitle'); // Recherche
}

if (oDivForm && oTitre) {
var divFormulaire = oDivForm.innerHTML; // Contenu du formulaire
var Titre = oTitre.innerHTML; // Titre de la page (ex : Utilisateur; Service...)
var lWindowTitle;
var Ident;

if (oTitre.isititle == 'HELP021' || oTitre.isititle == 'ADM020') {
var oAjax = new IsiAjax("../../Classes/IsiAjax/IsiAjax.aspx");
oAjax.init();
var sReponse = oAjax.SyncExecute("Traitement=IsiPrintWorkflow&TYPE=PRINT&NUM=" + oTitre.isititle, "POST", "TEXT", "TEXT");
if (sReponse != "") {
eval(sReponse);
if (sInfos != "") {
divFormulaire = WorkflowModification(divFormulaire, sInfos, "workflow");
}
}
}

if (oTitre.isititle == 'PARC076' || oTitre.isititle == 'ADM054') {
var oAjax = new IsiAjax("../../Classes/IsiAjax/IsiAjax.aspx");
oAjax.init();
var sReponse = oAjax.SyncExecute("Traitement=IsiPrintImpact&TYPE=PRINT&NUM=" + oTitre.isititle, "POST", "TEXT", "TEXT");
if (sReponse != "") {
eval(sReponse);
if (sInfos != "") {
divFormulaire = WorkflowModification(divFormulaire, sInfos, "impact");
}
}
}

oCritere = document.getElementById('TableCritere');
if ((oTitre.innerHTML.toString().search(/recherche/gi) != -1) && (oCritere)) {
bRechercheConnexe = true;
}
if (oIdent.innerHTML != "") {
Ident = oIdent.innerHTML; // Identifiant de l'enregistrement courant
lWindowTitle = Ident + ' ' + Titre; // Titre de la fenetre + identifiant enreg
} else {
lWindowTitle = Titre; // Titre de la fenetre seule (Page recherche ou VT)
}

if (oTitreGrid) {
var TitreGrid = oTitreGrid.innerHTML; // Titre de la grille
}

if (oDivDetail) {
var DivDetail = oDivDetail.innerHTML; // Contenu du detail
}

if (!bIsHierarchique) {
var oGrille = document.getElementById(GRD_FLAT + SEP_ENCAPS_GRID + NAME_ISIGRID);
var grid;
if (oGrille) {
grid = igtbl_getGridById(GRD_FLAT + SEP_ENCAPS_GRID + NAME_ISIGRID);
} else {
oGrille = document.getElementById(GRD_SEARCH + SEP_ENCAPS_GRID + NAME_ISIGRID);
if (oGrille) {
grid = igtbl_getGridById(GRD_SEARCH + SEP_ENCAPS_GRID + NAME_ISIGRID);
}
}
oGrille = null;
}

if (grid) {
CreationGrille(grid);
} else {
sTableau = "";
}

var sHtml = "";
var sHtmlEntete = "";
var sHtmlContenu = "";

sHtmlEntete = PreparationPageHTMLGeneree(lWindowTitle);
sHtmlContenu = SelectionTypeImpression(bParam, divFormulaire, DivDetail, TitreGrid);

sHtml = "\n<script id='print_Script' type='text/javascript'> \n";

if (sTableau != '') {
sHtml += "var oTabLargeur = new Array() ; \n var oTabElement = new Array() ; \n var oTabColGroupee = new Array() ; \n oTabLargeur[0] = new Array() ; \n oTabElement[0] = new Array() ; \n ";
sHtml += "var bRechercheConnexe = " + bRechercheConnexe + " ; \n var CURRENT_TYPEBASE = " + CURRENT_TYPEBASE + " ; var CURRENT_TITLE = \"" + document.title.toString() + "\" ; \n ";

if (grid.GroupCount > 0) {
sHtml += "sTableauEnteteGroupe = \"" + sTabEnteteGroupement.toString().replace(/\\/gi, "\\\\").replace(/"/gi, "\\\"") + "\" ; \n var oTabGroupement = new Array() ; \n var oTabGroupe = new Array() ; \n var bGrilleIsGroup = true ; \n ";

for (var g = 1; g < tabGroupe.length; g++) {
sHtml += "oTabGroupe[" + g + "] = \"" + tabGroupe[g].toString() + "\" ; \n ";
}
for (var i = 1; i < tabElement[0].length; i++) {
sHtml += "oTabLargeur[0][" + i + "] = \"" + tabLargeur[0][i] + "\" ; \n ";
sHtml += "oTabElement[0][" + i + "] = \"" + tabElement[0][i].replace(/"/gi, "\\\"") + "\" ; \n ";
sHtml += "oTabColGroupee[" + i + "] = \"" + tabColGroupee[i].toString() + "\" ; \n ";
}
for (var iLigne = 1; iLigne < tabElement.length; iLigne++) {
sHtml += "oTabElement[" + iLigne + "] = new Array() ; \n ";
sHtml += "oTabGroupement[" + iLigne + "] = \"" + tabGroupement[iLigne] + "\" ; \n ";
for (var iCol = 1; iCol < tabElement[iLigne].length; iCol++) {
if (!tabColGroupee[iCol]) {
sHtml += "oTabElement[" + iLigne + "][" + iCol + "] = \"" + tabElement[iLigne][iCol].toString().replace(/\\/gi, "\\\\").replace(/"/gi, "\\\"") + "\" ; \n ";
} else {
sHtml += "oTabElement[" + iLigne + "][" + iCol + "] = \"\" ; \n ";
}
}
}
} else {
sHtml += "var bGrilleIsGroup = false ; \n ";
var iIndex;
iIndex = 1;
for (var i = iIndex; i < tabElement[0].length; i++) {
sHtml += "oTabLargeur[0][" + i + "] = \"" + tabLargeur[0][i] + "\" ; \n ";
sHtml += "oTabElement[0][" + i + "] = \"" + tabElement[0][i].replace(/"/gi, "\\\"") + "\" ; \n ";
}
for (var iLigne = 1; iLigne < tabElement.length; iLigne++) {
sHtml += "oTabElement[" + iLigne + "] = new Array() ; \n ";
iIndex = 1;
for (var iCol = iIndex; iCol < tabElement[0].length; iCol++) {
sHtml += "oTabElement[" + iLigne + "][" + iCol + "] = \"" + tabElement[iLigne][iCol].toString().replace(/\\/gi, "\\\\").replace(/"/gi, "\\\"").replace(/\r\n/gi, "") + "\" ; \n ";
}
}
}
}

sHtml += EcritureFonctionPageGeneree();

try {
var newWindow = window.open("", "", "");
newWindow.document.write(sHtmlEntete);
newWindow.document.write(sHtmlContenu);
newWindow.document.write(sHtml);
} catch (e) { }
}
RAZVariables();
window.status = 'Termine';
oDivForm = null;
oIdent = null;
oDivDetail = null;
}

function SelectionTypeImpression(obParam, objDivFormulaire, objDivDetail, objTitreGrid) {
if (obParam.toString() == "True") {
var vState;
vState = GetValueFrame("HiddenFields", "ihdStateDetail");
if (vState == '0') {
return ImpressionFormulaire(objDivFormulaire);
} else {
return ImpressionFormulaireDetail(objTitreGrid, objDivFormulaire);
}
} else {
if (objDivDetail != "") {
return ImpressionDetail(objTitreGrid);
} else {
return ImpressionVT(objTitreGrid);
}
}
}

function EcritureFonctionPageGeneree() {


var sHtml = "iws_DesactiveElements() ; iws_CalculPosition() ; iws_Reposition() ; window.status = \"Termine\" ; \n\n";
sHtml += "</script></body></html>";

return sHtml;
}

function ImpressionFormulaireDetail(oTitreGrid, objDivFormulaire) {

var sHtml;

sHtml = "\n<div id='print_formulaire' style='position : relative ; height: 75%; visibility : hidden ; '>" + objDivFormulaire + "\n</div>\n";
if (!bIsHierarchique) {
sHtml += "\n<br><div style='page-break-before:always ;position : relative  ; background-color : #E2F0F8 ; padding : 5px ; font-size : 8pt ; font-family : Verdana ;font-weight : bold ; '>";
sHtml += oTitreGrid + "</div>\n\n";
sHtml += "\n\n<div  id='printdetail' style='position : relative ; left : 8px ; visibility : visible ; '><span id='pGrille_print'>" + sTableau + "</span>\n</div>\n";
sHtml += "\n<div id='print_recherche'></div> \n\n";
}

return sHtml;
}

function ImpressionFormulaire(objDivFormulaire) {
var sHtml;
sHtml = "\n<div id='print_formulaire' style='position : relative; height: 100%; visibility : visible ; '>" + objDivFormulaire + "\n</div>\n";
sHtml += "\n<div id='print_recherche'></div> \n\n";

return sHtml;
}

function ImpressionDetail(oTitreGrid) {

var sHtml;
sHtml = "\n<br><div style='position : relative  ; background-color : #E2F0F8 ; padding : 5px ; font-size : 8pt ; font-family : Verdana ;font-weight : bold ; '>";
sHtml += oTitreGrid + "</div>\n\n";
sHtml += "\n\n<div  id='print_detail' style='page-break-before:auto ;position : relative ; left : 8px ; visibility : visible ; '><span id='pGrille_print'>" + sTableau + "</span>\n</div>\n";
sHtml += "\n<div id='print_recherche'></div> \n\n";

return sHtml;
}

function ImpressionVT(oTitreGrid) {
var sHtml;
sHtml = "\n<div id='print_Critere' style='position : absolute ; padding : 10px ; width : 750px ; '><TABLE style='width : 750px ; '><TR><TD>";
if (oRequete) {
if (oCritere) {
sHtml += oRequete.innerHTML + "</TD></TR></TABLE><TABLE style='width : 750px ; '><TR><TD>" + oCritere.innerHTML;
} else {
sHtml += oRequete.innerHTML;
}
} else {
if (oCritere) {
sHtml += oCritere.innerHTML;
}
}
sHtml += "\n</TD></TR></TABLE></div>\n";
sHtml += "\n<div id='print_Espace' style='position : relative ;' > </div>\n";
sHtml += "\n<br><div id='print_TitreGrid' style='position : relative  ; background-color : #E2F0F8 ; padding : 5px ; font-size : 8pt ; font-family : Verdana ;font-weight : bold ; '>";
sHtml += oTitreGrid + "</div>\n\n";
sHtml += "\n<div id='print_recherche' style='position : relative; height: 100%; visibility : hidden ; '><span id='pGrille_print'>" + sTableau + "</span>\n</div>\n";

return sHtml;
}

function PreparationPageHTMLGeneree(olWindowTitle) {
var sHtml;

if (CURRENT_LANGUAGE == "FR") {
olWindowTitle = "Impression - " + olWindowTitle;
} else {
olWindowTitle = "Print - " + olWindowTitle;
}

sHtml = "<html id='print_MainPage'><head><title>" + olWindowTitle + "</title><LINK href='../../Others/Styles.css' type='text/css' rel='STYLESHEET'><LINK href='../../Others/IsiAttPreview.css' type='text/css' rel='STYLESHEET'><LINK href='../../Others/Menu.css' type='text/css' rel='STYLESHEET'><LINK href='../../Others/Title.css' type='text/css' rel='STYLESHEET'><LINK href='../../Others/bandeau.css' type='text/css' rel='STYLESHEET'><LINK href='../../Others/ManagementChart.css' type='text/css' rel='STYLESHEET'>";
sHtml += "<style type='text/css'> .cBody { background-color: #FFFFFF; } ";
sHtml += ".IsiLigneAlternateAll { background-color: #FFFBFF ; border-color: #000000; border-style: solid; border-width: 0px; padding-left: 3px; font-family: Verdana; font-size: 8pt; border-right : solid 1px #AAAAAA ; border-left : solid 1px #AAAAAA ; border-bottom : solid 1px #AAAAAA ; border-top : solid 1px #AAAAAA ; } .IsiLigneAlternateTop { background-color: #FFFBFF ; border-color: #000000; border-style: solid; border-width: 0px; padding-left: 3px; font-family: Verdana; font-size: 8pt; border-right : solid 1px #AAAAAA ; border-left : solid 1px #AAAAAA ; border-top : solid 1px #AAAAAA ; }";
sHtml += ".IsiLigneAll { border-color: solid 0px white; border-right : solid 1px #AAAAAA ; border-left : solid 1px #AAAAAA ; border-bottom : solid 1px #AAAAAA ;  border-top : solid 1px #AAAAAA ; padding-left: 3px; font-family: Verdana; font-size: 8pt; background-color: #EAEAEA ; } .IsiLigneTop { border-color: solid 0px white; border-right : solid 1px #AAAAAA ; border-left : solid 1px #AAAAAA ; border-top : solid 1px #AAAAAA ; padding-left: 3px; font-family: Verdana; font-size: 8pt; background-color: #EAEAEA ; }";
sHtml += ".IsiEnteteAll { font-weight : bold ; border-right : solid 1px #92c6e7 ; border-left : solid 1px #92c6e7 ; border-bottom : solid 1px #92c6e7 ; border-top : solid 1px #92c6e7 ;  height: 15px; font-size: 8pt; font-family: Verdana; background-color: #E2F0F8 ; vertical-align: top; } .IsiEnteteTop { font-weight : bold ; border-right : solid 1px #92c6e7 ; border-left : solid 1px #92c6e7 ; border-top : solid 1px #92c6e7 ;  height: 15px; font-size: 8pt; font-family: Verdana; background-color: #E2F0F8 ; vertical-align: top; } ";
sHtml += ".IsiGroup { background-color: #6699CC ; border-color: white ; border-style: solid ; border-width: 0px ; padding-left: 3px ; font-family: Verdana ; font-size: 8pt ; } ";
sHtml += "</style> \n\n";
sHtml += "<SCRIPT language=\"javascript\" src=\"../../Scripts/print.js\" type=\"text/javascript\"></script><SCRIPT language=\"javascript\" src=\"../../Scripts/IsiControlType.js\" type=\"text/javascript\"></script><SCRIPT language=\"javascript\" src=\"../../Scripts/IsiControlesNames.js\" type=\"text/javascript\"></script>";
sHtml += "<script language='javascript'>";
sHtml += "function iws_defCtrlPropr() {return true;} function igcmbo_onmousedown() {return true;} function igcmbo_onfocus() {return true;} function igcmbo_onmouseup() {return true;} function igdc_initDateChooser() {return true;} function iws_initMessageDiv() {return true;} function iws_miseEnForme() {return true;} function igcmbo_onmouseout() {return true;} function igtree_initTree(treeId) { var a=1 ; } function igtree_mouseover() { var a=1 ; } function igtree_nodeclick() { var a=1 ; } function igtree_dblclick() { var a=1 ; } function igtree_contextmenu() { var a=1 ; } function igtree_onscroll() { var a=1 ; } function igtree_selectStart() { var a=1 ; } function igtree_keydown() { var a=1 ; } function igtree_keyup() { var a=1 ; } function tooltp() { var a=1 ; } ";
sHtml += "function OnChangeCritereBefore() { var a=1 ; } function OnChangeCritereAfter() { var a=1 ; } function onchangeState() { var a=1 ; } function ActionOnCtrlFocus() { var a=1 ; } function OnChangeCritere() { var a=1 ; } function UpdateCtrlValue() { var a=1 ; } function UpdateCtrlChange() { var a=1 ; } function __doPostBack() { var a=1 ; } function igtree_mouseout() { var a=1 ; } function SaveCtrlNameClick() { var a=1 ; } function setStatusToDateMessage() { var a=1 ; } function assignCurrentDate() { var a=1 ; } function resetStatusFromDateMessage() { var a=1 ; } function igdc_initDateChooser(id,calID) {return true;} ";
sHtml += "function iws_LoadRootTree(treeId, sAction, sNoeud) {var a=1;}";
sHtml += "function IsiLinkButtonClientOnClick(treeId, sAction, sNoeud) {var a=1;}";
sHtml += "function IsiActionChartPieClientOnMouseClick(treeId, sAction, sNoeud) {var a=1;}";
sHtml += "function IsiCallChartPieClientOnMouseClick(treeId, sAction, sNoeud) {var a=1;}";
sHtml += "</script> \n\n";
sHtml += "</head><body class='cBody'>";


sHtml += "\n<div style='position : fixed ; left : 8px ; top : 0px ; height: 75px; background-color : Transparent ; padding : 5px ; color : #0030AC ;font-size : 8pt ; font-family : Verdana ;font-weight : bold ;' >";
sHtml += olWindowTitle + "</div>\n\n";

var DateDuJour = new Date();

if (CURRENT_LANGUAGE == "FR") {
if (sTableau != '') {
sHtml += "<div style='position : absolute ; right : 8px ; top : 0px ; color : #0030AC ;font-size : 8pt ; font-family : Verdana ;font-weight : bold ;'> " + DateDuJour.toLocaleString() + " <SELECT id='Print_Format' onChange=iws_AfficheGrille() style='visibility : visible ; '> <OPTGROUP label='A4'> <OPTION label='Portrait' value='A4_Portrait'>Portrait</OPTION> <OPTION selected label='Paysage' value='A4_Paysage'>Paysage</OPTION> </OPTGROUP> <OPTGROUP label='A3'> <OPTION label='Portrait' value='A3_Portrait'>Portrait</OPTION> <OPTION label='Paysage' value='A3_Paysage'>Paysage</OPTION> </OPTGROUP> </SELECT></div>";
} else {
sHtml += "<div style='position : absolute ; right : 8px ; top : 0px ; color : #0030AC ;font-size : 8pt ; font-family : Verdana ;font-weight : bold ;'> " + DateDuJour.toLocaleString() + " <SELECT id='Print_Format' onChange=iws_AfficheGrille() style='visibility : hidden ; '> <OPTGROUP label='A4'> <OPTION label='Portrait' value='A4_Portrait'>Portrait</OPTION> <OPTION selected label='Paysage' value='A4_Paysage'>Paysage</OPTION> </OPTGROUP> <OPTGROUP label='A3'> <OPTION label='Portrait' value='A3_Portrait'>Portrait</OPTION> <OPTION label='Paysage' value='A3_Paysage'>Paysage</OPTION> </OPTGROUP> </SELECT></div>";
}
} else {
if (sTableau != '') {
sHtml += "<div style='position : absolute ; right : 8px ; top : 0px ; color : #0030AC ;font-size : 8pt ; font-family : Verdana ;font-weight : bold ;'> " + DateDuJour.toGMTString().substr(0, DateDuJour.toGMTString().length - 3) + " <SELECT id='Print_Format' onChange=iws_AfficheGrille() style='visibility : visible ; '> <OPTGROUP label='A4'> <OPTION label='Portrait' value='A4_Portrait'>Portrait</OPTION> <OPTION selected label='Landscape' value='A4_Landscape'>Landscape</OPTION> </OPTGROUP> <OPTGROUP label='A3'> <OPTION label='Portrait' value='A3_Portrait'>Portrait</OPTION> <OPTION label='Landscape' value='A3_Landscape'>Landscape</OPTION> </OPTGROUP> </SELECT></div>";
} else {
sHtml += "<div style='position : absolute ; right : 8px ; top : 0px ; color : #0030AC ;font-size : 8pt ; font-family : Verdana ;font-weight : bold ;'> " + DateDuJour.toGMTString().substr(0, DateDuJour.toGMTString().length - 3) + " <SELECT id='Print_Format' onChange=iws_AfficheGrille() style='visibility : hidden ; '> <OPTGROUP label='A4'> <OPTION label='Portrait' value='A4_Portrait'>Portrait</OPTION> <OPTION selected label='Landscape' value='A4_Landscape'>Landscape</OPTION> </OPTGROUP> <OPTGROUP label='A3'> <OPTION label='Portrait' value='A3_Portrait'>Portrait</OPTION> <OPTION label='Landscape' value='A3_Landscape'>Landscape</OPTION> </OPTGROUP> </SELECT></div>";
}
}
return sHtml;
}

function CreationGrille(oGrid) {
if (oGrid.GroupCount > 0) {
sTableau = CreationEnteteGroupe(oGrid);
} else {
sTableau = '';
}

CreationEnteteGrille(oGrid);

if (oGrid.GroupCount > 0) {
iNiveauMaxParcours = oGrid.GroupCount - 1;
ParcoursLigneGroupement(oGrid);
} else {
ParcoursGrilleLigne(oGrid, null);
}
}

function CreationEnteteGrille(oGrid) {
sTableau += '<TABLE width=' + parseInt(iRedim + 30) + 'px cellspacing=2> <TR><TD width=10px> &nbsp; </TD><TD> \n\n <TABLE id=PrintTableEntete1 cellspacing=0 width=' + iRedim + 'px left=8px><TR>';
ParcoursGrilleEntete(oGrid);
sTableau += '</TR></TABLE>\n\n</TD></TR>\n\n';
}

function ParcoursLigneGroupement(oGrid) {
var objRow;
for (var iNbrligneGrp = 0; iNbrligneGrp < oGrid.Rows.length; iNbrligneGrp++) {
objRow = oGrid.Rows.getRow(iNbrligneGrp);
if (objRow.Value == null) {
sValeur = '';
} else {
sValeur = objRow.Value;
}
TraiterSousLigne(objRow, 0, oGrid);
iIndiceGroupe += 1;
tabGroupe[iIndiceGroupe] = '';
}
}

function CreationEnteteGroupe(oGrid) {
sTabEnteteGroupement = '<TABLE id=PrintTableEnteteGroupement class=' + classGroup + ' cellspacing=0 width=' + iRedim + 'px left=8px><TR><TD>';
var sEspace = '';
for (var h = 0; h < oGrid.GroupCount; h++) {
sTabEnteteGroupement += '<TABLE id=PrintTableEnteteGroupement class=' + classGroup + ' cellspacing=0 width=' + iRedim + 'px left=8px><TR>';
sTabEnteteGroupement += sEspace + '<TD>' + oGrid.GroupByBox.groups[h].Element.innerHTML + '</TD></TR></TABLE>';
sEspace += '<TD width=30> &nbsp; </TD>';
}
sTabEnteteGroupement += '</TD></TR></TABLE>';
return sTabEnteteGroupement;
}

function RAZVariables() {
iNiveauMaxParcours = 0;
iNbrTable = 1;
iLargEnCours = 0;
iNbrCol[iNbrTable] = 0;
largCol = 0;
iNbrLigne = 0;
iLigne = 0;
iIndiceGroupe = 1;
tabGroupe[iIndiceGroupe] = '';
}

function TraiterSousLigne(oRow, iNivCour, oGrid) {
if (iNivCour < iNiveauMaxParcours) {

for (var iNbrSsligneGrp = 0; iNbrSsligneGrp < oRow.Rows.length; iNbrSsligneGrp++) {
tabGroupe[iIndiceGroupe] += '<TABLE id=PrintTableEnteteGroupement1 class=' + classGroup + ' cellspacing=0 width=100% left=8px><TR>';
for (var iNivo = 0; iNivo <= iNivCour; iNivo++) {
if (iNivo == iNivCour) {
if (oRow.Value == null) {
sValeur = '';
} else {
sValeur = oRow.Value;
}
tabGroupe[iIndiceGroupe] += '<TD>' + igtbl_getColumnById(oRow.GroupColId).HeaderText + ' : ' + sValeur + '</TD>';
} else {
tabGroupe[iIndiceGroupe] += '<TD width=30> &nbsp; </TD>';
}
}
tabGroupe[iIndiceGroupe] += '</TR></TABLE>';

var objRow = oRow.Rows.getRow(iNbrSsligneGrp);

TraiterSousLigne(objRow, iNivCour + 1, oGrid);
iIndiceGroupe += 1;
tabGroupe[iIndiceGroupe] = '';
}
} else {
if (iNivCour == iNiveauMaxParcours) {
tabGroupe[iIndiceGroupe] += '<TABLE id=PrintTableEnteteGroupement1 class=' + classGroup + ' cellspacing=0 width=100% left=8px><TR>';
for (var iNivo = 0; iNivo <= iNivCour; iNivo++) {
if (iNivo == iNivCour) {
if (oRow.Value == null) {
sValeur = '';
} else {
sValeur = oRow.Value;
}
tabGroupe[iIndiceGroupe] += '<TD>' + igtbl_getColumnById(oRow.GroupColId).HeaderText + ' : ' + sValeur + '</TD>';
} else {
tabGroupe[iIndiceGroupe] += '<TD width=30> &nbsp; </TD>';
}
}
tabGroupe[iIndiceGroupe] += '</TR></TABLE>';
}
ParcoursGrilleLigne(oGrid, oRow);
}
return false;
}

function ParcoursGrilleLigne(grid, objRow) {
var row;
var oRow;
var iIndex;
if (grid.GroupCount > 0) {
row = objRow.Rows.length;
} else {
row = grid.Rows.length;
}
for (var i = 0; i < parseInt(row); i++) {
iNbrLigne += 1;
tabElement[iNbrLigne] = new Array();
tabGroupement[iNbrLigne] = iIndiceGroupe;
if (grid.GroupCount > 0) {
if (tabGroupement[iNbrLigne - 1] != tabGroupement[iNbrLigne]) {
sTableau += '<TABLE cellspacing=0 class=' + classGroup + ' width=' + iRedim + 'px left=8px><TR><TD>'
sTableau += tabGroupe[iIndiceGroupe];
sTableau += '</TD></TR></TABLE>'
}
}
if ((iNbrLigne) % 2 != 0) {
sTableau += '<TABLE width=30px><TR><TD class=' + classLigneAll + ' width=30px>' + iNbrLigne + '</TD><TD>';
} else {
sTableau += '<TABLE width=30px><TR><TD class=' + classLigneAlternateAll + ' width=30px>' + iNbrLigne + '</TD><TD>';
}
if (grid.GroupCount > 0) {
oRow = objRow.Rows.getRow(i);
} else {
oRow = grid.Rows.getRow(i);
}
iColonne = 1;
for (var n = 1; n <= iNbrTable; n++) {
iLigne += 1;
sTableau += '\n<TABLE id=PrintTableLigne' + iLigne + ' cellspacing=0 width=' + iRedim + 'px left=8px><TR>';
for (var a = 1; a <= iNbrCol[n]; a++) {
if (!tabColGroupee[iColonne]) {
tabElement[iNbrLigne][iColonne] = oRow.getCell(tabCorrespondance[iColonne]).Element.innerHTML;
if ((iLigne % 2) != 0) {
if (n != iNbrTable) {
sTableau += '<TD class=' + classLigne + ' width=' + grid.Bands[0].Columns[tabCorrespondance[iColonne]].Width + '>' + oRow.getCell(tabCorrespondance[iColonne]).Element.innerHTML + '</TD>';
} else {
sTableau += '<TD class=' + classLigneAll + ' width=' + grid.Bands[0].Columns[tabCorrespondance[iColonne]].Width + '>' + oRow.getCell(tabCorrespondance[iColonne]).Element.innerHTML + '</TD>';
}
} else {
if (n != iNbrTable) {
sTableau += '<TD class=' + classLigneAlternate + ' width=' + grid.Bands[0].Columns[tabCorrespondance[iColonne]].Width + '>' + oRow.getCell(tabCorrespondance[iColonne]).Element.innerHTML + '</TD>';
} else {
sTableau += '<TD class=' + classLigneAlternateAll + ' width=' + grid.Bands[0].Columns[tabCorrespondance[iColonne]].Width + '>' + oRow.getCell(tabCorrespondance[iColonne]).Element.innerHTML + '</TD>';
}
}
} else {
tabElement[iNbrLigne][iColonne] = '';
}
iColonne += 1;
}
sTableau += '</TR></TABLE>\n\n';
}
sTableau += '</TD></TR>\n\n';
}
sTableau += '</TR></TABLE>\n\n';
}

function ParcoursGrilleEntete(grid) {
var col = parseInt(grid.Bands[0].VisibleColumnsCount);
var iIndex;
var iNbrColonne;
iIndex = 1;
var iCpt = -1;
var bB_SELECTED_Exist = false;

do {
iCpt++;
if (!grid.Bands[0].Columns[iCpt].Hidden && grid.Bands[0].Columns[iCpt].Key == NAME_B_SELECTED_COL) {
bB_SELECTED_Exist = true;
}
} while (iCpt < col && grid.Bands[0].Columns[iCpt].Hidden);

if (bB_SELECTED_Exist) {
iNbrColonne = 1;
} else {
iNbrColonne = 0;
col += 1;
}

while (iIndex < col) {
if (!grid.Bands[0].Columns[iNbrColonne].Hidden) {
tabCorrespondance[iIndex] = iNbrColonne;
if (!grid.Bands[0].Columns[iNbrColonne].IsGroupBy) {
tabColGroupee[iIndex] = false;
tabLargeur[iNbrLigne][iIndex] = grid.Bands[0].Columns[iNbrColonne].Width;
tabElement[iNbrLigne][iIndex] = grid.Bands[0].Columns[iNbrColonne].HeaderText;
largCol = parseInt(grid.Bands[0].Columns[iNbrColonne].Width);
if ((iLargEnCours + largCol) > iRedim) {
iNbrTable += 1;
iNbrCol[iNbrTable] = 1;
iLargEnCours = largCol;
sTableau += '</TR></TABLE>\n\n<TABLE id=PrintTableEntete' + iNbrTable + ' cellspacing=0 width=' + iRedim + 'px left=8px><TR><TH class=' + classEnteteAll + ' width=' + grid.Bands[0].Columns[iNbrColonne].Width + '>' + grid.Bands[0].Columns[iNbrColonne].HeaderText + '</TH>';
} else {
if (iNbrCol[iNbrTable] > iNbrCol[1]) {
iNbrTable += 1;
iNbrCol[iNbrTable] = 1;
iLargEnCours = largCol;
sTableau += '</TR></TABLE>\n\n<TABLE id=PrintTableEntete' + iNbrTable + ' cellspacing=0 width=' + iRedim + 'px left=8px><TR><TH class=' + classEnteteAll + ' width=' + grid.Bands[0].Columns[iNbrColonne].Width + '>' + grid.Bands[0].Columns[iNbrColonne].HeaderText + '</TH>';
} else {
iNbrCol[iNbrTable] += 1;
iLargEnCours += largCol;
sTableau += '<TH class=' + classEnteteAll + ' width=' + grid.Bands[0].Columns[iNbrColonne].Width + '>' + grid.Bands[0].Columns[iNbrColonne].HeaderText + '</TH>';
}
}
} else {
tabColGroupee[iIndex] = true;
tabLargeur[iNbrLigne][iIndex] = 0;
tabElement[iNbrLigne][iIndex] = '.';
iNbrCol[iNbrTable] += 1;
}
iIndex += 1;
}
iNbrColonne += 1;
}
}

function WorkflowModification(divformulaire, nomFic, type) {
var index;
if (type == 'workflow') {
index = divformulaire.indexOf('<DIV class=isiworkflow id=isiworkflow');
} else if (type == 'impact') {
index = divformulaire.indexOf('<DIV class=isiworkflow id=isiWorkflowMetier');
}

if (index != -1) {

var img = document.createElement("IMG");
document.body.appendChild(img);
img.src = "../../ExportedFiles/" + nomFic;

var limage = img.width;
var himage = img.height;

document.body.removeChild(img);

var index2;
var temp;
if (type == 'workflow') {
index2 = divformulaire.indexOf('</SPAN></DIV>', index);
temp = divformulaire.slice(index, index2 + 13);
} else if (type == 'impact') {
index2 = divformulaire.indexOf('</SPAN></DIV>', index);
temp = divformulaire.slice(index, index2 + 15);
}
var indexabsc = temp.indexOf('LEFT:');
var indexabsc2 = temp.indexOf('px;', indexabsc);
var abscisse = parseFloat(temp.slice(indexabsc + 5, indexabsc2));

var indexord = temp.indexOf('TOP:');
var indexord2 = temp.indexOf('px;', indexord);
var ordonnee = parseFloat(temp.slice(indexord + 4, indexord2)) - 10;


var nomcourtfic = nomFic.slice(nomFic.indexOf('ExportedFiles/') + 14);
var codeimage = '<SPAN style=\"Z-INDEX: 75; MARGIN: 20px; BACKGROUND-COLOR: white LEFT: ' + abscisse + 'px;POSITION: absolute; TOP: ' + ordonnee + 'px;\"><IMG src=\"../../ExportedFiles/' + nomFic + '\" alt=\"Une erreur est apparue, l image ne peut etre affichee\"  " TITLE=\"Workflow\" ></SPAN>'; //WIDTH=50% HEIGHT=50%
divformulaire = divformulaire + codeimage;


divformulaire = divformulaire.slice(0, index) + divformulaire.slice(index2 + 13);

index = divformulaire.indexOf('<DIV class=IsiPanelPanel');
index2 = divformulaire.indexOf('</SPAN>', index);
temp = divformulaire.slice(index, index2 + 7);

var indexsize = temp.indexOf('HEIGHT:');
var indexsize2 = temp.indexOf('px', indexsize);

temp = temp.slice(0, indexsize + 7) + (himage + ordonnee + 15) + temp.slice(indexsize2);

indexsize = temp.indexOf('WIDTH:');
indexsize2 = temp.indexOf('px;', indexsize);
taille = parseFloat(temp.slice(indexsize + 6, indexsize2));

if (taille < limage) {
temp = temp.slice(0, indexsize + 6) + (limage + 20) + temp.slice(indexsize2);
}

divformulaire = divformulaire.slice(0, index) + temp + divformulaire.slice(index2 + 7);
}

if (type == 'workflow') {
index = divformulaire.indexOf('<DIV class=isioverview id=isioverview');
if (index != -1) {
index2 = divformulaire.indexOf('</SPAN></DIV>', index);
divformulaire = divformulaire.slice(0, index) + divformulaire.slice(index2 + 13);
}
} else if (type == 'impact') {
index = divformulaire.indexOf('<DIV class=isioverview id=isiOverviewMetier');
if (index != -1) {
index2 = divformulaire.indexOf('</SPAN></DIV>', index);
divformulaire = divformulaire.slice(0, index) + divformulaire.slice(index2 + 15);
}
}

index = divformulaire.indexOf('<DIV id=CtrlZoom');
if (index != -1) {
index2 = divformulaire.indexOf('</DIV>', index);
divformulaire = divformulaire.slice(0, index) + divformulaire.slice(index2 + 6);
}

return divformulaire
}




var gaFadedOutControls = new Array();

function iws_ColoredFadeOut(oCtrl, iRed, iGreen, iBlue) {
if (!iRed || !iGreen || !iBlue) {
iRed = 255;
iGreen = 240;
iBlue = 130;
}

var o = new FadeOut(oCtrl, iRed, iGreen, iBlue);
o.RunFadeOut();
}


function FadeOut(oCtrl, iRed, iGreen, iBlue) {
var _oCtrl = oCtrl;
var _iRed = iRed;
var _iGreen = iGreen;
var _iBlue = iBlue;
var _iFirstRed = iRed;
var _iFirstGreen = iGreen;
var _iFirstBlue = iBlue;
var _iIntervalId;
var _iIntervalSpeed = 30;

this.SetColors = function(iRed, iGreen, iBlue) {
if (iRed < 0) iRed = 0;
if (iRed > 255) iRed = 255;
if (iGreen < 0) iRed = 0;
if (iGreen > 255) iGreen = 255;
if (iBlue < 0) iRed = 0;
if (iBlue > 255) iBlue = 255;

_iRed = iRed;
_iGreen = iGreen;
_iBlue = iBlue;
}

this.GetIntervalId = function() {
return _iIntervalId;
}

this.GetIntervalSpeed = function() {
return _iIntervalSpeed;
}

this.GetRed = function() {
return _iRed;
}

this.GetGreen = function() {
return _iGreen;
}

this.GetBlue = function() {
return _iBlue;
}

this.GetControl = function() {
return _oCtrl;
}

this.IsWhite = function() {
return (_iRed == 255 && _iGreen == 255 && _iBlue == 255);
}

this.ColorizeCtrl = function() {
_oCtrl.style.backgroundColor = "#" + iws_iToHex(_iRed) + iws_iToHex(_iGreen) + iws_iToHex(_iBlue);
}

this.ReinitColors = function() {
_iRed = _iFirstRed;
_iGreen = _iFirstGreen;
_iBlue = _iFirstBlue;
}

this.RunFadeOut = function() {
if (_oCtrl) {
this.ColorizeCtrl();

var iIndexUsed = -1;
for (i = 0; i < gaFadedOutControls.length; i++) {
if (gaFadedOutControls[i].GetControl().id == _oCtrl.id)
iIndexUsed = i;
}

if (iIndexUsed > -1)
gaFadedOutControls[iIndexUsed].ReinitColors();
else {
var i = gaFadedOutControls.push(this);
i--; if (i < 0) return;
_iIntervalId = setInterval("iws_FadeOut(" + i + ")", _iIntervalSpeed);
}
}
}
}

function iws_FadeOut(i) {
if (gaFadedOutControls[i]) {

var o = gaFadedOutControls[i];

o.SetColors(o.GetRed() + 1, o.GetGreen() + 1, o.GetBlue() + 1);

o.ColorizeCtrl();

if (o.IsWhite()) {
clearInterval(o.GetIntervalId);
gaFadedOutControls.splice(i, 1);
}
}
}

function iws_ChangeStatusPage(sNewLabel) {
if (window.status != sNewLabel) {
window.status = sNewLabel;
}
}

function iws_CheckIwsVersion() {
if (window.gsJSVersion) {
if (window.gsVersionIWS) {
if (gsJSVersion != gsVersionIWS) {
if (typeof bClickEnter == "undefined") {
alert(messJsVersion);
}
if (typeof bClickEnter != "undefined") {
if (bClickEnter == false) {
alert(messJsVersion);
}
}
}
}
} else {
alert(messJsVersion);
}
}

function appendSessionId(sUrl) {
var sRetUrl = "";

if (sUrl != "") {
if (sUrl.indexOf(IWS_SESSION_ID_URL_PARAM) == -1) {

var _msIwsSessionId = "";
var pihdSessionId = document.getElementById("ihdIwsSessionId");
if (pihdSessionId) {
_msIwsSessionId = pihdSessionId.value;
pihdSessionId = null;
}

if (sUrl.indexOf("?") == -1) {
sRetUrl = sUrl + "?" + IWS_SESSION_ID_URL_PARAM + _msIwsSessionId;
} else {
sRetUrl = sUrl + "&" + IWS_SESSION_ID_URL_PARAM + _msIwsSessionId;
}
} else {
sRetUrl = sUrl;
}
}

return sRetUrl;
}


function firePulse(nPulsePeriod, nPulseDuration) {
if (nPulseDuration != 0) {

if (nPageDuration < nPulseDuration) {
if (nPageDuration != 0) { pulsar(); }
nPageDuration += nPulsePeriod;
setTimeout("firePulse(" + nPulsePeriod + ", " + nPulseDuration + ")", nPulsePeriod * 60000);
}
else {
if (nPulseDuration != -1) {
terminateThisSession();
}
}
}
}


function pulsar() {
pulseToServer(false);
}

function pulseToServer(bHasExpired) {
_msIwsSessionId = "";
pihdSessionId = document.getElementById("ihdIwsSessionId");
if (pihdSessionId) {
_msIwsSessionId = pihdSessionId.value;
}

oAjax = null;

try {
oAjax = new IsiAjax("../../Classes/IsiAjax/IsiAjax.aspx");
oAjax.init();
} catch (e) { }

if (oAjax) {
oAjax.AsyncExecute("Traitement=IsiSessionPersistence&" + IWS_SESSION_ID_URL_PARAM + _msIwsSessionId + "&HasExpired=" + bHasExpired, "POST", true, "TEXT", "TEXT");
}
}

function terminateThisSession() {
pulseToServer(true);
if (parent.document) {
parent.document.URL = "../../HOMEPAGE.aspx?Action=QUIT&bIsRedirected=YES";
}
}

function iws_launchRacBandeau(sLCD) {
if (sLCD) {
window.open(sLCD, '', 1024, 768, "scrollbars=1,resizable=yes,toolbar=yes,directories=yes,menubar=yes");
}
}

function iws_onEnterPressed(sCodeMenu, sLCD) {
var evt = window.event;
if (evt) {
if (evt.keyCode == 13) {
document.getElementById(sCodeMenu + '_' + TEXTBOX).fireEvent("onchange");
iws_launchRacParam(sCodeMenu, sLCD);
}
}
}

function iws_launchRacParam(sCodeMenu, sLCD) {
var txt = document.getElementById(sCodeMenu + "_" + TEXTBOX);
if (txt) {
var val = txt.value;
sLCD = sLCD.replace("ISIVA_PARAM", val);
iws_launchRacBandeau(sLCD);
txt = null;
}
}

function iws_clickRacBanner(button, div, conteneur) {
var divcont = document.getElementById(conteneur);
var divrac = document.getElementById(div);

var visilityRac = document.getElementById("ihdVisibilityBandeau");
var buttonrac = document.getElementById(button);
if ((divrac) && (buttonrac) && (divcont)) {
var visdiv = divrac.style.display;
if (visdiv == "none") {
divrac.style.display = "block";
buttonrac.src = "../../Images/Forms/uparrows_white.gif";
divcont.style.overflow = "auto";
if (visilityRac) {
visilityRac.value = "block"
}
} else {
divrac.style.display = "none";
buttonrac.src = "../../Images/Forms/downarrows_white.gif";
divcont.style.overflow = "hidden";
if (visilityRac) {
visilityRac.value = "none"
}
}
}
divcont = null;
divrac = null;
buttonrac = null;
visibilityRac = null;
}

function iws_changeVisibilityRacBanner(button, div, conteneur) {
var divcont = document.getElementById(conteneur);
var divrac = document.getElementById(div);
var buttonrac = document.getElementById(button);
var visibilityRac = document.getElementById("ihdVisibilityBandeau");
if ((divrac) && (buttonrac) && (divcont) && (visibilityRac)) {
if (visibilityRac.value) {
if (visibilityRac.value == "visible") {
divrac.style.visibility = "visible";
buttonrac.src = "../../Images/Forms/uparrows_white.gif";
divcont.style.overflow = "auto";
} else {
divrac.style.visibility = "hidden";
buttonrac.src = "../../Images/Forms/downarrows_white.gif";
divcont.style.overflow = "hidden";
}
}
}
divcont = null;
divrac = null;
buttonrac = null;
visibilityRac = null;
}
function IsiAbout() {
var sOptions = "center:yes;status:no;dialogHeight:701px;dialogWidth:718px";

parent.frames['HiddenFields'].document.getElementById('shdUrlModal').value = appendSessionId("../Global/GLOB002.aspx?BASE=");
ExecShowModal('../Global/GLOBXXX.aspx', "ABOUTGLOB007", sOptions);

return true;
}
function getUploadPath() {
var sRes = "";
var ihdPublicUpload = document.getElementById("ihdPublicUpload");
if (ihdPublicUpload) {
sRes = ihdPublicUpload.value;
}
ihdPublicUpload = null;
return sRes;
}

function pageSpecificIsiScheduleParametersHandling(params) {
return true;
}


function OnDblClickHandler_Overridable(gridName, cellId) {
return true;
}


function BlocPageDesign(codeEcran, idProp, idObj) {
if (codeEcran == 'HELP016') {
if ((idProp == "_filtre") && (idObj == "icbProc")) {
return false;
} else {
return true;
}
}
return false;
}

function mnuStart_onclick(img) {
var navVersion = navigator.appVersion;
if (navVersion.indexOf('MSIE 6.0', 0) != -1) {
img.src = "../../Images/Banner/start-clicked.gif";
}
else {
img.src = "../../Images/Banner/start-clicked.png";
}

var divMenuStart = document.getElementById('DivMenuListe');
var divMenuModule = document.getElementById('BoxModule');

if (divMenuStart != null) {
if (divMenuStart.style.display == "none" || divMenuStart.style.display == "") {
divMenuStart.style.display = "block";
EventManager.add(divMenuStart, "mouseover", window, false);
EventManager.add(divMenuStart, "mouseout", window, false);
if (divMenuModule != null) {
EventManager.add(divMenuModule, "mousemove", window, false);
divMenuModule.style.height = "200px";
}
} else {
if (navVersion.indexOf('MSIE 6.0', 0) != -1) {
img.src = "../../Images/Banner/start.gif";
}
else {
img.src = "../../Images/Banner/start.png";
}
if (!iws_bMouseIsInBox(divMenuStart.offsetTop, divMenuStart.offsetLeft, divMenuStart.offsetWidth, divMenuStart.offsetHeight, mouseY, mouseX, 0, 0)) {
divMenuStart.style.display = "none";
EventManager.remove(divMenuStart, "mouseover", window);
EventManager.remove(divMenuStart, "mouseout", window);
if (divMenuModule != null) {
EventManager.remove(divMenuModule, "mousemove", window);
divMenuModule.style.height = "0px";
}
} else {
closeStartMenu = window.setTimeout("mnuStart_onclick(document.getElementById('StartButton'));", 500);
}
}
}
}

function mnuStart_onmouseover(img) {
var navVersion = navigator.appVersion;
if (navVersion.indexOf('MSIE 6.0', 0) != -1) {
img.src = "../../Images/Banner/start-hover.gif";
}
else {
img.src = "../../Images/Banner/start-hover.png";
}
}

function mnuStart_onmouseout(img) {
var navVersion = navigator.appVersion;
if (navVersion.indexOf('MSIE 6.0', 0) != -1) {
img.src = "../../Images/Banner/start.gif";
}
else {
img.src = "../../Images/Banner/start.png";
}
}

function iws_bMouseIsInBox(boxTop, boxLeft, boxWidth, boxHeight, ctrlTop, ctrlLeft, ctrlWidth, ctrlHeight) {
if (ctrlLeft < boxLeft) return false;

if (ctrlTop < boxTop) return false;

boxLeft2 = boxLeft + boxWidth;
ctrlLeft2 = ctrlLeft + ctrlWidth;
if (ctrlLeft2 > boxLeft2) return false;

boxTop2 = boxTop + boxHeight;
ctrlTop2 = ctrlTop + ctrlHeight;
if (ctrlTop2 > boxTop2) return false;

return true;
}

window.handleEvent = function(oEvent) {
var myEvent = window.event;
switch (myEvent.type) {
case "mouseover":
if (closeStartMenu) {
window.clearTimeout(closeStartMenu);
}
break;
case "mouseout":
closeStartMenu = window.setTimeout("mnuStart_onclick(document.getElementById('StartButton'));", 500);
break;
case "mousemove":
mouseX = event.clientX;
mouseY = event.clientY;
break;
}
myEvent = null;
}

function OnclickModule(sItemclick, sCodeModule) {
var bSubmit = false;
switch (sCodeModule) {
case ModuleAdmin:
if (document.getElementById("ihdCurrentItemmnuModule").value != ModuleAdmin) {
document.getElementById("ihdItemClickmnuModule").value = ModuleAdmin;
bSubmit = true;
}
break;
case ModuleAssetManag:
if (document.getElementById("ihdCurrentItemmnuModule").value != ModuleAssetManag) {
document.getElementById("ihdItemClickmnuModule").value = ModuleAssetManag;
bSubmit = true;
}
break;
case ModuleHelpDesk:
if (document.getElementById("ihdCurrentItemmnuModule").value != ModuleHelpDesk) {
document.getElementById("ihdItemClickmnuModule").value = ModuleHelpDesk;
bSubmit = true;
}
break;
case ModuleInvent:
if (document.getElementById("ihdCurrentItemmnuModule").value != ModuleInvent) {
document.getElementById("ihdItemClickmnuModule").value = ModuleInvent;
bSubmit = true;
}
break;
default:
bSubmit = true;
break;
}

if (bSubmit) {
OnclickItem(sItemclick + '_' + sCodeModule);
poster();
}
}

function OnclickItem(sItemclick) {
document.getElementById('ihdItemClick').value = sItemclick;
ModifWaitStatus(true, true, LOADING);
}

function DisableEnterButton() {
if (bDisabledEnterClick) {
return false;
} else {
bDisabledEnterClick = true;
return true;
}
}
