﻿//ELA
var sListDescIdVisible = '';
var sListDescIdHidden = '';
var bAutomaticReload = true;
var bAdminRefresh = false;
//ELA le 07/04/2009 - Suppression manuelle de fiches template
var nTabToDeleteFrom = 0;
var oDeleteTplid = new Array();
var oDeleteTplidStatus = new Array();
var oDeleteTplidPile = new Array();
var nLastDeletedRecord = 0;
var nPreviousDeletedRecord = 0;
var nRang = 0;

function MsgBox( strMsg, nType, strTitle, strDesc, nShowDetail, oDescContent, nTypeDetail, oReturn )	
{	
	if( strMsg == null )
		strMsg = "";
	if( nType == null )
		nType = 0;
	if( strTitle == null )
		strTitle = "";
	if( strDesc == null )
		strDesc = "";
	if( nShowDetail == null )
		nShowDetail = 0;
	if( nTypeDetail == null )
		nTypeDetail = 0;
	var strReturn = window.showModalDialog( 'MsgBox.asp?msg='+encode( strMsg )+'&type='+nType+'&Detail='+nShowDetail+'&title='+encode( strTitle )+'&desc='+encode( strDesc )+'&typedetail='+nTypeDetail, oDescContent, 'dialogHeight:210px;dialogWidth:400px;edge:Raised;center:1;help:0;resizable:0;status:0');
	if( nTypeDetail > 0 && strReturn != null )
	{
		var aDatas = strReturn.split( '&' );
		oReturn.value = aDatas[1];
		return parseInt( aDatas[0], 10 );
	}
	else
		return strReturn;
	
}

function MsgErr( strTitle )	
{
	if( strTitle == null )
		strTitle = "";
	window.showModalDialog( 'MsgErr.asp?title='+encode( strTitle ), '', 'dialogHeight:150px;dialogWidth:400px;edge:Raised;center:1;help:0;resizable:0;status:0');
}

function InputBox( strTitle, strLabel, strDefaultValue  )	
{
	if( strTitle == null )
		strTitle = "";
	if( strLabel == null )
		strLabel = "";
	if( strDefaultValue == null )
		strDefaultValue = "";
	return window.showModalDialog( 'InputBox.asp?Title='+ encode( strTitle )+'&Label='+ encode( strLabel )+'&Value='+ encode( strDefaultValue ),'','dialogHeight:140px;dialogWidth:350px;edge:Raised;center:1;help:0;resizable:0;status:0' );

}

function showColor( strColor )
{
	return window.showModalDialog( 'SelectColor.asp?color='+encode( strColor ), '', 'dialogHeight:200px;dialogWidth:171px;edge:Raised;center:1;help:0;resizable:0;status:0');
}

// HLA - Cible Etendu - 10/12/2008
// HLA - Mapping des champs "téléphone" et "tel direct" dans les cibles étendues - Dev #9570
function SelectMailTarget( nType )
{
	return window.showModalDialog( 'SelectTargetFields.asp?type='+nType, '', 'dialogHeight:230px;dialogWidth:400px;edge:Raised;center:1;help:0;resizable:0;status:0');
}

function ShowWaitDialog( nType )	
{
	var hWindow;
	try
	{
		hWindow = window.showModelessDialog( 'DialogWait.asp?type='+nType, self, 'dialogHeight:130px;dialogWidth:300px;edge:Raised;center:1;help:0;resizable:0;status:0' );
	}
	catch(e)
	{
		/* SPH & MAB - 20080925 - une fenêtre window.open() est toujours ouverte modale sous FF3 si on l'ouvre depuis une fenêtre qui est elle-même modale (bug de Mozilla ?)
		Par conséquent, l'ouverture forcée de DialogWait en modal bloque l'exécution du script/traitement censé s'effectuer après l'affichage de cette DialogWait */
		/*
		var nTop = Math.round( (screen.availHeight-130) / 2 );
		var nLeft = Math.round( (screen.availWidth-300) / 2 );
		hWindow = window.open( 'DialogWait.asp?type='+nType, '', 'height=130px,width=300px,top='+nTop+'px,left='+nLeft+'px,dependent=yes,titlebar=yes' );
		*/
		
		// workaround : utilisation d'une fenêtre de type popup pour ouvrir DialogWait dans une iframe, ce qui ne bloque plus le traitement
		// requiert l'inclusion de crossBrowser.js dans la page appelante
		hWindow = window.createAlternatePopup(true, 'DialogWait.asp?type='+nType, '', '' );
		hWindow.show(0, 0, "100%", "100%", document.body);
	}
	return hWindow;
}

function OpenWaitDialog(strType, strCallBack)
{
	try
	{
		top.frames['FraWait'].location = "DialogWaitParent.asp?type="+strType+"&callback="+encode( strCallBack );
	}
	catch(e){}
}

function SetCustomMsg(strMsg)
{
	try
	{
		top.frames['FraWait'].SetCustomMsg(strMsg);
	}
	catch(e){}
}

function CloseWaitDialog()
{
	try
	{
		top.frames['FraWait'].CloseWaitDialog();
	}
	catch(e){}
}

function showFileDialog( nTab, nFileId, nTabFrom, oDialogArgument, nPpId, nPmId, nEvtId, nAdrId, strOptionalParam, nDialogHeight, nDialogWidth )
{
	if( !nFileId )				nFileId = 0;
	if( !nPpId )				nPpId = 0;
	if( !nPmId )				nPmId = 0;
	if( !nEvtId )				nEvtId = 0;
	if( !nAdrId )				nAdrId = 0;
	if( !nTabFrom )				nTabFrom = 0;
	if( !oDialogArgument )		oDialogArgument = top.frames;
	if( !strOptionalParam )		strOptionalParam = "";
	if( strOptionalParam.substr( 0, 1 ) != "&" )	
		strOptionalParam = "&"+ strOptionalParam;

	if( !nDialogHeight )		nDialogHeight = 0;
	if( nDialogHeight < 100 )	nDialogHeight = 300;
	if( !nDialogWidth )			nDialogWidth = 0;
	if( nDialogWidth < 100 )	nDialogWidth = 800;

	/* MAB V7 - 20080717 - URL absolue nécessaire afin de pouvoir afficher la popup depuis le menu contextuel du planning */
		
	var baseURL = window.location.href.substring(0, window.location.href.lastIndexOf('/') + 1);
	return window.showModalDialog( baseURL + 'FileDialogParent.asp?Tab='+nTab+'&FileId='+nFileId+'&TabFrom='+nTabFrom+'&PpId='+nPpId+'&PmId='+nPmId+'&EvtId='+nEvtId+'&AdrId='+nAdrId+strOptionalParam, oDialogArgument, 'edge:Raised;center:1;help:0;resizable:0;status:0;dialogHeight:'+ nDialogHeight +'px;dialogWidth:'+ nDialogWidth +'px;' );
}

function showFile( nTab, nFileId, nTabFrom )
{
        var nScrollPos = 0;
	var strFieldId = "";
	if( nTab == 100 )
		strFieldId = 'EVTId';
	else if( nTab == 200 )
		strFieldId = 'PPId';
	else if( nTab == 300 )
		strFieldId = 'PMId';
	else
		strFieldId = 'TPLId_'+ nTab;

    if ( nTabFrom == null ) nTabFrom = 0;
    if ( nTabFrom > 0 )
        nScrollPos = document.body.scrollTop;

	if( top.frames['FraParam'] && top.frames['FraParam'].document.getElementById( strFieldId ) && top.frames['FraParam'].document.getElementById("Rows") )
	{
		top.frames['FraParam'].document.getElementById( strFieldId ).value = nFileId;
        if ( nTabFrom > 0 && top.frames['FraParam'].document.getElementById( 'Scroll_' + nTabFrom ))
    		top.frames['FraParam'].document.getElementById( 'Scroll_' + nTabFrom ).value = nScrollPos;
		top.frames['FraTop'].SetTab( nTab );
	}
	else if(top.opener && top.opener.top)
	{
		
		if( top.opener.top.frames['FraParam'] && top.opener.top.frames['FraParam'].document.getElementById( strFieldId ) )
		{		
			top.opener.top.frames['FraParam'].document.getElementById( strFieldId ).value = nFileId;
			top.opener.top.frames['FraTop'].SetTab( nTab );
			if ( nTabFrom > 0 && top.opener.top.frames['FraParam'].document.getElementById( 'Scroll_' + nTabFrom ) )
				top.opener.top.frames['FraParam'].document.getElementById( 'Scroll_' + nTabFrom ).value = nScrollPos;
			top.close();		
		}
	}
	else if(window.parent && window.parent.dialogArguments &&window.parent.dialogArguments.top.frames['FraParam'] )
	{

		window.parent.dialogArguments.top.frames['FraParam'].document.getElementById( strFieldId ).value = nFileId;
		window.parent.dialogArguments.top.frames['FraTop'].SetTab( nTab );
		if ( nTabFrom > 0 && window.parent.frames['FraParam'].document.getElementById( 'Scroll_' + nTabFrom ) )
			window.parent.dialogArguments.top.frames['FraParam'].document.getElementById( 'Scroll_' + nTabFrom ).value = nScrollPos;
		top.close();		
	}
}

function showFilePlanning(nTab, strMode, strUserId, strDate)
{

	var nRefresh = 9;
	if (bAdminRefresh)
	{
	nRefresh = 10;
	bAdminRefresh = false;
	}
	if( !strDate )
		strDate = '';
	    top.frames['FraTmp'].location = 'PrefTreatment.asp?Refresh='+nRefresh+'&PrefTab='+nTab+'&PrefField=viewmode&Value='+encode(strMode)+'&Menu=1&UserId='+strUserId+'&Date='+encode(strDate);
}

function showFileTemplate(nTab, nType)
{
    document.location = 'NavBar.asp?tab='+nTab;
}

function FilterRec(nTab)	
{
	var nTop = (screen.availHeight-380) / 2;
	var nLeft = (screen.availWidth-650) / 2;
	window.open( 'FilterList.asp?Tab='+nTab, '', 'width=650,height=350,top='+nTop+',left='+nLeft+',dependent=yes,titlebar=yes' );
}

function FilterCancel(nTab)	
{
	top.frames['FraTmp'].location = 'FilterCancel.asp?Tab='+nTab;
}
function SearchRecMRU( nTab )	
{
	SearchRec('?type=0&tab='+nTab+'&tabfrom='+nTab);
}

function SearchRec( strParam )	
{
	var	nTop = ( screen.availHeight - 300 ) / 2; 
	var nLeft = ( screen.availWidth - 700 ) / 2;
	var nHeight = 275;
	var bWithSelection = ( strParam.indexOf( 'WithSelection=1', 1 ) > - 1 )
	
	if( bWithSelection )
		nHeight = 400;
	
	/* MAB V7 - 20080711 - Firefox requiert une URL absolue pour l'ouverture de popups lorsqu'elle est réalisée depuis une popup... */
	// récupération de la racine de l'URL de la fenêtre actuelle en vue de pouvoir afficher les images de la popup
	var appPath = window.location.href.substring(0, window.location.href.lastIndexOf('/') + 1);	
	window.open(window.location.href.substring(0, window.location.href.lastIndexOf('/') + 1) + 'Search.asp'+strParam, null, 'width=700,height='+nHeight+',top='+nTop+',left='+nLeft+',dependent=yes,titlebar=yes,resizable=yes,status=no');
}

function SearchRecAdv( strParam )
{
	var	nTop = ( screen.availHeight - 300 ) / 2; 
	var nLeft = ( screen.availWidth - 700 ) / 2;
	var strData = window.showModalDialog( 'FileSearchParent.asp'+strParam, top.frames, 'dialogHeight:420px;dialogWidth:700px;edge:Raised;center:1;help:0;resizable:1;status:0' );
	var strReload = '';
	if( strData )
	{
		aData = parseQueryString( strData );
		nPpId =	getArrayValue( aData, 'PPID' );
		nPmId = getArrayValue( aData, 'PMID' );
		nEvtId = getArrayValue( aData, 'EVTID' );
		nAdrId = getArrayValue( aData, 'ADRID' );
		nTab = getArrayValue( aData, 'TAB' );
		nType = getArrayValue( aData, 'TYPE' );
		strAction = getArrayValue( aData, 'ACTION' );
		strFile = getArrayValue( aData, 'FILE' );
		strDefault = getArrayValue( aData, 'DEFAULT' );
		strReload = getArrayValue( aData, 'RELOAD' );
		nAdrAuto = getArrayValue( aData, 'ADRAUTO' );
		nAutoBuildName = getArrayValue( aData, 'AUTOBUILDNAME' );
		
		if( top.frames['FraTmp'] )
			var oTmp = top.frames['FraTmp'];
		else if( top.opener.top.frames['FraTmp'] )
			var oTmp = top.opener.top.frames['FraTmp'];
		else
			var oTmp = top.opener.top.opener.top.frames['FraTmp'];
			
		if( strAction == 'ADDTPL')
		{
			strData = AddTpl( nTab );
		}
		else if( strAction == 'SHOWTPL')
		{
			strData = ShTpl( nTab, nEvtId );
		}
		else if( strAction == 'SHOWMAIN')
		{	
			SPV( 'PPId', nPpId, true );
			SPV( 'PMId', nPmId, true );
			if( nTab >= 1000 )
				SPV( 'TPLId_'+nTab, nEvtId, true );
			else
				SPV( 'EVTId', nEvtId, true );
			top.frames['FraTop'].SetTab( nTab );
		}
			
		else if( strAction == 'ADDMAIN' )
		{
			oTmp.location = 'AddNewRecord.asp?Type='+nType+'&File='+encode(strFile)+'&Default='+encode(strDefault)+'&PmId='+nPmId+'&PpId='+nPpId;
		}
		else if ( strAction == 'ADDEVT' )
		{
			//Nom event en construction auto
			if( nAutoBuildName == 1 )
				AddEvt( nTab );
			else
				AddEvt( nTab, true, '', 0, 0, strDefault );
		}
		else if( strAction == 'ADDADR' )
		{
			if(  nAdrAuto == 1 )
				AddAdr( nPpId, nPmId, true, 0, false);
			else
				AddAdr( nPpId, nPmId, false, 0, false);
		}
	}
	if( strReload == '1')
	{
		top.frames['FraDetail'].location.reload();
	}
}

