
/*******************************************************************
   visaphoto.js

   librairie de fonctions sp�ifiques
   pour visaphoto.com

   le code html g���fait appel �   la feuille de style visaphoto.css

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

/*
  variables globales
*/
var sPage;
var sDate;
var sHomePage = "index.html"

var iNum = new Number(-2);

/* affichage photo : largeur, hauteur de la nouvelle fen�re */
var iWidth = new Number(1024);
var iHeight = new Number(750);
/* affichage photo : coordonn�s (x, y) de la nouvelle fen�re */
var iScreenX = new Number(2);
var iScreenY = new Number(2);

/*
 La cha�e d'email est morcel� pour ne pas appara�re en clair dans le code HTML.
 les segments doivent �re rang� dans l'ordre 2, 0, 4, 3, 5, 1
*/
var rsEmailSegment = new Array("@", "com", "contact", "photo", "visa", ".");
var sEmail = new String(rsEmailSegment[2] + rsEmailSegment[0] + rsEmailSegment[4] + rsEmailSegment[3] + rsEmailSegment[5] + rsEmailSegment[1]);

function SendEmail()
{
  var sEmailLink = new String();

  sEmailLink = '<a name="courriel" href="mailto:' + sEmail + '" class="sombre">';
  sEmailLink += 'Contacter visaphoto.com';
  sEmailLink += '</a>';

  return sEmailLink;
}

/*
 Fonctions de construction des pages
*/

/* gestion du retour vers la page d'accueil dans les pages */
function SetLinkHome()
{
  var sLinkHome = new String();

  sLinkHome += '<h5>';
  sLinkHome += '<b>';
  sLinkHome += '<a href=' + sHomePage + '>';
  sLinkHome += '<img class="picto" src="images/pictos/camera.gif" align="center" border="0">';
  sLinkHome += '</a>';
  sLinkHome += " > " + document.title;
  sLinkHome += '</b>';
  sLinkHome += '</h5>';

  return(sLinkHome);
}

/* gestion du retour vers la page d'accueil dans les pages */
function SetLinkPath()
{
  var sLinkPath = new String();

  sLinkPath += '<h5>';
  sLinkPath += '<a href=' + sHomePage + '>';
  sLinkPath += '<img class="picto" src="images/pictos/camera.gif">';
  sLinkPath += '</a>';
  sLinkPath += '</h5>';

  return(sLinkPath);
}

/* mise en place du haut de page commun �toutes les pages du site */
function SetPageHeader()
{
  var sHeader = new String();
  var sAujourdhui = new String;

  sAujourdhui = DisplayDate();

  sHeader  = ' <table width="100%">';
  sHeader += ' <tr>';
  sHeader += '   <td>';
  sHeader += '      <img class="picto" src="images/pictos/logo_visaphoto.gif">';
  sHeader += '   </td>';
  sHeader += '   <td>';
  sHeader += '      <h5 style="color: #666666;">';
  sHeader += '        <b>';
  sHeader += sAujourdhui;
  sHeader += '        </b>';
  sHeader += '      </h5>';
  sHeader += '   </td>';
  sHeader += ' </tr>';
  sHeader += ' </table>';
  sHeader += ' <br>';

  return(sHeader);
}

/* bas de page (page d'accueil seulement pour le moment) */
function SetPageFooter()
{
  var sFooter = new String();

  sFooter =  '<p>';
  sFooter += '  site h&eacute;berg&eacute; par ';
  sFooter += '  <br>';
  sFooter += '  <a href="http://www.online.net/" target="_blank">';
  sFooter += '    <img class="picto" src="images/pictos/online.gif" name="online" align="center" border="0" alt="www.online.net">';
  sFooter += '  </a>';
  sFooter += '</p>';
  sFooter += '<p>';
  sFooter += '  <br>';
  sFooter += '</p>';

  return(sFooter);
}

/* fonction affichage des commentaires de la photo */
function SetPhotoComment(i)
{
  var sComment = new String();

  sComment = '<div class="photo_comment">';
  sComment += '<p>';
  sComment += rsComments[i];
  sComment += '<br>';
  sComment += 'n&deg; ' + rsImageName[i];
  sComment += '</p>';
  sComment += '</div>';

  return sComment;
}

