//Code JavaScript concernant l'interface Web du projet 
//Auteurs
//	Paul Peltier
//Date de création
//	28/11/2000

//--------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------
//Rafraîchissement de frames, manipulation URL, ouverture de document - Project standard - applet needed
//--------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------

//Affiche le menu principal (au chargement de l'application
//Ne pas isoler
//Auteur
//	Paul Peltier
//Date de création
//	29/01/2002
function openMainMenu()
{
	appAppletDesignBase = 
		window
			.top
			.frames[CONST_FS_START_FRAME_NAME]
			.frames[CONST_FS_PRINCIPAL_LEFT_FRAME_NAME]
			.document
			.applets
			.Applet99DesignBase;

	appAppletDesignBase.openMainMenu();
	refreshFrames();
}

//--------------------------------------------------------------------------------------------------------------

//Charge le rapport dans un fenêtre séparée
//Ne pas passer ds autre JS
//Paramètre
//	strParam - le numéro de l'agent (1 à 3)
//Auteur
//	Paul Peltier
//Date de création
//	29/11/2001
function execAgent(
	strParam)
{
	var strUrl;
	var winValue;

	strUrl = 
		appAppletDesignBase.getUrl(
			CONST_URL_AGENT,
			"system_data",
			"",
			"",
			"",
			strParam);

	//On crée la fenêtre fille
	winValue = window.open(
		strUrl, 
		'', 
		'width=200, height=20, left=150, top=75, resizable=yes, scrollbars=yes');

	//On lui donne le focus
	winValue.focus();
}

//--------------------------------------------------------------------------------------------------------------

//Affiche la fenêtre de création d'un document
//Paramètre
//	strType - le type d'URL à généré, , soit : "NEW_DOC", "VIEW", FROM_UNID", "CHOICE_VIEW"
//	strForm - le nom de la notion
//Auteur
//	Paul Peltier
//Date de création
//	27/11/2000
function getUrl_old(
	strType,
	strForm)
{
	var strUrl;
	var strUnId;

	//On recherche l'URL à ouvrir
	if (strForm == "")
		strForm = strCurrentForm;

	strUnId = "";

	strUrl = 
		appAppletDesignBase.getUrl(
			strType,
			strForm,
			"",
			"",
			"",
			strUnId);

	docCurrentDoc.location.replace(strUrl);
}

//--------------------------------------------------------------------------------------------------------------

//Ouvre la page résultat dans la fenêtre courrante
//Appelé en interface via les vues interprétées HTML (recherche)
//Paramètre
//	strBaseName - le nom de la base (formatté à partir des formules avec des / et pas des \)
//	strViewName - le nom d'une vue auquel le document est rattaché
//	strDocUnid - unid du document
//Auteur
//	Paul Peltier
//Date de création
//	02/01/2002
function openElement(
	iType,
	strUrl,
	strTargetFrameName,
	strNotionName,
	strMenuParentName,
	strStart,
	strCount,
	strUnId,
	strParam)
{
	//Modif pour permettre l'accès à des bases hors projet qui ont des notions communes
	appAppletDesignBase.openElement(
		iType,
		strUrl,
		strTargetFrameName,
		strCurrentForm,
		strNotionName,
		strMenuParentName,
		strStart,
		strCount,
		strUnId,
		strParam);
	
	refreshFrames();
}

//--------------------------------------------------------------------------------------------------------------

