/*
	This method checks all file reference checkboxes
*/
function checkAllCheckboxes( formName, checkboxName )
{
	var checkPids = document.forms[ formName ][ checkboxName ];
	if (checkPids != null)
	{
		if (typeof checkPids.length != "undefined")
		{
			var allChecked = true;
			for (i = 0; (i < checkPids.length) && allChecked; i++)
			{
				allChecked = checkPids[i].checked;
			}
			var newCheck = !allChecked;
			for (i = 0; i < checkPids.length; i++)
			{
				checkPids[i].checked = newCheck;
			}
		}
		else
		{
			checkPids.checked = !checkPids.checked;
		}
	}
}

function loadOptionalMask( optionalMask, formName, checkboxName)
{
	var pidsChecked = false;
	var aux = "";
	var checkPIDs = document.forms[ formName ][ checkboxName ];
	if (checkPIDs != null)
	{
		if (checkPIDs.checked)
		{
			pidsChecked = true;
		}
		if (checkPIDs.length > 1) {
			for (i = 0; (i < checkPIDs.length); i++)
			{
				if (checkPIDs[i].checked) { 
					aux=aux+checkPIDs[i].value+",";
					pidsChecked = true;
				}
			}
			document.forms[ formName ].id2.value=aux.substring(0,aux.length-1);
		} else
			document.forms[ formName ].id2.value=checkPIDs.value;
		if (pidsChecked)
		{
			{
				document.forms[ formName ].method="POST";
				document.forms[ formName ].action=optionalMask;
				document.forms[ formName ].submit();
			}
		}
		else
		{
			alert( "Debes elegir al menos una casilla." );
		}
	}
}

function loadOptional( optionalMask, formName, id)
{
	document.forms[ formName ].id2.value=id;
	document.forms[ formName ].method="POST";
	document.forms[ formName ].action=optionalMask;
	document.forms[ formName ].submit();
}


/**
 *	Si el navegador del usuario no soporta cookies, informa al usuario con
 *	el mensaje msg
 */
function testCookieSupport(msg)
{
	document.cookie = "test=testvalue;expires=Thu, 15 Dec 2029 14:32:00 GMT";
	
	if (document.cookie.indexOf('test') == -1) {
		alert(msg);
	}
}

//testCookieSupport('Este sitio requiere que las cookies estén habilitadas en su navegador.');


