// 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;

/*
***************************************************************************************

Legend functions 

***************************************************************************************
*/



// send request to create graphic legend
function getLegend() {
	legendVisible=true;
	drawLegendOnly=true;
	var theString=writeXML();
	showRetrieveMap();
	sendToServer(imsURL,theString,98);
}

// write out the legend display
function showLegend() {

		parent.CustFrame.document.open();
		parent.CustFrame.document.writeln('<html><meta http-equiv="Content-Type" content="text/html; charset=' + charSet + '"><head><title>' + titleList[3] + '</title>');
		parent.CustFrame.document.writeln('<style type="text/css">a {text-decoration:none;}</style>');
		parent.CustFrame.document.writeln('</head>');
		parent.CustFrame.document.writeln('<body text="Black" leftmargin=0 topmargin=0 rightmargin=0 link="Black" vlink="Black" alink="Black">');
		parent.CustFrame.document.writeln('<center>');
		parent.CustFrame.document.writeln('<IMG SRC="' + legendImage + '" HSPACE=0 VSPACE=0 BORDER=0 ALT="' + titleList[3] + '"></center>');

		parent.CustFrame.document.writeln('</body></html>');
		parent.CustFrame.document.close();
}

// add Legend to XML request
function addLegendToMap() {
	var legString = '<LEGEND title="' + legTitle + '" font="' + legFont + '" width="' + legWidth + '" height="' + legHeight + '" ';
	legString += 'autoextend="true" backgroundcolor="255,255,255"';
	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;
}