function FindRec( strParam )	
{
	return window.showModalDialog( 'Finder.asp'+strParam, top.frames, 'dialogHeight:250px;dialogWidth:650px;edge:Raised;center:1;help:0;resizable:1;status:0' );
}

function AddEvt( nEventTab, bDialog, strFile, nFileId, nType, strDefault, strTargetField, nMulti ,nRandom)
{
	if( !strFile )
		strFile = "";
	if( !strDefault )
		strDefault = "";
	if( !strTargetField )
		strTargetField = "";
	if( !nFileId )
		nFileId = 0;
	if( !nType )
		nType = 0;
	if ( !nMulti )
		nMulti = 0;
    if ( !bDialog ) 
        bDialog = false
	if(!nRandom)
		nRandom = '';
    var nDialog = 0;
    if ( bDialog ) nDialog = 1;

	if( top.frames['FraTmp'] )
	{
		var oTmp = top.frames['FraTmp'];
	}
	else if( top.opener.top.frames['FraTmp'] )
	{
		var oTmp = top.opener.top.frames['FraTmp'];
	}
	else
	{
		var oTmp = top.opener.top.opener.top.frames['FraTmp'];
	}

	if( top.frames['FraTop'] )
	{
		var oTop = top.frames['FraTop'];
	}
	
    if ( !bDialog )
    {
        try
        {
            if ( !oTop.TabExist( nEventTab ) ) 
            {
                bDialog = true;
                nDialog = 1;
            }
        }
        catch(e){}
    }
    
	if( bDialog )
	{
		var strEvent = window.showModalDialog( 'EvtFiche.asp?tab='+nEventTab+'&new=1&file='+encode(strFile)+'&fileid='+nFileId+'&def='+encode(strDefault)+'&Multi='+nMulti, top.frames, 'dialogHeight:200px;dialogWidth:910px;edge:Raised;center:1;help:0;resizable:0;status:0' );
		if( strEvent )
		{
			// JLA #9358
			if(nMulti != 0)
				OpenWaitDialog('0', '');
			var strFunction = "LaunchTreatment(" + nEventTab + ", " + nDialog + ", '" + strFile + "', " + nFileId + ", " + nType + ", '" + strDefault +"', '" + strTargetField + "', " + nMulti + ", '" + nRandom + "', '" + strEvent + "');";
			setTimeout(strFunction , 500);
		}
	}
	else
	{
		queryStringToPost(oTmp, 'EvtCreate.asp', 'tab='+nEventTab+'&targetfield='+encode(strTargetField)+'&Multi='+nMulti+'&new=1&file='+encode(strFile)+'&fileid='+nFileId+'&Dialog='+nDialog+'&strRandom='+nRandom);
	}
}

// JLA #9358
function LaunchTreatment(nEventTab, nDialog, strFile, nFileId, nType, strDefault, strTargetField, nMulti ,nRandom, strEvent) {
	if( top.frames['FraTmp'] )
	{
		var oTmp = top.frames['FraTmp'];
	}
	else if( top.opener.top.frames['FraTmp'] )
	{
		var oTmp = top.opener.top.frames['FraTmp'];
	}
	else
	{
		var oTmp = top.opener.top.opener.top.frames['FraTmp'];
	}
	/* SPH/MAB - 20090422 - bug #9453/#9593 - passage des champs à mettre à jour en POST et non en GET pour outrepasser la limite de 2083 caractères en GET */	
	queryStringToPost(oTmp, 'EvtCreate.asp', 'tab='+nEventTab+'&file='+encode(strFile)+'&fileid='+nFileId+'&'+strEvent+'&type='+nType+'&targetfield='+encode(strTargetField)+'&Multi='+nMulti+'&Dialog='+nDialog+'&strRandom='+nRandom);
}

/* SPH/MAB - 20090422 - bug #9453/#9593 - fonction permettant de transposer une requête GET en requête POST pour outrepasser la limite de 2083 caractères en GET */
function queryStringToPost(oTargetWindow, strTargetPage, strQueryString) {
	var bIsIE = ((sUserAgent.indexOf("msie") != -1) && (sUserAgent.indexOf("opera") == -1) && (sUserAgent.indexOf("webtv") == -1));

	var parameters = strQueryString.split('&');
	
	var formToPost = oTargetWindow.document.createElement('form');
	formToPost.id = "submitForm";

	for (var i = 0; i < parameters.length; i++) {
		var param = parameters[i].split('=');
		
		var input =  oTargetWindow.document.createElement('<input>');
		input.setAttribute("NAME", '' + param[0]);
		input.id = '' + param[0];
		input.type = 'hidden';
		input.value = decode(param[1]);
		
		formToPost.appendChild(input);	
	}
	
	formToPost.method = "POST";
	formToPost.action = strTargetPage;
	
	if(bIsIE)
		oTargetWindow.document.body.innerHTML = formToPost.outerHTML;
	else
		oTargetWindow.document.body.appendChild(formToPost);

	oTargetWindow.document.getElementById("submitForm").submit();
}

function showFileDialogClone( nTab, nFileId, nMulti )
{
	if( !nFileId )
		nFileId = 0;
	if ( !nMulti )
		nMulti = 0;
	
	var strDuplicate = window.showModalDialog( 'FileDialogClone.asp?tab='+nTab+'&fileid='+nFileId+'&Multi='+nMulti, top.frames, 'dialogHeight:380px;dialogWidth:850px;edge:Raised;center:1;help:0;resizable:0;status:0' );
}

function ShEvt( nEventTab, nEvtId )	{

	var strEvent = window.showModalDialog( 'EvtFiche.asp?tab='+nEventTab+'&new=0&evtid='+nEvtId, top.frames, 'dialogHeight:200px;dialogWidth:700px;edge:Raised;center:1;help:0;resizable:0;status:0' );

	if( strEvent )	{
		if( strEvent == '-1' )
			top.frames['FraTmp'].location = 'Delete.asp?tab='+nEventTab+'&FileId='+nEvtId;
		else {
			/* SPH/MAB - 20090720 - bug #9797 (portage #9453/#9593) - passage des champs à mettre à jour en POST et non en GET pour outrepasser la limite de 2083 caractères en GET */
			queryStringToPost(top.frames['FraTmp'],'EvtUpdate.asp','tab='+nEventTab+'&evtid='+nEvtId+'&'+strEvent);
		}
	}
}

function AddTpl( nTab, nEvtId, nPpId, nPmId, nTabFrom, nMulti, nType, nParentEvtId, nParentTplTab, strDefDate, nDialogHeight, nDialogWidth, strDefOwner, strDefRecipients, nFileIdFrom, nMasterMailId , nRandom, bAdvancedEmailingEnabled, nEventTabFrom)
{
	var is_ie = ( (navigator.userAgent.toLowerCase().indexOf("msie")!=-1) && (navigator.userAgent.toLowerCase().indexOf("opera")==-1) );
	if(!nEventTabFrom)
	{
		nEventTabFrom = 0;
	}
	if( !nDialogHeight )		nDialogHeight = 0;
	if( nDialogHeight < 100 )	nDialogHeight = 300;
	if( !nDialogWidth )			nDialogWidth = 0;
	if( nDialogWidth < 100 )	nDialogWidth = 840; // MAB - taille utilisée en v5

	if( !nMasterMailId )
		nMasterMailId = 0;
	if( !nMulti )
		nMulti = 0;
	if( !nFileIdFrom )
		nFileIdFrom = 0;
	if (!nRandom)
		nRandom = 0;
	if( !strDefOwner )
		strDefOwner = "";
	if( !strDefRecipients )
		strDefRecipients = "";
		
	/* MAB V7 - 20080717 - URL absolue nécessaire afin de pouvoir afficher la popup depuis le menu contextuel du planning */
	var baseURL = window.location.href.substring(0, window.location.href.lastIndexOf('/') + 1);
	// HLA - Taille fixe pour FireFox
	// MAB - à faire également sur IE
	//if( !is_ie )
	//{
		nDialogHeight = 650;
		nDialogWidth = 840;
	//}
	if (!bAdvancedEmailingEnabled)
	{
		var bAdvancedEmailingEnabled = false;
	}
	// JBE - Mailing	
	if (nMulti > 0 && nType ==3 && bAdvancedEmailingEnabled )
	{
		window.showModalDialog( 'TplMailing.asp?eventtabfrom='+ nEventTabFrom +'&new=1&Type='+nType+'&multi='+nMulti+'&tabfrom='+nTabFrom+'&fileidfrom='+nFileIdFrom+'&tab='+nTab+'&evtid='+nEvtId+'&ppid='+nPpId+'&pmid='+nPmId+'&parentevtid='+nParentEvtId+'&parenttpltab='+nParentTplTab+'&defdate='+encode(strDefDate)+'&defowner='+encode(strDefOwner)+'&defrecipients='+encode(strDefRecipients), top.frames, 'edge:Raised;center:1;help:0;resizable:0;status:0;dialogHeight:'+ nDialogHeight +'px;dialogWidth:'+ nDialogWidth +'px;' );
		
		return;
	}
	
	var strDatas = window.showModalDialog( baseURL + 'TplFiche.asp?new=1&Type='+nType+'&multi='+nMulti+'&tabfrom='+nTabFrom+'&fileidfrom='+nFileIdFrom+'&tab='+nTab+'&evtid='+nEvtId+'&ppid='+nPpId+'&pmid='+nPmId+'&parentevtid='+nParentEvtId+'&parenttpltab='+nParentTplTab+'&defdate='+encode(strDefDate)+'&defowner='+encode(strDefOwner)+'&defrecipients='+encode(strDefRecipients)+'&MasterMailId='+nMasterMailId, top.frames, 'edge:Raised;center:1;help:0;resizable:0;status:0;dialogHeight:'+ nDialogHeight +'px;dialogWidth:'+ nDialogWidth +'px;' );

	if( strDatas )	
	{

        var aDatas = parseQueryString( strDatas );
		var nFileId = getArrayValue( aDatas , 'FileId' );	
		if( nFileId == null )
		    nFileId = 0;
		if( isNaN( nFileId ) )
		    nFileId = 0;
	
		if( strDatas.substring(0,2) == '-1' )
		{
			top.frames['FraTmp'].location.replace( 'TplDelete.asp?'+strDatas.substring(3,strDatas.length) );
		}
		else if( strDatas.substring(0,2) == '-2' )
		{
				var aDatas = strDatas.split( '&' );
				var nTabToShow = parseInt( aDatas[1] );
				top.frames['FraTop'].SetTab( nTabToShow );
		}
		else if( nFileId != 0 )
		{
			var oFrm = document.getElementById('frmDlg'+nTab);
			if( oFrm.DialogValue )
			{
				oFrm.DialogValue.value = 'asp=TplUpdate.asp&'+strDatas; 
			}
			oFrm.submit();
		}
		else 
		{
			var oFrm = document.getElementById('frmDlg'+nTab);

			if( oFrm.DialogValue ) {
				// HLA - Ajout de la wait dialog pour avoir le compteur des enregistrements fait en temps réel
				if(nMulti != 0)
					OpenWaitDialog('0', '');
				
				var strFunction = "LaunchTreatmentTpl(" + nTab + ", " + nMulti + ", " + nRandom + ", '" + strDatas + "');";
				// HLA - Permet d'attendre que la WaitDialog s'ouvre avant le lancement du traitement
				setTimeout(strFunction, 500);
			}
			else
				oFrm.submit();
			
			if( nMulti != 0 )
				return 1;
		}
		if( strDatas.indexOf('&TabLink=') > 0 )
		{
			GoToLink( strDatas );
		}
	}
	else
	{
		if( nMulti != 0 )
		{
			return 0;
		}
	}
}

