// 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 Win1;


var sem_csi_nameFilepng=""
var sem_csi_nameLegendFilepng=""



/*
***************************************************************************************

SendMail functions

***************************************************************************************
*/

// prepara l'invio della mappa via mail
function getSendMail(title) {
//	showRetrieveMap();

	printTitle=title;
	var tempWidth = iWidth;
	var tempHeight = iHeight;

	legVis2=legendVisible;
	if (aimsLegendPresent) legendVisible=true;

	var theString = writeXML();
	alert("--->"+theString);
	iWidth=tempWidth;
	iHeight = tempHeight;
	legendVisible = legVis2;

	sendToServer(imsURL,theString,101);

	tempWidth=null;
	tempHeight=null;
	theString=null;
}

// funzione per il salvataggio della mappa
function getSaveMap(title) {
 showRetrieveMap();
 printTitle=title;
 var tempWidth = iWidth;
 alert(tempWidth);
 var tempHeight = iHeight;
 legVis2=legendVisible;
 if (aimsLegendPresent) legendVisible=true;
 var theString = writeXML();
 iWidth=tempWidth;
 iHeight = tempHeight;
 legendVisible = legVis2;
 okToSend=true;
 sendToServer(imsURL,theString,101);
 tempWidth=null;
 tempHeight=null;
 theString=null;
}

// apre la finestra con la mappa in formato .png da salvare tramite il tasto destro del mouse
function writeSavePage(imgOrURL) {
 //MAD var Win1 = open("","SaveMap","width=810,height=450,scrollbars=no,resizable=no");
 var Win1 = open("","SaveMap");
 Win1.document.writeln('<html><meta http-equiv="Content-Type" content="text/html; charset=' + charSet + '"><head>');
 Win1.document.writeln('<link rel="stylesheet" href="'+pagStile+'" type="text/css"><title>' + titleList[5] + '</title>');
 Win1.document.writeln('</head>');
 Win1.document.writeln('<body BGCOLOR="White" LEFTMARGIN=0 TOPMARGIN=0>');
 Win1.document.writeln('  <table width="100%" border="0" cellpadding="0" cellspacing="0">');
 Win1.document.writeln('   <tr>');
 Win1.document.writeln('    <td><div align="center"><IMG NAME="anImage" SRC="' + imgOrURL +'"></div></td>');
 Win1.document.writeln('   </tr>');
 Win1.document.writeln('   <tr>');
 Win1.document.writeln('    <td><img src="images/pixel.gif" width="6" height="16"></td>');
 Win1.document.writeln('   </tr>');
 Win1.document.writeln('   <tr>');
 Win1.document.writeln('    <td bgcolor="#006464" align="center" class="testo11white">Premi il tasto destro del mouse sulla mappa e seleziona \'Salva Immagine con nome\'</td>');
 Win1.document.writeln('   </tr>');
 Win1.document.writeln('  </table>');
 Win1.document.writeln('</body>');
 Win1.document.writeln('</html>');
 sem_csi_flagUseSaveMap=false;
 legendVisible=legVis2;
 hideRetrieveMap();
}


// display send form
function sendIt() {

	//Viene ricavato il nome del file .png che verrā passato via POST alla servlet
	//ATTENZIONE : SE NON SI LAVORA IN AMBIENTE CLUSTER TIPO AIMSVIP COMMENTARE LE SEGUENTI 2 RIGHE E DECOMMENTARE
	//LE 2 RIGHE SUCCESSIVE
	sem_csi_nameFilepng = new String(printMapURL.substring(printMapURL.indexOf("/output")+9,printMapURL.indexOf(".png")+4));
	sem_csi_nameLegendFilepng = new String(printLegURL.substring(printLegURL.indexOf("/output")+9,printLegURL.indexOf(".png")+4));
	//alert(printMapURL+" "+sem_csi_nameFilepng+" "+sem_csi_nameLegendFilepng);
 	//sem_csi_nameFilepng = new String(printMapURL.substring(printMapURL.indexOf("/output/")+8,printMapURL.indexOf(".png")+4));
	//sem_csi_nameLegendFilepng = new String(printLegURL.substring(printLegURL.indexOf("/output/")+8,printLegURL.indexOf(".png")+4));




//	hideLayer("measureBox");
	if (useTextFrame) {
		parent.TextFrame.document.location = doc_loc_sub + "/sendform.htm";
	} else {
		var Win1 = open("sendform.htm","SendFormWindow","width=575,height=160,scrollbars=yes,resizable=yes");
	}


//		sem_csi_InviaMappa(window);

}





