// 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.0 HTML Viewer Map";
var printMapURL="";
var printOVURL="";
var printLegURL="";

var legVis2=false;

/*
***************************************************************************************

Print functions 

***************************************************************************************
*/

// display print form
function printIt() {
	hideLayer("measureBox");
var title = "Web Map Output";
getPrintMap(title);
}


//custom version
function customGetPrintMap() {
	showRetrieveMap();
	//printTitle=title;
	var tempWidth = iWidth;
	var tempHeight = iHeight;
//	iWidth=350;
//	iHeight=350;
// property info report
	iWidth=500;
	iHeight=400;
	legVis2=legendVisible;
	//if (aimsLegendPresent) legendVisible=true;
	// set PrintReportFlag to true to modify the XML
	parent.MapFrame.PrintReportFlag = true;
	var theString = writeXML();
	iWidth=tempWidth;
	iHeight = tempHeight;
	legendVisible = legVis2;
	sendToServer(imsURL,theString,104);
	tempWidth=null;
	tempHeight=null;
	theString=null;

}

// create web page for printing
	// first get Map
function getPrintMap(title) {
	showRetrieveMap();
	printTitle=title;
	var tempWidth = iWidth;
	var tempHeight = iHeight;
	iWidth=450;
	iHeight=450;
	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","resizable=yes,scrollbars=yes,location=no,toolbar=no,menubar=yes,width=605,height=555");
	Win1.document.open();
	Win1.document.writeln('<html><head>');
	Win1.document.writeln('<title>City of Burnaby - Web Map Output</title>');
	Win1.document.writeln('<link rel=stylesheet type="text/css" href="'+asp_path+'bby_styles.css">');
	Win1.document.writeln('</head>');
	Win1.document.writeln('<body BGCOLOR="black" LEFTMARGIN=0 TOPMARGIN=0>');
	Win1.document.writeln('<table border=2><td>');
	Win1.document.writeln('<table WIDTH="600" height="500" BORDER="0" CELLSPACING="0" CELLPADDING="0" NOWRAP>');
	Win1.document.writeln('<tr height="50">');
	Win1.document.writeln('<td align="center" width="150" bgcolor="black"><IMG SRC="'+app_path+'images/bby_logo_2002.gif" HSPACE=0 VSPACE=0 BORDER=0 ALT="Burnaby Logo"></td>');
	Win1.document.writeln('<td align="center" class="white_b" width="450">Burnaby Web Map Output</td>');
	Win1.document.writeln('</tr>');
	Win1.document.writeln('<tr height="25"><td class="subBG" colspan="2"></td></tr>');
	Win1.document.writeln('<tr height="300">');
    Win1.document.writeln('<td class="subBG" align="center" colspan="2">');
	Win1.document.writeln('<IMG SRC="' + printMapURL + '" WIDTH=450 HEIGHT=450 HSPACE=0 VSPACE=0 BORDER=0 ALT="">');
	Win1.document.writeln('</td>');
	Win1.document.writeln('</tr>');
	Win1.document.writeln('<tr height="25" class="subBG"><td align="center" class="sidesmallbold" colspan="2">Scale: NOT TO SCALE</td></tr>');
	Win1.document.writeln('<tr height="50"><table><tr>');
	Win1.document.writeln('<td valign="top" halign="right" class="white_b_i" width="50">Disclaimer:</td>');
	Win1.document.writeln('<td valign="top" halign="left" class="white_b_i" width="550">This information has been gathered and assembled on City of Burnaby computer systems. Data provided herein is derived from a number of sources with varying levels of accuracy. The City of Burnaby disclaims all responsibility for the accuracy or completeness of information contained herein.</td>');
	Win1.document.writeln('</tr></table>');
	Win1.document.writeln('</table>');
	Win1.document.writeln('</td></table>');
	Win1.document.writeln('</body></html>');
	Win1.document.close();
	
	legendVisible=legVis2;
	Win1=null;
	hideRetrieveMap();
}

/*
function customWritePrintPage(){

	var w = screen.width;

	//if(w < 1024){
// property info report
	  var reportWin = window.open("","report","resizable=yes,scrollbars=yes,location=no,toolbar=no,menubar=no,width=600,height=650");

	var tempImageURLArray = printMapURL.split('/');

//used in internet version
	if(parent.QuerySelectFrame.PID != ''){
	// assemble the URL -> get the PID & address(extraArgs) from the QuerySelectFrame, where they are stored -> add the map .jpg as well
	var url = parent.MapFrame.asp_path+"internetbpdqryprint.asp?cmd=aspquery&searchby=1&pid="+parent.QuerySelectFrame.PID+"&image="+tempImageURLArray[tempImageURLArray.length-1]+parent.QuerySelectFrame.extraArgs;
	reportWin.location = url;
	}
	hideRetrieveMap();
}
*/
function customWritePrintPage(){
	var w = screen.width;
	var reportWin = window.open("","report","resizable=yes,scrollbars=yes,location=no,toolbar=no,menubar=yes,width=600,height=650");
	var tempImageURLArray = printMapURL.split('/');
//	if(parent.TOCFrame.one.pid.value != ''){
//	var url = parent.MapFrame.asp_path+"internetbpdqryprint.asp?cmd=aspquery&searchby=1&pid="+parent.TOCFrame.one.pid.value+"&image="+tempImageURLArray[tempImageURLArray.length-1]+parent.QuerySelectFrame.extraArgs;
	if(parent.QuerySelectFrame.PID != ''){
	var url = parent.MapFrame.asp_path+"internetbpdqryprint.asp?cmd=aspquery&searchby=1&pid="+parent.QuerySelectFrame.PID+"&image="+tempImageURLArray[tempImageURLArray.length-1]+parent.QuerySelectFrame.extraArgs;
	reportWin.location = url;
	}
	hideRetrieveMap();
}

function customSurveyPrintPage(){

	var w = screen.width;

	var surveyWin = window.open("","survey","resizable=yes,scrollbars=yes,location=no,toolbar=no,menubar=yes,width=450,height=650,dependent=no");
    var tempImageURLArray = printMapURL.split('/');

	if(parent.TOCFrame.document.forms["getmoncode"].moncode.value != ''){
		var lpr_url = parent.MapFrame.asp_path+"svymonumentprint.asp?cmd=aspquery&lyrindex=13&mon="+parent.TOCFrame.document.forms["getmoncode"].moncode.value+"&image="+tempImageURLArray[tempImageURLArray.length-1];
		surveyWin.location = lpr_url;
	}
	hideRetrieveMap();

}

function customBPBMPrintPage(){

	var w = screen.width;

	var surveyWin = window.open("","bpbm","resizable=yes,scrollbars=yes,location=no,toolbar=no,menubar=yes,width=450,height=650,dependent=no");
    var tempImageURLArray = printMapURL.split('/');

	if(parent.TOCFrame.document.forms["getmarkerid"].markerid.value != ''){
		var lpr_url = parent.MapFrame.asp_path+"svybpbmprint.asp?cmd=aspquery&lyrindex=1&markerid="+parent.TOCFrame.document.forms["getmarkerid"].markerid.value+"&image="+tempImageURLArray[tempImageURLArray.length-1];
		surveyWin.location = lpr_url;
	}
	hideRetrieveMap();

}
