// 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 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=600,height=800,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=550;
	iHeight=500;
	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 fr=parent.TextFrame.document.pData;
	if(fr) {
		tDLP=fr.pDLP.value;
		tOwner=fr.pOwn.value;
		tAddress=fr.pAddr.value;
		tZip_Code=fr.pZip.value;
		tLocid=fr.pLoc.value;
		tDistrict=fr.pDist.value;
		tLand_Lot=fr.pLand.value;
		tParcel=fr.pParcel.value;
		tZoning=fr.pZoning.value;
		tWard=fr.pWard.value;
		tSchool=fr.pSchool.value;
		tPolice=fr.pPolice.value;
		tDL=fr.pDL.value;
		tPlats=fr.pPlats.value;
		
	}
	var Win1 = open("","PrintPage","height=750,width=550,resizable=yes,scrollbars=yes,menubar=yes");

	//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="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" NOWRAP>');
	Win1.document.writeln('	<TR>');
	Win1.document.writeln('		<TH COLSPAN="3">' + printTitle + '</TH>');
	Win1.document.writeln('	</TR>');
	Win1.document.writeln('	<TR>');
	Win1.document.write('		<TD colspan=3>');
	Win1.document.writeln('			<IMG SRC="' + printMapURL + '"  HSPACE=0 VSPACE=0 BORDER=2 ALT="">');
	Win1.document.writeln('		</TD>');
	Win1.document.writeln('	</TR>');
	if (fr) {
		Win1.document.writeln('<tr>');
		Win1.document.writeln('<td width=300>');
		Win1.document.writeln('<blockquote><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+tDLP+'</font></blockquote>');
		Win1.document.writeln('<font size=-1>'+tOwner+'</font>');
		Win1.document.writeln('<br><font size=-1>'+tAddress+'</font>');
		Win1.document.writeln('<br><font size=-1>'+tZip_Code+'</font><font size=-1></font>');
		Win1.document.writeln('<p><font size=-1>District:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+tDistrict+'</font>');
		Win1.document.writeln('<br><font size=-1>Land Lot:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+tLand_Lot+'</font>');
		Win1.document.writeln('<br><font size=-1>Parcel:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+tParcel+'</font>');

		Win1.document.writeln('<br><font size=-1>Zoning:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+tZoning+'</font>');
		Win1.document.writeln('<br><font size=-1>Ward:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+tWard+'</font>');
		Win1.document.writeln('<br><font size=-1>School:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '+tSchool+'</font>');
		Win1.document.writeln('<br><font size=-1>Police Zone:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+tPolice+'</font></td>');
		Win1.document.writeln('<br><font size=-1>Tax Map:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+tDL+'</font></td>');
		Win1.document.writeln('<br><font size=-1>Subdivision:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+tPlats+'</font></td>');
	}
// OV map
	if (hasOVMap) {
		Win1.document.writeln('		<TD HEIGHT="150" ALIGN="RIGHT" VALIGN="TOP">');
		Win1.document.writeln('			<IMG SRC="' + printOVURL + '" WIDTH=190 HEIGHT=150 HSPACE=0 VSPACE=0 BORDER=2 ALT="">');
		Win1.document.writeln('		</TD>');
	}


//Legend
	Win1.document.writeln('		<TD ALIGN="CENTER" VALIGN="TOP">');
	Win1.document.writeln('			<IMG SRC="' + printLegURL + '" HSPACE=0 VSPACE=0 BORDER=2 ALT="">');
	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();
}