//Inizio SendMail : SEM
//Invio mail con allegata mappa .png: SEM
//Funzione di controllo campi form per lancio della servlet
//che gestisce il lancio della mail con in allegato la mappa .png
function sem_csi_InviaMappa(obj) {
	var theForm = obj.document.forms[0];
	var Destinatario = theForm.dest.value;

	invio=false;

	if (sem_csi_checkMail(Destinatario)) {

		//L'indirizzo controllato risulta corretto
		//Chiamata la servlet con metodo POST
		//Viene richiamata la funzione sem_csi_codifica per decodificare i font accentati inseriti dall'utente
		theForm.ogg.value=sem_csi_codifica(theForm.ogg.value);
		theForm.corpo.value=sem_csi_codifica(theForm.corpo.value);


//		alert('Destinatario: ' + Destinatario);
//		alert('Oggetto: ' + theForm.ogg.value);
//		alert('Messaggio: ' + theForm.corpo.value);


		obj.document.InviaMail.submit();

		//INIZIO BACO SEM: La finestra di invio deve essere chiusa dalla servlet ad invio avvenuto
		//obj.close();   //Viene chiusa la pop-up
		//FINE BACO SEM

		//Viene riportata a false la variabile sem_csi_flagUseSendMail dal momento
		//che la funzione di invio mappa č conclusa arrivata a questo punto
		sem_csi_flagUseSendMail = false;

		legendVisible=legVis2;
		Win1=null;
		hideRetrieveMap();


		invio=true;

	} else {
		alert("Indirizzo Destinatario non corretto");
	  	obj.focus();
	}

    if (invio) {
		stampaInvio(obj);
	}

//	return invio;
}
//Inizio SendMail : SEM


// Stampa il messaggio di avvenuto invio
function stampaInvio(finestra) {
	alert('Invio mail in corso...');
	finestra.close();
}

//Funzione di controllo correttezza indirizzo mail
function sem_csi_checkMail(mail) {
 correct = true;
 if(mail == "") {
     correct = false
 } else if(mail.indexOf("@")==-1 ||
        mail.indexOf("@")==0 ||
        mail.indexOf("@")==(mail.length-1) ||
        !(mail.indexOf("@")==mail.lastIndexOf("@")) ||
        mail.indexOf(".",mail.indexOf("@"))==-1 ||
        mail.indexOf(".",mail.indexOf("@"))==(mail.length-1) ||
        mail.lastIndexOf(".")==(mail.length-1) ||
        mail.indexOf(".",mail.indexOf("@"))==mail.indexOf("@")+1) {

     correct = false
 } else {
     for (j=0;j<mail.length;j++) {
        if (mail.charCodeAt(j)!=95 &&
            mail.charCodeAt(j)!=45 &&
            mail.charCodeAt(j)!=46 &&
            mail.charCodeAt(j)!=64 &&
           (mail.charCodeAt(j)<48 || mail.charCodeAt(j)>57) &&
           (mail.charCodeAt(j)<65 || mail.charCodeAt(j)>90) &&
           (mail.charCodeAt(j)<97 || mail.charCodeAt(j)>122)) {
           correct = false;
           break;
        }
    }
 }
 return correct;
}

//Fine SendMail : SEM