function LaunchTreatmentTpl(nTab, nMulti, nRandom, strDatas) {
	var oFrm = document.getElementById('frmDlg'+nTab);
	
	if( nMulti == 3  ) {
		oFrm.DialogValue.value = 'target=FraSelectTmp2&asp=TplCreate.asp&nRandom='+ nRandom +'&'+strDatas;
	}
	else {
	
		oFrm.DialogValue.value = 'asp=TplCreate.asp&nRandom='+ nRandom +'&'+strDatas;
	}
	
	oFrm.submit();
}

function ShTpl( nTab, nFileId, nTabFrom, nAutoOpenPj, nDialogHeight, nDialogWidth, nScheduleId, bAskScheduleSelect, e)	
{

var bShifKey = detectionShift(e);
var bCtrlKey = detectionCtrl(e);

if (bCtrlKey == false && bShifKey == false)
	{
	
		//ELA le 07/04/2009 - Suppression manuelle de fiches template
		CancelDeleteSelection();
		
		if( !nDialogHeight )		nDialogHeight = 0;
		if( nDialogHeight < 100 )	nDialogHeight = 300;
		if( !nDialogWidth )			nDialogWidth = 0;
		if( nDialogWidth < 100 )	nDialogWidth = 840;
		if( !nScheduleId )			nScheduleId = 0;
		if( bAskScheduleSelect == null )	bAskScheduleSelect = true;

		if( nTab == 100000 ) // TAB_HISTO
		{
			var strDatas = showFileDialog( nTab, nFileId );
			if( strDatas )	
			{
				if( strDatas.substring(0,2) == '-1' )
					top.frames['FraTmp'].location = 'TplDelete.asp?tab='+nTab+'&FileId='+nFileId;
			}
		}
		else
		{
			/* MAB V7 - 20080717 - URL absolue nécessaire afin de pouvoir afficher la popup depuis le menu contextuel du planning */
			var baseURL = window.location.href.substring(0, window.location.href.lastIndexOf('/') + 1);		
			
			if( !nAutoOpenPj )
				nAutoOpenPj = 0;
				
			var strSerie = '0';
			
			if( nScheduleId != 0 && bAskScheduleSelect )
			{
				// HLA - Appel depuis le mode mois sur le planning sur une popup, correction pour FF3 - 22/10/2008
				strSerie = window.showModalDialog( baseURL + 'ScheduleSelect.asp', '', 'dialogHeight:170px;dialogWidth:350px;edge:Raised;center:1;help:0;resizable:0;status:0' );
				if( strSerie == null )
					return;
			}
			else
				strSerie = '1';
			
			var strDatas = window.showModalDialog( baseURL + 'TplFiche.asp?new=0&tabfrom='+nTabFrom+'&tab='+nTab+'&FileId='+nFileId+'&AutoOpenPj='+nAutoOpenPj+'&OpenSerie='+strSerie+'&ScheduleId='+nScheduleId, top.frames, 'edge:Raised;center:1;help:0;resizable:0;status:0;dialogHeight:650px;dialogWidth:800px;' );
			if( strDatas )	
			{
				var strDatasTemp = strDatas;
				if( strDatas.indexOf('MasterMailId=') >= 0 && strDatas.indexOf('MasterMailId=0') == -1 )
				{
					var aDatas = parseQueryString ( strDatas );
					var nMasterMailId = getArrayValue ( aDatas , 'MasterMailId' );
					var nEvtId = getArrayValue ( aDatas , 'EvtId' );
					var nPpId = getArrayValue ( aDatas , 'PpId' );
					var nPmId = getArrayValue ( aDatas , 'PmId' );
					var nMulti = getArrayValue ( aDatas , 'Multi' );
					var nType = getArrayValue ( aDatas , 'Type' );
					var nFileIdFrom = getArrayValue ( aDatas , 'FileIdFrom' );
					AddTpl( nTab, nEvtId, nPpId, nPmId, nTabFrom, nMulti, nType, 0, 0,0 ,nDialogHeight, nDialogWidth,0 ,'' ,nFileIdFrom , nMasterMailId );
				}			
				else if( strDatas.substring(0,2) == '-1' )
				{
					top.frames['FraTmp'].location = 'TplDelete.asp?tab='+nTab+'&FileId='+nFileId+'&ScheduleId='+nScheduleId+'&OpenSerie='+strSerie;
				}
				else	
				{			
					var oFrm = document.getElementById('frmDlg'+nTab);
					if( oFrm.DialogValue )					
						oFrm.DialogValue.value = 'asp=TplUpdate.asp&'+strDatas+'&ScheduleId='+nScheduleId+'&OpenSerie='+strSerie;				
					oFrm.submit();
				}
				if( strDatas.indexOf('&TabLink=') > 0 )
				{
					GoToLink( strDatas );			
				}
			}
		}
	}
else
	{
	//ELA le 07/04/2009 - Suppression manuelle de fiches template
	if (bShifKey == true)
		{
		var bDown = false;
		var nFirstIndex = GetFileIdIndex(nLastDeletedRecord, nTab);
		var nLastIndex = GetFileIdIndex(nFileId, nTab);
		if (nFirstIndex >= nLastIndex)
			{
			if (oDeleteTplidStatus[nFirstIndex] == 1)
				{
				if (bDown == true) nFirstIndex = nFirstIndex - 1;
				bDown = false;
				}
			}
		else
			{
			if (oDeleteTplidStatus[nFirstIndex] == 1)
				{
				if (bDown == false) nFirstIndex = nFirstIndex + 1;
				bDown = true;
				}
			}
		SetFileIdStatus(nFirstIndex, nLastIndex, nTab);	
		}
	else
		{
		//ELA le 07/04/2009 - Suppression manuelle de fiches template
		var nLastIndex = GetFileIdIndex(nFileId, nTab);
		SetFileIdStatus(nLastIndex, nLastIndex, nTab);
		nTabToDeleteFrom = nTab;
		}
	}
	if (document.getElementById('ednlist_'+nTab))
		{
		window.focus();
		}
}

function GetFileIdIndex(nFileId, nTab)
{
var oTable = document.getElementById('ednlist_'+nTab);
if (oTable)
	{
	var oRecords = oTable.getElementsByTagName('tr');
	if (oRecords)
		{
		for (i=0;i<=oRecords.length-1;i++)
			{
			var sId = oRecords[i].getAttribute('id');
			if (sId.indexOf('Tr_Main') > -1)
				{
				var oId = sId.split('_');
				sId = 'TR_'+oId[3];
				}
			if (sId.indexOf('TR_') > -1)
				{
				sId = sId.replace('TR_','');
				}
			if (nFileId == sId) return i;
			}
		}
	else
		{
		return -1;
		}
	}
else
	{
	return -1;
	}
}

function SetFileIdStatus(nFirstIndex, nLastIndex, nTab)
{
var oTable = document.getElementById('ednlist_'+nTab);
strImgOrig = document.getElementById('PICTO_ORIG_'+nTab).value;
if (oTable)
	{
	var oRecords = oTable.getElementsByTagName('tr');
	if (oRecords)
		{
		if (nFirstIndex < nLastIndex)
			{
			for (i=nFirstIndex;i<=nLastIndex;i++)
				{
				SetFileIdTreatment(oRecords, i);
				}
			}
		else
			{
			for (i=nFirstIndex;i>=nLastIndex;i--)
				{
				SetFileIdTreatment(oRecords, i);
				}
			}
		}
	}
}

function SetFileIdTreatment(oFiles, x)
{
	var sId = oFiles[x].getAttribute('id');
	if (sId.indexOf('Tr_Main') > -1)
		{
		var oId = sId.split('_');
		sId = 'TR_'+oId[3];
		}
	if (sId.indexOf('TR_') > -1)
		{
		sId = sId.replace('TR_','');
		}
	oDeleteTplid[x] = sId;
	if (oDeleteTplidStatus[x] == 1)
		{
		document.getElementById('IMG_'+sId).parentNode.parentNode.style.backgroundColor = '';
		document.getElementById('IMG_'+sId).src = strImgOrig;
		oDeleteTplidStatus[x] = 0;
		nLastDeletedRecord = oDeleteTplidPile[nRang-2];
		nRang--;
		}
	else
		{
		document.getElementById('IMG_'+sId).parentNode.parentNode.style.backgroundColor = '#F0F0ED';
		document.getElementById('IMG_'+sId).src = strImgDelete;
		oDeleteTplidStatus[x] = 1;
		nLastDeletedRecord = sId;
		oDeleteTplidPile[nRang] = sId;
		nRang++;
		}
}

function GoToLink( strDatas )
{
	var aReturn = parseQueryString( strDatas );
	var nTabToShow = getArrayValue( aReturn, "TabLink" );
	var nFileIdLink = getArrayValue( aReturn, "FileLink" );
	
	showFile( nTabToShow, nFileIdLink );
}

function AddTplSelect( nTab, nEvtId, nPpId, nPmId, nTabFrom, nMulti )
{
	
	if( !nMulti )
		nMulti = 0;
	/* MAB V7 - 20080717 - URL absolue nécessaire afin de pouvoir afficher la popup depuis le menu contextuel du planning */
	var baseURL = window.location.href.substring(0, window.location.href.lastIndexOf('/') + 1);		
	var strDatas = window.showModalDialog( baseURL + 'TplSelect.asp?new=1&multi='+nMulti+'&tabfrom='+nTabFrom+'&tab='+nTab+'&evtid='+nEvtId+'&ppid='+nPpId+'&pmid='+nPmId, '', 'dialogHeight:170px;dialogWidth:350px;edge:Raised;center:1;help:0;resizable:0;status:0' );
	if( strDatas )
	{
		AddTpl( nTab, nEvtId, nPpId, nPmId, nTabFrom, nMulti, strDatas );
	}
}

function AddExTpl( nTab, nEvtId, nTabFrom )
{
	var	nTop = ( screen.availHeight - 400 ) / 2; 
	var nLeft = ( screen.availWidth - 720 ) / 2;
	window.open( 'SelectQuery.asp?delete=0&tabfrom='+nTabFrom+'&tab='+nTab+'&evtid='+nEvtId+'&bCancelExpressFilter=1', '', 'width=720,height=400,top='+nTop+',left='+nLeft+',dependent=yes,titlebar=yes,resizable=yes' );
}

function DelExTpl( nTab, nEvtId, nTabFrom )
{
	var	nTop = ( screen.availHeight - 400 ) / 2; 
	var nLeft = ( screen.availWidth - 720 ) / 2;
	window.open( 'SelectQuery.asp?delete=1&tabfrom='+nTabFrom+'&tab='+nTab+'&evtid='+nEvtId, '', 'width=720,height=400,top='+nTop+',left='+nLeft+',dependent=yes,titlebar=yes,resizable=yes' );
}

function Chart(nTab)	
{	
	var	nTop = ( screen.availHeight - 350 ) / 2; 
	var nLeft = ( screen.availWidth - 620 ) / 2;
	var strReturn = window.open('ChartWizard.asp?TabFrom='+nTab,'','width=650,height=350,top='+nTop+',status=yes,left='+nLeft+',dependent=yes,titlebar=yes,resizable=yes,scrollbars=no' );
}

function Import(nTab, nTabFrom, nFileId)	
{	
	var	nTop = ( screen.availHeight - 350 ) / 2; 
	var nLeft = ( screen.availWidth - 820 ) / 2;
	var strReturn = window.open('ImportWizard.asp?tabfrom='+nTabFrom+'&tab='+nTab+'&page=1&new=1&fileid='+nFileId,'','width=850,height=350,top='+nTop+',status=no,left='+nLeft+',dependent=yes,titlebar=yes,resizable=no,scrollbars=no' );
}

function Report( nMode, nTypeReport, nTab, nFromBkm, nFileId )	
{
	if( isNaN( nTypeReport ) )
		nTypeReport = 0;
	
	//HLA - Refonte de l'impression du mode fiche  - 02/07/08 - Refonte #8788

	var strReturn = window.showModalDialog( 'ReportList.asp?TypeReport='+nTypeReport+'&TabFrom='+nTab+'&FromBkm='+nFromBkm+'&FileId='+nFileId, '', 'dialogHeight:325px;dialogWidth:640px;edge:Raised;center:1;help:0;resizable:0;status:0' );
	if( strReturn != null )
	{
		//HLA - Refonte de l'impression du mode fiche  - 02/07/08 - Refonte #8788
		if( strReturn == 'PRINTEXPRESS')
		{
			var nLeft = ( screen.availWidth - 550 ) / 2;
			var nTop = ( screen.availHeight - 350 ) / 2;
			window.open( 'ReportWizardFiche.asp?FileId='+nFileId+'&Tab='+nTab,'','top='+nTop+',left='+nLeft+',dependent=yes,width=550,height=350,titlebar=yes' );
		}
		else
		{
			var qs = "";
			aReturn = strReturn.split( "&" );
			for( var i = 0 ; i < aReturn.length ; i++ )
			{
				strItems = aReturn[i];
				aItems = strItems.split( "=" );
				
				strField = decode( aItems[0] );
				strValue = decode( aItems[1] );
				strField = strField.toLowerCase();
				if( strField == "param" )
				{
					top.frames['FraParam'].document.getElementById("Report").value = strValue;
				}
				if( strField == "qs" )
				{
					qs = strValue;
				}
			}
			
			if( nTypeReport == 7 )
				window.open( 'ReportPrintFiche.asp?'+qs );
			else
				top.frames['FraTmp'].location.replace( 'Report.asp?'+qs );
		}
	}
}

