// aimsLegend.js
/*
*  JavaScript template file for ArcIMS HTML Viewer
*       dependent on aimsXML.js, ArcIMSparam.js, aimsCommon.js, aimsMap.js
*/

aimsLegendPresent=true;

var drawLegendOnly=false;
//var defaultLegTitle=legTitle;
var showLegendInTabs = true;

/*
***************************************************************************************

Legend functions

***************************************************************************************
*/



// send request to create graphic legend
function getLegend() {
    drawLegendOnly=true;
    var theString=writeXML();
    showRetrieveMap();
    sendToServer(imsURL,theString,98);
}

// write out the legend display
function showLegend() {

    if (! showLegendInTabs) {
/*        parent.TextFrame.document.open();
        parent.TextFrame.document.writeln('<html><meta http-equiv="Content-Type" content="text/html; charset=' + charSet + '"><head><title>' + titleList[3] + '</title>');
        parent.TextFrame.document.writeln('<style type="text/css">a {text-decoration:none;}</style>');
        parent.TextFrame.document.writeln('</head>');
        parent.TextFrame.document.writeln('<body BGCOLOR="blue" text="Black" leftmargin=0 topmargin=0 rightmargin=0 link="Black" vlink="Black" alink="Black">');
        parent.TextFrame.document.writeln('<center>');
        //parent.TextFrame.document.writeln('</br>');
        //parent.TextFrame.document.writeln('<font face="Arial" size="4" color="#2E81BE"><b>Legend</b></font>')
        //parent.TextFrame.document.writeln('<IMG SRC="' + window.parent.SiteName +'/images/lineonwhite.gif" HSPACE=0 VSPACE=0 BORDER=0 ALT=""><b>'+'</b>');
        //parent.TextFrame.document.writeln('<IMG SRC="' + legendImage + '" HSPACE=0 VSPACE=0 BORDER=0 ALT="' + titleList[3] + '"></center>');
        parent.TextFrame.document.writeln('</script>');
        parent.TextFrame.document.writeln('</head>');
        parent.TextFrame.document.writeln('<body BGCOLOR="White" text="Black" leftmargin=0 topmargin=0 rightmargin=0 link="Gray" vlink="Gray" alink="Gray" onclose="closeIt()">');
        parent.TextFrame.document.writeln('</body></html>');
        parent.TextFrame.document.close();
*/ 
   } else {
        parent.TextFrame.document.location = appDir+"toc.asp?tt=legend";
    }

}


// add Legend to XML request
function addLegendToMap() {

    //CDM Edit - This is the LEGEND TITLE.  THIS IS WHERE IS GENERATES THE LEGEND
    //var legString = '<LEGEND title="' + legTitle + '" font="' + legFont + '" width="' + legWidth + '" height="' + legHeight + '" ';

    var legString = '<LEGEND title="hh" font="Arial Bold" titlefontsize="1" width="' + legWidth + '" height="' + legHeight + '" ';
    legString += 'autoextend="true" backgroundcolor="255,255,255" valuefontsize="10" layerfontsize="12" cellspacing="7"';

    //alert(legString)


    if (hideLayersFromList) {
        legString += '>\n<LAYERS>\n';
        for (var legvar=0;legvar<noListLayer.length;legvar++) {
            if (noListLayer[legvar]) legString += '<LAYER id="' + LayerID[legvar] + '" />\n';
        }
        legString += '</LAYERS>\n';
        legString += '</LEGEND>\n';
    } else {
        legString += ' />\n';
    }
    if (drawLegendOnly) legString = legString + '<DRAW map="false" />\n';
    return legString;
}

