// 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 = "Black Hawk Co. Iowa";
var printMapURL="";
var printOVURL="";
var printLegURL="";

var legVis2=false;

/*
***************************************************************************************

Print functions 

***************************************************************************************
*/


// display print form
function printIt() {
	bhCloseWindows();
	hideLayer("measureBox");
	if (!useTextFrame) {
		parent.TextFrame.document.location = "printform.htm";
	} else {
		Win1 = window.open("printform.htm","PrintFormWindow","width=400,height=250,scrollbars=yes,resizable=yes,top=0,left=0");
	}
}

// create web page for printing
	// first get Map

function getPrintMap(title) {
	showRetrieveMap();
	printTitle=title;
	var tempWidth = iWidth;
	var tempHeight = iHeight;
	iWidth=500;
	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=140;
	i2Height=111;
	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() {
	Win1 = window.open("","PrintPage","width=780,height=520,toolbar=yes,scrollbars=yes,resizable=yes,top=0,left=0");
	//Win1.document.open();
	Win1.document.writeln('<html><meta http-equiv="Content-Type" content="text/html; charset=' + charSet + '"><head>');
	Win1.document.writeln('	<title>Printable Map Output</title>');
	Win1.document.writeln('</head>');
	Win1.document.writeln('<body BGCOLOR="White" TEXT="Black" LEFTMARGIN=0 TOPMARGIN=0 onload="window.focus()">');
	Win1.document.writeln('<FONT FACE="Arial" size=1><B>');
	Win1.document.writeln('<TABLE WIDTH="650" ALIGN=CENTER BORDER="1" CELLSPACING="0" CELLPADDING="0" NOWRAP>');

	if (printTitle == parent.MapFrame.apn) {
		Win1.document.writeln('	<TR><TH COLSPAN="2">Black Hawk County Parcel Map</TH></TR>');
		Win1.document.writeln(' <TR><TD WIDTH="20%"><font face="Arial" size=-1>Parcel ID:</TD><TD><font face="Arial" size=-1>' + printTitle + '</TD></TR>');
		if (parent.MapFrame.deedh1 !== "") {
			if (parent.MapFrame.deedh2 !== "") {
				var dspVal = "Deed Holders:";
				var deedh = parent.MapFrame.deedh1 + " & " + parent.MapFrame.deedh2;
			} else {
				var dspVal = "Deed Holder:";
				var deedh = parent.MapFrame.deedh1;
			}
			Win1.document.writeln(' <TR><TD WIDTH="20%"><font face="Arial" size=-1>' + dspVal + '</TD><TD><font face="Arial" size=-1>' + deedh + '</TD></TR>');
		}
		if (parent.MapFrame.contracth1 !== "") {
			if (parent.MapFrame.contracth2 !== "") {
				var dspVal = "Contract Buyers:";
				var contracth = parent.MapFrame.contracth1 + " & " + parent.MapFrame.contracth2;
			} else {
				var dspVal = "Contract Buyer:";
				var contracth = parent.MapFrame.contracth1;
			}
			Win1.document.writeln(' <TR><TD WIDTH="20%"><font face="Arial" size=-1>' + dspVal + '</TD><TD><font face="Arial" size=-1>' + contracth + '</TD></TR>');
		}
		if (parent.MapFrame.address !== "") {
			Win1.document.writeln(' <TR><TD WIDTH="20%"><font face="Arial" size=-1>Parcel Address:</TD><TD><font face="Arial" size=-1>' + parent.MapFrame.address + '</TD></TR>');
		} else if (parent.MapFrame.legal1 !== "") {
			if (parent.MapFrame.legal2 !== "") {
				var legal = parent.MapFrame.legal1 + " " + parent.MapFrame.legal2;
			} else {
				var legal = parent.MapFrame.legal1;
			}
			Win1.document.writeln(' <TR><TD WIDTH="20%"><font face="Arial" size=-1>Legal:</TD><TD><font face="Arial" size=-1>' + legal + '</TD></TR>');
		}
	} else {
		Win1.document.writeln('	<TR><TH COLSPAN="2">' + printTitle + '</TH></TR>');
	}

	Win1.document.writeln('</TABLE>');
	Win1.document.writeln('<TABLE WIDTH="650" ALIGN=CENTER BORDER="1" CELLSPACING="0" CELLPADDING="0" NOWRAP>');
	Win1.document.writeln('	<TR>');
	if (hasOVMap) {
		Win1.document.writeln('		<TD BGCOLOR="#E1E1E1" ALIGN="CENTER">');
		Win1.document.writeln('			<IMG SRC="' + printOVURL + '" HSPACE=0 VSPACE=0 BORDER=0 ALT="">');
		Win1.document.writeln('		</TD>');
	}
	Win1.document.write('		<TD WIDTH="500" HEIGHT="500" VALIGN="TOP"');
	if (hasOVMap) Win1.document.write(' ROWSPAN="2"');
	Win1.document.writeln('>');
	Win1.document.writeln('			<IMG SRC="' + printMapURL + '" 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 + '" WIDTH=140 HSPACE=0 VSPACE=0 BORDER=0 ALT="">');
	Win1.document.writeln('		</TD>');
	Win1.document.writeln('	</TR>');
	
	Win1.document.writeln('</TABLE>');
	Win1.document.writeln('<TABLE WIDTH="650" ALIGN=CENTER BORDER="1" CELLSPACING="0" CELLPADDING="0" NOWRAP>');
	Win1.document.writeln('	<TR><TD WIDTH="35%" VALIGN=TOP><font face="Arial" size=-2>Black Hawk County, Iowa<br>316 East 5th Street<br>Waterloo, Iowa 50703-4774<br>Phone: (319) 833-3002<br>Fax: (319) 833-3070<br>E-mail: <A HREF="mailto:auditor@co.black-hawk.ia.us.org">auditor@co.black-hawk.ia.us.org</A></TD>');
	Win1.document.writeln('	<TD VALIGN=TOP><font face="Arial" size=-2>Map Disclaimer: This map does not represent a survey. No liability is assumed for the accuracy of the data delineated herein, either expressed or implied by Black Hawk County, the Black Hawk County Assessor or their employees.  This map is compiled from official records, including plats, surveys, recorded deeds, and contracts, and only contains information required for local government purposes.  See the recorded documents for more detailed legal information.</TD></TR>');
	Win1.document.writeln('</TABLE>');
	Win1.document.writeln('</B></FONT>');
	Win1.document.writeln('</body></html>');
	Win1.document.close();
	
	// legendVisible=legVis2;
	// Win1=null;
	hideRetrieveMap();
}


