swidth = screen.width;
if (swidth>=1600)
{
  <!-- 1600x1200 --  L   L1   L2   L3   L4   L5   L6   P,   P1   P2   P3   P4>
  width  = new Array(600, 500,1000, 300,1500,1200, 600, 400, 332, 400, 400, 400);
  height = new Array(400, 332, 400, 240, 600, 400, 450, 600, 500,1000, 800,1000);
}
else if (swidth>=1024)
{
  <!-- 1024x 768 --  L   L1   L2   L3   L4   L5   L6   P,   P1   P2   P3   P4>
  width  = new Array(600, 500, 500, 300, 750, 900, 600, 400, 332, 300, 300, 240);
  height = new Array(400, 332, 200, 240, 300, 300, 450, 600, 500, 525, 600, 600);
}
else if (swidth>=800)
{
  <!-- 800 x 600 --  L   L1   L2   L3   L4   L5   L6   P,   P1   P2   P3   P4>
  width  = new Array(300, 250, 500, 300, 600, 600, 300, 200, 166, 240, 240, 200);
  height = new Array(200, 166, 200, 240, 240, 200, 225, 300, 250, 420, 480, 500);
}
else if (swidth>=640)
{
  <!-- 640 x 480 --  L   L1   L2   L3   L4   L5   L6   P,   P1   P2   P3   P4>
  width  = new Array(300, 250, 500, 300, 600, 600, 300, 200, 166, 240, 200, 171);
  height = new Array(200, 166, 200, 240, 240, 200, 225, 300, 250, 420, 400, 429);
}
else
{
  alert('Screen resolution must be 640x480 or more')
}


function lines(length,width)
{
  lines_required = (length*8) / width;
  if (lines_required < 1)
     return 1;
  else if (lines_required < 2)
     return 2;
  else if (lines_required < 3)
     return 3;
  else if (lines_required < 4)
     return 4;
  else if (lines_required < 5)
     return 5;
}

function selectsize(format)
{
  if (format == 'L')       index = 0;
  else if (format == 'L1') index = 1;
  else if (format == 'L2') index = 2;
  else if (format == 'L3') index = 3;
  else if (format == 'L4') index = 4;
  else if (format == 'L5') index = 5;
  else if (format == 'L6') index = 6;
  else if (format == 'P')  index = 7;
  else if (format == 'P1') index = 8;
  else if (format == 'P2') index = 9;
  else if (format == 'P3') index = 10;
  else if (format == 'P4') index = 11;

  return index;
}

function display_image(selection,format,caption,date,photographer) 
{
  i = selection.lastIndexOf("/");
  selection_file = selection.slice(i+1,selection.length);

  index = selectsize(format);

  pheight = height[index];
  pwidth  = width[index];

  wheight = pheight + 55 + lines(caption.length,pwidth) * 25;
  wwidth  = pwidth + 50;

  Photo = window.open("", "Photo", "resizable=1,width="+wwidth+",height="+wheight);
  if (navigator.appName == "Microsoft Internet Explorer")
     Photo.resizeTo(wwidth+10,wheight+33);

  Photo.document.open();
  Photo.document.write("<HTML><HEAD>");
  Photo.document.write("<TITLE>Hotel Angostura ("+selection_file+")</TITLE>");
  Photo.document.write("<link rel='stylesheet' TYPE='text/css' HREF='../photostyles.css'>");
  Photo.document.write("</HEAD>");
  Photo.document.write("<BODY>");
  Photo.document.write("<CENTER>");
  Photo.document.write("<TABLE border=5 cellspacing=0 cellpadding=0 bordercolor=#000000>");
  Photo.document.write("<TR><TD><IMG HSPACE=0 VSPACE=0 WIDTH="+pwidth+" SRC='"+selection+".jpg'></TD></TR>");
  Photo.document.write("</TABLE>");
  Photo.document.write("<TABLE border=0 width="+pwidth+" cellspacing=0 cellpadding=0>");
  Photo.document.write("<TR><TD align=left><p class='credit'>"+selection_file+"</p></TD>");
  Photo.document.write("<TD align=right><p class='credit'>"+photographer+" "+date+"</p></TD></TR>");
  Photo.document.write("<TR><TD colspan=2><p class='caption'>" + caption + "</p></TD></TR>");
  Photo.document.write("</TABLE>");
  Photo.document.write("</CENTER>");
  Photo.document.write("</BODY></HTML>");
  Photo.document.close();
  Photo.focus();
}