/*
   files which will show all forms */

var form_management=
{	
	getForm : function(formName)
	{
		return document.getElementById(formName);
	}
	,
	showAddRSSForm: function()
	{
		document.getElementById("addRSS-Form-Header").style.display='inline-block';
		document.getElementById("addRSS-Form").style.display='inline-block';
		document.getElementById("addRSS-URL").focus();
		document.getElementById("addRSS-URL").select();
	}
	,
	addRSSForm: function(parentObj, sTitle)
	{
		var  iWidth = 300;
		//var g_oMovableWindowManager = new MovableWindow();
		MovableWindow_addMovableWindow(parentObj, "addRSS-Form", sTitle, iWidth);
		parentObj.appendChild(document.createElement('BR'));
		var form = document.createElement('DIV');
		form.style.clear	= 'both';
		form.id 			= 'addRSS-Form';
		form.style.display	= 'none';
		form.style.width	= iWidth + 'px';
		form.setAttribute("align","left");
		
		var sTemp='http://';
		
		var content = '<label id="addRSS-Title">Ajouter : </label></br><form>Source:<input type="text" id="addRSS-URL" value="' + sTemp + '" size="25" maxlength="255">'
		+'<div align="center"><input id="addRSS-Public" type="radio" value="Public" name="public" checked>Public<input id="addRSS-Private" type="radio" value="Private" name="public">Private</div>'
		+'<div align="center"><input id="addRSS-Button" type="button" onclick="DB_addRSS(document.getElementById(\'addRSS-URL\').value);" value="Save"><input type=button onclick="document.getElementById(\'addRSS-Form-Header\').style.display=\'none\';document.getElementById(\'addRSS-Form\').style.display=\'none\';" value="Cancel"></div><\/form>';
		form.innerHTML = content;
		
		parentObj.appendChild(form);
		// Afficher un menu au milieu
	}
	,
	addAssertForm: function(parentObj)
	{
		var form = document.createElement('DIV');
		form.style.clear='both';
		form.id = 'assert-form';
		form.style.display='none';
		parentObj.appendChild(form);
		// Afficher en haut à droite
		// Ou au milieu en bas
	}
	,
	/************* LOADFORM *****************/
	loadForm: function(divName, name, sTitle)
	{
		if (name == "addRSS")
		{
			form_management.addRSSForm(document.getElementById(divName), sTitle);
		}
		else if (name == "assertForm")
		{
			form_management.addAssertForm(document.getElementById(divName));
		}
	}
	,	
	addLinkTo: function(boxIndex, boxIdDB)
	{
		AW_Show(g_lang_link_adding, false);
		var url = document.getElementById("addInput").value;
		var optionList = document.getElementsByName("addTypeRadio");
		var privacyValue = 0;
		for (var i = 0; i < optionList.length; i++)
		{
			if (optionList[i].checked)
			{
				privacyValue = optionList[i].value;
				break;
			}
		}
		// add link in the db
		DB_addLink(boxIdDB, boxIndex, url, privacyValue);
	}
	,
	shareLink: function()
	{
		AW_Show(g_lang_link_sharing, false);
		var url = document.getElementById("addInput").value;
		var optionList = document.getElementsByName("addTypeRadio");
		var privacyValue = 0;
		for (var i = 0; i < optionList.length; i++)
		{
			if (optionList[i].checked)
			{
				privacyValue = optionList[i].value;
				break;
			}
		}
		// add link in the db
		DB_shareLink(url, privacyValue);
	}
}
