// 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.TextFrame.document.open();
		parent.TextFrame.document.writeln('<html><head><title>Legend</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="White" text="Black" leftmargin=5 topmargin=0 rightmargin=0 link="Black" vlink="Black" alink="Black">');
		parent.TextFrame.document.writeln('<table width="350" border="0" cellspacing="0" cellpadding="0">');
    	parent.TextFrame.document.writeln('<tr>');
      	parent.TextFrame.document.writeln('<td width="300"><b><font face="Arial, Helvetica, sans-serif" size="3" color="#336699">Legend</font></b></td>');
      	parent.TextFrame.document.writeln('<td width="50" align="right"></td>');
    	parent.TextFrame.document.writeln('</tr>');
  		parent.TextFrame.document.writeln('</table>');
		parent.TextFrame.document.writeln('<IMG border=0 height=4 src="' + hardCodeURL + 'images/blueBar.gif" width=351><br>');
		parent.TextFrame.document.writeln('<center>');
		parent.TextFrame.document.writeln('<IMG SRC="' + legendImage + '" HSPACE=0 VSPACE=0 BORDER=0 ALT="Legend"></center>');
		parent.TextFrame.document.writeln('</body></html>');
		parent.TextFrame.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" />\n';
	if (drawLegendOnly) legString = legString + '<DRAW map="false" />\n';
	return legString;
}