/*
***************************************************************************************

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=160,scrollbars=yes,resizable=yes");
	}
}

// create web page for printing
	// first get Map
function getPrintMap(title) {
	showRetrieveMap();
	printTitle=title;
	var tempWidth = iWidth;
	var tempHeight = iHeight;
	//INIZIO - Baco Layout : GeDeONE 1.2.0.
	//iWidth=450;
	//iHeight=450;
	//FINE - Baco Layout : GeDeONE 1.2.0.
	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;
}

// funzione per il salvataggio della mappa
function getSaveMap(title) {
	showRetrieveMap();
	printTitle=title;
	var tempWidth = iWidth;
	var tempHeight = iHeight;
	legVis2=legendVisible;
	if (aimsLegendPresent) legendVisible=true;
	var theString = writeXML();
	iWidth=tempWidth;
	iHeight = tempHeight;
	legendVisible = legVis2;
	okToSend=true;
	sendToServer(imsURL,theString,101);
	tempWidth=null;
	tempHeight=null;
	theString=null;
}

// apre la finestra con la mappa in formato .png da salvare tramite il tasto destro del mouse
function writeSavePage(imgOrURL) {
	//MAD var Win1 = open("","SaveMap","width=810,height=450,scrollbars=no,resizable=no");
        var Win1 = open("","SaveMap");
	Win1.document.writeln('<html><meta http-equiv="Content-Type" content="text/html; charset=' + charSet + '"><head>');
	Win1.document.writeln('<link rel="stylesheet" href="'+pagStile+'" type="text/css"><title>' + titleList[5] + '</title>');
	Win1.document.writeln('</head>');
	Win1.document.writeln('<body BGCOLOR="White" LEFTMARGIN=0 TOPMARGIN=0>');
	Win1.document.writeln('		<table width="100%" border="0" cellpadding="0" cellspacing="0">');
	Win1.document.writeln('			<tr>');
	Win1.document.writeln('				<td><div align="center"><IMG NAME="anImage" SRC="' + imgOrURL +'"></div></td>');
	Win1.document.writeln('			</tr>');
	Win1.document.writeln('			<tr>');
	Win1.document.writeln('				<td><img src="images/pixel.gif" width="6" height="16"></td>');
	Win1.document.writeln('			</tr>');
	Win1.document.writeln('			<tr>');
	Win1.document.writeln('				<td bgcolor="#006464" align="center" class="testo11white">Premi il tasto destro del mouse sulla mappa e seleziona \'Salva Immagine con nome\'</td>');
	Win1.document.writeln('			</tr>');
	Win1.document.writeln('		</table>');
	Win1.document.writeln('</body>');
	Win1.document.writeln('</html>');
	sem_csi_flagUseSaveMap=false;
	legendVisible=legVis2;
	hideRetrieveMap();
}

// second, get OVMap
function getPrintOV() {
	var tempWidth = i2Width;
	var tempHeight = i2Height;
	//INIZIO - Baco Layout : GeDeONE 1.2.0.
	//i2Width=190;
	//i2Height=150;
	//FINE - Baco Layout : GeDeONE 1.2.0.
	var tempDraw=drawOVExtentBox;
	drawOVExtentBox=true;
	var theString = writeOVXML();
	drawOVExtentBox=tempDraw;
	i2Width=tempWidth;
	i2Height = tempHeight;
	sendToServer(imsOVURL,theString,102);
	tempWidth=null;
	tempHeight=null;
	theString=null;
	//INIZIO PMUL: 2.0.0 Correzione baco. Veniva caricata due volte l'interfaccia da stampare
	//writePrintPageM();
	//FINE PMUL 2.0.0
}

function getPrintLeg(title) {
  showRetrieveMap();
  	var tempWidth = iWidth;
	var tempHeight = iHeight;
	printTitle=title;
	if (aimsLegendPresent) legendVisible=true;
	//drawLegendOnly=true;
	var theString=writeXML();
	sendToServer(imsURL,theString,103);
	legVis2=legendVisible;

	var theString = writeXML();
	iWidth=tempWidth;
	iHeight = tempHeight;
	legendVisible = legVis2;
//	sendToServer(imsURL,theString,101);
	tempWidth=null;
	tempHeight=null;
	theString=null;
	if (printLegURL=="") printLegURL = "images/nolegend.gif";
	//writePrintPageL();
}

// third, get Legend
function getPrintLegend() {
	//  waiting for Legend tags
	if (printLegURL=="") printLegURL = "images/nolegend.gif";
	writePrintPageL();
}

// fourth, write the web page
function writePrintPageM() {

	var Win1 = open("","PrintPage","width=660,height=460,scrollbars=yes,resizable=yes");

	Win1.document.writeln('<html><meta http-equiv="Content-Type" content="text/html; charset=' + charSet + '"><head>');
	Win1.document.writeln('<link rel="stylesheet" href="'+pagStile+'" type="text/css"><title>' + titleList[5] + '</title>');
	Win1.document.writeln('</head>');
	Win1.document.writeln('<body BGCOLOR="White"  LEFTMARGIN=0 TOPMARGIN=0>');
	Win1.document.writeln('<FORM NAME="InviaMail" METHOD="POST" ACTION="' + sem_csi_urlServletInvioMail + '">');
 	Win1.document.writeln('<BR><BR><B><CENTER>');
	Win1.document.writeln('<TABLE WIDTH="75%"  CELLSPACING="0" CELLPADDING="0"  border=1 valign="center" nowrap>');
	Win1.document.writeln('<TR>');
	//INIZIO - Baco Layout : GeDeONE 1.2.0.
	//Win1.document.writeln('		<TH COLSPAN="2" height="100">' + printTitle + '</TH>');
 	Win1.document.writeln('<TH COLSPAN="2" height="30">' + printTitle + '</TH>');
	//FINE - Baco Layout : GeDeONE 1.2.0.
	Win1.document.writeln('</TR>');
	Win1.document.writeln('<TR>');
	//INIZIO - Baco Layout : GeDeONE 1.2.0
	//Win1.document.write('		<TD WIDTH="450" HEIGHT="450"');
	//FINE - Baco Layout : GeDeONE 1.2.0
	Win1.document.write('<TD');
	//FINE - Baco Layout : GeDeONE 1.2.0.

	//if (!(hasOVMap) || (sem_csi_flagUseSendMail)) Win1.document.write(' COLSPAN="2"');
	if (!(hasOVMap)) Win1.document.write(' COLSPAN="2"');

	Win1.document.writeln('>');
	Win1.document.writeln('<IMG SRC="' + printMapURL + '"  HSPACE=0 VSPACE=0 BORDER=0 ALT="">');
	Win1.document.writeln('</TD>');

	//INIZIO SEM INVIO LEGENDA NELLA MAIL
	if(sem_csi_flagUseSendMail) {
		Win1.document.writeln('<TD>');
		Win1.document.writeln('<IMG SRC="' + printLegURL + '"  HSPACE=0 VSPACE=0 BORDER=0 ALT="">');
		Win1.document.writeln('</TD>');
	}
	//FINE SEM INVIO LEGENDA NELLA MAIL

	//Inizio SendMail : SEM
	//Invio mail con allegata mappa .png: SEM
	if ( (hasOVMap) && (! sem_csi_flagUseSendMail) ) {
	    //INIZIO - Baco Layout : GeDeONE 1.2.0.
		//Win1.document.writeln('		<TD ALIGN="CENTER" VALIGN="CENTER">');
		//Win1.document.writeln('		<TD ALIGN="LEFT" VALIGN="CENTER">');
    	//FINE - Baco Layout : GeDeONE 1.2.0.
		//Layout di stampa proposto con Mappa + OVM
		Win1.document.writeln('<TD><IMG SRC="' + printOVURL + '"  HSPACE=0 VSPACE=0 BORDER=0 ALT="">');
		Win1.document.writeln('</TD>');
	}
	//Fine SendMail : SEM

	//Win1.document.writeln('		</TD>');
	Win1.document.writeln('</TR>');

	// pulsante Stampa mappa
	if (sem_csi_flagUseSendMail == false) {
		//Win1.document.writeln('<br><br>	<table border=0 cellpadding=0 cellspacing=0>');
		Win1.document.writeln('<TR><td COLSPAN="2" height="100" ALIGN="CENTER">');
		Win1.document.writeln('<input type="button" class=background NAME="printButton" VALUE="'+buttonList[76]+'" onClick="window.print();">');
		Win1.document.writeln('</td></TR>');
		//Win1.document.writeln('	</table>');
	}

	Win1.document.writeln('</TABLE>	');



/*
   	else if (sem_csi_flagUseSendMail){

		var Win1 = open("","PrintPage","width=250,height=270,scrollbars=no,resizable=no");

		Win1.document.writeln('<html><meta http-equiv="Content-Type" content="text/html; charset=' + charSet + '"><head>');
		Win1.document.writeln('<link rel="stylesheet" href="'+pagStile+'" type="text/css">');
		Win1.document.writeln('<link rel="stylesheet" href="/css/rollover.css" type="text/css">');
		Win1.document.writeln('<title>' + titleList[29] + '</title>');
		Win1.document.writeln('</head>');
		Win1.document.writeln('<body BGCOLOR="White"  LEFTMARGIN=0 TOPMARGIN=0>');

//		Win1.document.writeln('<FORM NAME="InviaMail" METHOD="POST" ACTION="' + eml_csi_urlServletInvioMail + '">');
		Win1.document.writeln('<FORM NAME="InviaMail" METHOD="POST" ACTION="' + sem_csi_urlServletInvioMail + '">');


// -------------------- DA CONTROLLARE --------------------------


	//Viene ricavato il nome del file .png che verrā passato via POST alla servlet
	//var sem_csi_nameFilepng = new String(printMapURL.substring(printMapURL.indexOf("/output/")+8,printMapURL.indexOf(".png")+4));
	//per le macchine di test, in cui ci sono 2 directory /output1 e /output2 devo cercare la stringa senza slash
	var sem_csi_nameFilepng = new String(printMapURL.substring(printMapURL.indexOf("/output")+9,printMapURL.indexOf(".png")+4));


	Win1.document.writeln('<INPUT type="hidden" name="NamePNG" value="' + sem_csi_nameFilepng + '">');
	Win1.document.writeln('<INPUT type="hidden" name="Mitt" value="' + sem_csi_mittente + '">');

	Win1.document.writeln('<CENTER>');

	Win1.document.writeln('<table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%">');
	Win1.document.writeln('<tr> ');
	Win1.document.writeln('<td background="' + doc_loc_sub + 'images/px_arancio.gif" valign="top" align="left">');
	Win1.document.writeln('  <table border="0" cellpadding="0" cellspacing="0" width="250" height="250">');
	Win1.document.writeln('	    <tr> ');
	Win1.document.writeln('        <td  valign="top" width="250" height="36"><img name="titolo" src="' + doc_loc_sub + 'images/wwwpiemonteitineratiitSmall2.gif" width="250" height="36" border="0" alt=""></td>');
	Win1.document.writeln('     </tr>');
	Win1.document.writeln('     <tr> ');
	Win1.document.writeln('        <td valign="top" align="center"> ');
	Win1.document.writeln('         <table width="234" border="0" cellspacing="0" cellpadding="0">');
	Win1.document.writeln('           <tr> ');
	Win1.document.writeln('              <td width="1"  height="1" background="' + doc_loc_sub + 'images/px_grigio.gif"><img src="' + doc_loc_sub + 'images/px_grigio.gif"  width="1"   height="1"></td>');
	Win1.document.writeln('              <td width="10" height="1"><img src="' + doc_loc_sub + 'images/px_grigio.gif"  width="10"  height="1"></td>');
	Win1.document.writeln('              <td width="212" height="1"><img src="' + doc_loc_sub + 'images/px_grigio.gif" width="212" height="1"></td>');
	Win1.document.writeln('		     <td width="10" height="1"><img src="' + doc_loc_sub + 'images/px_grigio.gif"  width="10"  height="1"></td>');
	Win1.document.writeln('		     <td width="1"  height="1" background="' + doc_loc_sub + 'images/px_grigio.gif"><img src="' + doc_loc_sub + 'images/px_grigio.gif"  width="1"   height="1"></td>');
	Win1.document.writeln('		  </tr>');
	Win1.document.writeln('		  <tr> ');
	Win1.document.writeln('		     <td width="1" height="40" background="' + doc_loc_sub + 'images/px_grigio.gif"><img src="' + doc_loc_sub + 'images/px_grigio.gif" width="1" height="40"></td>');
//	Win1.document.writeln('		     <td width="10" height="40" bgcolor="#FFFFFF">&nbsp;</td>');
//	Win1.document.writeln('              <td width="212" height="40" bgcolor="#FFFFFF" class="titolo">Invia Mappa</td>');
      Win1.document.writeln('              <td width="232" height="40" bgcolor="#FFFFFF" colspan="3"><img src="' + doc_loc_sub + 'images/inviomappa.gif" width="232" height="40"></td>');
//      Win1.document.writeln('		     <td width="10" height="40" bgcolor="#FFFFFF">&nbsp;</td>');
	Win1.document.writeln('              <td width="1" height="40" background="' + doc_loc_sub + 'images/px_grigio.gif"><img src="' + doc_loc_sub + 'images/px_grigio.gif" width="1" height="40"></td>');
	Win1.document.writeln('           </tr>');
	Win1.document.writeln('           <tr> ');
	Win1.document.writeln('              <td width="1"  height="1" background="' + doc_loc_sub + 'images/px_grigio.gif"><img src="' + doc_loc_sub + 'images/px_grigio.gif"  width="1"   height="1"></td>');
	Win1.document.writeln('              <td width="10" height="1"><img src="' + doc_loc_sub + 'images/px_grigio.gif"  width="10"  height="1"></td>');
	Win1.document.writeln('              <td width="212" height="1"><img src="' + doc_loc_sub + 'images/px_grigio.gif" width="212" height="1"></td>');
	Win1.document.writeln('              <td width="10" height="1"><img src="' + doc_loc_sub + 'images/px_grigio.gif"  width="10"  height="1"></td>');
	Win1.document.writeln('              <td width="1"  height="1" background="' + doc_loc_sub + 'images/px_grigio.gif"><img src="' + doc_loc_sub + 'images/px_grigio.gif"  width="1"   height="1"></td>');
	Win1.document.writeln('           </tr>');
	Win1.document.writeln('           <tr> ');
	Win1.document.writeln('              <td width="1" height="40" background="' + doc_loc_sub + 'images/px_grigio.gif"><img src="' + doc_loc_sub + 'images/px_grigio.gif" width="1" height="40"></td>');
	Win1.document.writeln('              <td width="10" height="40" bgcolor="#FFFFFF">&nbsp;</td>');
	Win1.document.writeln('              <td width="212" height="40" bgcolor="#FFFFFF" class="testo11GrigioTex">Destinatario (indirizzo e-mail)<br>');
	Win1.document.writeln('  		<input name="dest" type="text" id="dest" size="25">');
	Win1.document.writeln('              </td>');
	Win1.document.writeln('              <td width="10" height="40" bgcolor="#FFFFFF">&nbsp;</td>');
	Win1.document.writeln('              <td width="1" height="40" background="' + doc_loc_sub + 'images/px_grigio.gif"><img src="' + doc_loc_sub + 'images/px_grigio.gif" width="1" height="40"></td>');
	Win1.document.writeln('           </tr>');
	Win1.document.writeln('           <tr> ');
	Win1.document.writeln('              <td width="1"  height="1" background="' + doc_loc_sub + 'images/px_grigio.gif"><img src="' + doc_loc_sub + 'images/px_grigio.gif"  width="1"   height="1"></td>');
	Win1.document.writeln('              <td width="10" height="1"><img src="' + doc_loc_sub + 'images/px_grigio_chiaro.gif"  width="10"  height="1"></td>');
	Win1.document.writeln('              <td width="212" height="1"><img src="' + doc_loc_sub + 'images/px_grigio_chiaro.gif" width="212" height="1"></td>');
	Win1.document.writeln('              <td width="10" height="1"><img src="' + doc_loc_sub + 'images/px_grigio_chiaro.gif"  width="10"  height="1"></td>');
	Win1.document.writeln('              <td width="1"  height="1" background="' + doc_loc_sub + 'images/px_grigio.gif"><img src="' + doc_loc_sub + 'images/px_grigio.gif"  width="1"   height="1"></td>');
	Win1.document.writeln('		  </tr>');
	Win1.document.writeln('		  <tr> ');
	Win1.document.writeln('              <td width="1" height="40" background="' + doc_loc_sub + 'images/px_grigio.gif"><img src="' + doc_loc_sub + 'images/px_grigio.gif" width="1" height="40"></td>');
	Win1.document.writeln('              <td width="10" height="40" bgcolor="#FFFFFF">&nbsp;</td>');
	Win1.document.writeln('              <td width="212" height="40" bgcolor="#FFFFFF" class="testo11GrigioTex">Oggetto<br>');
	Win1.document.writeln('                 <input name="ogg" type="text" id="ogg" size="25">');
	Win1.document.writeln('              </td>');
	Win1.document.writeln('              <td width="10" height="40" bgcolor="#FFFFFF">&nbsp;</td>');
	Win1.document.writeln('              <td width="1" height="40" background="' + doc_loc_sub + 'images/px_grigio.gif"><img src="' + doc_loc_sub + 'images/px_grigio.gif" width="1" height="40"></td>');
	Win1.document.writeln('           </tr>');
	Win1.document.writeln('           <tr> ');
	Win1.document.writeln('              <td width="1"  height="1" background="' + doc_loc_sub + 'images/px_grigio.gif"><img src="' + doc_loc_sub + 'images/px_grigio.gif"  width="1"   height="1"></td>');
	Win1.document.writeln('              <td width="10" height="1"><img src="' + doc_loc_sub + 'images/px_grigio_chiaro.gif"  width="10"  height="1"></td>');
	Win1.document.writeln('              <td width="212" height="1"><img src="' + doc_loc_sub + 'images/px_grigio_chiaro.gif" width="212" height="1"></td>');
	Win1.document.writeln('              <td width="10" height="1"><img src="' + doc_loc_sub + 'images/px_grigio_chiaro.gif"  width="10"  height="1"></td>');
	Win1.document.writeln('              <td width="1"  height="1" background="' + doc_loc_sub + 'images/px_grigio.gif"><img src="' + doc_loc_sub + 'images/px_grigio.gif"  width="1"   height="1"></td>');
	Win1.document.writeln('           </tr>');
	Win1.document.writeln('           <tr> ');
	Win1.document.writeln('              <td width="1" height="60" background="' + doc_loc_sub + 'images/px_grigio.gif"><img src="' + doc_loc_sub + 'images/px_grigio.gif" width="1" height="60"></td>');
	Win1.document.writeln('              <td width="10" height="60" bgcolor="#FFFFFF">&nbsp;</td>');
	Win1.document.writeln('              <td width="212" height="60" bgcolor="#FFFFFF" class="testo11GrigioTex">Messaggio<br>');
	Win1.document.writeln('                <textarea name="corpo" cols="25" rows="2" id="corpo"></textarea>');
	Win1.document.writeln('              </td>');
	Win1.document.writeln('              <td width="10" height="60" bgcolor="#FFFFFF">&nbsp;</td>');
	Win1.document.writeln('              <td width="1" height="60" background="' + doc_loc_sub + 'images/px_grigio.gif"><img src="' + doc_loc_sub + 'images/px_grigio.gif" width="1" height="60"></td>');
	Win1.document.writeln('           </tr>');
	Win1.document.writeln('           <tr> ');
	Win1.document.writeln('              <td width="1"  height="1" background="' + doc_loc_sub + 'images/px_grigio.gif"><img src="' + doc_loc_sub + 'images/px_grigio.gif"  width="1"   height="1"></td>');
	Win1.document.writeln('              <td width="10" height="1"><img src="' + doc_loc_sub + 'images/px_grigio_chiaro.gif"  width="10"  height="1"></td>');
	Win1.document.writeln('              <td width="212" height="1"><img src="' + doc_loc_sub + 'images/px_grigio_chiaro.gif" width="212" height="1"></td>');
	Win1.document.writeln('              <td width="10" height="1"><img src="' + doc_loc_sub + 'images/px_grigio_chiaro.gif"  width="10"  height="1"></td>');
	Win1.document.writeln('              <td width="1"  height="1" background="' + doc_loc_sub + 'images/px_grigio.gif"><img src="' + doc_loc_sub + 'images/px_grigio.gif"  width="1"   height="1"></td>');
	Win1.document.writeln('           </tr>');
	Win1.document.writeln('           <tr> ');
	Win1.document.writeln('              <td width="1" height="40" background="' + doc_loc_sub + 'images/px_grigio.gif"><img src="' + doc_loc_sub + 'images/px_grigio.gif" width="1" height="40"></td>');
	Win1.document.writeln('              <td width="10" height="40" bgcolor="#FFFFFF">&nbsp;</td>');
	Win1.document.writeln('              <td width="212" height="40" bgcolor="#FFFFFF"> ');
	Win1.document.writeln('                <input name="InviaMappa" type="button" id="Invia" onclick="opener.sem_csi_InviaMappa(window);" value="  invia  " >');
	Win1.document.writeln('              </td>');
	Win1.document.writeln('              <td width="10" height="40" bgcolor="#FFFFFF">&nbsp;</td>');
	Win1.document.writeln('              <td width="1" height="40" background="' + doc_loc_sub + 'images/px_grigio.gif"><img src="' + doc_loc_sub + 'images/px_grigio.gif" width="1" height="40"></td>');
	Win1.document.writeln('           </tr>');
	Win1.document.writeln('          <tr> ');
	Win1.document.writeln('              <td width="1"  height="1" background="' + doc_loc_sub + 'images/px_grigio.gif"><img src="' + doc_loc_sub + 'images/px_grigio.gif"  width="1"   height="1"></td>');
	Win1.document.writeln('              <td width="10" height="1"><img src="' + doc_loc_sub + 'images/px_grigio.gif"  width="10"  height="1"></td>');
	Win1.document.writeln('              <td width="212" height="1"><img src="' + doc_loc_sub + 'images/px_grigio.gif" width="212" height="1"></td>');
	Win1.document.writeln('              <td width="10" height="1"><img src="' + doc_loc_sub + 'images/px_grigio.gif"  width="10"  height="1"></td>');
	Win1.document.writeln('              <td width="1"  height="1" background="' + doc_loc_sub + 'images/px_grigio.gif"><img src="' + doc_loc_sub + 'images/px_grigio.gif"  width="1"   height="1"></td>');
	Win1.document.writeln('           </tr>');
	Win1.document.writeln('		</table>');
	Win1.document.writeln('	       </td>');
	Win1.document.writeln('      </tr>');
	Win1.document.writeln('     </table>');
	Win1.document.writeln('   </td>');
	Win1.document.writeln(' </tr>');
	Win1.document.writeln('</table>	');
// -------------------------------------------------------------------------------------

















		// pulsante di Invia Mappa
//		Win1.document.writeln('<TD valign="BOTTOM" align="RIGHT">');
//		Win1.document.writeln('<input type="BUTTON" class=background NAME="InviaMappa" VALUE="Invia Mappa" onclick="opener.sem_csi_InviaMappa(window);">');
//		Win1.document.writeln('<br><p></TD>');


		//Viene riportata a false la variabile sem_csi_flagUseSendMail dal momento
		//che la funzione di invio mappa č conclusa arrivata a questo punto
		sem_csi_flagUseSendMail = false;

	}
	/* --------------------------------------------------------------------------------*/
	// Fine INVIA MAPPA
	/* --------------------------------------------------------------------------------*/


	//Win1.document.writeln('</B>');
	Win1.document.writeln('</FORM>');
	//Fine SendMail : SEM

	Win1.document.writeln('</body></html>');
	Win1.document.close();

	legendVisible=legVis2;
	Win1=null;
	hideRetrieveMap();
}

