//Code JavaScript concernant l'interface Web du projet 
//Auteur
//	Paul Peltier
//Date de création
//	28/11/2000

//--------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------
//Fonction commune de chargement
//--------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------

//Procédure de chargement d'une page
//Paramètre
//	docValue - contexte sur le document contenant le formulaire d'étude
//	strType - type d'exécution: "0": stand, "1": choice, "2":standalone, "3": qp
//Auteur
//	Paul Peltier
//Date de création
//	28/11/2000
function onLoadDocument(
	docValue,
	iType)
{
	switch(iType)
	{
		case CONST_LOAD_STANDAPPLET:
			//Lancement type Notes
			winCurrentWindow = window.top;
			docCurrentDoc = docValue;
			appAppletDesignBase = 
				window
					.top
					.frames[CONST_FS_START_FRAME_NAME]
					.frames[CONST_FS_PRINCIPAL_LEFT_FRAME_NAME]
					.document
					.applets
					.Applet99DesignBase;
			formCurrentForm = docCurrentDoc.forms[0];
			strCurrentForm = formCurrentForm.elements["doc_form"].value;
			strCurrentType = "";
			strCurrentBaseName = "";
			boolCurrentSelectMode = true;
			strCurrentLoad = "stand";
			onLoadStand();
			refreshFrames();
			break;

		case CONST_LOAD_CHOICE:
			//Cas du choice
			docChoiceDoc = docValue;
			formChoiceForm = docChoiceDoc.forms[0];
			strChoiceForm = formChoiceForm.elements["doc_form"].value;
			onLoadChoice();
			refreshFrames();
			break;

		case CONST_LOAD_STANDALONE:
			//C'est donc un lancement isole
			docCurrentDoc = docValue;
			formCurrentForm = docCurrentDoc.forms[0];
			if (fieldExists(formCurrentForm, "doc_form"))
				strCurrentForm = formCurrentForm.elements["doc_form"].value;
			strCurrentLoad = "standalone";
			strCurrentType = "";
			strCurrentBaseName = "";
			onLoadStandalone(formCurrentForm);
			break;
			
		case CONST_LOAD_QP:
			//Lancement type qp
			docCurrentDoc = docValue;
			appAppletDesignBase = 
				window
					.top
					.frames[CONST_FS_START_FRAME_NAME]
					.frames[CONST_FS_PRINCIPAL_LEFT_FRAME_NAME]
					.document
					.applets
					.Applet99DesignBase;
			formCurrentForm = docCurrentDoc.forms["h_PageUI"];
			strCurrentForm = formCurrentForm.elements["doc_form"].value;
			strCurrentLoad = "qp";
			strCurrentType = "";
			strCurrentBaseName = "";
			break;
			
		case CONST_LOAD_APPLET_PAGE:
			//Lancement page applet
			while(window == "undefined");
			while(window
				.top == "undefined");
			while(window
				.top
				.frames[CONST_FS_START_FRAME_NAME] == "undefined");
			while(window
				.top
				.frames[CONST_FS_START_FRAME_NAME]
				.frames[CONST_FS_PRINCIPAL_LEFT_FRAME_NAME] == "undefined");
			while(window
				.top
				.frames[CONST_FS_START_FRAME_NAME]
				.frames[CONST_FS_PRINCIPAL_LEFT_FRAME_NAME]
				.document == "undefined");
			while(window
				.top
				.frames[CONST_FS_START_FRAME_NAME]
				.frames[CONST_FS_PRINCIPAL_LEFT_FRAME_NAME]
				.document
				.applets == "undefined");
/*			alert(window
				.top
				.frames[CONST_FS_START_FRAME_NAME]
				.frames[CONST_FS_PRINCIPAL_LEFT_FRAME_NAME]
				.document
				.applets.Applet99DesignBase);
*/
			while(window
				.top
				.frames[CONST_FS_START_FRAME_NAME]
				.frames[CONST_FS_PRINCIPAL_LEFT_FRAME_NAME]
				.document
				.applets
				.Applet99DesignBase == "undefined");

			appAppletDesignBase = 
				window
					.top
					.frames[CONST_FS_START_FRAME_NAME]
					.frames[CONST_FS_PRINCIPAL_LEFT_FRAME_NAME]
					.document
					.applets
					.Applet99DesignBase;
//			alert(appAppletDesignBase);
			
			iIdCheck = window.setInterval(
				"checkApplet();",
				2000);
			break;
	}
}

//--------------------------------------------------------------------------------------------------------------

//Procédure de chargement d'une page
//Paramètre
//	docValue - contexte sur le document contenant le formulaire d'étude
//	strType - type d'exécution: "0": stand, "1": choice, "2":standalone, "3": qp
//Auteur
//	Paul Peltier
//Date de création
//	28/11/2000
function checkApplet()
{
	appAppletDesignBase = 
		window
			.top
			.frames[CONST_FS_START_FRAME_NAME]
			.frames[CONST_FS_PRINCIPAL_LEFT_FRAME_NAME]
			.document
			.applets
			.Applet99DesignBase;

	if(appAppletDesignBase
		.getFrameRefreshValues() == null)
		return;

	window.clearInterval(iIdCheck);
	refreshFrames();
}

