
// gotoLightbox()
function gotoLightbox(listLightboxes)
{
	strLightboxId = listLightboxes.options[listLightboxes.selectedIndex].value;
	window.location = "lightbox.aspx?id=" + strLightboxId;
}


// createLightbox()
function createLightbox()
{
	// get the textbox with the new lightbox name
	var newLightbox = document.getElementById('newLightbox');
	if (!newLightbox)	return;
	
	// get the new name
	var strNewLightboxName = newLightbox.value;
	
	// validate?
	if (strNewLightboxName.length < 1)
	{
		alert('Please enter a name for the new lightbox');
		return;
	}

	// close the window
	hidePopup();

	// call the lightbox page to do the CREATE
	var strURL = 'lightbox.aspx?action=CREATE'	+
							  '&values=' + escape(strNewLightboxName);
	window.location = strURL;
}

// deleteLightbox()
function deleteLightbox()
{
	// get the select list with the lightbox id
	var listLightbox = document.getElementById('listLightboxes');
	if (!listLightbox)	return;
	
	// get the selected lightbox id
	var strLightboxId = listLightbox.options[listLightbox.selectedIndex].value;
	
	// close the window
	hidePopup();
		
	// call the lightbox page to do the DELETE
	var strURL = 'lightbox.aspx?action=DELETE'	+
							  '&id=' + strLightboxId;
	window.location = strURL;
}


// setAll()
function setAll(blnChecked)
{
	// get all <input> controls
	var colCheckboxes = document.getElementsByTagName('input');
	
	// step through each control looking for checkboxes
	for (var ix=0; ix < colCheckboxes.length; ix++)
	{
		var strType = colCheckboxes[ix].type;
		var strName = colCheckboxes[ix].name;
		if ((strType == 'checkbox') && (strName.substring(0,3) == 'lbb'))
		{
			// checked or uncheck, depending on boolean
			colCheckboxes[ix].checked = blnChecked
		}
	}
}


// downloadSelected()
function downloadSelected()
{
	var hiddenLightboxAction		= document.getElementById('hiddenLightboxAction');
	var hiddenLightboxActionValues	= document.getElementById('hiddenLightboxActionValues');
	var	hiddenDownloadOptions		= document.getElementById('hiddenDownloadOptions');
	if (!hiddenLightboxAction)			return;
	if (!hiddenLightboxActionValues)	return;
	if (!hiddenDownloadOptions)			return;

	var chkRemoveSelectedAfterDownload	= document.getElementById('chkRemoveSelectedAfterDownload');
	var hiddenRemoveAfterDownload		= document.getElementById('hiddenRemoveAfterDownload');
	if (!chkRemoveSelectedAfterDownload)	return;
	if (!hiddenRemoveAfterDownload)			return;

	if (chkRemoveSelectedAfterDownload.checked)
		hiddenRemoveAfterDownload.value = 'Y';

	// set hidden values
	hiddenLightboxAction.value		 = 'DOWNLOAD';
	hiddenLightboxActionValues.value = getCheckboxValues();
	hiddenDownloadOptions.value		 = '';

	var rdoFormat	= document.forms[0].rdoFormat;
	var rdoDPI		= document.forms[0].rdoDPI;
	var rdoSize		= document.forms[0].rdoSize;

	for (ix=0; ix < rdoFormat.length; ix++)
		if (rdoFormat[ix].checked)	hiddenDownloadOptions.value += rdoFormat[ix].value + '|';
	for (ix=0; ix < rdoDPI.length; ix++)
		if (rdoDPI[ix].checked)		hiddenDownloadOptions.value += rdoDPI[ix].value + '|';
	for (ix=0; ix < rdoSize.length; ix++)
		if (rdoSize[ix].checked)	hiddenDownloadOptions.value += rdoSize[ix].value;

	// post the form
	__doPostBack('','');
}


// removeSelected()
function removeSelected()
{
	var hiddenLightboxAction		= document.getElementById('hiddenLightboxAction');
	var hiddenLightboxActionValues	= document.getElementById('hiddenLightboxActionValues');
	if (!hiddenLightboxAction)			return;
	if (!hiddenLightboxActionValues)	return;

	// set hidden values
	hiddenLightboxAction.value		 = 'REMOVE';
	hiddenLightboxActionValues.value = getCheckboxValues();
	
	// post the form
	__doPostBack('','');
}

// removeAll()
function removeAll()
{
	// get the select list with the lightbox id
	var listLightbox = document.getElementById('listLightboxes');
	if (!listLightbox)	return;
	
	// get the selected lightbox id
	var strLightboxId = listLightbox.options[listLightbox.selectedIndex].value;
	
	// close the window
	hidePopup();
		
	// call the lightbox page to do the REMOVE ALL
	var strURL = 'lightbox.aspx?action=REMOVE_ALL'	+
							  '&id=' + strLightboxId;
	window.location = strURL;
}