// fourth, write the web page
function writePrintPageL() {
	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('<link rel="stylesheet" href="'+pagStile+'" type="text/css"><title>' + titleList[5] + '</title>');
	Win1.document.writeln('</head>');
	Win1.document.writeln('<body BGCOLOR="White"  LEFTMARGIN=0 TOPMARGIN=0>');
	Win1.document.writeln('<B><CENTER>');
	Win1.document.writeln('<BR><BR><TABLE WIDTH="80%" CELLSPACING="0" CELLPADDING="0" NOWRAP>');
	Win1.document.writeln('	<TR>');
	Win1.document.writeln('		<TH COLSPAN="2" height="100">' + printTitle + '</TH>');
	Win1.document.writeln('	</TR>');
	Win1.document.writeln('	<TR>');

	Win1.document.writeln('	<TR>');
	Win1.document.writeln('		<TD ALIGN="CENTER" VALIGN="TOP">');

	//INIZIO Help-Legenda statici: HLS //L'utente sceglie se avere la Legenda statica o dinamica
	if (hls_csi_useStaticLegendImg == true) {
	   Win1.document.writeln('<IMG SRC="' + doc_loc_sub + hls_csi_fileStaticLegend + '" HSPACE=0 VSPACE=0 BORDER=1 ALT="' + titleList[3] + '">');
	} else {
	   Win1.document.writeln('<IMG SRC="' + printLegURL + '"  HSPACE=0 VSPACE=1 BORDER=0 ALT="">');
	}
        //FINE Help-Legenda statici: HLS

    Win1.document.writeln('		</TD>');
	Win1.document.writeln('	</TR>');

	// pulsante Stampa mappa
//	if (sem_csi_flagUseSendMail == false) {
		//Win1.document.writeln('<br><br>	<table border=0 cellpadding=0 cellspacing=0>');
		Win1.document.writeln('<TR><td COLSPAN="2" height="100" ALIGN="CENTER">');
		Win1.document.writeln('<input type="button" class=background NAME="printButton" VALUE="'+buttonList[76]+'" onClick="window.print();">');
		Win1.document.writeln('</td></TR>');
		//Win1.document.writeln('	</table>');
//	}


	Win1.document.writeln('</TABLE>');
	Win1.document.writeln('</CENTER></B>');
	Win1.document.writeln('</body></html>');
	Win1.document.close();

	legendVisible=legVis2;
	Win1=null;
	hideRetrieveMap();
}

