// 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 

// CREATED BY BRIAN FITZGERALD
// EDITED BY HECTOR CERVANTES

***************************************************************************************
*/


// 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;

// Print setting for Portrait

	if(printres == "Low" && printlayout == "Portrait")
	{
		iWidth=660;
		iHeight=600;
	}
	else if(printres == "Normal" && printlayout == "Portrait")
	{
		iWidth=990;
		iHeight=900;
	}
	else if(printres == "High" && printlayout == "Portrait")
	{
		iWidth=1320;
		iHeight=1200;
	}
	
// Print settings for Landscape

	else if(printres == "Low" && printlayout == "Landscape")
	{
		iWidth=660;
		iHeight=660;
	}
	else if(printres == "Normal" && printlayout == "Landscape")
	{
		iWidth=990;
		iHeight=990;
	}
	else if(printres == "High" && printlayout == "Landscape")
	{
		iWidth=1320;
		iHeight=1320;
	}
	

// Below should never happen

	else
	{
		iWidth=901;
		iHeight=901;
	}

//return

	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() {
	if (printLegURL=="") printLegURL = "images/nolegend.gif";
	//  waiting for Legend tags
	writePrintPage();
}
// fourth, write the web page
function writePrintPage() 
{




// 8.5 x 11 - Portrait

	if (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>Madison County Transit Map Output Page</title>');
			Win1.document.writeln('</head>');
			Win1.document.writeln('<body BGCOLOR="White" TEXT="#003366" LEFTMARGIN=0 TOPMARGIN=0>');
			
			Win1.document.writeln('<TABLE WIDTH="660" 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="arial" color="#003366" size=6></B>' + printTitle + '</font></CENTER></TD>');
			Win1.document.writeln('	</TR>');
			
			Win1.document.writeln('	<TR>');
			Win1.document.write('		<TD BGCOLOR="white" WIDTH="660" HEIGHT="600" COLSPAN="2"');
			//if (hasOVMap) Win1.document.write(' ROWSPAN="1"');
			Win1.document.writeln('>');
			Win1.document.writeln('			<IMG SRC="' + printMapURL + '" WIDTH=660 HEIGHT=600 HSPACE=0 VSPACE=0 BORDER=0>');
			Win1.document.writeln('		</TD>');
			
			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="0"><TR>');
		Win1.document.writeln('<TD><IMG SRC="' + websiteURL + '/images/mcttrails.jpg" ></TD>');
		Win1.document.writeln('<TD><font face="arial" size = "1"><B>Copyright 2004</font><br><font face="arial" size = "1">Madison County Transit GIS</font><br><font face="arial" size = "1">One Transit Way</font><br><font face="arial" size = "1">Granite City, IL 62040</font><B></TD>');
		//Win1.document.writeln('<TD ALIGN="RIGHT"><IMG SRC="' + websiteURL + '/images/rbom.gif" ></TD>');
		Win1.document.writeln('</tr><tr>');

		Win1.document.writeln('<TD colspan="3"><font face="arial" color="#003366" SIZE="1">DISCLAIMER : This is a product of the Madison County Transit GIS Department.  The data depicted here have been developed with extensive cooperation from other county departments, as well as other federal, state and local governments agencies.Madison County Transit expressly disclaims responsibility for damages or liability that may arise from the use of this map. </font><br><br>');

		Win1.document.writeln('<font face="arial" color="#003366" SIZE="1">PROPRIETARY INFORMATION:  Any resale of this information is prohibited, except in accordance with a licensing agreement.</font></td>');

		Win1.document.writeln('</tr></table>');	
			

			
			Win1.document.writeln('		<TD  ALIGN="LEFT" VALIGN="CENTER">');
			Win1.document.writeln('			    <center><IMG SRC="' + printOVURL + '" WIDTH=190 HEIGHT=150 HSPACE=0 VSPACE=0 BORDER=0 ALT=""></center>');
			Win1.document.writeln('		</TD>');
			Win1.document.writeln('	</TR></table>');
			
			
		}

// 8.5 x 11 - Landscape

	else if (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>Madison County Transit Map Output Page</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="5" 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('			    <td WIDTH="350"><center><IMG SRC="' + printOVURL + '" WIDTH=190 HEIGHT=150 HSPACE=0 VSPACE=0 BORDER=0 ALT=""></center></td>');
			//Win1.document.writeln('		<td WIDTH="350"><center><IMG SRC="http://www.richlandmaps.com/website/printimages/legend.gif" height=150 width=240 HSPACE=0 VSPACE=0 BORDER=0 ALT=""></center></td>');
			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="0"><TR>');
		Win1.document.writeln('<TD><IMG SRC="' + websiteURL + '/images/mcttrails.jpg" ></TD>');
		//Win1.document.writeln('<TD ALIGN="RIGHT"><IMG SRC="' + websiteURL + '/images/rbom.gif" ></TD>');
		Win1.document.writeln('</tr><tr>');

		Win1.document.writeln('<TD colspan="3"><br><br><font face="arial" color="#003366" SIZE="2">DISCLAIMER : This is a product of the Madison County Transit GIS Department.  The data depicted here have been developed with extensive cooperation from other county departments, as well as other federal, state and local governments agencies.Madison County Transit expressly disclaims responsibility for damages or liability that may arise from the use of this map. </font><br><br>');

		Win1.document.writeln('<font face="arial" color="#003366" SIZE="2">PROPRIETARY INFORMATION:  Any resale of this information is prohibited, except in accordance with a licensing agreement.</font></td>');

		Win1.document.writeln('</tr>');
		Win1.document.writeln('<tr>');

		Win1.document.writeln('<TD colspan="3"><br><center><font face="arial" size = "2"><B>Copyright 2002</font><br><font face="arial" size = "2">Madison County Transit GIS</font><br><font face="arial" size = "2">One Transit Way</font><br><font face="arial" size = "2">Granite City, ILL 62040</font><B></center></TD>');
			
					
		}
	
	Win1.document.writeln('</TABLE>');
	Win1.document.writeln('</B></FONT>');
	//Win1.document.writeln('</body></html>');
	Win1.document.close();
	
	legendVisible=legVis2;
	Win1=null;
	hideRetrieveMap();
}