/* fonction affichage de la photo */
function SetPhoto(i)
{
  var sPhoto = new String();
  var sImageSrc = new String();

  /* construction de la source de la photo */
  sImageSrc = sRepImages + rsImageName[i] + sExtImg;
  sPhoto = '<img name="photo1" src=' + sImageSrc + ' class="photo" alt="' + rsImageName[i] + '">';

  return sPhoto;
}

/* fonction affiche le titre de la fen�re */
function SetTitlePhoto(i)
{
  var sTitre = new String();

  sTitre = '<title>visaphoto.com - ' + rsImageName[i] + '</title>';

  return sTitre;
}

/* construit la page de pr�entation de l'image */
function BuildImagePage(i)
{
      var sDocument = new String();
      var iUp = new Number();
      var iDown = new Number();

      sDocument = '<html>';
      sDocument += '<head>';
      sDocument += '<div id="titre">';
      sDocument += SetTitlePhoto(i);
      sDocument += '</div>';
      sDocument += '<meta http-equiv="content-type" content="text/html; charset=iso-8859-15">';
      sDocument += '<script language="javascript" type="text/javascript" src="javascript/utiles.js"></script>';
      sDocument += '<script language="javascript" type="text/javascript" src="javascript/' + sScriptSource + '"></script>';
      sDocument += '<script language="javascript" type="text/javascript" src="javascript/visaphoto.js"></script>';
      sDocument += '<link rel="stylesheet" type="text/css" href="css/visaphoto.css">';
      sDocument += '<link rel="icon" type="image/png" href="favicon.png">';
      sDocument += '</head>';

      iNum = i;

      sDocument += '<body>';
      sDocument += '<div align="center">';
      sDocument += '<div class="fond">';
      sDocument += '   <table width="100%">';
      sDocument += '      <tr valign="top" class="filigrane">';
      sDocument += '         <td width="100%" colspan="2">';
      sDocument += SetPageHeader();
      sDocument += '         </td>';
      sDocument += '      </tr>';
      sDocument += '      <tr>';
      sDocument += '         <td width="25%">';
      sDocument += '           <table width="100%">';
      sDocument += '             <tr valign="top">';
      sDocument += '               <td align="justify">';
      sDocument += '                 <div id="descriptif">';
      sDocument += SetPhotoComment(i);
      sDocument += '                 </div>';
      sDocument += '               </td>';
      sDocument += '             </tr>';
      sDocument += '             <tr valign="top">';
      sDocument += '               <td align="justify">';
      sDocument += '                 <table width="100%">';
      sDocument += '                   <tr valign="top">';
      sDocument += '                     <td align="center">';
      sDocument += '                       <a href="javascript: ShowPrevPhoto(' + iNum + ')">';
      sDocument += '                         <img class="picto" src="images/pictos/l_arrow.gif" border="0">';
      sDocument += '                       </a>';
      sDocument += '                     </td>';
      sDocument += '                     <td align="center">';
      sDocument += '                       <a href="javascript: window.close()">';
      sDocument += '                         <img  class="picto" src="images/pictos/camera.gif" border="0">';
      sDocument += '                       </a>';
      sDocument += '                     </td>';
      sDocument += '                     <td align="center">';
      sDocument += '                       <a href="javascript: ShowNextPhoto(' + iNum + ')">';
      sDocument += '                         <img  class="picto" src="images/pictos/r_arrow.gif" border="0">';
      sDocument += '                       </a>';
      sDocument += '                     </td>';
      sDocument += '                   </tr>';
      sDocument += '                 </table>';
      sDocument += '               </td>';
      sDocument += '             </tr>';
      sDocument += '           </table>';
      sDocument += '         </td>';
      sDocument += '         <td width="75%" align="center">';
      sDocument += '           <div id="photo" style="padding : 20px 20px 20px 20px;">';
      sDocument += '                       <a href="javascript: window.close()">';
      sDocument += SetPhoto(i);
      sDocument += '                       </a>';
      sDocument += '           </div>';
      sDocument += '         </td>';
      sDocument += '      </tr>';
      sDocument += '   </table>';
      sDocument += '   <p><br><br></p>';
      sDocument += '</div>';
      sDocument += '</div>';
      sDocument += '</body>';
      sDocument += '</html>';

      return sDocument;
}

