function loadURL (url) {
	this.location = url;
}

function archiveAction (action) {
	var form = document.getElementById('form');
	var abox = document.getElementById('action');
	var archive = document.getElementById('archive');
	if (action == 'delete' && archive) {
		if (archive.selectedIndex == 0) {
			alert('You must select an archive to delete!');
			return;
		}
		var label = archive.options[archive.selectedIndex].text;
		if (!confirm('Are you sure you want to delete archive '+label+'?')) { return; }
	}
	if (abox) { abox.value = action; }
	if (form) { form.submit(); }
}

function portalAction (action) {
	var form = document.getElementById('form_portal');
	var abox = document.getElementById('action_portal');
	var portals = document.getElementById('portals');
	if (action == 'delete' && portals) {
		if (portals.selectedIndex == 0 ) {
			alert('You must select a portal to delete!');
			return;
		}
		var label = portals.options[portals.selectedIndex].text;
		if (!confirm('Are you sure you want to delete portal '+label+'?')) { return; }
	}
	else if (action == 'edit' && portals) {
		if (portals.selectedIndex == 0 ) {
			alert('You must select a portal to edit!');
			return;
		}
	}
	if (abox) { abox.value = action; }
	if (form) { form.submit(); }
}

function portalPreview () {
	var portals = document.getElementById('portals');
	if (portals) {
		if (portals.selectedIndex == 0 ) {
			alert('You must select a portal to preview!');
			return;
		}
		var id = portals.options[portals.selectedIndex].value;
		window.open('../index.php?id='+id, 'Preview');
	}
}

function toggle (id, on) {
	var box = document.getElementById(id);
	if (box) { box.style.display = on ? '' : 'none'; }
}

