// ask for a collection name and create a new collection with that name
function collection_create(ajax_url) {
	var collection_name = prompt("Hvad skal samlingen hedde?","");

	if(collection_name != null && collection_name.length > 0) {
		$(".loading_collections").show();
		$(".tx-historycollections-pi1").load(
			ajax_url,
			{
				'tx_historycollections_pi1[ajax]' : 1,
				'tx_historycollections_pi1[action]' : 'create',
				'tx_historycollections_pi1[collection_name]' : collection_name
			},
			function() {
			}
		);
	}
}

// select the given collection name as the active collection
function collection_select(ajax_url,collection_name) {
	$(".loading_collections").show();
	$(".tx-historycollections-pi1").load(
		ajax_url,
		{
			'tx_historycollections_pi1[ajax]' : 1,
			'tx_historycollections_pi1[action]' : 'select',
			'tx_historycollections_pi1[collection_name]' : collection_name
		},
		function() {
		}
	);
}

// add the given material to the active collection
function collection_add_material(ajax_url,material_id) {
	$(".loading_collections").show();
	$(".tx-historycollections-pi1").load(
		ajax_url,
		{
			'tx_historycollections_pi1[ajax]' : 1,
			'tx_historycollections_pi1[action]' : 'add_material',
			'tx_historycollections_pi1[material_id]' : material_id
		},
		function() {
		}
	);
}

// remove the given material from the active collection
function collection_remove_material(ajax_url,material_id) {
	$(".loading_collections").show();
	$(".tx-historycollections-pi1").load(
		ajax_url,
		{
			'tx_historycollections_pi1[ajax]' : 1,
			'tx_historycollections_pi1[action]' : 'remove_material',
			'tx_historycollections_pi1[material_id]' : material_id
		},
		function() {
		}
	);
}
