	$(function() {
		$("#dialog").dialog({
			bgiframe: true,
			modal: true,
			autoOpen: false,
			width: 600,
			height: 400,
			closeOnEscape: true,
			show: 'scale',
			resize: function(event, ui) {
				 $('#dialog-content').height($(this).height());
				 $('#ReferenceIframe').height($(this).height());

			},
			buttons: {
				'Export citation': function() {
					$('#Export-Citation').dialog('open');
					return true;
				},
				'Close': function() {
					$(this).dialog('close');
				}
			}
		});

		$("#Export-Citation").dialog({
			bgiframe: true,
			modal: true,
			autoOpen: false,
			width: 260,
			height: 170,
			closeOnEscape: true,
			resizable: false,
			overlay: {
				backgroundColor: '#000',
				opacity: 0.5
			},
			buttons: {
				'Export': function() {
					window.open('referencesupdateview.php?ID=' + $("input[name='PubMedID']").val() + "&export="+$('input[type=radio][name=export_citation]:checked').attr('value'));
					$(this).dialog('close');
					return false;
				},
				Cancel: function() {
					$(this).dialog('close');
				}
			}
		});


	});

	function LoadDialog(PubmedID, ID){
		$('#dialog-content').load('../preload.php?PubmedID='+PubmedID+'&ID='+ID);
		$("input[name='PubMedID']").attr('value', ID );
		if (PubmedID!='') {	
			$('#dialog-content').load('referenceabstract.php?pubmed='+ PubmedID);
			//$(":button:contains('Export_Citation')").attr("disabled","false");
		} else if (ID!='') {	
			$('#dialog-content').load('referenceabstract.php?id='+ ID);
			$(":button:contains('Export_citation')").attr("disabled","disabled");
		}
		$('#ReferenceIframe').height($('#dialog').height());
		$('#dialog').dialog('open');
		return false;
	}

	function ExportDialog(PubmedID, ID){
		$("input[name='PubMedID']").attr('value', ID );
		if (PubmedID!='') {	
			$('#Export-Citation').dialog('open');
		}

	}

