/****************************************************/
/* Vérifie une variable:							*/
/****************************************************/
function GL_CheckName(Name)
{
	a=0;
	while(RF_ListID[a]!=0)
	{
		if(RF_ListName[RF_ListID[a]]==Name)
			return 1;
		a++;
	}
	return 0;
}

/****************************************************/
/* Submit le formulaire:							*/
/****************************************************/
function GL_Submit()
{
	document.forms[GL_FormName].action=GL_Action;
	document.forms[GL_FormName].submit();
}

/****************************************************/
/* Crée un nouvelle liste:							*/
/****************************************************/
function GL_NewList(Check)
{
	var NL_Nom=document.forms[GL_FormName].elements["NL_Nom"].value;
	
	if(Check)
	{
		if(NL_Nom=="")
		{
			window.alert(RFMessage["GL_CHOSE_NAME_FIRST"]);
			return;	
		}
		if(GL_CheckName(NL_Nom))
		{
			window.alert(RFMessage["GL_NAME_USED"]);
			return;	
		}
	}
	document.forms[GL_FormName].elements["Action"].value="Create";
	GL_Submit();
}

/****************************************************/
/* Efface une liste:								*/
/****************************************************/
function GL_KillList(Check)
{
	if(Check)
	{
		if(RF_No_List(document.forms[GL_FormName].elements["GL_List[]"]))
		{
			window.alert(RFMessage["GL_CREATE_LIST_FIRST"]);
			return;	
		}
		if(document.forms[GL_FormName].elements["GL_List[]"].value<=0)
		{
			window.alert(RFMessage["GL_CHOSE_LIST_FIRST"]);
			return;	
		}
		if(RF_ListName[document.forms[GL_FormName].elements["GL_List[]"].value]==RF_Def_List_Name)
		{
			window.alert(RFMessage["GL_DEL_DEF_LIST"]);
			return;	
		}
	}
//	if(!window.confirm(RFMessage["GL_DL_WARNING"] + RF_ListName[document.forms[GL_FormName].elements["GL_List[]"].value]))return;
	if(!window.confirm(RFMessage["GL_DL_WARNING"]))return;
	document.forms[GL_FormName].elements["Action"].value="Kill";
	GL_Submit();
}

/****************************************************/
/* Si on veut renommer une liste:					*/
/****************************************************/
function GL_RenameList(Check)
{
	if(Check)
	{
		if(RF_No_List(document.forms[GL_FormName].elements["GL_List[]"]))
		{
			window.alert(RFMessage["GL_CREATE_LIST_FIRST"]);
			return;	
		}
		if(document.forms[GL_FormName].elements["GL_List[]"].value<=0)
		{
			window.alert(RFMessage["GL_CHOSE_LIST_FIRST"]);
			return;	
		}
		if(RF_ListName[document.forms[GL_FormName].elements["GL_List[]"].value]==RF_Def_List_Name)
		{
			window.alert(RFMessage["GL_REN_DEF_LIST"]);
			return;	
		}
		if(RF_ListName[document.forms[GL_FormName].elements["GL_List[]"].value]==document.forms[GL_FormName].elements["RL_Nom"].value)
		{
			window.alert(RFMessage["GL_REN_SAME_NAME"]);
			return;	
		}
		if(GL_CheckName(document.forms[GL_FormName].elements["RL_Nom"].value))
		{
			window.alert(RFMessage["GL_NAME_USED"]);
			return;	
		}
	}
	document.forms[GL_FormName].elements["Action"].value="Rename";
	GL_Submit();
}

/****************************************************/
/* Si on veut un lien vers une liste:				*/
/****************************************************/
function GL_GetLink(Check)
{
	if(Check)
	{
		if(RF_No_List(document.forms[GL_FormName].elements["GL_List[]"]))
		{
			window.alert(RFMessage["GL_CREATE_LIST_FIRST"]);
			return;	
		}
		if(document.forms[GL_FormName].elements["GL_List[]"].value<=0)
		{
			window.alert(RFMessage["GL_CHOSE_LIST_FIRST"]);
			return;	
		}
	}
	
	var SizeX=550;
	var SizeY=350;
	PopName="RFGL";
	TmpTxt="scrollbars=no,location=no,menubar=no,width="+SizeX+",height="+SizeY;
	window.open("",PopName,TmpTxt);

	Form=document.forms[GL_FormName];
	Form.action="GetLink.php";
	Form.target=PopName;
	Form.elements["Action"].value="GetLink";
	Form.submit();
	Form.target="_self";
}

/****************************************************/
/* Si on change le nom de la liste:					*/
/****************************************************/
function GL_ListChange()
{
	document.forms[GL_FormName].elements["RL_Nom"].value=RF_ListName[document.forms[GL_FormName].elements["GL_List[]"].value];
}