function AddAdr( nPpId, nPmId, bAutoBuilt, nRefreshWindow, bCloseWindow, nTabFrom, bUpdateAdrId , nRow, nCol)
{
	if( !bAutoBuilt ) 
	{
		if (!nTabFrom )
			nTabFrom = 0;


		strReturn = showFileDialog( 400, 0, nTabFrom, null, nPpId, nPmId,null,null,'',nCol,nRow );
		if( strReturn )
		{
			if( nRefreshWindow == 1 )
			{
				var bFinded = false;
				try
				{
					if(!bFinded){ 
						var oWin = top.opener.top.frames['FraDetail'];
						bFinded = true;
					}
				} catch(ex){}
				
				try
				{
					if(!bFinded){
						var oWin = top.frames['FraDetail'];
						bFinded = true;
					}
				} catch(ex){}
			
				if( oWin )
				{
					if (oWin.document.getElementById('TABLE_400'))
					{
						var strEdnParam = oWin.document.getElementById('TABLE_400').getAttribute('ednParam');
					}
					else
					{
						var strEdnParam = oWin.document.getElementById('TABLE_200').getAttribute('ednParam');
					}
					oWin.TabClick(strEdnParam);
				}
				
			}
			else if( nRefreshWindow != 0 )
			{
				if( top.frames['FraDetail'] )
					{
					if (top.frames['FraDetail'].document.getElementById('TABLE_400'))
						{
						var strEdnParam = top.frames['FraDetail'].document.getElementById('TABLE_400').getAttribute('ednParam');
						}
					else
						{
						var strEdnParam = top.frames['FraDetail'].document.getElementById('TABLE_200').getAttribute('ednParam');
						}
					top.frames['FraDetail'].TabClick(strEdnParam);
					}
			}

			if( bUpdateAdrId )
			{
				var strAdrId = GetUrlValue(strReturn, "ADRId");
				if ( document.getElementById("ADRId") )
					document.getElementById("ADRId").value = strAdrId;
			}
		}
		if( bCloseWindow )
			top.close();
	}
	else
	{
		var nCloseWindow = 0;
		var nUpdateAdrId = 0;
		var nNoRefresh = 1;
		if ( bCloseWindow ) nCloseWindow = 1;
		if ( bUpdateAdrId ) nUpdateAdrId = 1;
		if ( nRefreshWindow == 0 ) nNoRefresh = 1;

		var oFrm = document.getElementById( 'frmDlg400' );
		if( oFrm.DialogValue )	
		{
			oFrm.DialogValue.value = 'asp=AdrCreate.asp&autobuilt=1&target=_self&closewindow='+nCloseWindow+'&updateadrid='+nUpdateAdrId+'&Refresh='+nRefreshWindow+'&NoRefresh='+nNoRefresh+'&pmid='+nPmId+'&ppid='+nPpId;
		}
		oFrm.submit();
	}
}

function GetUrlValue(strUrl, strTag)
{
	var strReturnValue = "";
	var aFields = strUrl.split("&");
	var aData;
	for ( i=0 ; i<aFields.length ; i++)
	{
		aData = aFields[i].split("=");
		if ( aData.length >= 2 )
		{
			if ( aData[0] = strTag )
			{
				strReturnValue = aData[1];
				break;
			}
		}
	}
	return strReturnValue;
}

function SelectItem( cboTarget, strValue )	
{
	if( !cboTarget )
		return;
	
	for( var j = 0 ; j < cboTarget.length ; j++ )	
	{
        if (cboTarget.options.item(j).value == strValue)
	    {
			cboTarget.selectedIndex = j;
			break;
		} 
	}
	if( j > (cboTarget.length - 1) )
	{
		cboTarget.selectedIndex = -1;
	}
}

function CreateAddress( strParam )	{
	return window.showModalDialog( 'Finder.asp'+strParam, '', 'dialogHeight:250px;dialogWidth:650px;edge:Raised;center:1;help:0;resizable:1;status:0' );
}

function SelectTab( strTabs, nLabelResId )
{
	return window.showModalDialog( 'FileSelect.asp?LabelResId='+nLabelResId+'&Tabs='+strTabs, '', 'dialogHeight:200px;dialogWidth:450px;edge:Raised;center:1;help:0;resizable:0;status:0' );
}

function SendMultiVoicing( nTabFrom, strMailTabs, nMultiType, nParentEvtId, nParentTplTab  )
{

	var nMailTab = 0;
        
        	
	if( isNaN( strMailTabs ) )
	{
		nMailTab = SelectTab( strMailTabs, 1164 );
		if( nMailTab == null )
			return;
		if( isNaN( nMailTab ) )
			return;
	}
	else
	{
		nMailTab = parseInt( strMailTabs );
	}	
	
	    AddTpl( nMailTab, 0, 0, 0, nTabFrom, nMultiType, 7, nParentEvtId, nParentTplTab );
	
}

function SendMultiMail( nTabFrom, strMailTabs, nMultiType, nParentEvtId, nParentTplTab, bSmsEnabled, bAdvancedEmailingEnabled, nEventTabFrom)
{
	var nMailTab = 0;


	if (!nEventTabFrom)
	{
		nEventTabFrom= 0;
	}
	
	if( isNaN( strMailTabs ) )
	{
		nMailTab = SelectTab( strMailTabs, 801 );
		if( nMailTab == null )
			return;
		if( isNaN( nMailTab ) )
			return;
	}
	else
	{
		nMailTab = parseInt( strMailTabs );
	}	

    if( bSmsEnabled )
	{
		/* MAB V7 - 20080717 - URL absolue nécessaire afin de pouvoir afficher la popup depuis le menu contextuel du planning */
		var baseURL = window.location.href.substring(0, window.location.href.lastIndexOf('/') + 1);
	    var strDatas = window.showModalDialog( baseURL + 'TplSelect.asp?new=1&multi='+nMultiType+'&tabfrom='+nTabFrom+'&tab='+nMailTab+'&evtid='+nParentEvtId, '', 'dialogHeight:170px;dialogWidth:350px;edge:Raised;center:1;help:0;resizable:0;status:0' );
    	if( strDatas )
    	{
			if (strDatas == "3")
				{
					if (!bAdvancedEmailingEnabled)
						var bAdvancedEmailingEnabled = false;
					AddTpl( nMailTab, 0,0, 0, nTabFrom, nMultiType, 3, nParentEvtId, nParentTplTab,null,null,null,null,null,null,null,null, bAdvancedEmailingEnabled, nEventTabFrom);
				}
			else
				AddTpl( nMailTab, 0, 0, 0, nTabFrom, nMultiType, strDatas ,nParentEvtId, nParentTplTab );
	    }
	}
	else
	{
		if (!bAdvancedEmailingEnabled)
			var bAdvancedEmailingEnabled = false;
	    AddTpl( nMailTab, 0,0, 0, nTabFrom, nMultiType, 3, nParentEvtId, nParentTplTab,null,null,null,null,null,null,null,null, bAdvancedEmailingEnabled,nEventTabFrom);
	}
}

/* MAB V7 - 20080725 - ajout évènement en paramètre */
function SetAccelerator( nTab, e )
{
	/* MAB */
	if ((document.parentWindow) && (document.parentWindow.event)) {
		var accelEvent = document.parentWindow.event;
	}
	else {
		var accelEvent = e;
	}

	try
	{
		top.frames['FraTop'].SetMainAccelerator( accelEvent, nTab );
		//top.frames['FraTop'].SetMainAccelerator( document.parentWindow.event, nTab );
	}
	catch(e){}
}

function showPermission( nPermId )
{
	var strValue = window.showModalDialog( 'Permission.asp?PermId='+nPermId, '', 'dialogHeight:150px;dialogWidth:460px;edge:Raised;center:1;help:0;resizable:0;status:0' );
	return strValue;
}

