﻿/* **********************************************************
 * File Name      * PrintAndMailFunctions.js
 * Encoding       * UTF8
 * Description    * Javascript functions for Print and Mail
 * Author         * Sevda SAVRAN
 * Date           * 16/10/2003
 * Note           * None
 ************************************************************
 * Date           * Author    * Modification reason
 ******************************************************************************************************
 * 16/03/2005     * Magnus MARIE SAINT GERMAIN       * impression directe
 * 17/05/2005     * Magnus MARIE SAINT GERMAIN       * modifs pour compatibilite navigateur internet
 * 18/01/2006     * Magnus MARIE SAINT GERMAIN       * modifiction image entete + mise en place <HR>
 ******************************************************************************************************/
 

// added by Magnus MSG
/* **********************************************************
 * Function Name * showIcons()
 * Description   * Permet d'afficher les icones pour l'impression
 *                       * et l'envoi par mail
 ************************************************************/
function showIcons() {
	
	// ICONE D'IMPRESSON
	if (window.print) {
		document.write("<div class='buttonColor'><a href='javascript: PrintData();' onMouseOver='return true;'>" + printLabel + "</a></div><div class='buttonBlank'>&nbsp;</div>");
	}
	// ICONE D'ENVOI PAR E-MAIL
	document.write("<div class='buttonColor'><a href='javascript: Mail()' onMouseOver='return true;'>" + mailLabel + "</a></div><div class='buttonBlank'>&nbsp;</div>");
}


// added by Magnus MSG
/* *********************************************************************************
 * Function Name * newWindowToPrint()
 * Description   * Open a new window containing only article, print it and close it
 ***********************************************************************************/
function newWindowToLoad(newWindowPAC, data) {

      newWindowPAC.document.open();
      // TITRE DE LA FENETRE
      newWindowPAC.document.write("<html><head><title>" + windowTitle + "</title>");
      newWindowPAC.document.write("<LINK href='/css/PortailStyle.css' type=text/css rel=stylesheet></head>");
      newWindowPAC.document.write("<body leftMargin=0 topMargin=0 marginheight=0 marginwidth=0>");
      newWindowPAC.document.write("<table width=100% border=0 cellpadding=0 cellspacing=0>");
      // ENTETE DE LA PAGE
      newWindowPAC.document.write("<tr><td><img src='" + headerImage + "'></td></tr>");
      // ARTICLE A IMPRIMER
      newWindowPAC.document.write("<tr><td>");
      newWindowPAC.document.write("<hr color=#808080 size=1>");
      newWindowPAC.document.write(data);
      newWindowPAC.document.write("</td></tr>");
      // SCRIPT IMPRESSION
      newWindowPAC.document.write("</table>");
      newWindowPAC.document.write("<script language='javascript'>");
      newWindowPAC.document.write("self.print();");
      newWindowPAC.document.write("</script>");
      // PIED DE PAGE
      newWindowPAC.document.write("<table><tr><td>" + footer +"</td></tr></table>");
      newWindowPAC.document.write("</body></html>");
}

// added by Magnus MSG
/* **********************************************************
 * Function Name * PrintData()
 * Description   * Function called to print an article
 ************************************************************/
function PrintData() {

	if (window.print) {
		newPrintWindow = window.open('','printable','width=300,height=300,scrollbars=0,resizable=1');
      	newWindowToLoad(newPrintWindow, data.innerHTML);
      	newPrintWindow.location.reload(true);
		setTimeout('closeWindow(newPrintWindow)', 7000);	// delay 5 seconds before closing
	}
	 else {
	 	alert("Your internet browser does not support this functionality.\n\nVotre explorateur internet ne suporte pas cette fonctionnalitÃ©.");
		return;
	}
}
// added by Magnus MSG
/* ***********************************************************
 * Function Name * PrintData()
 * Description   * Function called to close a specified window
 *************************************************************/
function closeWindow(aWindow) {
aWindow.close();
}

/* **********************************************************
 * Function Name * Mail()
 * Description   * Open messaging client
 ************************************************************/
function Mail() {

      var pageUrl = window.location.href;
      window.location.href="mailto:?subject=" + strObject + "&body=" + escape(strBeforeUrl + pageUrl + strAfterUrl);
}

//===========================================================
//=====           commented by Magnus MSG               =====
//===========================================================

/* **********************************************************
 * Function Name * printWindow()
 * Description   * Open printer dialog box
 ************************************************************
function printWindow() {

      document.printForm.printImg.height=0;
      window.print();
      document.printForm.printImg.height=29;
}

// commented by Magnus MSG
/* **********************************************************
 * Function Name * showIcons()
 * Description   * Permet d'afficher les icones pour l'impression
 *                       * et l'envoi par mail
 ************************************************************
function showIcons() {

      var bName = navigator.appName;
      var bVer = parseInt(navigator.appVersion);

      if (bName == "Microsoft Internet Explorer" && bVer >= 4) {
            // ICONE D'IMPRESSON
            document.write("<a href='javascript: Print()' onMouseOver='return true;'><img src='" + printIcon + "' alt='" + printIconAlt + "'border=0></a>");

            // ICONE D'ENVOI PAR E-MAIL
            document.write("<a href='javascript: Mail()' onMouseOver='return true;'><img src='" + mailIcon + "' alt='" + mailIconAlt + "'border=0></a>");
      }
}
*/

// commented by Magnus MSG
/* **********************************************************
 * Function Name * newWindowPrint()
 * Description   * Open a new window containing only article
 ************************************************************
function newWindowPrint(newWindow, data) {

      newWindow.document.open();
      // TITRE DE LA FENETRE
      newWindow.document.write("<head><title>" + windowTitle + "</title>");
      newWindow.document.write("<LINK href='/PortailStyle_v2003.css' type=text/css rel=stylesheet>");
      // INCLUSION DU FICHIER JS
      newWindow.document.write("<script language='JavaScript' src='/printandmail/js/PrintAndMailFunctions.js'></script>");
      newWindow.document.write("</head><body leftMargin=0 topMargin=0marginheight=0 marginwidth=0>");
      newWindow.document.write("<form name='printForm'><table width=100%border=0 cellpadding=0 cellspacing=0>");
      // ENTETE DE LA PAGE
      newWindow.document.write("<tr><td>" + headerImage + "</td></tr>");
      // ICONE D'IMPRESSION
      newWindow.document.write("<tr align=center><td><a href='javascript:printWindow();'><img id='printImg' src='" + printArticleIcon + "' alt='" +printArticleIconAlt + "' border=0></a>");
      newWindow.document.write("</td></tr></table>");
      // ARTICLE A IMPRIMER
      newWindow.document.write(data)
      // PIED DE PAGE
      newWindow.document.write("<table><tr><td>" + footer +"</td></tr></table>");
      newWindow.document.write("</form>");
      newWindow.document.write("</body>");
      newWindow.document.close();
}
*/