/* affichage d'une photo s�ectionn� dans un planche contact */
function DisplayImage(i)
{
   var sPageOptions = new String();

   iNum = i;

   sPageOptions = 'width=' + iWidth + ', height=' + iHeight + ', screenX=' + iScreenX + ', screenY=' + iScreenY + ', toolbar=no, menubar=no, scrollbars=yes, resizable=yes';
   oPage = window.open('', '', sPageOptions);
   oPage.document.write(BuildImagePage(i));
}

/* fonction affichage de la photo pr��ente */
function ShowPrevPhoto(i)
{
   var sPage = new String();
   var sPageOptions = new String();

   if ( -2 == iNum )
      iNum = i;

   iNum--;
   if ( -1 == iNum )
      iNum = rsImageName.length - 1;

   window.close();
   sPageOptions = 'width=' + iWidth + ', height=' + iHeight + ', screenX=' + iScreenX + ', screenY=' + iScreenY + ', toolbar=no, menubar=no, scrollbars=yes, resizable=yes';
   oPage = window.open('', '', sPageOptions);
   oPage.document.write(BuildImagePage(iNum));
}

/* fonction affichage de la photo suivante */
function ShowNextPhoto(i)
{
   var sPage = new String();
   var sPageOptions = new String();

   if ( -2 == iNum )
      iNum = i;

   iNum++;
   if ( rsImageName.length == iNum )
      iNum = 0;

   window.close();
   sPageOptions = 'width=' + iWidth + ', height=' + iHeight + ', screenX=' + iScreenX + ', screenY=' + iScreenY + ', toolbar=no, menubar=no, scrollbars=yes, resizable=yes';
   oPage = window.open('', '', sPageOptions);
   oPage.document.write(BuildImagePage(iNum));
}

/* Construction de la planche contact.
   prend en argument un tableau de cha�es d�ini dans
   pc_couleur.jc ou pc_noir_blanc.js */
function DisplayPC(rsName)
{
  var iDx = new Number(0);
  var sTxt = new String("");
  var iMax = new Number(5); /* Nombre max d'images par ligne */
  var iMod = new Number(0); /* modulo */
  var sImageMiniSrc = new String();

  sTxt += '<table>';

  while( iDx < rsName.length )
  {
     /* construction de la source de la vignette photo */
     sImageMiniSrc = sRepImages + rsName[iDx] + sExtImgMini;

     /* cr�tion d'une nouvelle ligne (row) si la condition est remplie */
     if ( 0 == iMod )
     {
        sTxt += '<tr>';
        sTxt += '  <td>';
        sTxt += '    <table class="table_pc">';
        sTxt += '      <tr class="pc">';
     }

     /* cr�tion d'une cellule contenant l'image au format planche de contact */
     sTxt += '<td align="center" class="pc">';
     sTxt += '  <div class="diapo">';
     sTxt += '    <a href="javascript:DisplayImage(' + iDx + ');">'
     sTxt += '      <img src="' + sImageMiniSrc + '" class="miniphoto" alt="' + rsName[iDx] + '">';
     sTxt += '    </a>';
     sTxt += '  </div>';
     sTxt += '</td>';

     /* incr�entation */
     iDx++;
     iMod = iDx % iMax;

     /* fermeture de la ligne si la condition est remplie */
     if ( (0 == iMod) || (iDx == rsName.length) )
     {
        sTxt += '      </tr>';
        sTxt += '    </table>';
        sTxt += '  </td>';
        sTxt += '</tr>';
     }
  }

  sTxt += '</table>';

  return(sTxt);
}

var sVue = new String();

function Diapo(iNum)
{
  var sSrcImg = new String();

  sVue = sRepImages + rsImageName[iNum] + sExtImgMini;
  sSrcImg = '<img src="' + sVue + '" class="miniphoto">';

  return(sSrcImg);
}