/******************************************
JAS MRU sur Catalogues le 22/04/2010 
Recherche et renvoie la Frame donc le nom est passé en argument 
strFrame : Nom de la frame à rechercher.
TODO : voir pour le faire en récursif.
******************************************/
function GetFrame(strFrame)
{
	if(sUserAgent)
		sUserAgent = navigator.userAgent.toLowerCase();
	else
		var sUserAgent = navigator.userAgent.toLowerCase();
	
	var frame;
	var bIsIE = ((sUserAgent.indexOf("msie") != -1) && (sUserAgent.indexOf("opera") == -1) && (sUserAgent.indexOf("webtv") == -1));
	if(bIsIE)
	{		
		if(window.frames)
		{
			if(window.frames[strFrame])
				return window.frames;
		}

		if (window.parent)
		{		
			if(window.parent.frames)
				if (window.parent.frames[strFrame])
					return window.parent.frames[strFrame];

			if(window.parent.dialogArguments)
			{	
				if (window.parent.dialogArguments.frames[strFrame])
					return window.parent.dialogArguments.frames[strFrame];
				if(window.parent.dialogArguments.parent.dialogArguments)
				{
					if(window.parent.dialogArguments.parent.dialogArguments.frames)
						if(window.parent.dialogArguments.parent.dialogArguments.frames[strFrame])
							return window.parent.dialogArguments.parent.dialogArguments.frames[strFrame];
						if(window.parent.dialogArguments.parent.dialogArguments.parent)
							if(window.parent.dialogArguments.parent.dialogArguments.parent.dialogArguments)
								if(window.parent.dialogArguments.parent.dialogArguments.parent.dialogArguments.frames[strFrame])
									return window.parent.dialogArguments.parent.dialogArguments.parent.dialogArguments.frames[strFrame];
				}
						
				if(window.parent.dialogArguments.opener)
				{
					if(window.parent.dialogArguments.opener.frames)
						if(window.parent.dialogArguments.opener.frames[strFrame])
							return window.parent.dialogArguments.opener.frames[strFrame];
					if(window.parent.dialogArguments.opener.parent)
						if(window.parent.dialogArguments.opener.parent.frames)
							return window.parent.dialogArguments.opener.parent.frames[strFrame];
					if(window.parent.dialogArguments.opener.parent.opener.frames)
						return window.parent.dialogArguments.opener.parent.frames[strFrame];
				}
			}
		}
		if(top.frames)
			if(top.frames[strFrame])
				return top.frames[strFrame];
	}
	else //FF
	{
		if(top.frames)
		{
			if(top.frames[strFrame])
				return top.frames[strFrame];
			if (top.opener)
			{
				if(top.opener.top)
				{
					if (top.opener.top.frames[strFrame])
						return top.opener.top.frames[strFrame];
					if(top.opener.top.opener)
					{
						if (top.opener.top.opener.top)
						{
							if (top.opener.top.opener.top.frames[strFrame])
								return top.opener.top.opener.top.frames[strFrame];
							if(top.opener.top.opener.top.opener)
								if(top.opener.top.opener.top.opener.top)
									if(top.opener.top.opener.top.opener.top.frames[strFrame])
									return top.opener.top.opener.top.opener.top.frames[strFrame];
						}
					}
				}
			}
		}
	}
	return "";
}
/******************************************
JAS MRU sur Catalogues le 22/04/2010 
Fonction générant le menu de MRU pour les Catalogues utilisateurs.
e : Evenement déclencheur
strMru : combinaison id|valeur de la valeur de catalogue
nDescId : DescId du champ sur lequel porte la MRU.
nFileID : Id du fichier en cours.
bMultiple : Catalogue multiple ou pas
nShowGroupOnly  : n'afficher que les groupes (repris de l'affichage standard de catalogue utilisateur, au cas ou ce soit nécessaire dans le futur)
bTreeView : Arborescent ou non (repris de l'affichage standard de catalogue utilisateur, au cas ou ce soit nécessaire dans le futur)
bFullList : Afficher tous les utilisateurs(repris de l'affichage standard de catalogue utilisateur, au cas ou ce soit nécessaire dans le futur)

=> nShowGroupOnly, btreeView, et bFulllist sont non pris en charge au 10/05/2010( 7.204)
******************************************/
function CatUserMRUShow(e, strMru, nDescId, nFileId, bMultiple, nShowGroupOnly, bTreeView, bFullList)
{

	if (strMru == "")
	{
		
		oFrame = GetFrame("FraHeader");
		
		if(oFrame != "")
			strMru = oFrame.GPV('MRU_'+nDescId);
	}
		
	var bIsIE = ((sUserAgent.indexOf("msie") != -1) && (sUserAgent.indexOf("opera") == -1) && (sUserAgent.indexOf("webtv") == -1));
	if(bMultiple ==1)
		bMultiple = true;
	else
		bMultiple = false;

	var eX, eY;
	
	
	oItemPopup = createMenu();
	if(strMru != "")
	{
			// Coordonnées de souris
		if(window.event)
			e = window.event;
		eX = e.clientX;
		eY = e.clientY;
		
		beginMenu(oItemPopup);
		var strTmp, aTmp, strAction;
		
		strAction = "onclick=\"self.parent.hideMenu(self.parent.oItemPopup);self.parent.ShCU("+nDescId+","+bMultiple+","+nShowGroupOnly+", "+bTreeView+", "+bFullList+");try{self.parent.onChangeField("+nDescId+",8)}catch(e){};\"";
			
		addMenuLabelSep(oItemPopup, strSuggest,strAction,strImgSearch, null, 0,"#7e7e7e","#E2DEDE");
		
		var aMru = strMru.split('|');
		for (var i = 0 ; i < aMru.length; i++)
		{
			if(aMru[i] != "")
			{
				if(document.getElementById(nDescId)) // le champ existe on est donc en mode Fiche.
				{
					aTmp = aMru[i].split(';');
					addMenuLabelWithParams(oItemPopup,decode(aTmp[1].replace("'","\'")),"onclick=\"self.parent.SetCatFromMRU('"+aMru[i].replace("'","\\'")+"',"+nDescId+","+nFileId+",0,8);self.parent.hideMenu(self.parent.oItemPopup);try{self.parent.onChangeField("+nDescId+",8)}catch(e){};\"",null,null,0,"#FFFFFF","","#E2DEDE");
				}
			}
		}
		
		addMenuLabelWithParams(oItemPopup,strClear,"onclick=\"self.parent.SetCatFromMRU(0,"+nDescId+","+nFileId+",0,8);self.parent.hideMenu(self.parent.oItemPopup);try{self.parent.onChangeField("+nDescId+",8)}catch(e){};\"");
		addMenuLabelWithParams(oItemPopup, strLabelSearch,strAction ,strImgSearchArrow,null,0,"#E2DEDE","#BB1515","#E2DEDE",null, null, null,"search");
		endMenu( oItemPopup );
		showMenu( oItemPopup, eX, eY + 10, 150, null, e );
	}
	else //affichage du catalogue si aucune MRU existantes.
		ShCU(nDescId,bMultiple);
		
		/* MAB DEBUG FIREFOX - 20080611 - utilisation event capturé de manière globale pour Mozilla */
		if (window.event)
		{
			window.event.returnValue = false;
			window.event.cancelBubble = true;
		}
		else
		{
			e.preventDefault();
			e.stopPropagation();
		}
}
/******************************************
JAS MRU sur Catalogue 16/04/2010.
Fonction Appelant UpdateFunction pour mettre à jour les MRu des champs de liaison
nTab   : Id Du fichier concerné
strValue    : Chaine renvoyée par Findec() contenant les champs à mettre à jour.
Si on saisit un contact, on ne met à jour que la MRU de contact, et ce même si l'attachement peu 
mettre à jour des champs affaire, société etc.. ( planning, affaires) on n'update que le champ actif / cliqué.
******************************************/
function UpdateLinkedMru(nTab, strValue)
{
	if(!nTab || !strValue)
		return;
	var strVal; // valeur correspondant à l'id du champs actif
	var aVal = strValue.split("&"); //tableau des associations champs=valeur;
	var fVal;
	var bIsPPLink = (nTab == 200);
	var bIsPMLink = (nTab == 300);
	var bMultiField  = (strValue.split("&").length > 2);
	
	
	for( i = 0; i < aVal.length; i++) // on parcours le tableau d'association.
	{
		fVal =aVal[i].split("="); // on sépare le champ de la valeur.
		
		if(bMultiField)
		{
			switch(nTab)
			{
				case 200 :
					if(fVal[0].toLowerCase() == "ppid")
						strVal = fVal[1];
						break;
				case 300 :
					if(fVal[0].toLowerCase() == "pmid")
						strVal = fVal[1];
						break;
				default :
					if(fVal[0] == nTab)
						strVal = fVal[1];
						break;		
			}
		}
		else
		{
			if(!isNaN(fVal[1]) && fVal)
				strVal = fVal[1];
		}
	}
	if(strVal)
	{
		window.showModalDialog("CatalogMruTreatment.asp?MruAdd=1&nTab="+nTab+"&ValToAdd="+strVal, top.frames, 'dialogHeight:0;dialogWidth:0;edge:Raised;center:1;help:0;resizable:0;status:0' );			
	}
}
/******************************************
JAS MRU sur Catalogues le 16/04/2010 
Fonction générant le menu de MRU pour les Catalogues standards et avancés..
e : Evenement déclencheur
strMru : combinaison id|valeur de la valeur de catalogue
nDescId : DescId du champ sur lequel porte la MRU.
nFileID : Id du fichier en cours.
bMultiple : Catalogue multiple ou pas
bAdvancedPopup  : Catalogue avancé de type filedata.
******************************************/

function CatalogMRUShow(e, strMru, nDescId,nFileId, bMultiple, bAdvancedPopup, nFormat)
{	
	if (strMru == "")
	{
		oFrame = GetFrame("FraHeader");
		try
		{
			strMru = oFrame.GPV('MRU_'+nDescId);
		}
		catch(e)
		{
			strMru = "";
		}			
	}
	
	var strRechercher = strLabelSearch;	
	if(bMultiple ==1)
		bMultiple = true;
	else
		bMultiple = false;

	var eX, eY;
	
	oItemPopup = createMenu();	
	beginMenu(oItemPopup);
	
	if(strMru != "")
	{
		// Coordonnées de souris
		if(window.event)
			e = window.event;
		eX = e.clientX;
		eY = e.clientY;
		
		
		var strTmp, aTmp, strAction, strOnChangeField;
		var strAction ="";
		if(!bAdvancedPopup)
			strAction = "onclick=\"self.parent.hideMenu(self.parent.oItemPopup);self.parent.ShC("+nDescId+","+bMultiple+");try{self.parent.onChangeField('"+nDescId+"',"+nFormat+")}catch(e){};\""
		else
			strAction = "onclick=\"self.parent.hideMenu(self.parent.oItemPopup);self.parent.showFileData("+nDescId+","+nDescId+","+nFileId+","+bMultiple+",null,0);try{self.parent.onChangeField('"+nDescId+"',"+nFormat+")}catch(e){};\""
		
		addMenuLabelSep(oItemPopup, strSuggest,strAction,strImgSearch, null, 0,"#7e7e7e","#E2DEDE");
	
		var aMru = strMru.split('|');
		for (var i = 0 ; i < aMru.length; i++)
		{
			if(aMru[i] != "")
			{
				if(document.getElementById(nDescId)) // le champ existe on est donc en mode Fiche.
				{
					aTmp = aMru[i].split(';');
					strVal = !bAdvancedPopup ? encode(aTmp[1]).replace("'","\\'") : encode(aTmp[1]).replace("'","\\'")+"|"+aTmp[0] ;
						addMenuLabelWithParams(oItemPopup,decode(aTmp[1].replace("'","\'")),"onclick=\"self.parent.SetCatFromMRU('"+strVal+"',"+nDescId+","+nFileId+","+bAdvancedPopup+",1,"+aTmp[0]+");self.parent.hideMenu(self.parent.oItemPopup);try{self.parent.onChangeField('"+nDescId+"',"+nFormat+")}catch(e){};\"",null,null,0,"#FFFFFF","","#E2DEDE");
				}
			}
		}
		
		addMenuLabelWithParams(oItemPopup,decode(strClear),"onclick=\"self.parent.SetCatFromMRU(0,"+nDescId+","+nFileId+","+bAdvancedPopup+",1,0);self.parent.hideMenu(self.parent.oItemPopup);try{self.parent.onChangeField('"+nDescId+"',"+nFormat+")}catch(e){};\"",null,null,0,"#FFFFFF","","#E2DEDE");		

		if(!bAdvancedPopup)
			addMenuLabelWithParams(oItemPopup, strLabelSearch, "onclick=\";self.parent.hideMenu(self.parent.oItemPopup);self.parent.ShC("+nDescId+","+bMultiple+");try{self.parent.onChangeField('"+nDescId+"',"+nFormat+")}catch(e){};\"",strImgSearchArrow,null,0,"#E2DEDE","#BB1515","#E2DEDE",null, null, null,"search");
		else
			addMenuLabelWithParams(oItemPopup, strLabelSearch, "onclick=\";self.parent.hideMenu(self.parent.oItemPopup);self.parent.showFileData("+nDescId+","+nDescId+","+nFileId+","+bMultiple+",null,0);try{self.parent.onChangeField('"+nDescId+"',"+nFormat+")}catch(e){};\"",strImgSearchArrow,null,0,"#E2DEDE","#BB1515","#E2DEDE",null, null, null,"search");
		
		endMenu( oItemPopup );
		showMenu( oItemPopup, eX-5, eY-5, 150, null, e );
	}		
	else //affichage du catalogue si aucune MRU existantes.
		if(!bAdvancedPopup)
		{
			ShC(nDescId,bMultiple);
			try{onChangeField(nDescId,nFormat)}catch(e){};
		}
		else	
		{
			showFileData(nDescId,nDescId,nFileId,bMultiple,null,0);
			try{onChangeField(nDescId,nFormat)}catch(e){};
		}
	
		
		/* MAB DEBUG FIREFOX - 20080611 - utilisation event capturé de manière globale pour Mozilla */
		if (window.event)
		{
			window.event.returnValue = false;
			window.event.cancelBubble = true;
		}
		else
		{
			e.preventDefault();
			e.stopPropagation();
		}
}
/****************************************************************************************/
/*	Fonction GetXhr()																	*/
/*	Renvoie un objet XHR (XML_HTTP_REQUEST)												*/
/****************************************************************************************/
function GetXhr(){
	var xhr = null; 
	if(window.XMLHttpRequest) {// Firefox et autres
		xhr = new XMLHttpRequest(); 
	} else if(window.ActiveXObject) { // Internet Explorer 
		try {
			xhr = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			xhr = new ActiveXObject("Microsoft.XMLHTTP");
		}
	} else { // XMLHttpRequest non supporté par le navigateur 
		alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
		xhr = false; 
	} 
	return xhr;
}