// editSelected()
function editSelected()
{
	var hiddenLightboxAction		= document.getElementById('hiddenLightboxAction');
	var hiddenLightboxActionValues	= document.getElementById('hiddenLightboxActionValues');
	if (!hiddenLightboxAction)			return;
	if (!hiddenLightboxActionValues)	return;

	// set hidden values
	hiddenLightboxAction.value		 = 'EDIT_MD';
	hiddenLightboxActionValues.value = getCheckboxValues();
	
	// post the form
	__doPostBack('','');
}

// deleteSelected()
function deleteSelected()
{
	if (!confirm('This will DELETE the selected images \nAND REMOVE them from the lightbox\n\n' +
				 'Are you sure you wish to DELETE these images?'))
		return;

	var hiddenLightboxAction		= document.getElementById('hiddenLightboxAction');
	var hiddenLightboxActionValues	= document.getElementById('hiddenLightboxActionValues');
	if (!hiddenLightboxAction)			return;
	if (!hiddenLightboxActionValues)	return;

	// set hidden values
	hiddenLightboxAction.value		 = 'DELETE_SEL';
	hiddenLightboxActionValues.value = getCheckboxValues();
	
	// post the form
	__doPostBack('','');
}

	// somethingSelected()
	function somethingSelected()
	{
		// get all <input> controls
		var colCheckboxes	= document.getElementsByTagName('input');
		var strValues		= '';
		
		// step through each control looking for checkboxes
		for (var ix=0; ix < colCheckboxes.length; ix++)
		{
			var strType = colCheckboxes[ix].type;
			var strName = colCheckboxes[ix].name;
			if ((strType == 'checkbox') && (strName.substring(0,3) == 'lbb') && (colCheckboxes[ix].checked))
			{
				// if checked, something is selected
				return true;
			}
		}

		// if we are here, then nothing selected
		return false;
	}
	
	// getCheckboxValues()
	function getCheckboxValues()
	{
		// get all <input> controls
		var colCheckboxes	= document.getElementsByTagName('input');
		var strValues		= '';
		
		// step through each control looking for checkboxes
		for (var ix=0; ix < colCheckboxes.length; ix++)
		{
			var strType = colCheckboxes[ix].type;
			var strName = colCheckboxes[ix].name;
			if ((strType == 'checkbox') && (strName.substring(0,3) == 'lbb') && (colCheckboxes[ix].checked))
			{
				// if checked, add the value to the string
				strValues += strName.substring(3, strName.indexOf('$')) + '|';
			}
		}

		// return selected values as a string
		return strValues;
	}
	
	
// downloadLightbox()
function downloadLightbox(strLightboxId, strIdSuffix)
{
	if (strLightboxId == -1)
	{
		// get the select list with the lightbox id
		var listLightbox = document.getElementById('listLightboxes');
		if (!listLightbox)	return;

		// get the selected lightbox id
		strLightboxId = listLightbox.options[listLightbox.selectedIndex].value;
	}

	// close the window
	hidePopup();

	var chkRemoveAllAfterDL	= document.getElementById('chkRemoveAllAfterDownload_' + strIdSuffix)

	// call the lightbox page to do the download
	var strURL = 'lightbox.aspx?action=DOWNLOAD_ALL'	+
							  '&id=' + strLightboxId;

	if (chkRemoveAllAfterDL && chkRemoveAllAfterDL.checked)
		strURL += '&remove=Y';

	var rdoFormat	= document.forms[0]['rdoFormat_' + strIdSuffix];
	var rdoDPI		= document.forms[0]['rdoDPI_'	 + strIdSuffix];
	var rdoSize		= document.forms[0]['rdoSize_'	 + strIdSuffix];

	for (ix=0; ix < rdoFormat.length; ix++)
		if (rdoFormat[ix].checked)		strURL += '&format=' + rdoFormat[ix].value;
	for (ix=0; ix < rdoDPI.length; ix++)
		if (rdoDPI[ix].checked)			strURL += '&dpi='	 + rdoDPI[ix].value;
	for (ix=0; ix < rdoSize.length; ix++)
		if (rdoSize[ix].checked)		strURL += '&size='	 + rdoSize[ix].value;

	// load the page
	window.location = strURL;
}


// addAllToLightbox()
function addAllToLightbox(strResultType, strResultId, strRange)
{
	// get footer frame
	var fraHidden = window.frames.RPASS_BACKGROUND;
	if (!fraHidden)		return;

	// call the lightbox page to do the CREATE
	var strURL = 'addToLightbox.aspx?rtype='	+ strResultType	+ 
									'&rid='		+ strResultId	+
									'&range='	+ escape(strRange);
	fraHidden.location = strURL;
}

// downloadFooterLightbox()
function downloadFooterLightbox()
{
	// get footer frame
	var fraFooter = top.frames.footer;
	if (!fraFooter)	return;

	// get the select list with the lightbox id
	var listLightbox = fraFooter.document.getElementById('listLightboxes');
	if (!listLightbox)	return;

	// get the selected lightbox id
	strLightboxId = listLightbox.options[listLightbox.selectedIndex].value;

	// download the lightbox
	downloadLightbox(strLightboxId, 'LBF');
}
