///////////////////////////////////////////////////////////////////////////////////////////////////
//	DLibMod LD Links JavaScript code - copyright davidviner.com 2009
//
//	08.04.2009	1.6.1	DJV		Added clrRestrict function.
//
///////////////////////////////////////////////////////////////////////////////////////////////////

DLMLDLinks = function ()
{
	var	ajax;

	var _private =
	{
		response : function ()
		{
			if (DLibUtilities.checkAjax (ajax))
			{
				window.location.reload ();
			}
		}
	}

	var _public =
	{
		clrRestrict : function ()
		{
			ajax = DLibUtilities.initAjax ("/util.php?um=ldlinks&mode=c", _private.response);
		},

		setRestrict : function (fld, hierarchy)
		{
			var fv = document.getElementById (fld).value;

			ajax = DLibUtilities.initAjax ("/util.php?um=ldlinks&mode=" + hierarchy + "&f=" +
				fld + "&v=" + escape (fv), _private.response);
		},

		descriptionLimit : function (fn, max)
		{
			var fld = document.getElementById (fn);
			var txt = fld.value;
			var l = txt.length;

			if (l > max)
			{
				txt = txt.substring (0, max);
				fld.value = txt;
				l = max;
			}

			document.getElementById (fn + "limit").innerHTML = "Limit: " + (max - l);
		}
	}

	return _public;
} ();

///////////////////////////////////////////////////////////////////////////////////////////////////

