
/*************************************************************************/
// SCRIPT CLIENT ASSOCIE A simplectrl.asp
/*************************************************************************/

var cst_sAssistMoreURL = "assistmore.asp";

// CONSTANTES CAssistText
var cst_sAssitURL = "/_framework/business/assist.asp";

// VARIABLES GLOBALES !!!
var glb_bIsNetscape = (navigator.appName == "Netscape");	// True si netscape

/*************************************************************************/
// FONCTION : isUndefined
// DESCRIPTION : Definit si la fonction est definie
// PARAMETRES : 
//	- p_ToTest : Information a tester
// RETOUR : true si indefini, false sinon
/*************************************************************************/
function isUndefined(p_ToTest){
	return (escape(p_ToTest) == "undefined");
}

// CONTROLE CCheckList
/*************************************************************************/
// FONCTION : _chklExclusive, liee a CCheckList
// DESCRIPTION : Permet la gestion de l'exclusion
// PARAMETRES : 
//	- p_sCurrentForm : Nom du formulaire courant
//	- p_sId : Identifiant du groupe de control
//	- p_iNbCheck : Nombre de check dans le controle
//	- p_iCurrentCheck : Index du check courant
// RETOUR : rien
/*************************************************************************/
function _chklExclusive(p_sCurrentForm, p_sId, p_iNbCheck, p_iCurrentCheck)
{
	if (!glb_bIsNetscape)
	{
		var iIndex;
		var currentForm = document.forms[0];
	
		if (p_sCurrentForm)
			currentForm = document.forms[p_sCurrentForm];
	
		for (iIndex = 0; iIndex < p_iNbCheck; iIndex++)
		{
			// On passe a faux tous les controles deja coche
			if (iIndex != p_iCurrentCheck &&
				currentForm.elements(p_sId + iIndex).status)
				currentForm.elements(p_sId + iIndex).status = false;
		}
	}
	else
	{
		var iIndex;
		var iElementIndex;
		var currentForm = document.forms[0];
		var tCheck = new Array();
	
		// Recherche du premier element
		for (iElementIndex = 0; 
			 iElementIndex < currentForm.elements.length; 
			 iElementIndex++)
		{
			if (currentForm.elements[iElementIndex].name == p_sId)
				tCheck[tCheck.length] = currentForm.elements[iElementIndex];
		}
		
		for (iIndex = 0; iIndex < p_iNbCheck; iIndex++)
		{
			// On passe a faux tous les controles deja coche
			if (iIndex != p_iCurrentCheck &&
				tCheck[iIndex].status)
				tCheck[iIndex].status = false;
		}
	}	
}

// CONTROLE CAssitText
/*************************************************************************/
// FONCTION : _atLaunchAssist, liee a CAssitText
// DESCRIPTION : Permet de lancer un assistant
// PARAMETRES : 
//	- p_sType : Type de l'assistant
//	- p_sCtrlTarget : Contrôle texte cible
//	- p_bConcat : Definit si on est en concatenation ou non
//	- p_sLng : Langue
//	- [p_sMultiple] : Si multiple
//	- [p_sCtrlTargerShow] : Cible pour affichage
// RETOUR : rien
/*************************************************************************/
function _atLaunchAssist(p_sType, 
						 p_sCtrlTarget, 
						 p_bConcat,
						 p_sLng,
						 p_sMultiple, 
						 p_sCtrlTargerShow)
{
	if (isUndefined(p_sMultiple)) p_sMultiple = false;
	if (isUndefined(p_sCtrlTargerShow)) p_sCtrlTargerShow = "";
	window.open(cst_sAssitURL + 
					"?type=" + p_sType +
					"&ctrlTarget=" + p_sCtrlTarget + 
					"&concat=" + p_bConcat +
					"&lng=" + p_sLng + 
					"&multiple=" + p_sMultiple +
					"&ctrlTargetShow=" + p_sCtrlTargerShow,
				"assistWnd",
				"location=no,personalbar=no,status=no,resizable=yes," + 
					"menubar=no,alwaysRaised=yes,scrollbars=yes");
}

// CONTROLE CMoreButton
/*************************************************************************/
// FONCTION : _mbtLaunchMoreWnd, liee a CMoreButton
// DESCRIPTION : Permet de lancer une fenêtre de saisie multiple
// PARAMETRES : 
//	- p_sType : Type de l'assistant
//	- p_sCtrlTarget : Contrôle texte cible
//	- p_sLng : Langue
// RETOUR : rien
/*************************************************************************/
function _mbtLaunchMoreWnd(p_sType, 
						   p_sCtrlTarget, 
						   p_sLng,
						   p_sValues,
						   p_lMaxFileSize)
{
	if (isUndefined(p_lMaxFileSize)) p_lMaxFileSize = 0;
	
	window.open(cst_sAssistMoreURL + 
					"?type=" + p_sType +
					"&ctrlTarget=" + p_sCtrlTarget + 
					"&lng=" + p_sLng +
					"&values=" + p_sValues +
					(p_lMaxFileSize > 0 ? "&maxfilesize=" + p_lMaxFileSize : ""),
				"assistWnd",
				"location=no,personalbar=no,status=no,resizable=yes," + 
					"menubar=no,alwaysRaised=yes,scrollbars=yes");
}
