function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


function loadCitationTemplate(popup_ref)
{
	var citation_record = popup_ref.options[popup_ref.selectedIndex].value;
	// get any comments
	var ajax_obj = new Ajax.Request('ajax_receiver.php?action=load_citation_template&item_id=' + citation_record,{method:'get',onSuccess:displayTemplate,onFailure:function(){alert('something went wrong')}})
	
}


function displayTemplate (transport)
{
	//alert(transport.responseText);
	var the_element = document.getElementById("citation");
	//alert(the_element);
	if (the_element.value)
	{
		var res = confirm("Do you wish to replace the existing citation?");
		if (res)
		{
			the_element.value = transport.responseText;
		}
	}
	else
	{
		the_element.value = transport.responseText;
	}
}



function addItem()
{
	var form_ref = document.forms["item_bib"];
	if (form_ref.onsubmit())
	{
		select_ref = form_ref.bibliography_id;
		biblio_id = select_ref.options[select_ref.selectedIndex].value;

		self.location = "item_edit.php?bib=" + biblio_id;
	}
}

function confirmDelete(table,id)
{
	res = confirm("Are you sure you wish to delete this item from the " + table + " table?");
	if (res)
	{
		self.location = "generic_delete.php?type=" + table + "&id=" + id;
	}
}


function superDelete(table,id)
{
	res = confirm("Are you SURE you wish to super-delete this item from the " + table + " table? This will remove ALL connected records!");
	if (res)
	{
		self.location = "super_delete.php?type=" + table + "&id=" + id;
	}
}