//Rafraîchit les frames qui doivent l'être
//Auteur
//	Paul Peltier
//Date de création
//	18/02/2002
function refreshFrames()
{
	var vectFrameRefreshValues;
	var tblFrameRefreshValues;
	var tblTemp;
	var strFrameName;
	var strUrl;
	var i;

	vectFrameRefreshValues = 
		appAppletDesignBase.getFrameRefreshValues();

	tblFrameRefreshValues = 
		convertVectorToArray(
			vectFrameRefreshValues);
	
	for (i = 0; i < tblFrameRefreshValues.length; i++)
	{
		tblTemp = tblFrameRefreshValues[i];
		strFrameName = tblTemp[0];
		strUrl = tblTemp[1];
		
		//Refraîchissement par switch
		if (strFrameName == CONST_FS_PRINCIPAL_RIGHT_FRAME_NAME)
			window
				.top
				.frames[CONST_FS_START_FRAME_NAME]
				.frames[CONST_FS_PRINCIPAL_RIGHT_FRAME_NAME]
				.location.replace(strUrl);
		if (strFrameName == CONST_FS_PRGM_MAIN_FRAME_NAME)
			window
				.top
				.frames[CONST_FS_START_FRAME_NAME]
				.frames[CONST_FS_PRINCIPAL_RIGHT_FRAME_NAME]
				.frames[CONST_FS_PRGM_MAIN_FRAME_NAME]
				.location.replace(strUrl);
		if (strFrameName == CONST_FS_PRGM_TOP_FRAME_NAME)
			window
				.top
				.frames[CONST_FS_START_FRAME_NAME]
				.frames[CONST_FS_PRINCIPAL_RIGHT_FRAME_NAME]
				.frames[CONST_FS_PRGM_TOP_FRAME_NAME]
				.location.replace(strUrl);
		if (strFrameName == CONST_FS_INITIAL_TOP_FRAME_NAME)
			window
				.top
				.frames[CONST_FS_START_FRAME_NAME]
				.frames[CONST_FS_PRINCIPAL_RIGHT_FRAME_NAME]
				.frames[CONST_FS_PRGM_LEFT_FRAME_NAME]
				.frames[CONST_FS_INITIAL_TOP_FRAME_NAME]
				.location.replace(strUrl);
		if (strFrameName == CONST_FS_INITIAL_BOTTOM_FRAME_NAME)
			window
				.top
				.frames[CONST_FS_START_FRAME_NAME]
				.frames[CONST_FS_PRINCIPAL_RIGHT_FRAME_NAME]
				.frames[CONST_FS_PRGM_LEFT_FRAME_NAME]
				.frames[CONST_FS_INITIAL_BOTTOM_FRAME_NAME]
				.location.replace(strUrl);
		if (strFrameName == CONST_FS_CHOICE_MAIN_FRAME_NAME)
			winChoiceWindow
				.top
				.frames[CONST_FS_CHOICE_MAIN_FRAME_NAME]
				.location.replace(strUrl);
		if (strFrameName == CONST_FS_CHOICE_TOP_FRAME_NAME)
			winChoiceWindow
				.top
				.frames[CONST_FS_CHOICE_TOP_FRAME_NAME]
				.location.replace(strUrl);
		if (strFrameName == "_blank")
			window.open(
				strUrl, 
				'', 
				'width=640, height=480, left=150, top=75, resizable=yes, scrollbars=yes');
	}

	appAppletDesignBase.resetFrameRefreshValues();
}

//--------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------
//Manipulation URL (no applet needed)
//--------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------

//Ouvre la page résultat dans la fenêtre courrante
//Paramètre
//	strFIELDNAME - le nom du champ à chercher
//Auteur
//	Paul Peltier
//Date de création
//	02/01/2002
function changeURL_old(
	strUrl)
{
	window.location.replace(strUrl);
}

//--------------------------------------------------------------------------------------------------------------

//Ouvre la page résultat dans la fenêtre courrante
//Appelé en interface via les vues interprétées HTML (recherche)
//Paramètre
//	strBaseName - le nom de la base (formatté à partir des formules avec des / et pas des \)
//	strViewName - le nom d'une vue auquel le document est rattaché
//	strDocUnid - unid du document
//Auteur
//	Paul Peltier
//Date de création
//	02/01/2002

function openDocInParent(
	strBaseName,
	strViewName,
	strDocUnid)
{
	var winValue;
	var strUrl;
	
//	strUrl = "/" + strBaseName + "/" + strViewName + "_view/" + strDocUnid + "?OpenDocument";
	strUrl = "/" + strBaseName + "/" + strViewName + "_view/" + strDocUnid + "/$FILE/visu.html?OpenElement";

	this.popupW = window.open(
		strUrl, 
		'Popup', 
		'width=640, height=480, left=150, top=75, resizable=yes, scrollbars=yes');
if (this.popupW != null) if (!this.popupW.closed) this.popupW.focus();				
}

//--------------------------------------------------------------------------------------------------------------

//Ouvre la page résultat dans le frame
//Appelé en interface via les vues interprétées HTML (recherche)
//Paramètre
//	strBaseName - le nom de la base (formatté à partir des formules avec des / et pas des \)
//	strViewName - le nom d'une vue auquel le document est rattaché
//	strDocUnid - unid du document
//Auteur
//	Paul Peltier
//Date de création
//	02/01/2002
function openDocInFrame(
	strBaseName,
	strViewName,
	strDocUnid)
{
	
	var strUrl;
	
//	strUrl = "/" + strBaseName + "/" + strViewName + "_view/" + strDocUnid + "?OpenDocument";
	strUrl = "/" + strBaseName + "/" + strViewName + "_view/" + strDocUnid + "/$FILE/visu.html?OpenElement";

	window.location.href=strUrl;
}

