function displayAll()
{
    try
    {
        var img = $("#imgAll");
        var imageState = null;
        var on = false;

        if (img.attr("src").match(COLLAPSED1_GIF))
        {
            imageState = EXPANDED1_GIF;
            on = true;
        }
        else
        {
            imageState = COLLAPSED1_GIF;

        }

        img.attr("src", imageState);

        for ( var i = 0; i < 10; i++)
        {
            display(i, on, 1);
        }

    }
    catch (ex)
    {
        alert(ex);
    }
}

function display(id, on, imgSize)
{
    try
    {
        var tab = $("#highLightRow" + id);
        var ele = $("#result" + id);
        var img = $("#img" + id);
        
        if (!on)
        {
            img.attr("src", COLLAPSED[imgSize]);
            ele.hide();
         
            tab.removeClass("highLight");
        }
        else
        {
        	img.attr("src", EXPANDED[imgSize]);
        	ele.show();
         
            tab.addClass("highLight");
        }
    }
    catch (ignored)
    {
        alert(ignored);
    }
}

function displayDiv(id, imgSize)
{
	display(id, $("#result" + id).is(":hidden"), imgSize);
}

function getAbstract(id)
{
   
	$.get(pubPath + "/pubmedAbstract", { pubmed: id }, function(html) {
	    html = html + "";
	    html = html.replace(/.*<body>/m,'').replace(/<\/body>.*/m,'');
	  
		$("#pAbstract").html(html);
	});
}

function clearPdBoxes()
{

    $('#pdShowInts').attr("checked", false);
    $('#pdShowActs').attr("checked", false);
    $('#pdShowBoth').attr("checked", true);
    showHidePubDetails();
}

function displayAbstract()
{

    var img = $("#imgPubSummary");

    var matchString = COLLAPSED1_GIF;
    var header = null;

    if (img.attr("src").match(matchString))
    {
        imageState = EXPANDED1_GIF;
        $("#pubAbstract").show();
    }
    else
    {
        imageState = COLLAPSED1_GIF;
        $("#pubAbstract").hide();

    }

    img.attr("src", imageState);
}

function showHidePubDetails()
{
    if ($('#pdShowInts').is(":checked"))
    {
    	$(".pdActUnqRow, .pdActRow").hide();
    	$(".pdIntRow, .dbHeaderRow").show();
    }
    else if ($('#pdShowActs').is(":checked"))
    {
        $('.pdActRow, .pdIntRow, .dbHeaderRow').hide();
        $('.pdActUnqRow').show();
    }
    else if ($('#pdShowBoth').is(":checked"))
    {
        $('.pdActUnqRow').hide();
        $('.pdIntRow, .pdActRow, .dbHeaderRow').show();
       
    }
}



var codeWindow = null;

function displayCodes()
{
    try
    {
        if (codeWindow == null)
        {
            codeWindow = $('#mappingCodes').dialog( {
                height : 500,
                width : 700,
                title : 'Mapping/Assignment Code Definitions',
                dialogClass : 'codeTable'
            });
        }
        else
        {
            codeWindow.dialog('open');
        }
    }
    catch (e)
    {
        alert(e);
    }
}

var lprDef = null;

function lprAlert()
{
  
    if (lprDef == null)
    {
        lprDef = $("#lprDefDia").dialog( {
            resizable : true,
            height :300,
            width : 500,
            modal : true,
            title : 'Lowest and Highest PubMed Identifier (PMID) Reuse',
            overlay : {
                backgroundColor : '#000',
                opacity : 0.5
            },
            buttons : {
                'Read more about LPR, HPR, and NP....' : function()
                {
                    window.location = '../faq#npLprHpr';
                },
                'Stay on this page' : function()
                {
                    $(this).dialog('close');
                }
            }
        });
    }
    else
    {
        lprDef.dialog('open');
    }

}

var mAlerts = new Array();

function malert(text)
{

    if (mAlerts[text] == null)
    {
        try
        {
        	var d = $("<div><p>" + text + "</p></div>")
        		.attr("id", "mAlert" + (mAlerts.length + 1))
        		.addClass("iDialog")
        		.hide();
        	
            mAlerts[text] = d.dialog( {
                height : 200,
                width : 400,
                modal : true,
                resizable: false,
                buttons: {
                    Ok: function() {
                        $(this).dialog('close');
                    }
                },
                title : 'Alert'
            });
        }
        catch (mae)
        {
            alert("error creating dialog: " + mae);
        }

    }
    else
    {
        mAlerts[text].dialog('open');
    }

}