//Fonction de MRU en Ajax pour les catalogues enfants.
function ChildCatalogMRUShow(e, strMru, nDescId,nFileId, bMultiple, bAdvancedPopup, nFormat, nParentDescId, bDialog)
{	
	
	var date = new Date();
	var Timer = date.getTime();
	var bParent = null;
	if(!bAdvancedPopup)
	{
		if(document.getElementById(nParentDescId))
		{
			var strParentCatVal = document.getElementById(nParentDescId).value;
			bParent = document.getElementById(nParentDescId).value != "";
		}
	}
	else
	{
		if(document.getElementById(nParentDescId))
		{
		var strParentCatVal = document.getElementById(nParentDescId).value;
		bParent = document.getElementById(nParentDescId).value != 0;
		}
		nFormat = 2;
		
	}
	
	if (strMru == "" && bParent ) //si la mru est vide (pas de mru pour cat enfant, et si le parent est renseigné au préalable.
	{
		if(bMultiple ==1)
		bMultiple = true;
		else
		bMultiple = false;

		var eX, eY;
		// Coordonnées de souris
		if(window.event)
		e = window.event;
		eX = e.clientX;
		eY = e.clientY;
		oItemPopup = createMenu();	
		beginMenu(oItemPopup);
		var xhr = GetXhr();
		xhr.onreadystatechange = function()
		{
			if(xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0))
			{
				if(xhr.responseText)
					strMru = xhr.responseText.substring(xhr.responseText.indexOf("<body>")+7,xhr.responseText.indexOf("</body>")-1).replace("\n","").replace("\r","");
				else
					strMru = "";
				
				var strRechercher = strLabelSearch;	

				if(strMru != "")
				{					
					var strTmp, aTmp, strAction, strOnChangeField;
					var strAction ="";

					if(!bAdvancedPopup)
						strAction = "onclick=\"self.parent.hideMenu(self.parent.oItemPopup);if(self.parent.ShCat("+nDescId+","+bMultiple+","+nFileId+", "+bDialog+", "+nParentDescId+")){try{self.parent.SV(self.parent.document.getElementById("+nDescId+"),1)}catch(e){}};try{self.parent.onChangeField('"+nDescId+"',"+nFormat+")}catch(e){};\""
					else
						strAction = "onclick=\"self.parent.hideMenu(self.parent.oItemPopup);self.parent.showFileData("+nDescId+","+nDescId+","+nFileId+","+bMultiple+","+nParentDescId+",0);try{self.parent.onChangeField('"+nDescId+"',"+nFormat+")}catch(e){};\""
					
					addMenuLabelSep(oItemPopup, strSuggest,strAction,strImgSearch, null, 0,"#7e7e7e","#E2DEDE");
				
					var aMru = strMru.split('|');

					for (var i = 0 ; i < aMru.length; i++)
					{
						if(aMru[i] != "")
						{
							if(document.getElementById(nDescId)) // le champ existe on est donc en mode Fiche.
							{
								aTmp = aMru[i].split(';');
								strVal = !bAdvancedPopup ? encode(aTmp[1]).replace("'","\\'") : encode(aTmp[1]).replace("'","\\'")+"|"+aTmp[0] ;
									addMenuLabelWithParams(oItemPopup,decode(aTmp[1].replace("'","\'")),"onclick=\"self.parent.SetCatFromMRU('"+strVal+"',"+nDescId+","+nFileId+","+bAdvancedPopup+",1,"+aTmp[0]+");self.parent.hideMenu(self.parent.oItemPopup);try{self.parent.onChangeField('"+nDescId+"',"+nFormat+")}catch(e){};\"",null,null,0,"#FFFFFF","","#E2DEDE");
							}
						}
					}
					
					addMenuLabelWithParams(oItemPopup,strClear,"onclick=\"self.parent.SetCatFromMRU(0,"+nDescId+","+nFileId+","+bAdvancedPopup+",1,0);self.parent.hideMenu(self.parent.oItemPopup);try{self.parent.onChangeField('"+nDescId+"',"+nFormat+")}catch(e){};\"",null,null,0,"#FFFFFF","","#E2DEDE");		

					if(!bAdvancedPopup)
						addMenuLabelWithParams(oItemPopup, strLabelSearch, "onclick=\";self.parent.hideMenu(self.parent.oItemPopup);if(self.parent.ShCat("+nDescId+","+bMultiple+","+nFileId+", "+bDialog+", "+nParentDescId+")){try{self.parent.SV(self.parent.document.getElementById("+nDescId+"),1)}catch(e){}};try{self.parent.onChangeField('"+nDescId+"',"+nFormat+")}catch(e){};\"",strImgSearchArrow,null,0,"#E2DEDE","#BB1515","#E2DEDE",null, null, null,"search");
					else
						addMenuLabelWithParams(oItemPopup, strLabelSearch, "onclick=\";self.parent.hideMenu(self.parent.oItemPopup);self.parent.showFileData("+nDescId+","+nDescId+","+nFileId+","+bMultiple+","+nParentDescId+",0);try{self.parent.onChangeField('"+nDescId+"',"+nFormat+")}catch(e){};\"",strImgSearchArrow,null,0,"#E2DEDE","#BB1515","#E2DEDE",null, null, null,"search");
					
					endMenu( oItemPopup );
					showMenu( oItemPopup, eX-5, eY-5, 150, null, e );
				}		
				else //affichage du catalogue si aucune MRU existantes.
					if(!bAdvancedPopup)
					{
						if(ShCat(nDescId,bMultiple,nFileId, bDialog, nParentDescId))
						{
								try
								{
									SV(document.getElementById(nDescId),nFormat);
								}
								catch(e){alert(e.description);}
								try
								{
									onChangeField(nDescId,nFormat);
									
								}catch(e)
								{};
						}
								
					}
					else
					{
						showFileData(nDescId,nDescId,nFileId,bMultiple,nParentDescId,0);
						try{onChangeField(nDescId,nFormat)}catch(e){};
					}
			}
		}
		var querystring = "nDescId=" + nDescId +"&user="+nFormat+"&nParentDescId="+nParentDescId+"&parentVal="+encode(strParentCatVal)+"&timer="+Timer;
		
		xhr.open("POST","CatalogMruSearch.asp",true);
		xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
		xhr.send(querystring);
		
	}
	else
	{
	// si la valeur parente n'est pas renseignée, on reprends le comportement des versions précédentes
	//on lance la fenêtre catalogue vide.
		if(!bAdvancedPopup)
		{
			if(ShCat(nDescId,bMultiple,nFileId, bDialog, nParentDescId))
			{
				try
				{
					SV(document.getElementById(nDescId),nFormat);
				}
				catch(e){}
				try
				{
					onChangeField(nDescId,nFormat);
				}
				catch(e){};
			}
		}
		else	
		{
			showFileData(nDescId,nDescId,nFileId,bMultiple,nParentDescId,0);
			try{onChangeField("'"+nDescId+"'",nFormat)}catch(e){};
		}
	}
	/* MAB DEBUG FIREFOX - 20080611 - utilisation event capturé de manière globale pour Mozilla */
	if (window.event)
	{
		window.event.returnValue = false;
		window.event.cancelBubble = true;
	}
	else
	{
		e.preventDefault();
		e.stopPropagation();
	}
}

/*
	Vérifie pour les MRU D'association d'event/template (champ du bas en ajout)
	qu'aucun champ n'est renseigné.
	Si on a déjà renseigné  : 
	-	une affaire : pp, pm sont renseigné dans la foulée.
	-	un pp : pm est renseigné.
	
	donc on évite les MRU dans ce cas pour ne pas proposer de valeur incohérentes avec les saisies.
*/
function CheckMru(nDescId, strField)
{
	var pp, pm, evt, adr;

	if(strField) //champ de liaison du corps de la fiche, pas besoin de check les champs du bas, car pas de rapport.
		return true;
	
	if(self.document.getElementById("PMId"))
		if(self.document.getElementById("301").value != "")	
			pm = 1;
		else
			pm = 0;
	else 
		pm = 0;
		
	if(self.document.getElementById("PPId"))
		if(self.document.getElementById("201").value != "")
			pp = 1;
		else
			pp = 0;
	else
		pp = 0;
		
	if(self.document.getElementById("ADRId"))
		if(self.document.getElementById("401").value != "")
			adr = 1;
		else
			adr = 0;
	else
		adr = 0;
		
	if(self.document.getElementById(self.document.getElementById("EVTId")))
		if(self.document.getElementById(self.document.getElementById("EVTId").value) != "")
			evt = 1;
		else
			evt = 0;
	else
		evt = 0;
		
		return (evt + pm + adr + pp) == 0;
}
function MRUShow(e, strMru, strField,nDescId,nFileId, bIsPopup,oItem, bShCat)
{
	var eX, eY;
	bShCat = bShCat ? bShCat :  false;
	
	if (strMru == "")
	{
		oFrame = GetFrame("FraHeader");
		try
		{
			strMru = oFrame.GPV('MRU_'+nDescId);
		}
		catch(e)
		{
			strMru = "";
		}			
	}
	
	if(!CheckMru(nDescId, strField))
	{
		if(bShCat)
			self.ShSpecCat("'"+strField+"'","'"+nDescId+"'",false,'');
		else
			self.AttachPers((strField ? strField:nDescId ));
		// MAB DEBUG FIREFOX - 20080611 - utilisation event capturé de manière globale pour Mozilla 
		if (window.event)
			window.event.returnValue = false;
		else
			e.preventDefault();
		return;
	}

	if (strMru != "")
	{
		// Coordonnées de souris
		if(window.event)
			e = window.event;
		eX = e.clientX;
		eY = e.clientY;
	
		oItemPopup = createMenu();
		if(!(oItemPopup && oItemPopup.document))
			return;
		beginMenu( oItemPopup );
		//JAS : Attachement au click droit sur le champ de liaison OU au click droit via le lien hypertexte du mode liste.
		var strSearchAction = "";
		var strCatalogAction = "";
		strCatalogAction = "onclick=\"self.parent.hideMenu(self.parent.oItemPopup);self.parent.ShSpecCat('"+strField+"','"+ nDescId +"',false,'');\""
	
	if(!oItem)
			strSearchAction = "onclick=\"self.parent.hideMenu(self.parent.oItemPopup);self.parent.AttachPers("+(strField ? strField:nDescId )+");\" ";
		else
			strSearchAction = "onclick=\"self.parent.hideMenu(self.parent.oItemPopup);self.parent."+oItem.toString().replace("javascript:","")+"\"";
				
		addMenuLabelSep(oItemPopup, strSuggest,(bShCat ? strCatalogAction : strSearchAction),strImgSearch, null, 0,"#7e7e7e","#E2DEDE");
	
		var strTmp, aTmp, strAction;
		var aMru = strMru.split( "|" );
		
		for( var i=0 ; i < aMru.length ; i++ )
		{
			
			strTmp = aMru[i];
			if ( strTmp != "" )
			{	
				aTmp = strTmp.split( ";" );
				
				if( !strField )
				{	
					if(oItem) // oItem =  composant web depuis lequel on appelle la MRU en mode liste.
					{									
						//Depuis un mode liste
						strAction = getMenuAction( aTmp, 3 );
						strAction = strAction.replace( "$descid$", nDescId );
						strAction = strAction.replace( "$parentfileid$", nFileId );
					}
					else
					{
						strAction = getMenuAction( aTmp, 1 );
					}
				}
				else
				{
					sLib = decode( aTmp[4] );
					re = new RegExp( "'", "gmi" );
					sLib = sLib.replace( re, "\\\'" );
					strAction = "self.parent.ShSpecCatFromMru( "+ strField+ ", "+ decode( aTmp[3] ) +", '"+ sLib +"' );";
				}
				
				if( aTmp[4] != null )
					addMenuLabelWithParams( oItemPopup, decode( aTmp[4].replace( "'", "\'" ) )+"", " onclick=\"self.parent.hideMenu(self.parent.oItemPopup);" +strAction+ "\" ", getMenuIcon( decode( aTmp[1] ) ), null,0,"#FFFFFF","","#E2DEDE" );
			}
		}

		addMenuLabelWithParams(oItemPopup,strClear,"onclick=\"self.parent.ShSpecCatFromMru( "+ strField+ ", '', '' );self.parent.hideMenu(self.parent.oItemPopup);\"");
		addMenuLabelWithParams(oItemPopup, strLabelSearch ,(bShCat ? strCatalogAction : strSearchAction),strImgSearchArrow,null,0,"#E2DEDE","#BB1515","#E2DEDE",null, null, null,"search");						
		endMenu( oItemPopup );
		showMenu( oItemPopup, eX-5, eY-5, 150, null, e );
		
		// MAB DEBUG FIREFOX - 20080611 - utilisation event capturé de manière globale pour Mozilla 
		if (window.event)
			window.event.returnValue = false;
		else
			e.preventDefault();
	}
	else
	{
		self.ShSpecCat( strField , nDescId  ,false,'');
		
		if (window.event)
		{
			window.event.cancelBubble = true	
			window.event.returnValue = false;
		}
		else
		{
			e.stopPropagation();

			e.preventDefault();
		}
	}
}

function showMRU( nTab, strMru, nType, bSearchLink, nAction, bShowTextBox, bAdminLink, nMode, e )
{
	var nMaxItemVisible = 7;	//Nombre max de MRU
    
		
	oItemPopup = createMenu();

	beginMenu( oItemPopup );
	
	if( bShowTextBox )
	{
		addMenuTextBox( oItemPopup, "",  " value='' ednTab='"+ nTab +"' ednTabFrom='0' ednDescId='"+ (nTab + 1) +"' ednType='0' ednMaxLine='"+ nMaxItemVisible +"' ", strImgSearch )
		beginScrollArea( oItemPopup, "SCROLLVALUES" )
	}
	
	if ((nType!=2 && nType!=3) && nMode==0 ) // ELA 
	{
	    var aMru = strMru.split( "|" );
	    for( var i=0 ; i < aMru.length ; i++ )
	    {
		    var strTmp = aMru[i];
		    if ( strTmp != "" )
		    {
			    var aTmp = strTmp.split( ";" );
			    var strAction = getMenuAction( aTmp, nAction );
                
			    if( aTmp[4] != null )
			        
				    addMenuLabel( oItemPopup, decode( aTmp[4] ), " onclick=\""+ strAction +"self.parent.hideMenu(self.parent.oItemPopup);\" ", getMenuIcon( decode( aTmp[1] ) ) );
				    //IA 22/02/05 : Unicode -> decode (encode dans GetMruHTML() dans Function.asp)
		    }
	    }
	}
	

	if(self.location.pathname.indexOf("AdminNavBar.asp")>0)
	{
		if ((nType!=2 && nType!=3) && bAdminLink == false && nType!=1) // Retour au mode liste pour les fichiers principaux
		{
			var strLabel = top.frames['FraParam'].document.getElementById("LabelListMode").value;
			addMenuSeparator( oItemPopup );
			addMenuLabel( oItemPopup, strLabel, " onclick=\"self.parent.ShApp("+nTab+");self.parent.hideMenu(self.parent.oItemPopup);\" ", getMenuIcon( 0 ) );
		}
	}
	
	if ((nType==2 || nType == 3) && nMode==0 )// && (bAdminLink==false)) // Retour au mode liste du template 'ELA le 20/02/2007
	{
	    var aMru = strMru.split( "|" );
	    var strTmp = aMru[0];
	    var strAction = aMru[1];
	    strAction = "self.parent.showFileTemplate("+nTab+", "+nType+");";
	    
	    addMenuLabel( oItemPopup, decode( strTmp ), " onclick=\"" + strAction + "self.parent.hideMenu(self.parent.oItemPopup);\" ", getMenuIcon( 0 ) );
			
	}
	
	if (nMode==2) // Retour à la fiche de provenance 'ELA le 03/04/2007
	{
		//var aMruFiles = strMru.split( "|" );
		var aMru = strMru.split( ";" );
	    var nTabSource = aMru[3];
	    var nIdSource = aMru[4];
	    var strLabelSource = aMru[0]+' '+aMru[5];
	    strAction = "self.parent.ShApp("+nTabSource+", "+nIdSource+");";
	    addMenuLabel( oItemPopup, decode( strLabelSource ), " onclick=\"" + strAction + "self.parent.hideMenu(self.parent.oItemPopup);\" ", getMenuIcon( 0 ) );
	}
	
	if( bShowTextBox )
	{
		if( i < nMaxItemVisible )
		{
			for( j = i; j < nMaxItemVisible; j++ )
			{
				addMenuLabel( oItemPopup, "", "", null );
			}
		}
		endScrollArea( oItemPopup, "SCROLLVALUES", nMaxItemVisible );
	}

	if( bSearchLink )
	{
		addMenuSeparator( oItemPopup );
		// Rechercher
		addMenuLabel( oItemPopup, strResSearch, " onclick=\"self.parent.SearchRecMRU("+ nTab +");self.parent.hideMenu(self.parent.oItemPopup);\" ", strImgSearch );
	}
	if( bAdminLink )
	{
	    if (nType!=2 && nType!=3 && nMode==0) // ELA 
	       {
		    addMenuSeparator( oItemPopup );
		   }
		// Administrer
		if (nMode == 1)
		    {
	        addMenuLabel( oItemPopup, strResAdmin, " onclick=\"self.parent.ShAdmin("+ nTab +", 1, '"+strMru+"');self.parent.hideMenu(self.parent.oItemPopup);\" ", strImgAdmin );
	        }
	    else
	        {
	        addMenuLabel( oItemPopup, strResAdmin, " onclick=\"self.parent.ShAdmin("+ nTab +", 0, '');self.parent.hideMenu(self.parent.oItemPopup);\" ", strImgAdmin );
	        }
	}
	endMenu( oItemPopup );
	
	/* MAB V7 - 20080623 */
	showMenu( oItemPopup, null, null, null, null, e ); 
    
    /* MAB V7 - 20080619 */
    if (window.event)
	    window.event.returnValue = false;
	else
		e.preventDefault();
}

