function archiveItem_downloadChoices_click(self, who) {

	var subDivs = document.getElementsByTagName("div");

	if(subDivs.length) {
		for(i=0; i<subDivs.length; i++) {
			if(subDivs[i].id.substr(0,27) == "downloadChoices_subChoices_") {
				if(subDivs[i].id == "downloadChoices_subChoices_"+who) {
					subDivs[i].style.display = "";
				} else {
					subDivs[i].style.display = "none";
				}
			}
		}
	}
}

function archiveItem_downloadChoices_toggleOptions(self) {
	var el = document.getElementById("downloadChoices_options");
	if(el) {
		if(el.style.display == "none") {
			el.style.display = "";
			self.value = locale.hideDownloadOptions;
		} else {
			el.style.display = "none";
			self.value = locale.showDownloadOptions;
		}
	}
}

function archiveItem_downloadChoices_download() {
	alert('archiveItem_downloadChoices_download() is deprecated. Check templates.');
	return false;

	var hashEl = document.getElementById("downloadHash");
	if(hashEl) {
		var hash = hashEl.value;
		url = "index.php?action=archive-getAttachment&archive-hash="+hash;

		var params = archiveItem_downloadChoices_getParams();
		if(params) url += "&" + params;

		window.location.href = url;

//		window.open(url, "","width=250, height=150");
	}

}

function archiveItem_downloadChoices_getParams() {
	var sel = archiveItem_downloadChoices_getSelected();
	return sel.value;
}

function archiveItem_downloadChoices_getType() {
	var sel = archiveItem_downloadChoices_getSelected();
	return sel.getAttribute("attr_type");
}

function archiveItem_downloadChoices_getSize() {
	var sel = archiveItem_downloadChoices_getSelected();
	return sel.getAttribute("attr_size");
}


function archiveItem_downloadChoices_getSelected() {
	var sel = null;

	var mainChoices = document.getElementsByName("downloadChoice");
	if(mainChoices.length) for(mainIndex=0; mainIndex<mainChoices.length; mainIndex++) {
		var mainItem = mainChoices.item(mainIndex);
		var mainTag = mainItem.id.substr(4);
		if(mainItem.checked) {
			var subChoices = document.getElementsByName(mainTag);
			if(subChoices.length) for(subIndex=0; subIndex<subChoices.length; subIndex++) {
				var subItem = subChoices.item(subIndex);
				if(subItem.checked) {
					sel = subItem;
				}
			} else {
				sel = mainItem;
			}
		}
	}
	return sel;
}

