
// 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 = "ArcIMS 3.1 HTML Viewer Map";
var printMapURL="";
var printOVURL="";
var printLegURL="";

var legVis2=false;

// Variables to hold the HTML image size
    var printWidth = 0;
    var printHeight = 0;


/*
***************************************************************************************

Print functions 

***************************************************************************************
*/


// display print form
function printIt() {
	hideLayer("measureBox");
	if (useTextFrame) {
		parent.TextFrame.document.location = "printform.htm";
	} else {
		var Win1 = open("printform.htm","PrintFormWindow","width=575,height=150,scrollbars=yes,resizable=yes");
	}
}

// create web page for printing
	// first get Map
//function getPrintMap(title) {
function getPrintMap(title,pWidth,pHeight,quality) {
	showRetrieveMap();
	printTitle=title;
	var tempWidth = iWidth;
	var tempHeight = iHeight;
	//iWidth=450;
	//iHeight=450;
	// Image width and quality supplied by the printform
    printWidth = pWidth;
    printHeight = pHeight;

    iWidth = Math.floor( parseFloat(printWidth) * quality );
    iHeight = Math.floor( parseFloat(printHeight) * quality );
    //alert( iWidth + " " + iHeight );
    
	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");
	//Win1.document.open();
	Win1.document.writeln('<html><head>');
	Win1.document.writeln('	<title>Map Output</title>');
	Win1.document.writeln('</head>');
	Win1.document.writeln('<body BGCOLOR="White" TEXT="Black" LEFTMARGIN=0 TOPMARGIN=0>');
	Win1.document.writeln('<FONT FACE="Arial"><B>');
	Win1.document.writeln('<TABLE WIDTH="650" BORDER="2" CELLSPACING="0" CELLPADDING="0" NOWRAP>');
	Win1.document.writeln('	<TR>');
	Win1.document.writeln('		<TH COLSPAN="2">' + printTitle + '</TH>');
	Win1.document.writeln('	</TR>');
	Win1.document.writeln('	<TR>');
	//Win1.document.write('		<TD WIDTH="450" HEIGHT="450"');
	Win1.document.write('      <TD WIDTH="'+printWidth+'" HEIGHT="'+printHeight+'" ROWSPAN="2"');
	//if (hasOVMap) Win1.document.write(' ROWSPAN="2"');
	Win1.document.writeln('>');
	Win1.document.writeln('         <IMG SRC="' + printMapURL + '" WIDTH="'+printWidth+'" HEIGHT="'+printHeight+'" HSPACE=0 VSPACE=0 BORDER=0 ALT="">');
	//Win1.document.writeln('			<IMG SRC="' + printMapURL + '" WIDTH=450 HEIGHT=450 HSPACE=0 VSPACE=0 BORDER=0 ALT="">');
	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=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 + '" 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("	<font face='Verdana' size='-3' color='#B7334E'><b><u>DISCLAIMER</u></b><br>MOA's GIS data is made available on the condition that users agree that the MOA shall not be liable for tangible or intangible loss or damage of any kind, including physical injury, death, property damage, economic loss or consequential damages arising from any errors, inaccuracies or omissions in the GIS data, even if such errors, inaccuracies or omissions are attributable in whole or in part to the MOA's negligence or failure to use due care in obtaining or presenting the GIS data. By accessing GIS data on The Municipality of Anchorage website, you accept this limitation on the MOA's liability.</font>");
	Win1.document.writeln('		</TD>');
	Win1.document.writeln('	</TR>');
	Win1.document.writeln('</TABLE>');
	Win1.document.writeln('</B></FONT>');
	//Win1.document.writeln('</body></html>');
	Win1.document.close();
	
	legendVisible=legVis2;
	Win1=null;
	hideRetrieveMap();
}