function getMenuIcon( nIconIndex )
{
	switch( parseInt( nIconIndex, 10 ) )
	{
	case 1:		return strImgAgenda;
	case 2:		return strImgTask;
	default:	return strImgRecord;
	}
}

function getMenuAction( aActionArray, nAction )
{
	var re, strAction = "";
	
	switch( parseInt( decode( aActionArray[0] ), 10 ) )									//ajout decode IA 25/02/05 (encode dans GetMruHTML() dans Function.asp)
	{
	case 1:			// Lien présent dans le menu
			strAction = decode( aActionArray[2] );										//decode
			break;
			
	default:
		switch( nAction )
		{
		case 1:			// Association
			strAction = "self.parent.AttachPersFromMru($tab$,$fileid$,'$filename$');";
			break;
		case 2:			// Lien sur la fiche depuis admin
			strAction = "self.parent.ShApp($tab$,$fileid$);";
			break;
		case 3 :
			strAction = "self.parent.AttachFileMRU($tab$,$fileid$,'$filename$',$descid$,$parentfileid$);";
			break;		
		default:		// Lien sur la fiche
			strAction = "self.parent.showFile($tab$,$fileid$);";
		}
		strAction = strAction.replace( "$tab$", decode( aActionArray[2] ) );				//decode
		strAction = strAction.replace( "$fileid$", decode( aActionArray[3] ) );				//decode
		strFileName = decode( aActionArray[4] ); 											//decode
		// HLA - Gestion des apostrophes dans les MRU (double apostrophe pour l'appelle à l'action)
		re = new RegExp( "'", "gmi" );
		strFileName = strFileName.replace( re, "\\\'" );
		strAction = strAction.replace( "$filename$", strFileName );
	}
	return strAction;
}
function onExpand ( nDispOrder, nTab, nUserId, nExpand )
{
	var aElements = null;
	var aSubElements = null;
	var aDivElements = null;
	var nId = null;
	var strTrId = null;
	var strImgId = 'ImgTree_'+nDispOrder;
	var strImgSrc = document.getElementById(strImgId).src;
	var nTag = document.getElementById(strImgId).getAttribute("ednTag");
	var bExpand = ( nTag == 0 );
	var bExpandLoad = (nExpand == 1);
	var strVisibility;
	var strPosition;
	var strDisplay;
	
	if ( bExpand || bExpandLoad )
	{
		strVisibility = 'visible';
		strPosition = 'relative';
		/* MAB V7 - 20080620 - correction CSS compatibilité Firefox */
	    /* le display des balises TR doit être laissé au libre choix du navigateur, et non forcé en "block" pour s'afficher correctement sous Firefox */		
		//strDisplay = 'block';
		strDisplay = ""; // utilisation de la valeur par défaut employée par le navigateur pour les TR
		//Modifie l'image
		document.getElementById(strImgId).src = strImgSrc.replace( "Plus.gif","Minus.gif");
		//Modifie le Tag
		document.getElementById(strImgId).setAttribute("ednTag", 1);
		//Enregistre l'ouverture
		loadPage('Process.asp?Type=1&Tab='+nTab+'&Userid='+nUserId+'&DispOrder='+nDispOrder+'&Open=1');
	}
	else
	{
		strVisibility = 'hidden';
		strPosition = 'absolute';
		strDisplay = 'none';
		//Modifie l'image
		document.getElementById(strImgId).src = strImgSrc.replace( "Minus.gif","Plus.gif");
		//Modifie le Tag
		document.getElementById(strImgId).setAttribute("ednTag", 0);
		//Enregistre la fermeture
		loadPage('Process.asp?Type=1&Tab='+nTab+'&Userid='+nUserId+'&DispOrder='+nDispOrder+'&Open=0');
	}
	var aElements = document.getElementsByTagName("TR");
	for( var i=0 ; i < aElements.length ; i++ )
	{
		/* MAB V7 - 20080623 - correction de l'accès à l'attribut "name" */
		//if( aElements[i].name == nDispOrder+'_TR_SEP' && aElements[i].innerHTML != '')
		if( aElements[i].getAttribute('name') == nDispOrder+'_TR_SEP' && aElements[i].innerHTML != '')
		{	
			aElements[i].style.display = strDisplay;
			aElements[i].style.visibility = strVisibility;
			// HLA - Champs notes sous un séparateur inaccessible (mise en commentaire de la mdification de la position de l'objet) - Bug #8585
			//aElements[i].style.position = strPosition;
			aSubElements = aElements[i].childNodes;
			z=0;
			for( j = 0 ; j < aSubElements.length ; j++ )
			{
				if ( aSubElements[j].tagName == 'TD' )
				{
					if (aSubElements[j].getAttribute("ednHidden") != 1)
					{
						aSubElements[j].style.visibility = strVisibility;
						// HLA - Champs notes sous un séparateur inaccessible (mise en commentaire de la mdification de la position de l'objet) - Bug #8585
						//aSubElements[j].style.position = strPosition;
						aSubElements[j].style.display = strDisplay;
					}
					else
					{
						z=z+1;
					}
					
				}
			}
			
			if (z==j)
				aElements[i].style.display = 'none';
			
		}
	}

	// Sur IE, il faut recalculer la taille de l'iframe des champs notes
	// après ouverture/fermeture des titre séparateur
	if(bIsIE)
	{
		var aElements = document.getElementsByTagName("IFRAME");
		for( var i=0 ; i < aElements.length ; i++ )
		{	
			if(aElements[i].id.indexOf("iframe") == 0)
			{
				var nId = aElements[i].id.replace("iframe","");					
				resizeRTE(nId);
			}
		}
	}
		
	//Redimensionne la fiche
	Resize();
}

function onExpandClose ( nDispOrder, nTab, nUserId )
{
	var aElements = null;
	var aSubElements = null;
	var aDivElements = null;
	var nId = null;
	var strTrId = null;
	var strImgId = 'ImgTree_'+nDispOrder;
	var strImgSrc = document.getElementById(strImgId).src;
	var nTag = document.getElementById(strImgId).getAttribute("ednTag");
	var strVisibility;
	var strPosition;
	var strDisplay;
	
	strVisibility = 'hidden';
	strPosition = 'absolute';
	strDisplay = 'none';
	//Modifie l'image
	document.getElementById(strImgId).src = strImgSrc.replace( "Minus.gif","Plus.gif");
	//Modifie le Tag
	document.getElementById(strImgId).setAttribute("ednTag", 0);
	//Enregistre la fermeture
	loadPage('Process.asp?Type=1&Tab='+nTab+'&Userid='+nUserId+'&DispOrder='+nDispOrder+'&Open=0');

	var aElements = document.getElementsByTagName("TR");
	for( var i=0 ; i < aElements.length ; i++ )
	{
		if( aElements[i].name == nDispOrder+'_TR_SEP' && aElements[i].innerHTML != '')
		{	
			aElements[i].style.visibility = strVisibility;
			// HLA - Champs notes sous un séparateur inaccessible (mise en commentaire de la mdification de la position de l'objet) - Bug #8585
			//aElements[i].style.position = strPosition;
			aElements[i].style.display = strDisplay;
			aSubElements = aElements[i].childNodes;
			for( j = 0 ; j < aSubElements.length ; j++ )
			{
				if ( aSubElements[j].tagName == 'TD' )
				{
			        aSubElements[j].style.visibility = strVisibility;
					// HLA - Champs notes sous un séparateur inaccessible (mise en commentaire de la mdification de la position de l'objet) - Bug #8585
                    //aSubElements[j].style.position = strPosition;
                    aSubElements[j].style.display = strDisplay;
				}
			}
		}
	}
	//Redimensionne la fiche
	Resize();
}

function IsFieldObligatEmpty( bSave, strDescId, nTab )
{

	
	var COL_FLD_OBLIGAT = '#FFCCCC';
	var COL_FLD_BLANK = '#FFFFFF';
	var COL_FLD_READONLY = '#E6E6E6';
	
	var bNotEmpty = true;
	var bFieldObligatRules = false;
	if( !strDescId )
		strDescId = '0';
		
	// sph
	// 04/11/2007 
	// variable globale externe a tt.js
	var strListObligatField ='';	
	if (typeof(strListDescIdObligatRules) !='undefined')		
		strListObligatField = ';'+strListDescIdObligatRules+';';

	
	if( strDescId != '0')
		bFieldObligatRules = ( strListObligatField.indexOf(';' + strDescId +';', 0) > - 1 );

	//Démarrage
	if( strDescId == -1 )
		bFieldObligatRules = true;
			
	//Si la rubrique fait partie d'une régle de saisie obligatoire ou enregistrement de la fiche
	bFieldObligatRules = ( bFieldObligatRules || bSave )

	var strListObligatFieldEmpty ='';
	if( strListObligatField != ';;' && bFieldObligatRules )
	{	
		var strReturn = window.showModalDialog( 'DialogWaitRules.asp?Tab='+nTab+'&ObligatDescId='+strListObligatField, self, 'dialogHeight:130px;dialogWidth=300px;edge:Raised;center:1;help:0;resizable:0;status:0' );
		

		
		if( strReturn != '' )
		{
			var aList = strReturn.split ("&");
			for( var i=0;i<aList.length;i++)
			{
				aDescIdObligat = aList[i].split ( "=" );
				var strDescIdObligat = aDescIdObligat[0];
				aObligat = aDescIdObligat[1].split ( ";" );
				var strLabel = aObligat[0];
				var nObligat = parseInt( aObligat[1], 10 );
				var bObligat = ( nObligat == 1);
				if( document.getElementById( strDescIdObligat ) )	
				{
					if( document.getElementById( strDescIdObligat+'A' ) )
						strDescIdObligat = strDescIdObligat +'A';
					
					//Mise à jour du tag pour la saisie obligatoire
					document.getElementById( strDescIdObligat ).setAttribute("ednObligat", nObligat);
					
					//Changement de la couleur de fond
					if( !bObligat )
					{
						if( document.getElementById( strDescIdObligat ).readOnly )
							document.getElementById( strDescIdObligat ).style.backgroundColor = COL_FLD_READONLY;
						else
							document.getElementById( strDescIdObligat ).style.backgroundColor = COL_FLD_BLANK;
					}
					else
					{
						document.getElementById( strDescIdObligat ).style.backgroundColor = COL_FLD_OBLIGAT;
						if( trim( document.getElementById(strDescIdObligat).value ) == "" && bSave )	
						{
							if( strListObligatFieldEmpty != '' ) 
								strListObligatFieldEmpty = strListObligatFieldEmpty + ";";
							strListObligatFieldEmpty = 	strListObligatFieldEmpty + strLabel;
							G_bApply = false;
							bNotEmpty = false;
						}
					}
				}
			}
		}
	}
	if( strListObligatFieldEmpty != '')
	{
		var aListObligat = strListObligatFieldEmpty.split( ';' );
		strListObligatFieldEmpty ='';
		for( var i=0;i<aListObligat.length;i++)
		{
			var strLabel = '- ' + aListObligat[i];
			if( strListObligatFieldEmpty != '' )
				strListObligatFieldEmpty = strListObligatFieldEmpty + "\n";
			
			strListObligatFieldEmpty = strListObligatFieldEmpty + strLabel;
		}
		var strMsg = strRes1268;
		alert( strMsg + strListObligatFieldEmpty ); //JBE
		//DisableEnableLinks(1);
		//return bNotEmpty
	}
	//DisableEnableLinks(0);
	return bNotEmpty;
}

