// 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
*/

aimsPrintPresent=true;

var printTitle = titleList[4];
var printTitle = titleList[4];
var printMapURL="";
var printOVURL="";
var printLegURL="";

var legVis2=false;

/*
***************************************************************************************

Print functions 

***************************************************************************************
*/


// display print form
function printIt() {
	hideLayer("measureBox");
	//if (useTextFrame) {
	//	parent.TextFrame.document.location = "printform.htm";
	//} else {
		var Win1 = open("printform.htm","PrintFormWindow","width=575,height=200,scrollbars=yes,resizable=yes");
	//}
}

// create web page for printing
	// first get Map
function getPrintMap(title,notes) {
	showRetrieveMap();
	printTitle=title;
              printNotes=notes
	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");
	//Win1.document.open();
	Win1.document.writeln('<html><meta http-equiv="Content-Type" content="text/html; charset=' + charSet + '"><head>');
	Win1.document.writeln('	<title>' + titleList[5] + '</title>');
	Win1.document.writeln('</head>');
	Win1.document.writeln('<body BGCOLOR="White" TEXT="Black" LEFTMARGIN=0 TOPMARGIN=0>');
	Win1.document.writeln('<FONT FACE="Arial"><B>');
        Win1.document.writeln('<TABLE WIDTH="700" BORDER = "1" BORDERCOLOR = "#000033" CELLSPACING="0" CELLPADDING="0">');
        Win1.document.writeln(' <TR>');
	Win1.document.writeln('		<TH bgcolor="#CCCCCC"><FONT COLOR = "#000033" FACE="VERDANA">' + printTitle + '</FONT></TH>');
	Win1.document.writeln('	</TR>');
        Win1.document.writeln('	<TR><TD>');
        Win1.document.writeln('    <TABLE WIDTH="700" CELLSPACING="0" CELLPADDING="0">');
	Win1.document.writeln('	     <TR>');
	Win1.document.writeln('		<TD ALIGN="CENTER" WIDTH="500" HEIGHT="500" >');
	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 ALIGN="CENTER" VALIGN="TOP">');
        Win1.document.writeln('			<IMG SRC="' + printOVURL + '" WIDTH=130 HEIGHT=100 HSPACE=0 VSPACE=0 BORDER=0 ALT="">');
        Win1.document.writeln('			<BR><IMG SRC="' + printLegURL + '" HSPACE=0 VSPACE=0 BORDER=0 ALT="">');     
        Win1.document.writeln('			<BR><FONT COLOR = "#000033" size="2">' + printNotes + '</FONT>');
	Win1.document.writeln('		</TD>');
	Win1.document.writeln('	      </TR>');
	Win1.document.writeln('    </TABLE>');
        Win1.document.writeln('	  </TD>');
	Win1.document.writeln('	</TR>');
	Win1.document.writeln('</TABLE>');
	Win1.document.writeln('</B></FONT>');
	//Win1.document.writeln('</body></html>');
	Win1.document.close();
	
	legendVisible=legVis2;
	Win1=null;
	hideRetrieveMap();
}

