/*****************************************************************************/
/*                                                                           */
/* SCRIPT                                                                    */
/*   signon.js                                                               */
/*                                                                           */
/* TYPE                                                                      */
/*   javascript library                                                      */
/*                                                                           */
/* DESCRIPTION                                                               */
/*   signon form validation                                                  */
/*                                                                           */
/*****************************************************************************/

/*                                                                           */
/* check for deleted photos                                                  */
/*                                                                           */
function selectedPhotos()
{
	var selectedCount = 0;
	for (nr in photoIdList)
	{
		if (document.getElementById('select' + photoIdList[nr]) && document.getElementById('select' + photoIdList[nr]).checked) {
			selectedCount ++;
		}
	}
	return selectedCount;
}

/*                                                                           */
/* submit the form                                                           */
/*                                                                           */
function submitForm(photoAction)
{
	if (selectedPhotos() > 0)
	{
		if (photoAction == 'delete')
		{
			if (confirm(msgConfirm))
			{
				document.getElementById('photoAction').value = photoAction;
				document.getElementById('photoform').submit();
			}
		}
		else if (photoAction == 'addtoalbum')
		{
			if (document.getElementById('addAlbumId').value == '')
			{
				alert(msgNoAlbum);
			}
			else
			{
				document.getElementById('photoAction').value = photoAction;
				document.getElementById('photoform').submit();
			}
		}
	}
	else
	{
		alert(msgNoPhotos);
	}
}

function albumSelect()
{
	try
	{
		document.getElementById('newAlbum').style.display = (document.getElementById('addAlbumId').value == -1 ? 'table-row' : 'none');
	}
	catch (e)
	{
		/* IE doesn't support "table-row" */
		document.getElementById('newAlbum').style.display = (document.getElementById('addAlbumId').value == -1 ? 'block' : 'none');
	}
}

function selectAll(selectOn)
{
	for (nr in photoIdList)
	{
		if (document.getElementById('select' + photoIdList[nr]))
		{
			document.getElementById('select' + photoIdList[nr]).checked = selectOn;
		}
	}
}

function showSelect(selectOn)
{
	for (nr in photoIdList)
	{
		if (document.getElementById('selectspan' + photoIdList[nr]))
		{
			document.getElementById('selectspan' + photoIdList[nr]).style.visibility = (selectOn ? 'visible' : 'hidden');
		}
	}
	document.getElementById('deletelinkspan').style.visibility = (selectOn ? 'visible' : 'hidden');
	document.getElementById('editlinkspan').style.visibility = (!selectOn ? 'visible' : 'hidden');
}

