aimsLegendPresent=true;

var drawLegendOnly=true;
var defaultLegTitle=legTitle;

// 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() {

		var Win1 = open("","LegendWindow","width=290,height=550,scrollbars=no,resizable=no");
		Win1.document.writeln('<html><meta http-equiv="Content-Type" content="text/html; charset=' + charSet + '"><head><title>' + titleList[3] + '</title>');
		Win1.document.writeln('<style type="text/css">a {text-decoration:none;}</style>');
		Win1.document.writeln('<script language="Javascript">');
		Win1.document.writeln('	var t;');
		Win1.document.writeln('	var tName = "";');
		Win1.document.writeln('	if (opener) {');
		Win1.document.writeln('		if (opener.name=="MapFrame") {');
		Win1.document.writeln('			t = opener.parent.MapFrame;');
		Win1.document.writeln('			tName = "opener.parent.MapFrame.";');
		Win1.document.writeln('		} else {');
		Win1.document.writeln('			t = opener;');
		Win1.document.writeln('			tName = "opener.";');
		Win1.document.writeln('		}');
		Win1.document.writeln('	} else {');
				
		Win1.document.writeln('		if (parent.MapFrame!=null) {');
		Win1.document.writeln('			t = parent.MapFrame;');
		Win1.document.writeln('			tName = "parent.MapFrame.";');
		Win1.document.writeln('		} else {');
		Win1.document.writeln('			t=document;');
		Win1.document.writeln('		}');
		Win1.document.writeln('	}');
		Win1.document.writeln(' function closeIt() {');
		Win1.document.writeln('		t.legendVisible=false;');
		Win1.document.writeln('		window.close();');
		Win1.document.writeln('	}');
		Win1.document.writeln('</script>');
		Win1.document.writeln('</head>');
		Win1.document.writeln('<body bgcolor="#E0E0E0" text="Black" leftmargin=0 topmargin=0 rightmargin=0 link="Gray" vlink="Gray" alink="Gray" onclose="closeIt()">');
		Win1.document.writeln('<form onsubmit="closeIt(); return false;">');
		Win1.document.writeln('<center><big><b> Quelques Servitudes </b></big>');
		Win1.document.writeln('<hr width="75%">');
		Win1.document.writeln('<INPUT TYPE="button" NAME="hideButton1" VALUE="Fermer la légende" onClick="closeIt()">');
		Win1.document.writeln('<input type="button" name="details" value="Explications" onClick="window.open(\'/urba/legendes/legende.htm\');">');
		Win1.document.writeln('<hr>');
		Win1.document.writeln('<font face="Arial" size="-2"><b>');
		Win1.document.writeln('<IMG SRC="' + legendImage + '" HSPACE=0 VSPACE=0 BORDER=0 ALT="Servitudes">');
		Win1.document.writeln('<hr width="75%">');
		Win1.document.writeln('</b></font></center></FORM>');
		Win1.document.writeln('</body></html>');
		Win1.document.close();
		Win1.focus();
		Win1=null;
	
}

// add Legend to XML request
function addLegendToMap() {
	var legString = '<LEGEND title="' + legTitle + '" font="' + legFont + '" width="' + legWidth + '" height="' + legHeight + '" ';
	legString += 'autoextend="true" backgroundcolor="230,230,230"';
	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;
}