// 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;

/*
***************************************************************************************

Print functions 

***************************************************************************************
*/


// display print form
function printIt() {
	hideLayer("measureBox");
	if (useTextFrame) {
		parent.TextFrame.document.location = "printform.htm";
	} else {
    // aanpassing logis (MB - afdruksjablonen)
    // -  resolutie popup wat aangepast om extra parameter te tonen
		//var Win1 = open("printform.htm","PrintFormWindow","width=575,height=150,scrollbars=yes,resizable=yes");
		open("printform.htm","PrintFormWindow","width=575,height=250,scrollbars=yes,resizable=yes");
    // einde aanpassing logis (MB - afdruksjablonen)
	}
}

// create web page for printing
	// first get Map
function getPrintMap(title) {
 	showRetrieveMap();
	printTitle=title;
        var tempWidth = iWidth;
	var tempHeight = iHeight;
// aanpassing LOGIS : er wordt dezelfde grootte gepakt als het opgevraagd kaartje zelf!!!
// hierdoor komt schaal steeds overeen
	//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;
// aanpassing LOGIS : er wordt dezelfde grootte gepakt als het opgevraagd kaartje zelf!!!
	//i2Width=190;
	//i2Height=150;
	
  // aanpassing logis (MB - afdruksjablonen)
  if ((logisPrintOVWidth != 0) && (logisPrintOVHeight != 0))
  {
    var tmpWidth = getLogisPOVWidth();
    var tmpHeight = getLogisPOVHeight();
  
    i2Width = tmpWidth;
    i2Height = tmpHeight;
  };
  // einde aanpassing logis (MB - afdruksjablonen)
	
	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 = "../logisarcims/images/nolegend.gif";
	
  // aanpassing logis (MB - afdruksjablonen)
	if (logisPrintTemplateURL == "")
	{
    // standaard afdruk	   
    writePrintPage();
  }
  else
  {
    // afdruk met template
    writePrintPage2();
  };
  // einde aanpassing logis (MB - afdruksjablonen)
  
  //logis : herzetten parameters :
  LogisResetPrintVar();
}
// fourth, write the web page
function writePrintPage() {
	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>' + titleList[5] + '</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>');
// aanpassing LOGIS : breedte van oorspronkelijk kaartje genomen
// LogisWeb versie 1.6 : onderstaande op vraag van POVL overgenomen
// aanpassing EV: " valign="top" " toegevoegd
        //Win1.document.write('		<TD WIDTH="450" HEIGHT="450"');
	Win1.document.write('		<TD WIDTH="' + iWidth + '" HEIGHT="' + iHeight + '" valign="top"');
	if (hasOVMap) Win1.document.write(' ROWSPAN="2"');
	Win1.document.writeln('>');
// aanpassing LOGIS : breedte van oorspronkelijk kaartje genomen
	//Win1.document.writeln('			<IMG SRC="' + printMapURL + '" WIDTH=450 HEIGHT=450 HSPACE=0 VSPACE=0 BORDER=0 ALT="">');
	Win1.document.writeln('			<IMG SRC="' + printMapURL + '" WIDTH=' + iWidth + ' HEIGHT=' + iHeight + 'HSPACE=0 VSPACE=0 BORDER=0 ALT="">');
	Win1.document.writeln('		</TD>');

// LogisWeb versie 1.6 bijkomende parametertest ofdat overview kaartje moet afgedrukt worden.


	if (hasOVMap && logisbPrintOVMap) {
// aanpassing LOGIS : er wordt dezelfde grootte gepakt als het opgevraagd kaartje zelf!!!
		// 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 HEIGHT="' + i2Height + '" ALIGN="CENTER">');
		Win1.document.writeln('			<IMG SRC="' + printOVURL + '" WIDTH=' + i2Width + ' HEIGHT=' + i2Height + ' 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('</TABLE>');
	Win1.document.writeln('</B></FONT>');

// logis aanpassing om identify resultaat te kunnen toevoegen.
if (typeof LogisPrintText != 'undefined') {
        Win1.document.writeln(LogisPrintText);
        LogisPrintText = "";
}

// einde logis aanpassing
	//Win1.document.writeln('</body></html>');
	Win1.document.close();
	
	legendVisible=legVis2;
	Win1=null;
	hideRetrieveMap();
}

function writePrintPage2() 
{
  // aanpassing logis (MB - afdruksjablonen)
  // - nieuwe functie
  // - afdruksjabloon gebruiken om afdruk te genereren
  logisAddLog('<br><b>writePrintPage2</b><br>');
  
	open(logisPrintTemplateURL, "PrintPage");
	legendVisible=legVis2;
	hideRetrieveMap();
}
