// 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 printsize="";
var printres="";
var printlayout="";

var legVis2=true;

/*
***************************************************************************************

Print functions 

// EDITED BY BRIAN FITZGERALD
// RICHLAND COUNTY GIS
// WWW.RICHLANDMAPS.COM
//
// Modified by Reese Tietje, Gnomon, Inc. 2/2004

***************************************************************************************
*/


// display print form
function printIt() {
	hideLayer("measureBox");
	if (useTextFrame) {
		//parent.TextFrame.document.location = "printform.htm";
		var Win1 = open("printform.htm","PrintFormWindow","width=575,height=500,scrollbars=yes,resizable=yes");
	} else {
		var Win1 = open("printform.htm","PrintFormWindow","width=575,height=500,scrollbars=yes,resizable=yes");
	}
}

// create web page for printing
	// first get Map
function getPrintMap(title, pagesize, resolution, layout) {
	printlayout = layout;
	printres = resolution;
	printsize = pagesize;	
	showRetrieveMap();
	printTitle=title;
	var tempWidth = iWidth;
	var tempHeight = iHeight;
//
	var tempeLeft = eLeft;
	var tempeRight = eRight;
	var tempeBottom = eBottom;
	var tempeTop = eTop;

	var dDotsPerInch = 144;
	var dMapUnitsPerInch = 0.3048/12.0;
	var dCenterX = (eLeft + eRight) * 0.5;
	var dCenterY = (eBottom + eTop) * 0.5;

// Print setting for Portrait

	if(printsize == "small" && printres == "Low" && printlayout == "Portrait")
	{
		iWidth=560;
		iHeight=600;
	}
// 8.5 x 11 size
// Change iWidth and iHeight proportionally with changes in table size
// Use only normal res - other options interfere with scale settings
	else if(printsize == "small" && printres == "Normal" && printlayout == "Portrait")
	{
		iWidth=915;
		iHeight=900;
	}
	else if(printsize == "small" && printres == "High" && printlayout == "Portrait")
	{
		iWidth=1320;
		iHeight=1200;
	}
	else if(printsize == "large" && printres == "Low" && printlayout == "Portrait")
	{
		iWidth=900;
		iHeight=990;
	}
//11 x 17 size
// Change iWidth and iHeight proportionally with changes in table size
	else if(printsize == "large" && printres == "Normal" && printlayout == "Portrait")
	{
		iWidth=1275;
		iHeight=1785;
	}
	else if(printsize == "large" && printres == "High" && printlayout == "Portrait")
	{
		iWidth=1800;
		iHeight=1980;
	}

// Print settings for Landscape

	else if(printsize == "small" && printres == "Low" && printlayout == "Landscape")
	{
		iWidth=660;
		iHeight=660;
	}
	else if(printsize == "small" && printres == "Normal" && printlayout == "Landscape")
	{
		iWidth=990;
		iHeight=990;
	}
	else if(printsize == "small" && printres == "High" && printlayout == "Landscape")
	{
		iWidth=1320;
		iHeight=1320;
	}
	else if(printsize == "large" && printres == "Low" && printlayout == "Landscape")
	{
		iWidth=990;
		iHeight=900;
	}
	else if(printsize == "large" && printres == "Normal" && printlayout == "Landscape")
	{
		iWidth=1485;
		iHeight=1350;
	}
	else if(printsize == "large" && printres == "High" && printlayout == "Landscape")
	{
		iWidth=1980;
		iHeight=1800;
	}

// Below should never happen

	else
	{
		iWidth=901;
		iHeight=901;
	}

//return


// DETERMINES SCALE
	var tempScreenWidth = eRight - eLeft;
	var tempWidthFactor = tempScreenWidth / tempWidth;
        var tempDotsPerInch = 96;
	var tempMapUnitsPerInch = 0.3048/12.0 * .85;
	var dScaleDenominator = tempWidthFactor / tempMapUnitsPerInch * tempDotsPerInch;
	var dScreenToMapScaleFactor = dMapUnitsPerInch / dDotsPerInch * dScaleDenominator;
	var dNewWidthHalf = iWidth * dScreenToMapScaleFactor * 0.5;
	var dNewHeightHalf = iHeight * dScreenToMapScaleFactor * 0.5;
	saveLastExtent();
	eLeft = dCenterX - dNewWidthHalf;
	eRight = dCenterX + dNewWidthHalf;
	eBottom = dCenterY - dNewHeightHalf;
	eTop = dCenterY + dNewHeightHalf;

	legVis2=legendVisible;
	if (aimsLegendPresent) legendVisible=true;
	var theString = writeXML();

	iWidth=tempWidth;
	iHeight = tempHeight;
	eLeft = tempeLeft;
	eRight = tempeRight;
	eBottom = tempeBottom;
	eTop = tempeTop;
	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() {
	if (printLegURL=="") printLegURL = "images/nolegend.gif";
	//  waiting for Legend tags
	writePrintPage();
}
// fourth, write the web page
function writePrintPage() 
{




// 8.5 x 11 - Portrait

	if (printsize == "small" && printlayout == "Portrait")
	{
			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>Wyoming SHPO Cultural Resources</title>');
			Win1.document.writeln('</head>');
			Win1.document.writeln('<body BGCOLOR="White" TEXT="#003366" LEFTMARGIN=0 TOPMARGIN=0>');
			
			Win1.document.writeln('<TABLE WIDTH="660" BORDER="0" CELLSPACING="0" CELLPADDING="0" NOWRAP>');
			
			Win1.document.writeln('		<TR>');
//Margin follows - margin width plus map width = table width : ajust both accordingly
			Win1.document.writeln('		<TD BGCOLOR="white" WIDTH="50" COLSPAN="1" ROWSPAN="3"><CENTER></CENTER></TD>');
			Win1.document.writeln(' 	<TD>');
			Win1.document.writeln('		<TABLE CELLSPACING="0" BORDER="2" BORDERCOLORLIGHT="BLACK" BORDERCOLORDARK="BLACK" CELLPADDING="0" NOWRAP>');
			Win1.document.writeln('			<TR>');
			Win1.document.writeln('			<TD BGCOLOR="#DDDDDD" COLSPAN="2"><CENTER><B><font face="Palatino Linotype color="#003366" size=6></B>' + printTitle + '</font></CENTER></TD>');
			Win1.document.writeln('			</TR>');
			
			Win1.document.writeln('			<TR>');
			Win1.document.write('			<TD BGCOLOR="white" WIDTH="610" HEIGHT="600" COLSPAN="2"');
			//if (hasOVMap) Win1.document.write(' ROWSPAN="1"');
			Win1.document.writeln('>');
			Win1.document.writeln('			<IMG SRC="' + printMapURL + '" WIDTH=610 HEIGHT=600 HSPACE=0 VSPACE=0 BORDER=0>');
			Win1.document.writeln('			</TD>');
			
			Win1.document.writeln('			</TR>');
			Win1.document.writeln(' 		<TR>');
			Win1.document.writeln(' 		<TD>');
			
var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")

		Win1.document.writeln('				<TABLE CELLSPACING="3" BORDER="1">');
		Win1.document.writeln('				<TR>');
		Win1.document.writeln('				<TD ALIGN="CENTER"><IMG SRC="http://maps.gnomon.com/website/wycris_12/images/stateparks_logo.gif" height=60 width = 85></TD>');
		Win1.document.writeln('				<TD><font face="Palatino Linotype" size = "1"><B>Copyright '+dayarray[day]+', '+montharray[month]+' '+daym+', '+year+'</font><br><font face="Palatino Linotype" size = "1">State Historic Preservation Office</font><br><font face="Palatino Linotype" size = "1">Dept. 3421, 1000 E. University</font><br><font face="Palatino Linotype" size = "1">Laramie, WY  82071</font><B></TD>');
		Win1.document.writeln('</TR>');

		Win1.document.writeln('				<TR>');
		Win1.document.writeln('				<TD colspan="2"><font face=Palatino Linotype color="#003366" SIZE="1">DISCLAIMER : This is a product of the Wyoming State Historic Preservation Office. The data depicted here have been developed with extensive cooperation from various federal, state and local government agencies. Wyoming SHPO expressly disclaims responsibility for damages or liability that may arise from the use of this map. </font><br><br>');

		Win1.document.writeln('<font face=Palatino Linotype color="#003366" SIZE="1">PROPRIETARY CONFIDENTIAL INFORMATION:  Use of this information is bound by the Wyoming Cultural Resources Information System agreement.</font></TD>');

		Win1.document.writeln('				</TR>');	
		Win1.document.writeln('				</TABLE>');	
			

			
		Win1.document.writeln('				</TD>');

		Win1.document.writeln('			<TD  ALIGN="LEFT" VALIGN="CENTER">');
		Win1.document.writeln('			<center><IMG SRC="http://maps.gnomon.com/website/wycris_12/images/legend.gif" height=180 width=300 HSPACE=0 VSPACE=0 BORDER=0 ALT=""></center>');
		Win1.document.writeln('			</TD>');
		Win1.document.writeln('			</TR>');	
		Win1.document.writeln('		</TABLE>');	
		Win1.document.writeln('		</TD>');
		Win1.document.writeln('</TR>');	
		Win1.document.writeln('</TABLE>');	
			
			
		}




// 11 x 17 Portrait

	else if (printsize == "large" && printlayout == "Portrait")
	{

			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>Wyoming SHPO Cultural Resources</title>');
			Win1.document.writeln('</head>');
			Win1.document.writeln('<body BGCOLOR="White" TEXT="#003366" LEFTMARGIN=0 TOPMARGIN=0>');
			
			Win1.document.writeln('<TABLE WIDTH="900" CELLSPACING="0" CELLPADDING="0" NOWRAP>');
			
			Win1.document.writeln('		<TR>');
//Margin follows - margin width plus map width = table width : ajust both accordingly
			Win1.document.writeln('		<TD BGCOLOR="white" WIDTH="50" COLSPAN="1" ROWSPAN="3"><CENTER></CENTER></TD>');
			Win1.document.writeln('		<TD>');
			Win1.document.writeln('		<TABLE BORDER="2" CELLSPACING="0" BORDERCOLORLIGHT="BLACK" BORDERCOLORDARK="BLACK" CELLPADDING="0" NOWRAP>');
			Win1.document.writeln('		<TR>');
			Win1.document.writeln('		<TD BGCOLOR="#DDDDDD" COLSPAN="2"><CENTER><B><font face="Palatino Linotype color="#003366" size=6></B>' + printTitle + '</font></CENTER></TD>');
			Win1.document.writeln('		</TR>');
			
			Win1.document.writeln('		<TR>');
			Win1.document.write('		<TD BGCOLOR="BLACK" WIDTH="850" HEIGHT="1190" COLSPAN="2"');
			if (hasOVMap) Win1.document.write(' ROWSPAN="1"');
			Win1.document.writeln('>');
			Win1.document.writeln('		<IMG SRC="' + printMapURL + '" WIDTH=850 HEIGHT=1190 HSPACE=0 VSPACE=0 BORDER=0>');
			Win1.document.writeln('		</TD>');
			
			Win1.document.writeln('		</TR>');
			Win1.document.writeln(' 	<TR>');
			Win1.document.writeln(' 	<TD>');



var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
		Win1.document.writeln('		<TABLE CELLSPACING="3" BORDER="1">');
		Win1.document.writeln('		<TR>');
		Win1.document.writeln('		<TD ALIGN="CENTER"><IMG SRC="http://maps.gnomon.com/website/wycris_12/images/stateparks_logo.gif" height=60 width = 85></TD>');
		Win1.document.writeln('		<TD><font face="Palatino Linotype" size = "1"><B>Copyright '+dayarray[day]+', '+montharray[month]+' '+daym+', '+year+'</font><br><font face="Palatino Linotype" size = "1">State Historic Preservation Office</font><br><font face="Palatino Linotype" size = "1">Dept. 3421, 1000 E. University</font><br><font face="Palatino Linotype" size = "1">Laramie, WY  82071</font><B></TD>');
		Win1.document.writeln('		</TR>');
		Win1.document.writeln('		<TR>');

		Win1.document.writeln('		<TD colspan="3"><font face=Palatino Linotype color="#003366" SIZE="2">DISCLAIMER : This is a product of the Wyoming State Historic Preservation Office. The data depicted here have been developed with extensive cooperation from various federal, state and local government agencies. Wyoming SHPO expressly disclaims responsibility for damages or liability that may arise from the use of this map. </font><br><br>');

		Win1.document.writeln('<font face=Palatino Linotype color="#003366" SIZE="2">PROPRIETARY CONFIDENTIAL INFORMATION:  Use of this information is bound by the Wyoming Cultural Resources Information System agreement.</font></TD>');

		Win1.document.writeln('		</TR>');
		Win1.document.writeln('		</TABLE>');

		Win1.document.writeln('		</TD>');
			
			
		Win1.document.writeln('		<TD  ALIGN="LEFT" VALIGN="CENTER">');
		Win1.document.writeln('		<center><IMG SRC="http://maps.gnomon.com/website/wycris_12/images/legend.gif" height=180 width=300 HSPACE=0 VSPACE=0 BORDER=0 ALT=""></center>');
		Win1.document.writeln('		</TD>');
		Win1.document.writeln('	</TR>');
		Win1.document.writeln('</TABLE>');
		Win1.document.writeln('	</TD>');
		Win1.document.writeln('	</TR>');
		Win1.document.writeln('</TABLE>');
	}


// 8.5 x 11 - Landscape
//THIS OPTION IS CURRENTLY DISABLED - MUST BE ADDED TO PRINTFORM.HTM

	else if (printsize == "small" && printlayout == "Landscape")
	{
			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>Wyoming SHPO Cultural Resources</title>');
			Win1.document.writeln('</head>');
			Win1.document.writeln('<body BGCOLOR="White" TEXT="#003366" LEFTMARGIN=0 TOPMARGIN=0>');
			
			Win1.document.writeln('<TABLE HEIGHT="660" WIDTH="790" BORDER="2" CELLSPACING="0" BORDERCOLORLIGHT="BLACK" BORDERCOLORDARK="BLACK" CELLPADDING="0" NOWRAP>');
			
			Win1.document.writeln('	<TR>');
			Win1.document.writeln('		<TD ROWSPAN="3"><IMG SRC="' + printMapURL + '" WIDTH=660 HEIGHT=660 HSPACE=0 VSPACE=0 BORDER=0></TD>');
			Win1.document.writeln('		<TD ><CENTER><B><font face="Palatino Linotype color="#003366" size=5></B>' + printTitle + '</font></CENTER>  </TD>');
			Win1.document.writeln('	</TR>');
			
			Win1.document.writeln('	<TR>');
			Win1.document.writeln('			<center><IMG SRC="http://maps.gnomon.com/website/wycris_12/images/legend.gif" height=180 width=300 HSPACE=0 VSPACE=0 BORDER=0 ALT=""></center>');
			Win1.document.writeln('	</TR>');

			Win1.document.writeln(' 	<TR>');
			Win1.document.writeln(' 		<TD BACKGROUND="/images/large_trans_seal_gray.JPG" ALIGN="LEFT" VALIGN="TOP">');
			

		Win1.document.writeln('<TABLE CELLSPACING="3" BORDER="1"><TR>');
		Win1.document.writeln('<TD ALIGN="CENTER"><IMG SRC="http://maps.gnomon.com/website/wycris_12/images/stateparks_logo.gif" height=60 width = 85></TD>');
		Win1.document.writeln('</tr><tr>');

		Win1.document.writeln('<TD colspan="3"><font face=Palatino Linotype color="#003366" SIZE="2">DISCLAIMER : This is a product of the Wyoming State Historic Preservation Office. The data depicted here have been developed with extensive cooperation from various federal, state and local government agencies. Wyoming SHPO expressly disclaims responsibility for damages or liability that may arise from the use of this map. </font><br><br>');

		Win1.document.writeln('<font face=Palatino Linotype color="#003366" SIZE="2">PROPRIETARY CONFIDENTIAL INFORMATION:  Use of this information is bound by the Wyoming Cultural Resources Information System agreement.</font></td>');

		Win1.document.writeln('</tr>');
		Win1.document.writeln('<tr>');

		Win1.document.writeln('<TD><font face="Palatino Linotype" size = "1"><B>Copyright '+dayarray[day]+', '+montharray[month]+' '+daym+', '+year+'</font><br><font face="Palatino Linotype" size = "1">State Historic Preservation Office</font><br><font face="Palatino Linotype" size = "1">Dept. 3421, 1000 E. University</font><br><font face="Palatino Linotype" size = "1">Laramie, WY  82071</font><B></TD>');
			
					
		}


// 11 x 17 - Landscape
//THIS OPTION IS CURRENTLY DISABLED - MUST BE ADDED TO PRINTFORM.HTM

	else if (printsize == "large" && printlayout == "Landscape")
	{
			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>Wyoming SHPO Cultural Resources</title>');
			Win1.document.writeln('</head>');
			Win1.document.writeln('<body BGCOLOR="White" TEXT="#003366" LEFTMARGIN=0 TOPMARGIN=0>');
			
			Win1.document.writeln('<TABLE HEIGHT="900" WIDTH="1300" BORDER="2" CELLSPACING="0" BORDERCOLORLIGHT="BLACK" BORDERCOLORDARK="BLACK" CELLPADDING="0" NOWRAP>');
			
			Win1.document.writeln('	<TR>');
			Win1.document.writeln('		<TD ROWSPAN="3"><IMG SRC="' + printMapURL + '" WIDTH=990 HEIGHT=900 HSPACE=0 VSPACE=0 BORDER=0></TD>');
			Win1.document.writeln('		<TD  HEIGHT="100"><CENTER><B><font face="Palatino Linotype color="#003366" size=5></B>' + printTitle + '</font></CENTER>  </TD>');
			Win1.document.writeln('	</TR>');
			
			Win1.document.writeln('	<TR>');
			Win1.document.writeln('			<center><IMG SRC="http://maps.gnomon.com/website/wycris_12/images/legend.gif" height=180 width=300 HSPACE=0 VSPACE=0 BORDER=0 ALT=""></center>');
			Win1.document.writeln('	</TR>');

			Win1.document.writeln(' 	<TR>');
			Win1.document.writeln(' 		<TD BACKGROUND="/images/large_trans_seal_gray.JPG" ALIGN="LEFT" VALIGN="TOP">');
			
var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")

		Win1.document.writeln('<TABLE CELLSPACING="3" BORDER="1"><TR>');
		Win1.document.writeln('<TD ALIGN="CENTER"><IMG SRC="http://maps.gnomon.com/website/wycris_12/images/stateparks_logo.gif" height=60 width = 85></TD>');
		Win1.document.writeln('</tr><tr>');

		Win1.document.writeln('<TD colspan="3"><font face=Palatino Linotype color="#003366" SIZE="2">DISCLAIMER : This is a product of the Wyoming State Historic Preservation Office. The data depicted here have been developed with extensive cooperation from various federal, state and local government agencies. Wyoming SHPO expressly disclaims responsibility for damages or liability that may arise from the use of this map. </font><br><br>');

		Win1.document.writeln('<font face=Palatino Linotype color="#003366" SIZE="2">PROPRIETARY CONFIDENTIAL INFORMATION:  Use of this information is bound by the Wyoming Cultural Resources Information System agreement.</font></td>');

		Win1.document.writeln('</tr>');
		Win1.document.writeln('<tr>');

		Win1.document.writeln('<TD><font face="Palatino Linotype" size = "1"><B>Copyright '+dayarray[day]+', '+montharray[month]+' '+daym+', '+year+'</font><br><font face="Palatino Linotype" size = "1">State Historic Preservation Office</font><br><font face="Palatino Linotype" size = "1">Dept. 3421, 1000 E. University</font><br><font face="Palatino Linotype" size = "1">Laramie, WY  82071</font><B></TD>');
		}


	
	Win1.document.writeln('</TABLE>');
	Win1.document.writeln('</B></FONT>');
	//Win1.document.writeln('</body></html>');
	Win1.document.close();
	
	legendVisible=legVis2;
	Win1=null;
	hideRetrieveMap();
}

