// aimsPrint.js
/*
*  JavaScript template file for ArcIMS HTML Viewer
*		dependent on aimsXML.js, ArcIMSparam.js, aimsCommon.js, aimsMap.js,
*		aimsLayers.js, aimsDHTML.js
*		aimsClick.js, aimsNavigation.js,
*		aimsLegend.js
*/

var aimsPrintPresent=true;

var printTitle = "ArcIMS 3.0 HTML Viewer Map";
var printMapURL="";
var printOVURL="";
var printLegURL="";

var legVis2=false;

/*
***************************************************************************************

Print functions 

***************************************************************************************
*/


// display print form
function printIt() {
	// alert ("hello from aimsPrint.js -- ln 30");
	hideLayer("measureBox");
	if (useTextFrame) {
		parent.TextFrame.document.location = "printform.htm";
	 } else {
	// 	var Win1 = open("printform.htm","PrintFormWindow","width=575,height=150,scrollbars=yes,resizable=yes");
		var Win1 = open("printform.htm","PrintFormWindow","width=575,height=322,scrollbars=yes,resizable=yes");
	}
}

// create web page for printing
	// first get Map
function getPrintMap(title) {
	showRetrieveMap();
	printTitle=title;
	var tempWidth = iWidth;
	var tempHeight = iHeight;
	iWidth=450;
	iHeight=450;
	legVis2=legendVisible;
	if (aimsLegendPresent) legendVisible=true;
	var theString = writeXML();
	iWidth=tempWidth;
	iHeight = tempHeight;
	legendVisible = legVis2;
	sendToServer(imsURL,theString,101);
	tempWidth=null;
	tempHeight=null;
	theString=null;
}
// second, get OVMap
function getPrintOV() {
	var tempWidth = i2Width;
	var tempHeight = i2Height;
	i2Width=190;
	i2Height=150;
	var tempDraw=drawOVExtentBox;
	drawOVExtentBox=true;
	var theString = writeOVXML();
	drawOVExtentBox=tempDraw;
	i2Width=tempWidth;
	i2Height = tempHeight;
	sendToServer(imsOVURL,theString,102);
	tempWidth=null;
	tempHeight=null;
	theString=null;
}
// third, get Legend
function getPrintLegend() {
	//  waiting for Legend tags
	if (printLegURL=="") printLegURL = "images/nolegend.gif";
	writePrintPage();
}
// fourth, write the web page
function writePrintPage() {
	var Win1 = open("","PrintPage","width=690,height=531,resizable=yes,toolbar=1,menubar=1");
	//Win1.document.open();
	Win1.document.writeln('<html><head>');
	Win1.document.writeln('	<title>Map Output</title>');
	Win1.document.writeln('</head>');
	Win1.document.writeln('<body BGCOLOR="#344D80" TEXT="Black" LEFTMARGIN=0 TOPMARGIN=0>');
	//Win1.document.writeln('<FONT FACE="Arial"><B>');
	
	Win1.document.write('		<br>');
	
	// header
	Win1.document.writeln('<table width="650" border="0" cellspacing="0" cellpadding="0" nowrap align="center">');
	Win1.document.writeln('<tr><td bgcolor="#344D80" height="6"><img src="zbimages/transparent.gif" border="0" width="1" height="1"></td></tr>');
	Win1.document.writeln('<tr><td bgcolor="white" height="1"><img src="zbimages/transparent.gif" border="0" width="1" height="1"></td></tr>');
	Win1.document.writeln('<tr><TH bgcolor="#1D2A45"><font color="white">&nbsp;' + printTitle + '&nbsp;</TH></tr>');
	Win1.document.writeln('<tr><td bgcolor="white" height="1"><img src="zbimages/transparent.gif" border="0" width="1" height="1"></td></tr>');
	Win1.document.writeln('<tr><td bgcolor="#344D80" height="6"><img src="zbimages/transparent.gif" border="0" width="1" height="1"></td></tr>');
	Win1.document.writeln('</table>');
	// header -end
	
	Win1.document.writeln('<table width="650" border="0" cellspacing="0" cellpadding="0" bgcolor="black" nowrap align="center">');
	Win1.document.writeln('	<tr>');
	Win1.document.write('		<td>');
	
	Win1.document.writeln('<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="white" nowrap align="center">');
	Win1.document.writeln('<tr><td colspan="11" bgcolor="black" height="2"><img src="zbimages/transparent.gif" border="0" width="1" height="1"></td></tr>');
	Win1.document.writeln('<tr><td colspan="11" bgcolor="silver" height="2"><img src="zbimages/transparent.gif" border="0" width="1" height="1"></td></tr>');
	Win1.document.writeln('<tr><td colspan="11" bgcolor="black" height="2"><img src="zbimages/transparent.gif" border="0" width="1" height="1"></td></tr>');
	
	Win1.document.writeln('<TR>');
	Win1.document.writeln('<td bgcolor="black" width="2"><img src="zbimages/transparent.gif" border="0" width="1" height="1"></td>');
	Win1.document.writeln('<td bgcolor="silver" width="2"><img src="zbimages/transparent.gif" border="0" width="1" height="1"></td>');
	Win1.document.writeln('<td bgcolor="black" width="2"><img src="zbimages/transparent.gif" border="0" width="1" height="1"></td>');

		Win1.document.write('<TD WIDTH="450" HEIGHT="450">');
		Win1.document.writeln('<IMG SRC="' + printMapURL + '" WIDTH=450 HEIGHT=450 HSPACE=0 VSPACE=0 BORDER=0 ALT="">');
		Win1.document.writeln('</TD>');

	Win1.document.writeln('<td bgcolor="black" width="2"><img src="zbimages/transparent.gif" border="0" width="1" height="1"></td>');
	Win1.document.writeln('<td bgcolor="silver" width="2"><img src="zbimages/transparent.gif" border="0" width="1" height="1"></td>');
	Win1.document.writeln('<td bgcolor="black" width="2"><img src="zbimages/transparent.gif" border="0" width="1" height="1"></td>');

		Win1.document.writeln('		<TD ALIGN="CENTER">');
		Win1.document.writeln('			<IMG SRC="' + printLegURL + '" HSPACE=0 VSPACE=0 BORDER=0 ALT="">');
		Win1.document.writeln('		</TD>');

	Win1.document.writeln('<td bgcolor="black" width="2"><img src="zbimages/transparent.gif" border="0" width="1" height="1"></td>');
	Win1.document.writeln('<td bgcolor="silver" width="2"><img src="zbimages/transparent.gif" border="0" width="1" height="1"></td>');
	Win1.document.writeln('<td bgcolor="black" width="2"><img src="zbimages/transparent.gif" border="0" width="1" height="1"></td>');
	
	Win1.document.writeln('	</TR>');

	Win1.document.writeln('<tr><td colspan="100" bgcolor="black" height="2"><img src="zbimages/transparent.gif" border="0" width="1" height="1"></td></tr>');
	Win1.document.writeln('<tr><td colspan="100" bgcolor="silver" height="2"><img src="zbimages/transparent.gif" border="0" width="1" height="1"></td></tr>');
	Win1.document.writeln('<tr><td colspan="100" bgcolor="black" height="2"><img src="zbimages/transparent.gif" border="0" width="1" height="1"></td></tr>');

	
	Win1.document.writeln('</TABLE>');


	Win1.document.writeln('  </td>');
	Win1.document.writeln('  </tr>');
	Win1.document.writeln('</table>');
	
	//Win1.document.writeln('</body></html>');
	Win1.document.close();
	
	legendVisible=legVis2;
	Win1=null;
	hideRetrieveMap();
}

