// 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;

// brb -- for PDF printing
var printToPDF = "Print"

/*
***************************************************************************************

Print functions 

***************************************************************************************
*/


// display print form
function printIt() {
	hideLayer("measureBox");
	if (useTextFrame) {
		parent.TextFrame.document.location = "printform.htm";
	} else {
//brb		var Win1 = open("printform.htm","PrintFormWindow","width=575,height=150,scrollbars=yes,resizable=yes");
		var Win1 = open("printform.htm","PrintFormWindow","width=575,height=350,scrollbars=yes,resizable=yes");
	}
}







// create web page for printing
	// first get Map
function getPrintMap(title) {
	showRetrieveMap();
	printTitle=title;
	var tempWidth = iWidth;
	var tempHeight = iHeight;
//brb	iWidth=450;
//brb	iHeight=450;
//	iWidth=650;
//	iHeight=550;
	iWidth=677;
	iHeight=612;
	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() {

if (printToPDF == "PDF") {
//this works    Win1.document.location.href = 'http://a018/_common_UI/asp/printtopdf.asp?Map=' + printMapURL + '&Legend=' + printLegURL + '&Overview=' + printOVURL;
//	var sWin = 'http://a018/_common_UI/asp/printtopdf.asp?Map=' + printMapURL + '&Legend=' + printLegURL + '&Overview=' + printOVURL + '&Title=' + printTitle;
	var sWin = '/_common_UI/asp/printtopdf.asp?Map=' + printMapURL + '&Legend=' + printLegURL + '&Overview=' + printOVURL + '&Title=' + printTitle;
	var Win1 = open(sWin,"PrintPage","scrollbars=yes,resizable=yes,toolbar=yes,directories=no,location=no,status=no,menubar=yes");
//	Win1.document.close();
	Win1.document.close();
} else {
	var Win1 = open("","PrintPage","scrollbars=yes,resizable=yes,toolbar=yes,directories=no,location=no,status=no,menubar=yes");
	var now = new Date();
	var month = now.getMonth();
	var date = now.getDate();
	var year = now.getYear();
	var textout;

	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">');
	Win1.document.writeln('<TABLE WIDTH="908" BORDER="0" CELLSPACING="0" CELLPADDING="0" NOWRAP>');
	Win1.document.writeln('	<TR>');
	Win1.document.writeln('		<B><TH>' + printTitle + '</TH></B>');

	if (month==0) textout="January";
	if (month==1) textout="Febuary";
	if (month==2) textout="March";
	if (month==3) textout="April";
	if (month==4) textout="May";
	if (month==5) textout="June";
	if (month==6) textout="July";
	if (month==7) textout="August";
	if (month==8) textout="September";
	if (month==9) textout="October";
	if (month==10) textout="November";
	if (month==11) textout="December";
	textout += " " + date + ", " + year;

	Win1.document.writeln('		<TD ALIGN="CENTER"><FONT FACE="Arial" SIZE="-2">Created: ' + textout + '</FONT></TD>');
	Win1.document.writeln('	</TR>');
	Win1.document.writeln('	<TR>');
	Win1.document.write('		<TD WIDTH="677" HEIGHT="612"');
	if (hasOVMap) Win1.document.write(' ROWSPAN="3"');
	Win1.document.writeln('>');
	Win1.document.writeln('			<TABLE BORDER=1 PADDING=1><TR><TD><IMG SRC="' + printMapURL + '" WIDTH=677 HEIGHT=612 HSPACE=0 VSPACE=0 BORDER=2 ALT=""></TD></TR></TABLE>');
	Win1.document.writeln('		</TD>');
	if (hasOVMap) {
		Win1.document.writeln('		<TD HEIGHT="150" ALIGN="CENTER">');
		Win1.document.writeln('			<IMG SRC="' + printOVURL + '" WIDTH=190 HEIGHT=150 HSPACE=0 VSPACE=0 BORDER=2 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 + '" HEIGHT=333 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" WIDTH="231" HEIGHT="89" VALIGN="BOTTOM">');
	Win1.document.writeln('			<IMG SRC="http://maps.idwr.idaho.gov/images/idwr_arcims_wob.gif" WIDTH="231" HEIGHT="89" HSPACE=0 VSPACE=0 BORDER=0 ALT="">');
	Win1.document.writeln('		</TD>');
	Win1.document.writeln('	</TR>');
	Win1.document.writeln('	<TR><TD COLSPAN="2">');
	Win1.document.writeln('<FONT FACE="Arial" SIZE="-2">The Idaho Department of Water Resources is maintaining this web site as a public service. ');
	Win1.document.writeln('Persons using information from this site for official purposes, or other purposes, for');
	Win1.document.writeln('which accuracy and completeness are required, are hereby notified that they should first verify the information with the');
	Win1.document.writeln('public records or other primary sources from which the information was obtained.');
	Win1.document.writeln('	</FONT></TD></TR>');

	
	Win1.document.writeln('</TABLE>');
	Win1.document.writeln('</FONT>');

	Win1.document.close();
}

	legendVisible=legVis2;
	Win1=null;
	hideRetrieveMap();
}

