// 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;

var retname = "";
var retsize = 0;
var myArr = new Array();
var maxRows =15;
var tableArr = new Array(300);
var categoryArray = new Array()
var numCol = 1;
var landflag = false;
/*
***************************************************************************************

Print functions 

***************************************************************************************
*/


// display print form

function printIt() {
	hideLayer("measureBox");
	//if (useTextFrame) {
		parent.TOCFrame.document.location = "printform.htm";
	//} else {
	//	var Win1 = open("printform.htm","PrintFormWindow","width=575,height=300,scrollbars=yes,resizable=yes,left=0,top=0");
	//	Win1.focus()
	//}
}

// create web page for printing
	// first get Map
function getPrintMap(title) {
	showRetrieveMap();
	printTitle=title;
	var tempWidth = iWidth;
	var tempHeight = iHeight;
	iWidth=620;
	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 Win1 = open("","PrintPage");
	var i=0;
	var idx=0;
	
	var str = "";
	var j = 0;
	var cnt_ramp = 0;
	var ramp1,ramp2,ramp3,ramp4,ramp5;
	ramp1=false; ramp2=false; ramp3=false; ramp5=false;
	var r1,r2,r3,r4,r5 = new Array()
	
  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(' <LINK rel="stylesheet" href="' + appDir +'westchester.css" type="text/css">');
  Win1.document.writeln('</head>');
  Win1.document.writeln('<body BGCOLOR="White" TEXT="#000000" LEFTMARGIN=2 TOPMARGIN=2 MARGINWIDTH="2" MARGINHEIGHT="2">');
  Win1.document.writeln(' <TABLE border="0"  cellspacing="0" cellpadding="0">');
  Win1.document.writeln('  <TR>');
//  Win1.document.writeln('   <TD bgcolor="#015963"><IMG src="' + appDir +'images/top_cap_left.gif" width="20" height="39"></TD>');
//  Win1.document.writeln('   <TD bgcolor="#015963" align="center" class="printmaptitle">' + printTitle + '</TD>');
 Win1.document.writeln('   <TD colspan=3 align="center" class="printmaptitle">' + printTitle + '</TD>');
//  Win1.document.writeln('   <TD align="right" bgcolor="#015963"><IMG src="' + appDir +'images/top_cap_right.gif" width="20" height="39"></TD>');
  Win1.document.writeln('  </TR>');
  Win1.document.writeln('  <TR>');
  Win1.document.writeln('   <TD colspan="3"><IMG src="' + appDir +'images/transparent.gif" width="4" height="5"></TD>');
  Win1.document.writeln('  </TR>');
  Win1.document.writeln('  <TR>');
  Win1.document.writeln('   <TD colspan="3" bgcolor="#015963">');
  Win1.document.writeln('    <TABLE border="0" cellspacing="1" cellpadding="2">');
  Win1.document.writeln('     <TR>');
  Win1.document.writeln('      <TD  bgcolor="#FFFFFF" align="center"><IMG src="' + printMapURL + '"></TD>');
  Win1.document.writeln('     </TR>');
  Win1.document.writeln('     <TR>');
 
  Win1.document.writeln('      <TD bgcolor="#FFFFFF">');
 
  Win1.document.writeln('			<IMG   SRC="' + printLegURL + '" HSPACE=0 VSPACE=0 BORDER=0 ALT="">');
  Win1.document.writeln('</TD>');
  Win1.document.writeln('     </TR>');
  Win1.document.writeln('    </TABLE>');
  Win1.document.writeln('   </TD>');
  Win1.document.writeln('  </TR>');
  Win1.document.writeln('  <TR>');
  Win1.document.writeln('   <TD colspan="3"><IMG src="' + appDir +'images/transparent.gif" width="4" height="5"></TD>');
  Win1.document.writeln('  </TR>');
//  Win1.document.writeln('  <TR>');
//  Win1.document.writeln('   <TD bgcolor="#015963"><IMG src="' + appDir +'images/bottom_cap_left.gif" width="20" height="39"></TD>');
//  Win1.document.writeln('   <TD bgcolor="#015963">&nbsp;</TD>');
//  Win1.document.writeln('   <TD bgcolor="#015963" align="right"><IMG src="' + appDir +'images/bottom_cap_right.gif" width="20" height="39"></TD>');
//  Win1.document.writeln('  </TR>');
  Win1.document.writeln(' </TABLE>');

	Win1.document.close();
	
	legendVisible=legVis2;
	Win1=null;
	hideRetrieveMap();
}
