//
// BY-RITE Products
// Photoviewer.js
// 14-sep-02
// Version 1.0
// Cherie Donels
// 
<!-- // 

var imagesarr = new Array;
var newWinSwitch, perRow, imgnum, index, Num, i = Number;
var imgtype, NxtPic, NumVal, newWin, imgloc, imgnam, myimg, qNam, img = String;

function CreateAlbum(imgloc, qNam, imgtype, imgnum, perRow, newWin)
{
  if (imgtype == null || imgtype == "")
  {
    return self.document.writeln("Image type is needed...");
  }

  if (imgnum == null || imgnum == 0)
  {
    return self.document.writeln("# of images is needed...");
  }

  if (perRow == null || perRow == 0)
  {
    return self.document.writeln("# of images per row is needed...");
  }

  if (CreateAlbum.arguments.length < 4)
  {
    return self.document.writeln("# of parms passed are not valid...");
  }

  self.document.writeln('<table>');
  self.document.writeln('<tr><td VALIGN="TOP">');
  self.document.writeln('<P>');
  self.document.writeln('<CENTER>');
  self.document.writeln('<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="12">');
  self.document.writeln('  <TR>');
  for (i = 1; i < imgnum + 1; i++)
  {
    
    if (qNam != null && qNam != "")
    {
      var Num = i;
      var NumVal = i;
      var imgnam = qNam + i + imgtype;
      var myimg = imgloc + imgnam;
    }

    var img = new Image(40,40);
    img.src = myimg;
    imagesarr[i - 1] = myimg;

    var NxtPic = '<TD WIDTH="25" HEIGHT="5" VALIGN="TOP">'
    NxtPic += '<A style="cursor: hand" '
    NxtPic += 'onMouseover="javascript:window.focus()" '
    NxtPic += 'onclick="javascript:displayImg('
    NxtPic += i
    NxtPic += ')">'
    NxtPic += '<IMG SRC="'
    NxtPic += imagesarr[i - 1]
    NxtPic += '" '
      NxtPic += 'onAbort="escapeErr()"'
      NxtPic += ' '
      NxtPic += 'onError="escapeErr()"'
      NxtPic += ' '
    NxtPic += 'WIDTH="35" HEIGHT="35" '
    NxtPic += 'ALIGN="BOTTOM" ALT="'
    NxtPic += imgnam
    NxtPic += '" BORDER="0" NAME="'
    NxtPic += imgnam
    NxtPic += '">'
    NxtPic += '</A></TD>'
    self.document.writeln(NxtPic);
    if (i % perRow == 0)
    {
      self.document.writeln('  </TR>');
      self.document.writeln('  <TR>');
    }
  }
  self.document.writeln('  </TR>');
  self.document.writeln('</TABLE>');
  self.document.writeln('</CENTER>');
  self.document.writeln('</P>');
  self.document.writeln('</td><td VALIGN="TOP">');

  if (newWin == null || newWin == "")
  {

      newWinSwitch = -1
   
      CrtDumbWin();
   
  }

  if (newWinSwitch > 0)
  {
    CrtNewWin(index);
  } else {
    self.document.writeln('<P>');
    self.document.writeln('<CENTER>');
    self.document.writeln('  <br><br>');
    self.document.writeln('    <IMG SRC="');
    self.document.writeln(     imagesarr[0]     );
    self.document.writeln('" ');
      self.document.writeln('onAbort="javascript:escapeErr()"');
      self.document.writeln(' ');
      self.document.writeln('onError="javascript:escapeErr()"');
      self.document.writeln(' ');
    self.document.writeln('ALIGN="TOP" ALT="Photos" BORDER="0" NAME="Photos">');
    self.document.writeln('  <br><br>');
    self.document.writeln('</CENTER>');
  }

  self.document.writeln('</P>');
  self.document.writeln('</td>');
  self.document.writeln('</tr>');
  self.document.writeln('</table>');
  if (newWinSwitch > 0)
  {
//    self.document.writeln('<a href="javascript:self.close()">Close Both Windows</a>');
  } else {
//    self.document.writeln('<a href="javascript:self.close()">Click Here to Close Window </a>');
  }

  return false;
}

function CrtDumbWin()
{
  newWin = window.open("", "newWin", "height=140, width=140, resize=no, "
    + "scrollbars=no, top=0, left="
    + (screen.availWidth + 1)
    + "\"");
  newWin.location.reload(LoadDummyWin());
  newWin.focus();
  self.window.focus();
}

function LoadDummyWin()
{
  newWin.document.writeln('<html><head>');
  newWin.document.writeln('<a href="javascript:self.close()">Close This Window...</a>');
  newWin.document.writeln('<title>Temporary Picture Window</title>');
  newWin.document.writeln('</head><body>');
  newWin.document.writeln('</body></html>');
  return false;
}

function escapeErr()
{
//  return self.document.writeln("There was an error loading " + imagesarr[i - 1] + " ...");
 return
}

function CrtNewWin(index)
{
  var newWinWidth = screen.availWidth / 2;
  var newWinHeight = screen.availHeight;
  newWin = window.open("", "newWin", "height="
    + newWinHeight + ", width="
    + newWinWidth + ", resize=yes, scrollbars=yes, top=0, left="
    + newWinWidth + "\"");
  return newWin.location.reload(LoadNewWin(index));

}

function LoadNewWin(index)
{
  newWin.document.writeln('<html><head>');
  newWin.document.writeln('<title>Temporary Picture Window</title>');
  newWin.document.writeln('</head><body>');
  newWin.document.writeln('<CENTER>');
  newWin.document.writeln('<a href="javascript:self.close()">Close This Window</a>');
  newWin.document.writeln('  <br><br>');
  newWin.document.writeln('    <IMG SRC="');
  if (index > 0)
  {
    newWin.document.writeln(     imagesarr[index - 1]     );
  } else {
    newWin.document.writeln(     imagesarr[0]     );
  }
  newWin.document.writeln('" ');
    newWin.document.writeln('onAbort="javascript:escapeErr()"');
    newWin.document.writeln(' ');
    newWin.document.writeln('onError="javascript:escapeErr()"');
    newWin.document.writeln(' ');
  newWin.document.writeln('ALIGN="TOP" ALT="ChgInImg" BORDER="0" NAME="Photos">');
  newWin.document.writeln('  <br><br>');
  newWin.document.writeln('</CENTER>');
  newWin.document.writeln('</body></html>');
  return false;
}

function displayImg(index)
{
  if (newWinSwitch > 0)
  {
    window.onError = CrtNewWin(index);
    newWin.document.Photos.src = imagesarr[index - 1];
    newWin.focus();
    return false;
  } else {
    return self.document.Photos.src = imagesarr[index - 1];
  }
}

//  -->


