// 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 = "Internet Map Viewer";
var printMapURL = "";
var printOVURL = "";
var printLegURL = "";
var printWidth = "";

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=150,scrollbars=yes,resizable=yes");
	}
}

// Create web page for printing.
// First get the Map.
function getPrintMap(title, printMode)
{
	showRetrieveMap();
	printTitle = title;
	var tempWidth = iWidth;
	var tempHeight = iHeight;

// alert("printMode = " + printMode);

	// iWidth = 650;
	if (printMode == "Landscape")
	{
		printWidth = 650;
		iWidth = 650;
	}
	else
	{
		printWidth = 450;
		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(printWidth);
}
// fourth, write the web page
function writePrintPage()
{
	var Win1 = open("", "PrintPage");
	//Win1.document.open();
	Win1.document.writeln('<html><head>');
	Win1.document.writeln('	<title>Map Output</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="' + printWidth + '" BORDER="2" CELLSPACING="0" CELLPADDING="0" NOWRAP>');
	Win1.document.writeln('	<TR>');
	Win1.document.writeln('		<TH COLSPAN="2">' + printTitle + '</TH>');
	Win1.document.writeln('	</TR>');
	Win1.document.writeln('	<TR>');
	Win1.document.write('		<TD WIDTH="850" HEIGHT="450"');

// alert(hasOVMap);
// alert(">" + printOVURL + "<" + printOVURL.length);

	// if (hasOVMap && printOVURL != "")
		Win1.document.write(' ROWSPAN="4"');
	// else
	//	Win1.document.write(' ROWSPAN="3"');

	Win1.document.writeln('>');
	Win1.document.writeln('			<IMG SRC="' + printMapURL + '" WIDTH=' + printWidth + ' HEIGHT=450 HSPACE=0 VSPACE=0 BORDER=0 ALT="">');
	Win1.document.writeln('		</TD>');

//	if (hasOVMap && printOVURL != "")
//	{
//		Win1.document.writeln('	</TR>');
//		Win1.document.writeln('	<TR>');
//		Win1.document.writeln('		<TD HEIGHT="150" ALIGN="CENTER">');
//		Win1.document.writeln('			<IMG SRC="' + printOVURL + '" WIDTH=190 HEIGHT=150 HSPACE=0 VSPACE=0 BORDER=0 ALT="">');
//		Win1.document.writeln('		</TD>');
//	}

	Win1.document.writeln('	</TR>');
	Win1.document.writeln('	<TR>');
	Win1.document.writeln('		<TD ALIGN="CENTER" VALIGN="TOP">');
	Win1.document.writeln('			<IMG SRC="' + printLegURL + '" HSPACE=0 VSPACE=0 BORDER=0 ALT="">');
	Win1.document.writeln('		</TD>');
	Win1.document.writeln('	</TR>');

	Win1.document.writeln('	<TR>');
	Win1.document.writeln('		<TD ALIGN="CENTER" VALIGN="TOP">');
	Win1.document.writeln('<FONT SIZE=2><B>City of Corpus Christi<BR>GIS Map Viewer</B></FONT>');
	Win1.document.writeln('		</TD>');
	Win1.document.writeln('	</TR>');

	Win1.document.writeln('	<TR>');
	Win1.document.writeln('		<TD ALIGN="CENTER" VALIGN="TOP">');
	Win1.document.writeln('<img name="Corpus Christi Logo" src="/Corpus/images/CorpusLogo.bmp" hspace=40 vspace=0 border=0>');
	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();
}