//TODO - 
//JBE - 31/03/2008 - Saisie obligatoire	
// Cette fonction active/désactive les divs sur les liens des pages affichées 
// pour obliger la saisie sur les champs obligatoires
/* function DisableEnableLinks(vAction)
{
	var divObligTop = top.frames['FraTop'].document.getElementById('DivOblig');
	var divObligBottom = top.frames['FraBottom'].document.getElementById('DivOblig');
	var divObligLeft = top.frames['FraLeft'].document.getElementById('DivOblig');
	var divObligDetail = top.frames['FraDetail'].document.getElementById('DivOblig');

	var strDivStyle;
	if (vAction = 0)
		strDivStyle = "none";
	else
		strDivStyle = "block";

	divObligTop.style.visibility = strDivStyle;
	divObligBottom.style.visibility = strDivStyle;
	divObligLeft.style.visibility = strDivStyle;
	divObligDetail.style.visibility = strDivStyle;
} */

function UpdateDefaultCatValue( nTab )
{
	for( i = nTab + 1 ; i < nTab + 100 ; i++ )	
	{
		if( document.getElementById('CAT_'+ i ) )
		{
			if( document.getElementById(i) )
				document.getElementById('CAT_'+ i ).value = document.getElementById(i).value;
		}
	}
}



function CollapseAllInlineTpl(nTab, strInlineFileIds)
{

	var aTmpInlineTpl = strInlineFileIds.split(";");
	var i;
	var nMaxExpandedTpl = aTmpInlineTpl.length;
	var InlineDiv;
	var InlineTr;
	for (i=0;i< nMaxExpandedTpl;i++)
	{
		InlineDiv = top.frames["FraDetail"].document.getElementById("DivInlineTpl_"+ nTab + "_" + aTmpInlineTpl[i]);
		InlineTr = top.frames["FraDetail"].document.getElementById("TrInlineTpl_"+ nTab + "_" + aTmpInlineTpl[i]);
		InlineTr.style.display = 'none';
	}
}


function ExpandAllInlineTpl(nExpandedTmp, nTab,strInlineFileIds,nTabFrom, nAutoOpenPj, nDialogHeight, nDialogWidth, nScheduleId, bAskScheduleSelect, vAction )
{

	var aTmpInlineTpl = strInlineFileIds.split(";");
	var i;
	var nMaxExpandedTpl = aTmpInlineTpl.length;
	if (nExpandedTmp == -1)
		nMaxExpandedTpl = aTmpInlineTpl.length;
	else
		if (nExpandedTmp < nMaxExpandedTpl)
			nMaxExpandedTpl = nExpandedTmp ;
	//ouvrir n fiches max
	if (nMaxExpandedTpl > 5)
		nMaxExpandedTpl = 5;
	for (i=0;i< nMaxExpandedTpl;i++)
	{
		ShInlineTpl (nTab,aTmpInlineTpl[i], nTabFrom, nAutoOpenPj, nDialogHeight, nDialogWidth, nScheduleId, bAskScheduleSelect, vAction );
	}
}
function ShInlineTpl( nTab, nFileId, nTabFrom, nAutoOpenPj, nDialogHeight, nDialogWidth, nScheduleId, bAskScheduleSelect, vAction )	
{

	if( !nDialogHeight )		nDialogHeight = 0;
	if( nDialogHeight < 100 )	nDialogHeight = 300;
	if( !nDialogWidth )			nDialogWidth = 0;
	if( nDialogWidth < 100 )	nDialogWidth = 710;
	if( !nScheduleId )			nScheduleId = 0;
	if( bAskScheduleSelect == null )	bAskScheduleSelect = true;
	

	if (vAction == 0){

		try{
			var InlineDiv = top.frames["FraDetail"].document.getElementById("DivInlineTpl_"+ nTab + "_" + nFileId);
			var InlineTr = top.frames["FraDetail"].document.getElementById("TrInlineTpl_"+ nTab + "_" + nFileId);
			InlineTr.style.display='none';
			var MainTr = top.frames["FraDetail"].document.getElementById("Tr_Main_" + nTab + "_" + nFileId);
			MainTr.style.backgroundColor = "";
		}catch(e){}
			return;
		}
	
	if( nTab == 100000 ) // TAB_HISTO
	{
		var strDatas = showFileDialog( nTab, nFileId );
		if( strDatas )	
		{
			if( strDatas.substring(0,2) == '-1' )
				top.frames['FraTmp'].location = 'TplDelete.asp?tab='+nTab+'&FileId='+nFileId;
		}
	}
	else
	{
		if( !nAutoOpenPj )
			nAutoOpenPj = 0;
			
		var strSerie = '0';
		

	
		try{
			var MainTr = top.frames["FraDetail"].document.getElementById("Tr_Main_" + nTab + "_" + nFileId);
			MainTr.style.backgroundColor = "#D9ECFF";
		}
		catch(e){}
		var InlineTr  = top.frames["FraDetail"].document.getElementById("TrInlineTpl_"+ nTab + "_" + nFileId);
		var InlineDiv = top.frames["FraDetail"].document.getElementById("DivInlineTpl_"+ nTab + "_" + nFileId);

		// JLA #8966
		var is_ie = (((navigator.userAgent.toLowerCase()).indexOf("msie")!=-1)&&((navigator.userAgent.toLowerCase()).indexOf("opera")==-1));
		
		if(is_ie){
			InlineTr.style.display = 'block';
			InlineTr.style.height = nDialogHeight + 'px';
		} else {
			InlineTr.style.display = '';
		}
			
		InlineDiv.innerHTML = "<img align=center id='IMG_"+nTab + "_" + nFileId +"' src='"+ strImgLoading +"' />";
		var strOnload = "this.style.visibility = 'visible';document.getElementById('IMG_"+nTab + "_" + nFileId+"').style.display = 'none';";
		// MAB - 20090731 - bug #9918 - la bordure à 0 doit être définie dans le style et non par attribut border pour Firefox
		InlineDiv.innerHTML += "<iframe scrolling=\"no\" onload=\""+ strOnload +"\" style='visibility:hidden; border: 0px;' id='frm_"+ nTab + "_" + nFileId +"' width=\"100%\" height=\"100%\" src=\""  + "TplFiche.asp?new=0&tabfrom="+nTabFrom+"&tab="+nTab+"&FileId="+nFileId+"&AutoOpenPj="+nAutoOpenPj+"&OpenSerie="+strSerie+"&ScheduleId="+nScheduleId + "&InlineMode=1\"><br><hr>";

	}
}



//JBE - Mode incrusté Address
function ShInlineAdr( nFileId )	
{
		
	
		try{
			var MainTr = top.frames["FraDetail"].document.getElementById("Tr_Main_400_" + nFileId);
			MainTr.style.backgroundColor = "#D9ECFF";
		}
		catch(e){}
		var InlineTr  = top.frames["FraDetail"].document.getElementById("TrInlineTpl_400_" + nFileId);
		var InlineDiv = top.frames["FraDetail"].document.getElementById("DivInlineTpl_400_" + nFileId);

		// JLA #8966
		var is_ie = (((navigator.userAgent.toLowerCase()).indexOf("msie")!=-1)&&((navigator.userAgent.toLowerCase()).indexOf("opera")==-1));
		
		if(is_ie){
			InlineTr.style.display = 'block';
			InlineTr.style.height = nDialogHeight + 'px';
		} else {
			InlineTr.style.display = '';
		}
			
		InlineDiv.innerHTML = "<img align=center id='IMG_400_" + nFileId +"' src='"+ strImgLoading +"' />";
		var strOnload = "this.style.visibility = 'visible';document.getElementById('IMG_400_" + nFileId+"').style.display = 'none';";
		// MAB - 20090731 - bug #9918 - la bordure à 0 doit être définie dans le style et non par attribut border pour Firefox
		InlineDiv.innerHTML += "<iframe scrolling=\"no\" onload=\""+ strOnload +"\" style='visibility:hidden; border: 0px;' id='frm_400_" + nFileId +"' width=\"100%\" height=\"100%\" src=\"FileDialogParent.asp?InlineMode=1&Tab=400&FileId="+ nFileId +"&TabFrom=200&PpId=0&PmId=0&EvtId=0&AdrId=0&\"><br><hr>";

	
}
//ELA le 13/05/2008
function SubmitMemoHtml(strValue, nDescId, nFileId, nFrom)
{
//Fichier Principal
if (nFrom == '1') top.frames['FraTmp'].location = 'Update.asp?fileid='+nFileId+'&descid='+nDescId+'&value='+encode(strValue);
//Fichier Principal (boîte de dialogue)
//if (nFrom == '3') top.frames['FraTmp'].location = 'Update.asp?fileid='+nFileId+'&descid='+nDescId+'&value='+encode(strValue);
//Sous-Fichier (boîte de dialogue)
if (nFrom == '2') top.frames['FraTplFicheTmp'].location = 'Update.asp?fileid='+nFileId+'&descid='+nDescId+'&value='+encode(strValue);
}

/*function sleep(nMs) 
{
var date = new Date();
var curDate = null;

do { curDate = new Date(); } 
while(curDate-date < nMs);
} 
*/

// HLA - Ajout de la signature sur un memo non HTML sur une fiche planning - Bug #9167
function AddDateUser( sItemId, sSign, sReadOnly )
{
	if( sReadOnly == '1' )
		return;
	
	var oItem = document.getElementById(sItemId);
	if(oItem) {
		oItem.value = decode(sSign)+ '\r\n' + oItem.value;
		oItem.focus();
	}
}

function detectionShift(e)
{
	try
	{
		e = e || event;
		return e.shiftKey;
	}
	catch(exp)
	{
		return false;
	}
}

function detectionCtrl(e)
{
	try
	{
		e = e || event;
		return e.ctrlKey;
	}
	catch(exp)
	{
		return false;
	}
}


//ELA le 07/04/2009 - Suppression manuelle de fiches template
function OKU(e)
{
	if (e.keyCode == 46)
		{
		var oFrTmp = top.frames['FraTmp'];
		var strDeletedDescId = '';
		for (i=0;i<=oDeleteTplid.length-1;i++)
			{
			if (oDeleteTplidStatus[i] == 1)
				{
				strDeletedDescId = strDeletedDescId + oDeleteTplid[i] + ';';
				}
			}
		if (strDeletedDescId != '' && nTabToDeleteFrom != 0)
			{
			var strDelete = window.showModalDialog( 'TplDeleteManual.asp?variable=SelectedId&value='+strDeletedDescId+'&tab='+nTabToDeleteFrom, '', 'dialogHeight:110px;dialogWidth:400px;edge:Raised;center:1;help:0;resizable:0;status:0');
			if (strDelete)
				{
				oFrTmp.location = 'TplDelete.asp?tab='+nTabToDeleteFrom+'&session=SelectedId';
				}
			}
		}
	else
		{
		if (e.keyCode == 27)
		{
		CancelDeleteSelection();
		}
		}
}
function CancelDeleteSelection ()
{
		//ELA le 07/04/2009 - Suppression manuelle de fiches template
		if (document.getElementById('ednlist_'+nTabToDeleteFrom))
				{
				var oTable = document.getElementById('ednlist_'+nTabToDeleteFrom);
				}
		if (oTable)
			{
			var oRecords = oTable.getElementsByTagName('tr');
			for (var i=0; i<=oRecords.length-1; i++)
				{
				oRecords[i].style.backgroundColor = '';
				if (oRecords[i].getElementsByTagName('img'))
					{
					var oImg = oRecords[i].getElementsByTagName('img');
					for (var j=0; j<=oImg.length-1; j++)
						{
						if (oImg[j].getAttribute('id'))
							{
							var sAttrib = oImg[j].getAttribute('id');
							if (sAttrib.indexOf('IMG_') > -1)
								{
								oImg[j].src = document.getElementById('PICTO_ORIG_'+nTabToDeleteFrom).value;
								}
							}
						}
					}
				}
			for (i=0;i<=oDeleteTplid.length-1;i++)
			{
			oDeleteTplid[i] = '';
			oDeleteTplidStatus[i] = 0;
			}
			strDeletedDescId = '';
			nTabToDeleteFrom = 0;
			}
}

