// Mozilla and Mac version
// Only one light box is open at any time
// called the window lightboxbcp
// Keep the cookie for for the lightbox handle
// uses another2.pl and preview2.pl rather then
// another.pl and preview.pl
// constants
var thumbdir="http://www.arcticphoto.co.uk/search/thumbs/"
var previewdir="http://www.arcticphoto.co.uk/search/previews/"
var previewdira="http://www.arcticphoto.co.uk/search/previews/"
var previewdirb="http://www.arcticphoto.co.uk/search/previewss/"
var imagedir = "/images/"
var backgrd = "/images/flakes1.gif"
var cgidir = "http://www.arcticphoto.co.uk/cgi-bin/search/"
var jsdir="/search/"
var who2
//get browser
   var browser = navigator.appName;
   var Nav = (browser == "Netscape");
   var IE = (browser == "Microsoft Internet Explorer");
//---------------------------------------------------------------------------
// Error Handling
window.onerror = myOnError
msgArray = new Array()
urlArray = new Array()
lnoArray = new Array()
function myOnError(msg, url, lno) {
alert(msg)
   msgArray[msgArray.length] = msg
alert(url)
   urlArray[urlArray.length] = url
alert(lno)
   lnoArray[lnoArray.length] = lno
   return true
}
function displayErrors() {
   win2=window.open('','window2','scrollbars=yes')
   win2.document.writeln('<B>Error Report</B><P>')
alert(msgArray.length)
   for (var i=0; i < msgArray.length; i++) {
      win2.document.writeln('<B>Error in file:</B> ' + urlArray[i] + '<BR>')
      win2.document.writeln('<B>Line number:</B> ' + lnoArray[i] + '<BR>')
      win2.document.writeln('<B>Message:</B> ' + msgArray[i] + '<P>')
   }
   win2.document.close()
}
//-------------------------------------------------------------------------------
// name - name of the cookie
// value - value of the cookie
// [expires] - expiration date of the cookie (defaults to end of current session)
// [path] - path for which the cookie is valid (defaults to path of calling document)
// [domain] - domain for which the cookie is valid (defaults to domain of calling document)
// [secure] - Boolean value indicating if the cookie transmission requires a secure transmission
// * an argument defaults when it is assigned null as a placeholder
// * a null placeholder is not required for trailing omitted arguments
function setCookie(name, value, expires, path, domain, secure) { 
   var curCookie = name + "=" + escape(value) + 
      ((expires) ? "; expires=" + expires.toGMTString() : "") + 
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : ""); 
   document.cookie = curCookie;
}
// name - name of the desired cookie
// * return string containing value of specified cookie or null if cookie does not exist
function getCookie(name) { 
   var dc = document.cookie; 
   var prefix = name + "="; 
   var begin = dc.indexOf("; " + prefix); 
   if (begin == -1) { 
      begin = dc.indexOf(prefix); 
      if (begin != 0) return null; 
   } else 
      begin += 2; 
   var end = document.cookie.indexOf(";", begin); 
   if (end == -1) 
      end = dc.length; 
   return unescape(dc.substring(begin + prefix.length, end));
}
// name - name of the cookie
// [path] - path of the cookie (must be same as path used to create cookie)
// [domain] - domain of the cookie (must be same as domain used to create cookie)
// * path and domain default if assigned null or omitted if no explicit argument proceeds
function deleteCookie(name, path, domain) { 
   if (getCookie(name)) { 
      document.cookie = name + "=" + 
      ((path) ? "; path=" + path : "") + 
      ((domain) ? "; domain=" + domain : "") + 
      "; expires=Thu, 01-Jan-70 00:00:01 GMT"; 
   }
}
// date - any instance of the Date object
// * hand all instances of the Date object to this function for "repairs"
function fixDate(date) { 
   var base = new Date(0); 
   var skew = base.getTime(); 
   if (skew > 0) 
      date.setTime(date.getTime() - skew);
}
var now = new Date();
fixDate(now);
now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
//--------------------------------------------------------
function discard(mypic,box) {
// Copyright Keith Robinson ccaakwr@ucl.ac.uk
// box will hold the cookie name with the list of pictures
// for the lightbox
   var saw = getCookie(box);
   var p= saw.split("#");
   var n = p.length;
   var saw2 ="";  
   var gap = "";
   for(var i=0; i < p.length; i++) {
      if (p[i].match(mypic)){
// discards is list of pictures in lightbox
         var t=getCookie("discards");
         if (!t) {
            t=""
            var sep=""
         } else {
            var sep="#";
         }
// need to check if mypic already in list
         if (t.match(mypic)) {
         } else {
            t += sep+p[i]
            setCookie("discards",t,now,"/")
         }
      } else {
         saw2 += gap+p[i];
         gap="#";
      }
   }
  setCookie(box,saw2,now,"/")
//Mac Version difference
// Only need to worry about current lightbox
//  checkwin("discards")
//  checkwin("boxman")
  makewin3(box)
}
//--------------------------------------------------------
function undiscard(mypic) {
// Copyright Keith Robinson ccaakwr@ucl.ac.uk
// Restore picture to box in lightbox cookie
   var saw = getCookie("discards");
   var p= saw.split("#");
   var n = p.length;
   var saw2 ="";  
   var gap = "";
   for(var i=0; i < p.length; i++) {
      if (p[i].match(mypic)){
// throw is list of discards
// b will hold the cookie name with the list of pictures for the lightbox
         var box = getCookie("box");
         if (!box) {
            alert ("Lightbox not set")
            box = "main"
         }
         var t=getCookie(box);
         if (!t) {
            t=""
            var sep=""
         } else {
            var sep="#";
         }
         t += sep+p[i]
         setCookie(box,t,now,"/")
      } else {
         saw2 += gap+p[i];
         gap="#";
      }
   }
   setCookie("discards",saw2,now,"/")
//Mac Version difference
// only one lightbox for Mac
//   checkwin(box)
//   checkwin("boxman")
   makewin3('discards')
}
//---------------------------------------------------------------------------
function winclose(box){
// Copyright Keith Robinson ccaakwr@ucl.ac.uk
// Change the cookie that keeps track of whether a lightbox is open
   var b = box + "han"
   setCookie(b,"no",now,"/")
}
//---------------------------------------------------------------------------
function movepic(mypic,box){
// Copyright Keith Robinson ccaakwr@ucl.ac.uk
// box will hold the cookie name with the list of pictures
// for the lightbox
   var saw = getCookie(box);
// p has list of pictures in source box
   var p= saw.split("#");
   var n = p.length;
   var saw2 ="";  
   var gap = "";
// get target box details
   box2=getCookie("box")
   for(var i=0; i < p.length; i++) {
      if (p[i].match(mypic)){
// box2 is list of pictures in lightbox
         var t=getCookie(box2);
         if (!t) {
            t=""
            var sep=""
         } else {
            var sep="#";
         }
// need to check if mypic already in list
         if (t.match(mypic)) {
         } else {
            t += sep+p[i]
            setCookie(box2,t,now,"/")
         }
      } else {
         saw2 += gap+p[i];
         gap="#";
      }
   }
   setCookie(box,saw2,now,"/")
// Mac version
//   checkwin(box2)
//   checkwin("boxman")
   makewin3(box)
}
//----------------------------------------------------------------
function resetwin(box){
// Copyright Keith Robinson ccaakwr@ucl.ac.uk
// reset all open windows, box should be name of current window but is
// undefined if called from boxes.htm
// Mac version on needs to check one lightbox
   var boxes=getCookie("boxes")
   p = boxes.split("#")
   if (!box){
      for(var i=0; i < p.length; i++) {
         checkwin(p[i])
      }
      if(box != "discards"){
         checkwin("discards")
      }
      checkwin("boxman")
   } else {
      for(var i=0; i < p.length; i++) {
         if (p[i] != box){
            checkwin(p[i])
         }
      }
      if(box != "discards"){
         checkwin("discards")
      }
      checkwin("boxman")
      makewin3(box)
   }
}
//-----------------------------------------------------------------
function checkwin(box){
// Copyright Keith Robinson ccaakwr@ucl.ac.uk
// check and reset windows
   var b = box + "han"
   var c = getCookie(b)
   if (!c){
   } else {
      if (c == "no"){
      } else {
         if (box == "discards"){
            makewin4('discards')
         } else if(box == "boxman"){
            boxman2()
         } else {
            makewin4(box)
         }
      }
   }
}
//----------------------------------------------------------------
//Add a Lightbox
function newbox(){
// Copyright Keith Robinson ccaakwr@ucl.ac.uk
   var b = prompt("Please enter the name for the Lightbox. Please use a single short word:", "");
   if (!b) {
   } else {
// check for spaces and brackets
      var nameok="yes"
      var l = b.length
      for (var i =0;i<l;i++){
         var buc = b.substring(i,i+1)
         buc = buc.toLowerCase()
         if ( buc == "(" || buc == ")"){
            buc = "brackets"
            alert("You cannot use "+buc+" in the Lightbox name. You used - \""+b+"\". Please try again just using letters and\/or numbers")
            nameok = "no"
         } else if ( "abcdefghijklmnopqrstuvwxyz1234567890".match(buc) ) {
         } else {
            if (buc == " ") {
               buc = "spaces"
            } else if (buc == "(") {
               buc = "brackets"
            }
            alert("You cannot use "+buc+" in the Lightbox name. You used - \""+b+"\". Please try again just using letters and\/or numbers")
            nameok = "no"
         }
      }
      if (nameok == "yes") { 
         b=b.toLowerCase()
         var buc = b.substring(0,1)
         buc = buc.toUpperCase()
         var l = b.length
         buc += b.substring(1,l)
// Check if name in use
         var boxes=getCookie("boxes")
// split boxes into seperate items
         var bo = boxes.split("#")
         l = bo.length
         var nameok="yes"
         for (var i =0;i<l;i++){
            if (bo[i]==b){
// Already in use
               alert("You already have a slde box called "+buc+". Please try again.")
               nameok="no"
            }
         }
      }
      if (nameok == "yes"){
         boxes += "#"+b
         setCookie("boxes",boxes,now,"/")
         setCookie(b,"",now,"/")
         var bhan = b + "han"
         setCookie(bhan,"no",now,"/")
// Check if new box is to be selected box
         if(confirm("Do you want to make the "+buc+" Lightbox the active lightbox to receive pictures?")){
            setCookie("box",b,now,"/")
         } else {
            var box = getCookie("box")
            var buc = box.substring(0,1)
            buc = buc.toUpperCase()
            var l = box.length
            buc += box.substring(1,l)
            alert("Main Lightbox is still "+buc)
         }
         var   box=getCookie("box");
         document.light.D1.options.length=0
         var bo = boxes.split("#")
         var l = bo.length
         for (i=0;i < l;i++){
            if (bo[i]==box){
               var s = i;
            }
// adding selected box
            document.light.D1.options[i] = new Option(bo[i],bo[i]);
         }
         document.light.D1.options[s].selected=true
         resetwin()
         self.focus()
      }
   }
}
//-----------------------------------------------------------------------------
function newbox2(){
// Copyright Keith Robinson ccaakwr@ucl.ac.uk
   var b = prompt("Please enter the name for the Lightbox. Please use a single short word:", "");
   if (!b) {
   } else {
// check for spaces and brackets
      var nameok="yes"
      var l = b.length
      for (var i =0;i<l;i++){
         var buc = b.substring(i,i+1)
         buc = buc.toLowerCase()
         if ( buc == "(" || buc == ")"){
            buc = "brackets"
            alert("You cannot use "+buc+" in the Lightbox name. You used - \""+b+"\". Please try again just using letters and\/or numbers")
            nameok = "no"
         } else if ( "abcdefghijklmnopqrstuvwxyz1234567890".match(buc) ) {
         } else {
            if (buc == " ") {
               buc = "spaces"
            } else if (buc == "(") {
               buc = "brackets"
            }
            alert("You cannot use "+buc+" in the Lightbox name. You used - \""+b+"\". Please try again just using letters and\/or numbers")
            nameok = "no"
         }
      }
      if (nameok == "yes") {  
         var boxes=getCookie("boxes");
         b=b.toLowerCase();
         var buc = b.substring(0,1)
         buc = buc.toUpperCase()
         var l = b.length
         buc += b.substring(1,l)
// Check if name in use
         var boxes=getCookie("boxes")
// split boxes into seperate items
         var bo = boxes.split("#")
         l = bo.length
         for (var i =0;i<l;i++){
            if (bo[i]==b){
// Already in use
               alert("You already have a slde box called "+buc+". Please try again.")
               nameok="no"
            }
         }
      }
      if (nameok == "yes") {
         boxes += "#"+b;
         setCookie("boxes",boxes,now,"/");
         setCookie(b,"",now,"/");
         var bhan = b + "han"
         setCookie(bhan,"no",now,"/")
         var buc = b.substring(0,1)
         buc = buc.toUpperCase()
         var l = b.length
         buc += b.substring(1,l)
         if(confirm("Do you want to make the "+buc+" Lightbox the active lightbox to receive pictures?")){
            setCookie("box",b,now,"/")
         } else {
            var box = getCookie("box")
            buc = box.substring(0,1)
            buc = buc.toUpperCase()
            var l = box.length
            buc += box.substring(1,l)
            alert("Main Lightbox is still "+buc)
         }
         resetwin()
      }
   }
}
//------------------------------------------------------------------------------
function updatesel(){
// Copyright Keith Robinson ccaakwr@ucl.ac.uk
// read in boxes and split into seperate items
//var a = document.cookie
var   boxes=getCookie("boxes");
var   box=getCookie("box");
var bo = boxes.split("#")
var l = bo.length
document.light.D1.options.length=0
for (i=0;i < l;i++){
   if (bo[i]==box){
      var s = i;
   }
// adding selected box
   document.light.D1.options[i] = new Option(bo[i],bo[i]);
}
document.light.D1.options[s].selected=true
var   box = getCookie("box");
   if (!box) {
      alert ("Lightbox not set")
      box="main"
   } 
   var buc = box.substring(0,1)
   buc = buc.toUpperCase()
   var l = box.length
   buc += box.substring(1,l)
//   document.light.openbox.value="Open "+buc+" Lightbox"
}
//------------------------------------------------------------------------------
function whichbox(element) {
// Copyright Keith Robinson ccaakwr@ucl.ac.uk
   for (var i = 0 ; i < element.options.length; i++){
      if (element.options[i].selected){
         var b = element.options[i].value
      }
   }
//save lightbox name in cookie box
   box = getCookie("box");
   if (!box) {
      alert ("Lightbox not set")
   } else {
      box = b
      setCookie("box",box,now,"/");
   }
//   checkwin("boxman")
   resetwin()
   var buc = box.substring(0,1)
   buc = buc.toUpperCase()
   var l = box.length
   buc += box.substring(1,l)
//   document.light.openbox.value="Open "+buc+" Lightbox"
   self.focus()
}
//------------------------------------------------------------------
function whichbox2(element) {
// Copyright Keith Robinson ccaakwr@ucl.ac.uk
   for (var i = 0 ; i < element.options.length; i++){
      if (element.options[i].selected){
         var b = element.options[i].text
      }
   }
//save lightbox name in cookie box
   box = getCookie("box");
   if (!box) {
      alert ("Lightbox not set")
   } else {
      box = b
      setCookie("box",box,now,"/");
   }
//   resetwin("boxman")
   resetwin()
}
//------------------------------------------------------------------
function whichbox3(element,a) {
// Copyright Keith Robinson ccaakwr@ucl.ac.uk
   for (var i = 0 ; i < element.options.length; i++){
      if (element.options[i].selected){
         var b = element.options[i].text
      }
   }
//save lightbox name in cookie box
   var box = getCookie("box");
   if (!box) {
      alert ("Lightbox not set")
   } else {
      var box2 = box
      box = b
      setCookie("box",box,now,"/");
   }
   resetwin(a)
}
//-----------------------------------------------------------------
function closebox(box){
// Copyright Keith Robinson ccaakwr@ucl.ac.uk
   winclose(box)
   self.close()
}
//-------------------------------------------------------------
function makewin2(b){
// Copyright Keith Robinson ccaakwr@ucl.ac.uk
//Mac Version only uses one lightbox Window
   if (!b) {
      box = getCookie("box");
   } else {
      box = b
   }
   if (!box) {
      alert ("Lightbox not set")
      box = "main"
   }
   var h = getCookie(box+"han")
   if (!h || h != "yes"){
      var a=window.open(jsdir+"patient.htm","lightboxbcp","height=450,width=630,menubar=yes,toolbar=no,location=no,scrollbars=yes,resizable=yes")
   } else {
//      var a=window.open("","lightboxbcp")
   }
//   a.close
   document.light.target = "lightboxbcp"
   document.light.thisbox.value=box
   setCookie("openwin",box,now,"/")
   setCookie(box+"han","yes",now,"/")
//   a.focus()
   document.light.submit()
}
//-------------------------------------------------------------
function makewin3(box){
// Copyright Keith Robinson ccaakwr@ucl.ac.uk
// update the current window
   document.light.target = "_self"
   document.light.thisbox.value=box
   setCookie("openwin",box,now,"/")
   document.light.submit()
}
//-------------------------------------------------------------
function makewin4(b){
// Copyright Keith Robinson ccaakwr@ucl.ac.uk
// Mac version - only change self
// can deal with lighbox, discards and boxmanager
   if (!b) {
      box = getCookie("box");
   } else {
      box = b
   }
   if (!box) {
      alert ("Lightbox not set")
      box = "main"
   }
   if (box=="boxman") {
      document.light.thisbox.value="boxmanager"
   } else {
      document.light.thisbox.value=box
   }
   setCookie("openwin",box,now,"/")
   setCookie(box+"han","yes",now,"/")
//   a.focus()
   document.light.submit()
}
//-------------------------------------------------------------
function boxman2(){
// Copyright Keith Robinson ccaakwr@ucl.ac.uk
   var h = getCookie("boxmanhan")
   if (!h || h != "yes"){
      var man=window.open(jsdir+"patient.htm","lightboxbcp","height=450,width=630,menubar=yes,toolbar=no,location=no,scrollbars=yes,resizable=yes", statusbar="yes")
   } else {
//      var man=window.open("","lightboxbcp")
   }
//   man.close
   document.light.target = "lightboxbcp"
   document.light.thisbox.value="boxmanager"
//   man.focus()
   setCookie("boxmanhan","yes",now,"/")
   setCookie("openwin","boxman",now,"/")
   document.light.submit()
}
//------------------------------------------------------------
// function preview(mypic,mycap,w,h,who,nums) {
function preview(mypic,mycap3,nums) {
// Copyright Keith Robinson ccaakwr@ucl.ac.uk
// nums added 14-10-2001
// addpic added 23-12-2001, also check for picture in lightbox
// Modified for Mozilla and Netscape 7 - 18-10-2002
   var q=mycap3.split("@")
   var l = q.length
   var w  = q[2] - 0
   var h  = q[3] - 0
   var who = q[4]
   var mycap= q[5]
   var d= "\',\'"+q[0]+"@"+q[1]+"@"+w+","+h+"@"+who+"@"
// allow for low screen res
   if (h <= w) {
// landscape
      var w2 = w+75
      var h2 = h+330
   } else {
      var w2 = w+400
      var h2 = h+140
   }
   var sh = screen.height
   if (sh < 750) {
// small screen
      w2=w2*.9
      h2=h2*.8
      if (h2 >= 620){
         h2=570
      }
   }
   var f = 'height='+h2+',width='+w2+',toolbar=no,location=no,scrollbars=yes,resizable=yes'
//   var f = 'height='+h2+',width='+w2+',toolbar=no,location=no,scrollbars=no,resizable=yes'
   f += ' ,left=10,top=0'
   var mypic2 = mypic.toUpperCase()
   var a=window.open("","reviewbcp",f)
   var b = "<html>\n<head>\n<title>Preview</title>\n"
   b += "<script LANGUAGE=\"JavaScript\" src=\""+jsdir+"polar2m.js\">\n";
   b += "</script>\n";
   b += "</head><body background=\""+ backgrd + "\">\n"
   if (h <= w) {
// landscape
// use small preview on small screen
// Different sections for IE or Netscape and Mozilla
      if (IE) {
         b += "<center>\n"
         b += "<script language=\"JavaScript\">\n"
         b += "<!--\n"
         b += "var h = screen.height\n"
         b += "if (h < 750) {\n"
         b += "var s =\"<img src=\\\"" + previewdirb + mypic+"m.jpg\\\" border=\\\"0\\\" >\"\n"
         b += "} else {\n"
         b += "var s =\"<img src=\\\"" + previewdira + mypic+"m.jpg\\\" border=\\\"0\\\">\"\n"
         b += "}\n"
         b += "var whichwindow=\"preview\"\n"
         b += "document.write(s)\n"
         b += "// -->\n"
         b += "</script>\n"
      } else {
         b += "<script language=\"JavaScript\">\n"
         b += "<!--\n"
         b += "var whichwindow=\"preview\"\n"
         b += "// -->\n"
         b += "</script>\n"
         b += "<center>\n"
         var h = screen.height
         if (h < 750) {
            var s ="<img src=\"" + previewdirb + mypic+"m.jpg\" border=\"0\" >"
         } else {
            var s ="<img src=\"" + previewdira + mypic+"m.jpg\" border=\"0\" >"
         }
         b += s
      }
// End
      b += "<table colspan=\"4\" >\n"
      b += "<td width=\"5%\"></td>\n"
      b += "<td align=\"center\" width=\"30%\" valign=\"top\">"+mypic2+":</td>\n"
      b += "<td align=\"left\" width=\"60%\">"+mycap+"</td>\n"
      b += "<td width=\"5%\"></td></tr>\n"
      b += "</table>\n"
// Add rollover button for add image to lightbox
// check for image being in lightbox
      var match=""
      var boxes = getCookie("boxes")
      var bo = boxes.split("#")
      var l = bo.length
      for (i=0;i < l;i++){
         var box = bo[i]
         var c = getCookie(box)
         if (!c) {
         } else {
// split into pictures
            var p= c.split("#");
            var n = p.length;
            for(var j=0; j < p.length; j++) {
               var q=p[j].split("@")
// check if mypic in list of images
               if (q[0] == mypic){
               var buc = box.substr(0,1)
               buc = buc.toUpperCase()
               var l2 = box.length
               buc += box.substr(1,l2-1)
               match=buc
               }
            }
         }
      }
      if (match == 0) {
         b += "<a onMouseOut=\"MM_swapImgRestore2()\"\n"
         b += "onMouseOver=\"MM_swapImage2(\'a"+mypic+"\',\'\',\'/images/addpic2.gif\',1)\"\n"
         b += "href=\"javascript:addpic(\'"+mypic+d+mycap+"\')\">\n"
         b += "<img src=\"/images/addpic1.gif\" alt=\"Click to add picture to light box\"\n"
         b += " border=\"0\" name=\"a"+mypic+"\"\n"
         b += " width=\"156\" height=\"37\"></a>\n"
      } else {
         b += "<img src=\"/images/added.gif\" alt=\"Picture already in "+match+" Light Box\"\n"
         b += " border=\"0\" name=\"a"+mypic+"\" width=\"156\" height=\"37\">\n"
      }
// end of button
      b += "</center>\n"
      b += "<p align=\"center\"><font SIZE=\"-1\">© Copyright \n"
      photograher(who)
      b += who2
      b += "</font></p>\n"
//add form next preview
      b += "<form METHOD=\"GET\" ACTION=\""+cgidir+"another2.pl\" name=\"nextprev\" >\n"
// add hidden elements for form elements in next form
      b += "<input type=\"hidden\" name=\"keywords\" size=\"50\" value=\""+keys1+"\">\n";
      b += "<input type=\"hidden\" name=\"type\" value=\""+type1+"\">\n";
      b += "<input type=\"hidden\" name=\"keywords2\" value=\""+keys2+"\">\n";
      b += "<input TYPE=\"hidden\" NAME=\"type2\" VALUE=\""+type2+"\">\n";
      b += "<input TYPE=\"hidden\" NAME=\"numf\" VALUE=\""+numf+"\">\n";
      b += "<input TYPE=\"hidden\" NAME=\"nums\" VALUE=\""+nums+"\">\n";
      b += "<input TYPE=\"hidden\" NAME=\"nextpic\" VALUE=\"xxxx\">\n";
      if (show == "ON") {
         b += "<input type=\"hidden\" name=\"show\" value=\"ON\"> \n";
      }
// add buttons for slide show, modified to rollover
      b += "<table border=\"0\" align=\"center\"><tr>\n";
      if (nums != 1) {
         b += "<td valign=\"bottom\"><a  href=\"javascript:nextpreview('previous')\"";
         b += " onMouseOut=\"MM_swapImgRestore()\"";
         b += " onMouseOver=\"MM_swapImage('previous','','/images/previous2.gif',1)\">";
         b += "<img name=\"previous\" border=\"0\" src=\"/images/previous1.gif\" ";
         b += "width=\"63\" height=\"14\"></a></td>\n";
      }
      b += "<td valign=\"bottom\">This is picture "+nums+" of "+numf+"</td>\n";
      if (nums != numf) {
         b += "<td valign=\"bottom\"><a  href=\"javascript:nextpreview('next')\"";
         b += " onMouseOut=\"MM_swapImgRestore()\"";
         b += " onMouseOver=\"MM_swapImage('next','','/images/next2.gif',1)\">";
         b += "<img name=\"next\" border=\"0\" src=\"/images/next1.gif\" ";
         b += "width=\"38\" height=\"14\"></a></td>\n";
            }
      b += "</table>\n";
      b += "</form>\n"
      b += "<hr width=\"50%\">\n"
      b += "<form METHOD=\"GET\" ACTION=\""+cgidir+"preview2.pl\">\n"
// add hidden elements for form elements in next form
        b += "<input type=\"hidden\" name=\"keywords\" size=\"50\" value=\""+keys1+"\">\n";
        b += "<input type=\"hidden\" name=\"type\" value=\""+type1+"\">\n";
        b += "<input type=\"hidden\" name=\"keywords2\" value=\""+keys2+"\">\n";
        b += "<input TYPE=\"hidden\" NAME=\"type2\" VALUE=\""+type2+"\">\n";
        b += "<input TYPE=\"hidden\" NAME=\"numf\" VALUE=\""+numf+"\">\n";
        b += "<input TYPE=\"hidden\" NAME=\"nums\" VALUE=\""+nums+"\">\n";
        if (show == "ON") {
           b += "<input type=\"hidden\" name=\"show\" value=\"ON\"> \n";
      }
      b += "<input type=\"hidden\" name=\"picture\" value=\""+mypic2+"\"><div align=\"center\"><center><p>\n"
      b += "<input  type=\"submit\" value=\"Show Keywords for this Picture\" name=\"B1\"></p>\n"
      b += "</center></div><div align=\"center\"><center><p>Use the button above to start a search<br>\n"
      b += "based apon the keywords for this picture</p>\n"
      b += "</center></div>\n"
      b += "</form>\n"
//      b += "</td>\n"
   } else {
// portrait
      b += "<table colspan=\"2\" cellspacing=\"5\">\n"
      b += "<tr><td>\n"
//      b += "<img src=\""+previewdir+mypic+"m.jpg\"></td>\n"
// use small preview on small screen
// Different sections for IE or Netscape and Mozilla
      if (IE) {
         b += "<script language=\"JavaScript\"><!--\n"
         b += "var h = screen.height\n"
         b += "if (h < 750) {\n"
         b += "var s =\"<img src=\\\"" + previewdirb + mypic+"m.jpg\\\" border=\\\"0\\\" ></td>\"\n"
         b += "} else {\n"
         b += "var s =\"<img src=\\\"" + previewdira + mypic+"m.jpg\\\" border=\\\"0\\\"></td>\"\n"
         b += "}\n"
         b += "document.write(s)\n"
         b += "var whichwindow=\"preview\"\n"
         b += "// -->\n"
         b += "</script>\n"
      } else {
         b += "<script language=\"JavaScript\"><!--\n"
         b += "var whichwindow=\"preview\"\n"
         b += "// -->\n"
         b += "</script>\n"
         b += "<center>\n"
         var h = screen.height
         if (h < 750) {
            var s ="<img src=\"" + previewdirb + mypic+"m.jpg\" border=\"0\" >"
         } else {
            var s ="<img src=\"" + previewdira + mypic+"m.jpg\" border=\"0\" >"
         }
         b += s
      }
// end
      b += "<td><center><p>"+mypic2+":</center></p>\n"
      b += mycap+"\n"
// Add rollover button for add image to lightbox
// check for image being in lightbox
      var match=""
      var boxes = getCookie("boxes")
      var bo = boxes.split("#")
      var l = bo.length
      for (i=0;i < l;i++){
         var box = bo[i]
         var c = getCookie(box)
         if (!c) {
         } else {
// split into pictures
            var p= c.split("#");
            var n = p.length;
            for(var j=0; j < p.length; j++) {
               var q=p[j].split("@")
// check if mypic in list of images
               if (q[0] == mypic){
               var buc = box.substr(0,1)
               buc = buc.toUpperCase()
               var l2 = box.length
               buc += box.substr(1,l2-1)
               match=buc
               }
            }
         }
      }
      b += "<center>\n"
      if (match == 0) {
         b += "<a onMouseOut=\"MM_swapImgRestore2()\"\n"
         b += "onMouseOver=\"MM_swapImage2(\'a"+mypic+"\',\'\',\'/images/addpic2.gif\',1)\"\n"
         b += "href=\"javascript:addpic(\'"+mypic+d+mycap+"\')\">\n"
         b += "<img src=\"/images/addpic1.gif\" alt=\"Click to add picture to light box\"\n"
         b += " border=\"0\" name=\"a"+mypic+"\"\n"
         b += " width=\"156\" height=\"37\"></a>\n"
      } else {
         b += "<img src=\"/images/added.gif\" alt=\"Picture already in "+match+" Light Box\"\n"
         b += " border=\"0\" name=\"a"+mypic+"\" width=\"156\" height=\"37\">\n"
      }
// end of button
      b += "<p align=\"center\"><font SIZE=\"-1\">© Copyright \n"
      photograher(who)
      b += who2
      b += "</font></p>\n"
      b += "</table>\n"
//add form next preview
      b += "<form METHOD=\"GET\" ACTION=\""+cgidir+"another2.pl\" name=\"nextprev\" >\n"
// add hidden elements for form elements in next form
      b += "<input type=\"hidden\" name=\"keywords\" size=\"50\" value=\""+keys1+"\">\n";
      b += "<input type=\"hidden\" name=\"type\" value=\""+type1+"\">\n";
      b += "<input type=\"hidden\" name=\"keywords2\" value=\""+keys2+"\">\n";
      b += "<input TYPE=\"hidden\" NAME=\"type2\" VALUE=\""+type2+"\">\n";
      b += "<input TYPE=\"hidden\" NAME=\"numf\" VALUE=\""+numf+"\">\n";
      b += "<input TYPE=\"hidden\" NAME=\"nums\" VALUE=\""+nums+"\">\n";
      b += "<input TYPE=\"hidden\" NAME=\"nextpic\" VALUE=\"xxxx\">\n";
      if (show == "ON") {
         b += "<input type=\"hidden\" name=\"show\" value=\"ON\"> \n";
      }
// add buttons for slide show, modified to rollover
      b += "<table border=\"0\" align=\"center\"><tr>\n";
      if (nums != 1) {
         b += "<td valign=\"bottom\"><a  href=\"javascript:nextpreview('previous')\"";
         b += " onMouseOut=\"MM_swapImgRestore()\"";
         b += " onMouseOver=\"MM_swapImage('previous','','/images/previous2.gif',1)\">";
         b += "<img name=\"previous\" border=\"0\" src=\"/images/previous1.gif\" ";
         b += "width=\"63\" height=\"14\"></a></td>\n";
      }
      b += "<td valign=\"bottom\">This is picture "+nums+" of "+numf+"</td>\n";
      if (nums != numf) {
         b += "<td valign=\"bottom\"><a  href=\"javascript:nextpreview('next')\"";
         b += " onMouseOut=\"MM_swapImgRestore()\"";
         b += " onMouseOver=\"MM_swapImage('next','','/images/next2.gif',1)\">";
         b += "<img name=\"next\" border=\"0\" src=\"/images/next1.gif\" ";
         b += "width=\"38\" height=\"14\"></a></td>\n";
      }
      b += "</table>\n";
      b += "</form>\n"
      b += "<hr width=\"50%\">\n"
      b += "<form METHOD=\"GET\" ACTION=\""+cgidir+"preview2.pl\">\n"
// add hidden elements for form elements in next form
      b += "<input type=\"hidden\" name=\"keywords\" size=\"50\" value=\""+keys1+"\">\n";
      b += "<input type=\"hidden\" name=\"type\" value=\""+type1+"\">\n";
      b += "<input type=\"hidden\" name=\"keywords2\" value=\""+keys2+"\">\n";
      b += "<input TYPE=\"hidden\" NAME=\"type2\" VALUE=\""+type2+"\">\n";
      b += "<input TYPE=\"hidden\" NAME=\"numf\" VALUE=\""+numf+"\">\n";
      b += "<input TYPE=\"hidden\" NAME=\"nums\" VALUE=\""+nums+"\">\n";
      if (show == "ON") {
         b += "<input type=\"hidden\" name=\"show\" value=\"ON\"> \n";
      }
      b += "<input type=\"hidden\" name=\"picture\" value=\""+mypic2+"\"><div align=\"center\"><center><p>\n"
      b += "<input  type=\"submit\" value=\"Show Keywords for this Picture\" name=\"B1\"></p>\n"
      b += "</center></div><div align=\"center\"><center><p>Use the button above to start a search<br>\n"
      b += "based apon the keywords for this picture</p>\n"
      b += "</center></div>\n"
      b += "</form>\n"
      b += "</td>\n"
      b += "</tr>\n"
      b += "</table>\n"
   }
   b += "</body>\n"
   b += "</html>\n"
   a.document.write(b);
   a.document.close();
   a.focus();
   a.resizeTo(w2,h2);
}
//------------------------------------------------------------
function preview2(mypic,mycap,w,h,who,nums,numf,box) {
// Copyright Keith Robinson ccaakwr@ucl.ac.uk
// nums and numf added 28-12-2001
// allow for low screen res
   if (h <= w) {
// landscape
      var w2 = w+75
      var h2 = h+330
   } else {
      var w2 = w+400
      var h2 = h+140
   }
   var sh = screen.height
   if (sh < 750) {
// small screen
      w2=w2*.9
      h2=h2*.8
      if (h2 >= 620){
         h2=570
      }
   }
   var f = 'height='+h2+',width='+w2+',toolbar=no,location=no,scrollbars=yes,resizable=yes'
//   var f = 'height='+h2+',width='+w2+',toolbar=no,location=no,scrollbars=no,resizable=yes'
   f += ' ,left=10,top=0'
   var mypic2 = mypic.toUpperCase()
   var a=window.open("","reviewbcp",f)
   var b = "<html>\n<head>\n<title>Preview</title>\n"
   b += "<script LANGUAGE=\"JavaScript\" src=\""+jsdir+"polar2m.js\">\n";
   b += "</script>\n";
   b += "</head><body background=\""+ backgrd + "\">\n"
   if (h <= w) {
// landscape
// use small preview on small screen
// Different sections for IE or Netscape and Mozilla
      if (IE) {
         b += "<center>\n"
         b += "<script language=\"JavaScript\">\n"
         b += "<!--\n"
         b += "var h = screen.height\n"
         b += "if (h < 750) {\n"
         b += "var s =\"<img src=\\\"" + previewdirb + mypic+"m.jpg\\\" border=\\\"0\\\" >\"\n"
         b += "} else {\n"
         b += "var s =\"<img src=\\\"" + previewdira + mypic+"m.jpg\\\" border=\\\"0\\\">\"\n"
         b += "}\n"
         b += "var whichwindow=\"preview\"\n"
         b += "document.write(s)\n"
         b += "// -->\n"
         b += "</script>\n"
      } else {
         b += "<script language=\"JavaScript\">\n"
         b += "<!--\n"
         b += "var whichwindow=\"preview\"\n"
         b += "// -->\n"
         b += "</script>\n"
         b += "<center>\n"
         var h = screen.height
         if ( sh < 750) {
            var s ="<img src=\"" + previewdirb + mypic+"m.jpg\" border=\"0\" >"
         } else {
            var s ="<img src=\"" + previewdira + mypic+"m.jpg\" border=\"0\" >"
         }
         b += s
      }
// End
      b += "<table colspan=\"4\" >\n"
      b += "<td width=\"5%\"></td>\n"
      b += "<td align=\"center\" width=\"30%\" valign=\"top\">"+mypic2+":</td>\n"
      b += "<td align=\"left\" width=\"60%\">"+mycap+"</td>\n"
      b += "<td width=\"5%\"></td></tr>\n"
      b += "</table>\n"
      b += "<p align=\"center\"><font SIZE=\"-1\">© Copyright \n"
      photograher(who)
      b += who2
      b += "</font></p>\n"
//add next preview using Javascript version of another2.pl as all info is known
// add buttons for slide show
      nextbutons(nums,nums,numf,box)
      b += who2
// end of slideshow
      b += "<hr width=\"50%\">\n"
//      b += "<tr>\n"
//      b += "<td align=\"center\">\n"
      b += "<form METHOD=\"GET\" ACTION=\""+cgidir+"preview2.pl\">\n"
// add hidden elements for form elements in next form
        b += "<input type=\"hidden\" name=\"nonext\" size=\"50\" value=\"1\">\n";
        b += "<input type=\"hidden\" name=\"screenh\" size=\"50\" value=\""+sh+"\">\n";
//        b += "<input type=\"hidden\" name=\"keywords\" size=\"50\" value=\""+keys1+"\">\n";
//        b += "<input type=\"hidden\" name=\"type\" value=\""+type1+"\">\n";
//        b += "<input type=\"hidden\" name=\"keywords2\" value=\""+keys2+"\">\n";
//        b += "<input TYPE=\"hidden\" NAME=\"type2\" VALUE=\""+type2+"\">\n";
//        b += "<input TYPE=\"hidden\" NAME=\"numf\" VALUE=\""+numf+"\">\n";
//        b += "<input TYPE=\"hidden\" NAME=\"nums\" VALUE=\""+nums+"\">\n";
//        if (show == "ON") {
//           b += "<input type=\"hidden\" name=\"show\" value=\"ON\"> \n";
//      }
      b += "<input type=\"hidden\" name=\"picture\" value=\""+mypic2+"\"><div align=\"center\"><center><p>\n"
      b += "<input  type=\"submit\" value=\"Show Keywords for this Picture\" name=\"B1\"></p>\n"
      b += "</center></div><div align=\"center\"><center><p>Use the button above to start a search<br>\n"
      b += "based apon the keywords for this picture</p>\n"
      b += "</center></div>\n"
      b += "</form>\n"
//      b += "</td>\n"
   } else {
// portrait
      b += "<table colspan=\"2\" cellspacing=\"5\">\n"
      b += "<tr><td>\n"
//      b += "<img src=\""+previewdir+mypic+"m.jpg\"></td>\n"
// use small preview on small screen
// Different sections for IE or Netscape and Mozilla
      if (IE) {
         b += "<script language=\"JavaScript\"><!--\n"
         b += "var h = screen.height\n"
         b += "if (h < 750) {\n"
         b += "var s =\"<img src=\\\"" + previewdirb + mypic+"m.jpg\\\" border=\\\"0\\\" ></td>\"\n"
         b += "} else {\n"
         b += "var s =\"<img src=\\\"" + previewdira + mypic+"m.jpg\\\" border=\\\"0\\\"></td>\"\n"
         b += "}\n"
         b += "document.write(s)\n"
         b += "var whichwindow=\"preview\"\n"
         b += "// -->\n"
         b += "</script>\n"
      } else {
         b += "<script language=\"JavaScript\"><!--\n"
         b += "var whichwindow=\"preview\"\n"
         b += "// -->\n"
         b += "</script>\n"
         b += "<center>\n"
         var h = screen.height
         if ( sh < 750 ) {
            var s ="<img src=\"" + previewdirb + mypic+"m.jpg\" border=\"0\" >"
         } else {
            var s ="<img src=\"" + previewdira + mypic+"m.jpg\" border=\"0\" >"
         }
         b += s
      }
// end
      b += "<td><center><p>"+mypic2+":</center></p>\n"
      b += mycap+"\n"
      b += "<p align=\"center\"><font SIZE=\"-1\">© Copyright \n"
      photograher(who)
      b += who2
      b += "</font></p>\n"
//      b += "</td></tr>\n"
//      b += "<tr>\n"
//      b += "<td align=\"center\">\n"
//add next preview using Javascript version of another2.pl as all info is known
// add buttons for slide show
      nextbutons(nums,nums,numf,box)
        b += who2
// end of slideshow
      b += "<hr width=\"50%\">\n"
      b += "<form METHOD=\"GET\" ACTION=\""+cgidir+"preview2.pl\">\n"
// add hidden elements for form elements in next form
        b += "<input type=\"hidden\" name=\"nonext\" size=\"50\" value=\"1\">\n";
        b += "<input type=\"hidden\" name=\"screenh\" size=\"50\" value=\""+sh+"\">\n";
//        b += "<input type=\"hidden\" name=\"keywords\" size=\"50\" value=\""+keys1+"\">\n";
//        b += "<input type=\"hidden\" name=\"type\" value=\""+type1+"\">\n";
//        b += "<input type=\"hidden\" name=\"keywords2\" value=\""+keys2+"\">\n";
//        b += "<input TYPE=\"hidden\" NAME=\"type2\" VALUE=\""+type2+"\">\n";
//        b += "<input TYPE=\"hidden\" NAME=\"numf\" VALUE=\""+numf+"\">\n";
//        b += "<input TYPE=\"hidden\" NAME=\"nums\" VALUE=\""+nums+"\">\n";
//        if (show == "ON") {
//           b += "<input type=\"hidden\" name=\"show\" value=\"ON\"> \n";
//      }
      b += "<input type=\"hidden\" name=\"picture\" value=\""+mypic2+"\"><div align=\"center\"><center><p>\n"
      b += "<input  type=\"submit\" value=\"Show Keywords for this Picture\" name=\"B1\"></p>\n"
      b += "</center></div><div align=\"center\"><center><p>Use the button above to start a search<br>\n"
      b += "based apon the keywords for this picture</p>\n"
      b += "</center></div>\n"
      b += "</form>\n"
      b += "</td>\n"
      b += "</tr>\n"
      b += "</table>\n"
   }
   b += "</body>\n"
   a.document.write(b);
   a.document.close();
   a.focus();
   a.resizeTo(w2,h2);
}
//------------------------------------------------------------
function nextbutons(np,nums,numf,box){
// Copyright Keith Robinson ccaakwr@ucl.ac.uk
//add next preview using Javascript version of another2.pl as all info is known
// add buttons for slide show
   if(numf != 1){
        var b = "<form>\n"
      b += "<div align=\"center\"><center><p>\n";
      if (nums != 1) {
         var np=nums-1;
         b += "<input type=\"button\" value=\"Previous\" name=\"previous\" \n";
         b += "onclick=\"another('"+np+"','"+nums+"','"+numf+"','"+box+"')\" >\n";
      } else if (numf != 2) {
         var np=numf;
         b += "<input type=\"button\" value=\"Last Picture\" name=\"previous\" \n";
         b += "onclick=\"another('"+np+"','"+nums+"','"+numf+"','"+box+"')\" >\n";
      }
      b += "\&nbsp\;\&nbsp\;This\&nbsp\;is\&nbsp\;picture\&nbsp\;"+nums+ "\&nbsp\;of\&nbsp\;"+numf+"\&nbsp\;\n";
      if (nums != numf) {
         var np=nums-0+1;
         b += "<input type=\"button\" value=\"Next\" name=\"next\" \n";
         b += "onclick=\"another('"+np+"','"+nums+"','"+numf+"','"+box+"')\" >\n";
      } else  if (numf != 2) {
         var np=1;
         b += "<input type=\"button\" value=\"First Picture\" name=\"previous\" \n";
         b += "onclick=\"another('"+np+"','"+nums+"','"+numf+"','"+box+"')\" >\n";
      }
      b += "</center></div>\n";
        b += "</form>\n"
      who2=b
   } else {
      who2 =""
   }
}
//------------------------------------------------------------
function another(np,nums,numf,box){
// Copyright Keith Robinson ccaakwr@ucl.ac.uk
// Javascript version of another 28-12-2001
// box will hold the cookie name with the list of pictures
// for the lightbox
   var saw = getCookie(box);
   var p= saw.split("#");
// sort p
   p.sort()
   var n = p.length;
   var c = p[np-1].split("@")
//mypic,mycap,w,h,who,nums,numf,box needed as in preview2
   var mypic = c[0]
   var who = c[4]
   var c2 = c[3].split(",")
   var w = c2[0]-0
   var h = c2[1]-0
   var mycap = c[5]
   nums=np
// allow for low screen res
   if (h <= w) {
// landscape
      var w2 = w+75
      var h2 = h+330
   } else {
      var w2 = w+400
      var h2 = h+140
   }
   var sh = screen.height
   if (sh < 750) {
// small screen
      w2=w2*.9
      h2=h2*.8
      if (h2 >= 620){
         h2=570
      }
   }
   var f = 'height='+h2+',width='+w2+',toolbar=no,location=no,scrollbars=yes,resizable=yes'
//   var f = 'height='+h2+',width='+w2+',toolbar=no,location=no,scrollbars=no,resizable=yes'
   f += ' ,left=10,top=0'
   var mypic2 = mypic.toUpperCase()
   var a=window.open("","reviewbcp",f)
   var b = "<html>\n<head>\n<title>Preview</title>\n"
   b += "<script LANGUAGE=\"JavaScript\" src=\""+jsdir+"polar2m.js\">\n";
   b += "</script>\n";   b += "</head><body background=\""+ backgrd + "\">\n"
   if (h <= w) {
// landscape
// use small preview on small screen
// Different sections for IE or Netscape and Mozilla
      if (IE) {
         b += "<center>\n"
         b += "<script language=\"JavaScript\">\n"
         b += "<!--\n"
         b += "var h = screen.height\n"
         b += "if (h < 750) {\n"
         b += "var s =\"<img src=\\\"" + previewdirb + mypic+"m.jpg\\\" border=\\\"0\\\" >\"\n"
         b += "} else {\n"
         b += "var s =\"<img src=\\\"" + previewdira + mypic+"m.jpg\\\" border=\\\"0\\\">\"\n"
         b += "}\n"
         b += "var whichwindow=\"preview\"\n"
         b += "document.write(s)\n"
         b += "// -->\n"
         b += "</script>\n"
      } else {
         b += "<script language=\"JavaScript\">\n"
         b += "<!--\n"
         b += "var whichwindow=\"preview\"\n"
         b += "// -->\n"
         b += "</script>\n"
         b += "<center>\n"
         var h = screen.height
         if (h < 750) {
            var s ="<img src=\"" + previewdirb + mypic+"m.jpg\" border=\"0\" >"
         } else {
            var s ="<img src=\"" + previewdira + mypic+"m.jpg\" border=\"0\" >"
         }
         b += s
      }
// End
      b += "<table colspan=\"4\" >\n"
      b += "<td width=\"5%\"></td>\n"
      b += "<td align=\"center\" width=\"30%\" valign=\"top\">"+mypic2+":</td>\n"
      b += "<td align=\"left\" width=\"60%\">"+mycap+"</td>\n"
      b += "<td width=\"5%\"></td></tr>\n"
      b += "</table></center>\n"
      b += "<p align=\"center\"><font SIZE=\"-1\">© Copyright \n"
      photograher(who)
      b += who2
      b += "</font></p>\n"
//add next preview using Javascript version of another2.pl as all info is known
// add buttons for slide show
      nextbutons(np,nums,numf,box)
        b += who2
// end of slideshow
      b += "<hr width=\"50%\">\n"
//      b += "<tr>\n"
//      b += "<td align=\"center\">\n"
      b += "<form METHOD=\"GET\" ACTION=\""+cgidir+"preview2.pl\">\n"
// add hidden elements for form elements in next form
        b += "<input type=\"hidden\" name=\"nonext\" size=\"50\" value=\"1\">\n";
//        b += "<input type=\"hidden\" name=\"keywords\" size=\"50\" value=\""+keys1+"\">\n";
//        b += "<input type=\"hidden\" name=\"type\" value=\""+type1+"\">\n";
//        b += "<input type=\"hidden\" name=\"keywords2\" value=\""+keys2+"\">\n";
//        b += "<input TYPE=\"hidden\" NAME=\"type2\" VALUE=\""+type2+"\">\n";
//        b += "<input TYPE=\"hidden\" NAME=\"numf\" VALUE=\""+numf+"\">\n";
//        b += "<input TYPE=\"hidden\" NAME=\"nums\" VALUE=\""+nums+"\">\n";
//        if (show == "ON") {
//           b += "<input type=\"hidden\" name=\"show\" value=\"ON\"> \n";
//      }
      b += "<input type=\"hidden\" name=\"picture\" value=\""+mypic2+"\"><div align=\"center\"><center><p>\n"
      b += "<input  type=\"submit\" value=\"Show Keywords for this Picture\" name=\"B1\"></p>\n"
      b += "</center></div><div align=\"center\"><center><p>Use the button above to start a search<br>\n"
      b += "based apon the keywords for this picture</p>\n"
      b += "</center></div>\n"
      b += "</form>\n"
//      b += "</td>\n"
   } else {
      b += "<table colspan=\"2\" cellspacing=\"5\">\n"
      b += "<tr><td>\n"
//      b += "<img src=\""+previewdir+mypic+"m.jpg\"></td>\n"
// use small preview on small screen
// Different sections for IE or Netscape and Mozilla
      if (IE) {
         b += "<script language=\"JavaScript\">\n"
         b += "<!--\n"
         b += "var h = screen.height\n"
         b += "if (h < 750) {\n"
         b += "var s =\"<img src=\\\"" + previewdirb + mypic+"m.jpg\\\" border=\\\"0\\\" >\"\n"
         b += "} else {\n"
         b += "var s =\"<img src=\\\"" + previewdira + mypic+"m.jpg\\\" border=\\\"0\\\">\"\n"
         b += "}\n"
         b += "var whichwindow=\"preview\"\n"
         b += "document.write(s)\n"
         b += "// -->\n"
         b += "</script>\n"
      } else {
         b += "<script language=\"JavaScript\">\n"
         b += "<!--\n"
         b += "var whichwindow=\"preview\"\n"
         b += "// -->\n"
         b += "</script>\n"
         b += "<center>\n"
         var h = screen.height
         if (h < 750) {
            var s ="<img src=\"" + previewdirb + mypic+"m.jpg\" border=\"0\" >"
         } else {
            var s ="<img src=\"" + previewdira + mypic+"m.jpg\" border=\"0\" >"
         }
         b += s
      }
// End
      b += "<td><center><p>"+mypic2+":</center></p>\n"
      b += mycap+"\n"
      b += "<p align=\"center\"><font SIZE=\"-1\">© Copyright \n"
      photograher(who)
      b += who2
      b += "</font></p>\n"
//      b += "</td></tr>\n"
//      b += "<tr>\n"
//      b += "<td align=\"center\">\n"
//add form next preview
//      b += "</table>\n"
//add next preview using Javascript version of another2.pl as all info is known
// add buttons for slide show
      nextbutons(np,nums,numf,box)
      b += who2
// end of slideshow
      b += "<hr width=\"50%\">\n"
      b += "<form METHOD=\"GET\" ACTION=\""+cgidir+"preview2.pl\">\n"
// add hidden elements for form elements in next form
        b += "<input type=\"hidden\" name=\"nonext\" size=\"50\" value=\"1\">\n";
//        b += "<input type=\"hidden\" name=\"keywords\" size=\"50\" value=\""+keys1+"\">\n";
//        b += "<input type=\"hidden\" name=\"type\" value=\""+type1+"\">\n";
//        b += "<input type=\"hidden\" name=\"keywords2\" value=\""+keys2+"\">\n";
//        b += "<input TYPE=\"hidden\" NAME=\"type2\" VALUE=\""+type2+"\">\n";
//        b += "<input TYPE=\"hidden\" NAME=\"numf\" VALUE=\""+numf+"\">\n";
//        b += "<input TYPE=\"hidden\" NAME=\"nums\" VALUE=\""+nums+"\">\n";
//        if (show == "ON") {
//           b += "<input type=\"hidden\" name=\"show\" value=\"ON\"> \n";
//      }
      b += "<input type=\"hidden\" name=\"picture\" value=\""+mypic2+"\"><div align=\"center\"><center><p>\n"
      b += "<input  type=\"submit\" value=\"Show Keywords for this Picture\" name=\"B1\"></p>\n"
      b += "</center></div><div align=\"center\"><center><p>Use the button above to start a search<br>\n"
      b += "based apon the keywords for this picture</p>\n"
      b += "</center></div>\n"
      b += "</form>\n"
      b += "</td>\n"
      b += "</tr>\n"
      b += "</table>\n"
   }
   b += "</body>\n"
   a.document.write(b);
   a.document.close();
   a.focus();
   a.resizeTo(w2,h2);
}
//------------------------------------------------------------
function photograher(who){
// Copyright Keith Robinson ccaakwr@ucl.ac.uk
    if (who=="BC" || who == "CA" || who == "BA"){
      who2 = "Bryan &amp; Cherry Alexander Photography\n"
   } else if (who=="AH"){
      who2 = "Ann Hawthorne\n"
   } else if (who=="BW"){
      who2 = "Bob Wilson\n"
   } else if (who=="DR"){
      who2 = "David Rootes\n"
   } else if (who=="DS"){
      who2 = "Dave Saunders\n"
   } else if (who=="EP"){
      who2 = "Dr Eckart Pott\n"
   } else if (who=="FI"){
      who2 = "Fiona Hall\n"
   } else if (who=="FT"){
      who2 = "Frank Todd\n"
   } else if (who=="HJ"){
      who2 = "Hans Jensen\n"
   } else if (who=="HR"){
      who2 = "Hans Reinhard\n"
   } else if (who=="IC"){
      who2 = "Ian Cumming\n"
   } else if (who=="JH"){
      who2 = "John Hyde\n"
   } else if (who=="JD"){
      who2 = "Julian Dowdeswell\n"
   } else if (who=="KR"){
      who2 = "Keith Robinson\n"
   } else if (who=="LC"){
      who2 = "Louise Crossley\n"
   } else if (who=="MJ"){
      who2 = "Mike Jaques\n"
   } else if (who=="MR"){
      who2 = "Mark Ryan\n"
   } else if (who=="OC"){
      who2 = "Oakley Cochran\n"
   } else if (who=="PD"){
      who2 = "Paul Drummond\n"
   } else if (who=="PO"){
      who2 = "Rinie van Meurs\n"
   } else if (who=="SP"){
      who2 = "Steve Pinfield\n"
   } else if (who=="WE"){
      who2 = "Wendy Else\n"
   } else if (who=="WL"){
      who2 = "Wayne Lynch\n"
   }
}
//------------------------------------------------------------
function register(mypic,mycap3,ns){
// Copyright Keith Robinson ccaakwr@ucl.ac.uk
// has to pass on ns to server
// addpic added 23-12-2001, also check for picture in lightbox
   var q=mycap3.split("@")
   var l = q.length
   var w  = q[2] - 0
   var h  = q[3] - 0
   var who = q[4]
   var mycap= q[5]
//
   var c = mypic+"@"+mycap+"@"+w+"@"+h+"@"+who
   var p = getCookie("preview")
   if (p=="Yes") {
      preview(mypic,mycap3,ns)
   } else {
      setCookie("previewpic",c,now,"/")
      if (h <= w) {
         var w2 = w+50
         var h2 = h+300
      } else {
         var w2 = w+350
         var h2 = h+75
      }
      var f = 'height='+h2+',width='+w2+',toolbar=no,location=no,scrollbars=yes,resizable=yes'
      f += ' ,left=10,top=10'
      var a=window.open("" + jsdir + "register.htm","reviewbcp",f)
      var a=window.open("" + jsdir + "register.htm","reviewbcp",f)
   }
}
//------------------------------------------------------------
function addpic(mypic,mycap) {
// Copyright Keith Robinson ccaakwr@ucl.ac.uk
   var i = 0
   if ((c=MM_findObj("a"+mypic))!=null){
   } else {
      alert("object not found")
   }
// b will hold the cookie name with the list of pictures for the lightbox
   var cook = document.cookie
   var csize = cook.length
   var savecap = getCookie("savecap")
   if (!savecap) {
      savecap = "yes"
   }
   if (csize >= 3900) {
      if (savecap=="yes") {
         var msg = "You have reached the limit of the numbers of pictures"
         msg += " you can have have in your lightboxes. You have the choice of"
         msg += " switching to working without picture captions which will allow"
         msg += " you to have many more pictures."
         alert(msg)
         msg = "Do you wish to switch?"
         if(confirm(msg)){
           removecap()
         } else {
           alert("You will not be able to add new pictures untill you have removed")
         }
      } else { 
         var msg = "You have reached the limit of the numbers of pictures"
         msg += " you can have have in your lightboxes. Even without saving captions"
         msg += " you have now reached a point where adding further pictures will"
         msg += " cause you to loose others you have selected. Before you can add"
         msg += " any more pictures you will have to discards some others and then empty"
         msg += " the Discards Lightbox."
         alert(msg)
      }
   } else {
      var box = getCookie("box");
      if (!box) {
         alert ("Lightbox not set")
         box = "main"
      }
      saw = getCookie(box);
      if (!saw) {
         saw="";
         var sep=""
      } else {
         var sep= "#";
      }
// need to check if mypic already in list, need to check list in cookie
//      if (c.src.match("added.gif")) {
      var match=""
      var mboxes = getCookie("boxes")
      var mbo = mboxes.split("#")
      var ml = mbo.length
      mbo[ml]="discards"
      ml += 1
      for (mi=0;mi < ml;mi++){
         var mbox = mbo[mi]
         var mc = getCookie(mbox)
         if (!mc) {
         } else {
// split into pictures
            var mp= mc.split("#");
            var mn = mp.length;
            for(var mj=0; mj < mn; mj++) {
               var mq=mp[mj].split("@")
// check if mypic in list of images
               if (mq[0] == mypic){
               var mbuc = mbox.substr(0,1)
               mbuc = mbuc.toUpperCase()
               var ml2 = mbox.length
               mbuc += mbox.substr(1,ml2-1)
               match=mbuc
               }
            }
         }
      }
      if (match != ""){
         alert("The picture has already been added to the "+match+" lightbox")
         c.src =imagedir+"added.gif"
         c.alt ="Picture already in "+match+ " Lightbox"
      } else {
         if (savecap=="no") {
// still need to keep the size information
            var q=mycap.split("@")
            var l = q.length
            saw=saw+sep+mypic+"@"
            for (var j = 0;j< q.length-1;j++){
               saw += q[j]+"@"
            }
         } else {
            saw=saw+sep+mypic+"@"+mycap
         }
         setCookie(box,saw,now,"/");
         var a = c.alt
// Change button to show lightbox
         box = getCookie("box");
         if (!box) {
            alert ("Lightbox not set")
         } else {
            var buc = box.substr(0,1)
            buc = buc.toUpperCase()
            var l = box.length
            buc += box.substr(1,l-1)
            c.alt ="Added to "+buc+ " Lightbox"
            c.src =imagedir+"added.gif"
         }
//Mac Version
         var openwin=getCookie("openwin")
         var h=getCookie(openwin+"han")
         if (!h || h != "yes" ){
         } else {
// alert(openwin + " "+ h +" " +box)
            if (openwin==box || openwin=="boxman"){
               document.light.target = "lightboxbcp"
               makewin4(openwin)
            }
         }
//-----------
      } 
      window.focus()
   }
}
//--------------------------------------------------------------------
function addpic2(mypic,mycap) {
// Copyright Keith Robinson ccaakwr@ucl.ac.uk
// b will hold the cookie name with the list of pictures for the lightbox
   var box = getCookie("box");
   var savecap = getCookie("savecap")
   if (!savecap) {
      savecap = "yes"
   }
   if (!box) {
      alert ("Lightbox not set")
      box = "main"
   }
   saw = getCookie(box);
   if (!saw) {
                saw="";
                var sep=""
   } else {
                var sep= "#";
   }
// need to check if mypic already in list, need to check list in cookie
// if (c.src.match("added.gif")) {
   var match=""
   var mboxes = getCookie("boxes")
   var mbo = mboxes.split("#")
   var ml = mbo.length
   mbo[ml]="discards"
   ml += 1
   for (mi=0;mi < ml;mi++){
      var mbox = mbo[mi]
      var mc = getCookie(mbox)
      if (!mc) {
      } else {
// split into pictures
         var mp= mc.split("#");
         var mn = mp.length;
         for(var mj=0; mj < mn; mj++) {
            var mq=mp[mj].split("@")
// check if mypic in list of images
            if (mq[0] == mypic){
            var mbuc = mbox.substr(0,1)
            mbuc = mbuc.toUpperCase()
            var ml2 = mbox.length
            mbuc += mbox.substr(1,ml2-1)
            match=mbuc
            }
         }
      }
   }
   if (match != ""){
      alert("The picture has already been added to a lightbox")
      c.src =imagedir+"added.gif"
      c.alt ="Picture already in "+match+ " Lightbox"
   } else {
      if (savecap=="no"){
// replace caption by single blank
         var q=mycap.split("@")
         var nq = q.length
         newp = q[0]+"@"
// replace caption by a single blank
         q[nq-1]=" "
         for ( var jp = 1; jp < nq;jp++){
            newp += q[jp]+"@"
         }
         saw=saw+sep+mypic+"@"+newp
      } else {
         saw=saw+sep+mypic+"@"+mycap
      }
      setCookie(box,saw,now,"/");
      var a = c.value
// Change button to show lightbox
      box = getCookie("box");
      if (!box) {
         alert ("Lightbox not set")
      } else {
         var buc = box.substr(0,1)
         buc = buc.toUpperCase()
         var l = box.length
         buc += box.substr(1,l-1)
         c.alt ="Added to "+buc+ " Lightbox"
         c.src =imagedir+"added.gif"
      }
//Mac Version
      var openwin=getCookie("openwin")
      var h=getCookie(openwin+"han")
      if (!h || h != yes){
      } else {
// alert("addpic2 "+openwin + " "+ h +" " +box)
            if (openwin==box || openwin=="boxman"){
//               document.light.target = "lightboxbcp"
               makewin4(openwin)
            }
      }
//-----------
   } 
   window.focus()
}
//---------------------------------------------------------------------
function chkbut(){
// Copyright Keith Robinson ccaakwr@ucl.ac.uk
var x = 1
if (x==1) {
   } else {
// get list of boxes
   var boxes=getCookie("boxes")
   if (!boxes) {
   } else {
   var bo = boxes.split("#")
   l = bo.length   
   bo[l]="discards"
   var sets = new Array()
   var labs = new Array()
   var s = -1
   for (var i = 0;i< bo.length;i++){
// read in pictures in lightbox
      var c = getCookie(bo[i])
      if (!c) {
      } else {
         s += 1
         var p= c.split("#");
         var n = p.length;
         for (var j=0;j<n;j++){
            var pic=p[j].split("@")
            var x=pic[0].replace(/-/g,"")
// add picture to array
            if (!sets[s]) {
               sets[s] = x+"#"
               buc = bo[i].substring(0,1)
               buc = buc.toUpperCase()
               var m = bo[i].length
               buc += bo[i].substr(1,m)
               labs[s] = "Picture in "+buc +" Box"
            } else {
               sets[s] += x+"#"
            }
         }
      }
   }
   s = sets.length
   var a = document.images.length
   for (var i = 0 ;i<a;i++){
      var b = document.images[i].src
      var b1 = document.images[i].name
      var b3 = /added.gif/i
      var b4 = /addpic.jpg/i
      if (b3.test(b) || b4.test(b)){
         for (j=0;j<s;j++){
            if (sets[j].match(b1)){
               document.images[i].alt=labs[j]
               document.images[i].src=imagedir+"added.gif" 
            }
         }
      }
   }
   }
}
}
//--------------------------------------------------------------
function removecap(){
// Copyright Keith Robinson ccaakwr@ucl.ac.uk
   setCookie("savecap","no",now,"/")   
   var boxes = getCookie("boxes")
   var bo = boxes.split("#")
   var l = bo.length
   for (i=0;i < l;i++){
      var box = bo[i]
      var c = getCookie(box)
      var newc = ""
      sep =""
      if (!c) {
         alert("No Pictures in "+box+" Lightbox")
      } else {
// split into pictures
         var p= c.split("#");
// sort p 
         p.sort()
         var n = p.length;
         for(var j=0; j < p.length; j++) {
            var q=p[j].split("@")
// check for missing thumbnail
            if (q[1]=="x"){
               newc += sep+p[j]
               sep = "#"
            } else {
// check for thumbnail size
               var nq = q.length
               newp = q[0]+"@"
// replace caption by a single blank
               q[nq-1]=" "
               for ( var jp = 1; jp < nq;jp++){
                  newp += q[jp]+"@"
               }
               newc += sep + newp
               sep = "#"
            }   
         }
         var msg = box +"\nbefore \n"+c
         msg += "\nafter \n"+newc
         setCookie(box,newc,now,"/")
      } 
   }
}
//---------------------------------------------------------------
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n,d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}
function MM_swapImage() { //v3.0
   var i,j=0,x,a=MM_swapImage.arguments; 
   document.MM_sr=new Array; 
   for(i=0;i<(a.length-2);i+=3){
      if ((x=MM_findObj(a[i]))!=null){
         document.MM_sr[j++]=x;
         if(!x.oSrc) {
            x.oSrc=x.src;
         }
         x.src=a[i+2];
      }
   }
}
function MM_swapImage2() { //v3.0
   var i,j=0,x,a=MM_swapImage2.arguments; 
   document.MM_sr=new Array; 
   for(i=0;i<(a.length-2);i+=3){
      if ((x=MM_findObj(a[i]))!=null){
         document.MM_sr[j++]=x;
         if(!x.oSrc) {
            x.oSrc=x.src;
         }
         if (x.src.match("added.gif")) {
         } else {
            x.src=a[i+2];
         }
      }
   }
}
function MM_swapImgRestore2() { //v3.0
   var i,x,a=document.MM_sr; 
   for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) {
      if (x.src.match("added.gif")) {
      } else {
         x.src=x.oSrc;
      }
   }
}
//---------------------------------------------------------------
function empty_box(box){
// Copyright Keith Robinson ccaakwr@ucl.ac.uk
   var quest = "Click OK to empty the lightbox. All the "
   quest += "pictures will be removed. Click Cancel to stop this operation"
   if(confirm(quest)){
      if (box == "discards") {
         setCookie(box,"",now,"/");
         checkwin("boxman")
         checkwin(box)
      } else {
         quest = "You have the choice of moving all the pictures to "
         quest += "the Discards Lightbox or throwing the selection away."
         quest += "Click OK to move all the pictures to the "
         quest += "Discards Lighbox. Click Cancel for NO - I want "
         quest += "to throw away this selection."
         if(confirm(quest)){
            var saw = getCookie(box);
            var p= saw.split("#");
            var n = p.length;
            var saw2 ="";  
            var gap = "";
// discards is list of pictures in lightbox
            var t=getCookie("discards");
            if (!t) {
               t=""
               var sep=""
            } else {
               var sep="#";
            }
            for(var i=0; i < n; i++) {
// need to check if mypic already in list
               if (t.match(p[i])) {
               } else {
                  t += sep+p[i]
                  sep="#"
               }
            }
            setCookie("discards",t,now,"/")
            setCookie(box,"",now,"/");
// mac version
//            checkwin("discards")
//            checkwin("boxman")
            makewin3(box)
         } else {
            setCookie(box,"",now,"/");
//            checkwin("boxman")
//            checkwin(box)
            makewin3(box)
         }
      }
   }
}
//------------------------------------------------------------------------
function deletebox(bb){
// Copyright Keith Robinson ccaakwr@ucl.ac.uk
// Mac version - switch window to Main
var c =getCookie("boxmanhan")
   var box = bb
   var b = box + "han"
   var c = getCookie(b)
   if (c == "yes") {
// Mac version. Switch contents of open lightbox window
//      kill_window(box)
        setCookie(box+"han","no",now,"/")
   } 
// window closed - ok to carry on
      var quest = "Click OK to delete the lightbox. All the "
      quest += "pictures will be removed and the lightbox removed from "
      quest += "your set of lightboxes. Click Cancel to stop this "
      quest += "operation and keep the lightbox."
      if(confirm(quest)){
// Check if there are any pictures
              var c = getCookie(box)
              if (!c) {
// No pictures to worry about so box can just be deleted
        } else {
            quest = "You have the choice of moving all the pictures to "
            quest += "the Discards Lightbox or throwing the selection away. "
            quest += "Click OK to move all the pictures to the "
            quest += "Discards Lighbox. Click Cancel for NO - I want "
            quest += "to throw away this selection."
            if(confirm(quest)){
               var saw = getCookie(box);
               var p= saw.split("#");
               var n = p.length;
               var saw2 ="";  
               var gap = "";
// discards is list of pictures in lightbox
               var t=getCookie("discards");
               if (!t) {
                  t=""
                  var sep=""
               } else {
                  var sep="#";
               }
               for(var i=0; i < n; i++) {
// need to check if mypic already in list
                  if (t.match(p[i])) {
                  } else {
                     t += sep+p[i]
                     sep="#"
                  }
               }
               setCookie("discards",t,now,"/")
// Mac version
//               checkwin("discards")
               setCookie(box,"",now,"/");
            } else {
               setCookie(box,"",now,"/");
            }
         }
         deleteCookie(box,"/")
         var active = getCookie("box")
         if (active == box) {
            alert("Active Lightbox is now Main")
            setCookie("box","main",now,"/")
         }
         var boxes = getCookie("boxes")
         var bo = boxes.split("#")
         var l = bo.length
         var sep = ""
         boxes = ""
         for (i=0;i < l;i++){
            if (bo[i] == box) {
            } else {
               boxes += sep+bo[i];
               sep="#"
            }
         }
         setCookie("boxes",boxes,now,"/");
// Mac version
//         resetwin("boxman")
         makewin4("main")
      }
}
//------------------------------------------------------------------
function kill_window(bb){
// Copyright Keith Robinson ccaakwr@ucl.ac.uk
// not used by Mac
   box = bb
   var buc = box.substring(0,1)
   buc = buc.toUpperCase()
   var l = box.length
   buc += box.substr(1,l)
// Create a back that will self distruct
      var b = "<html>\n<head>\n<title>"+buc+" Lightbox Closing</title>\n"
// add cookie stuff
      b += "</head><body onUnload=\"winclose('"+box+"')\" background=\""+ backgrd + "\" >\n"
      b += "<p>Window Closing</p>\n"
      b += "<p><script language=\"JavaScript\"><!--\n"
      b += "self.close()\n"
      b += "// --></script></p>\n"
      b += "</body></html>\n"
      var a=window.open("",box+"bcp","height=450,width=630,toolbar=no,location=no,scrollbars=yes,resizable=yes")
      if(a != null) {
         a.document.write(b);
//         a.document.close();
//         a.focus();
      }  
      var b = box + "han"
      setCookie(b,"no",now,"/")
}
//---------------------------------------------------------------
function request(b){
// Copyright Keith Robinson ccaakwr@ucl.ac.uk
   box = b
   setCookie("requestpics",box,now,"/")
   var a=window.open(jsdir+"request.htm")
}
//---------------------------------------------------------------
function resize1() {
// Copyright Keith Robinson ccaakwr@ucl.ac.uk
alert("resize 1")
}
//---------------------------------------------------------------
function resize2() {
// Copyright Keith Robinson ccaakwr@ucl.ac.uk
alert("resize 2")
}
//---------------------------------------------------------------
function qwikstart(){
// Copyright Keith Robinson ccaakwr@ucl.ac.uk
   var keywords=document.qwikstart.keywords.value
   setCookie("keywords",keywords,now,"/")
   deleteCookie("firsttimer")
// which type, always use 1
   setCookie("type","type1",now,"/")
// use correct platform
   var plat= navigator.platform;
   var mac= (plat=="MacPPC")
   if (mac) {
      a=window.open("/qindex2m.htm","_self")
   } else {
     a=window.open("/qindex2n.htm","_self")
   } 
}
//----------------------------------------------------------
function qwikstart2(){
// Copyright Keith Robinson ccaakwr@ucl.ac.uk
   var keywords=document.gallery.keywords.value
   setCookie("keywords",keywords,now,"/")
   deleteCookie("firsttimer")
   var backgal=document.gallery.backgal.value
   setCookie("backgal",backgal,now,"/")
   var type=document.gallery.type.value
   if (!type) {
      setCookie("type","type1",now,"/")
   } else {
      setCookie("type",type,now,"/")
   }
// use correct platform
   var plat= navigator.platform;
   var mac= (plat=="MacPPC")
   if (mac) {
      a=window.open("/qindex2m.htm","_self")
   } else {
     a=window.open("/qindex2n.htm","_self")
   } 
}
//----------------------------------------------------------
function addkey(S) {
// Copyright Keith Robinson ccaakwr@ucl.ac.uk
   var i = S.options.length
   for (var i = 0 ; i < S.options.length; i++){
      if ( S.options[i].selected){
         var b =  S.options[i].value
      }
   }
   if (b != S.options[0].value) {
      var a = document.form1.keywords.value
      l = a.length
      if (a.match(b)){
         alert ("All ready there")
      } else {
         if (b.match(" ")){
            b = "\""+b+"\""
         }
         if (l==0) {
            a = b
         } else {
            a = a+" "+b
         }
         document.form1.keywords.value=a
      }
   }
}
//------------------------------------------------------------------
function addkeysmenu(){
// Copyright Keith Robinson ccaakwr@ucl.ac.uk
// get back gallery cookie
   var backgal=getCookie("backgal")
   if (!backgal) {
      var s = ""
   } else {
      var s = "<p><a href=\"/"+backgal+"\" target=\"_top\">Back to Galleries</a></p>\n"
   }
   s += "<form name=\"form2\">\n"
   s += "<div align=\"center\"><center><table border=\"0\" width=\"630\">\n"
   s += "<tr>\n"
   s += "<td colspan=\"4\">Suggested Keywords - use the drop-down menus to add words to the your keyword list above</td>\n"
   s += "</tr><tr>\n"
   s += "<td width=\"25%\"><select name=\"S1\" onChange=\"addkey(S1)\" size=\"1\">\n"
   s += "<option value=\"Wildlife\" selected>Wildlife</option>\n"
   s += "<option value=\"Polar Bear\">Polar Bear</option>\n"
   s += "<option value=\"Wolf\">Wolf</option>\n"
   s += "<option value=\"Caribou\">Caribou</option>\n"
   s += "<option value=\"Seal\">Seal</option>\n"
   s += "<option value=\"Walrus\">Walrus</option>\n"
   s += "<option value=\"Whale\">Whale</option>\n"
   s += "<option value=\"Bird\">Bird</option>\n"
   s += "<option value=\"Penguin\">Penguin</option>\n"
   s += "<option value=\"Albatross\">Albatross</option>\n"
   s += "</select></td>\n"
   document.writeln(s)
   s = "<td width=\"25%\"><select name=\"S2\" onChange=\"addkey(S2)\" size=\"1\">\n"
   s += "<option value=\"Native Peoples\" selected>Native Peoples</option>\n"
   s += "<option value=\"Inuit\">Inuit - (Eskimo)</option>\n"
   s += "<option value=\"Khanty\">Khanty</option>\n"
   s += "<option value=\"Evenk\">Evenk</option>\n"
   s += "<option value=\"Even\">Even</option>\n"
   s += "<option value=\"Koryak\">Koryak</option>\n"
   s += "<option value=\"Yakut\">Yakut</option>\n"
   s += "<option value=\"Tuvans\">Tuvans</option>\n"
   s += "<option value=\"Cree\">Cree</option>\n"
   s += "<option value=\"Innu\">Innu</option>\n"
   s += "<option value=\"Nenets\">Nenets</option>\n"
   s += "<option value=\"Chukchi\">Chukchi</option>\n"
   s += "<option value=\"Sami\">Sami - (Lapps)</option>\n"
   s += "</select></td>\n"
   s += "<td width=\"25%\"><select name=\"S3\" onChange=\"addkey(S3)\" size=\"1\">\n"
   s += "<option value=\"Native People\" selected>Arctic Regions</option>\n"
   s += "<option value=\"Greenland\">Greenland</option>\n"
   s += "<option value=\"Canada\">Canada</option>\n"
   s += "<option value=\"Scandinavia\">Scandinavia</option>\n"
   s += "<option value=\"Alaska\">Alaska</option>\n"
   s += "<option value=\"Siberia\">Siberia</option>\n"
   s += "<option value=\"North Pole\">North Pole</option>\n"
   s += "</select></td>\n"
   s += "<td width=\"25%\"><select name=\"S4\" onChange=\"addkey(S4)\" size=\"1\">\n"
   s += "<option value=\"Antarctica\" selected>Antarctica</option>\n"
   s += "<option value=\"Antarctic Peninsula\">Antarctic Peninsula</option>\n"
   s += "<option value=\"Ross Sea\">Ross Sea</option>\n"
   s += "<option value=\"Weddell Sea\">Weddell Sea</option>\n"
   s += "<option value=\"East Antarctica\">East Antarctica</option>\n"
   s += "<option value=\"South Pole\">South Pole</option>\n"
   s += "<option value=\"Sub Antarctic Islands\">Sub Antarctic Is</option>\n"
   s += "</select></td></tr><tr>\n"
   s += "<td width=\"25%\"><select name=\"S5\" onChange=\"addkey(S5)\" size=\"1\">\n"
   s += "<option value=\"Landscapes\" selected>Landscapes</option>\n"
   s += "<option value=\"Mountains\">Mountains</option>\n"
   s += "<option value=\"Sunset\">Sunset</option>\n"
   s += "<option value=\"Tundra\">Tundra</option>\n"
   s += "<option value=\"Boreal Forest\">Boreal Forest</option>\n"
   s += "</select></td>\n"
   s += "<td width=\"25%\"><select name=\"S6\" onChange=\"addkey(S6)\" size=\"1\">\n"
   s += "<option value=\"Ice\" selected>Ice</option>\n"
   s += "<option value=\"Icecap\">Icecap</option>\n"
   s += "<option value=\"Polar Plateau\">Polar Plateau</option>\n"
   s += "<option value=\"Glacier\">Glacier</option>\n"
   s += "<option value=\"Iceberg\">Iceberg</option>\n"
   s += "<option value=\"Sea Ice\">Sea Ice</option>\n"
   s += "<option value=\"Pack Ice\">Pack Ice</option>\n"
   s += "<option value=\"Ice Flower\">Ice Flower</option>\n"
   s += "</select></td>\n"
   s += "<td width=\"25%\"><select name=\"S7\" onChange=\"addkey(S7)\" size=\"1\">\n"
   s += "<option value=\"Modern Arctic\" selected>Modern Arctic</option>\n"
   s += "<option value=\"Industry\">Industry</option>\n"
   s += "<option value=\"Petro-chemical\">Petro-chemical</option>\n"
   s += "<option value=\"Mining\">Mining</option>\n"
   s += "<option value=\"Communications\">Communications</option>\n"
   s += "<option value=\"Education\">Education</option>\n"
   s += "<option value=\"Scientific research\">Scientific research</option>\n"
   s += "<option value=\"Pollution\">Pollution</option>\n"
   s += "</select></td>\n"
   s += "<td width=\"25%\"><select name=\"S8\" onChange=\"addkey(S8)\" size=\"1\">\n"
   s += "<option value=\"Weather\" selected>Weather</option>\n"
   s += "<option value=\"Snow\">Snow</option>\n"
   s += "<option value=\"Storm\">Storm</option>\n"
   s += "<option value=\"Wind\">Wind</option>\n"
   s += "<option value=\"Clouds\">Clouds</option>\n"
   s += "<option value=\"Rain\">Rain</option>\n"
   s += "<option value=\"Rainbow\">Rainbow</option>\n"
   s += "<option value=\"Polar Phenomena\">Polar Phenomena</option>\n"
   s += "</select></td></tr></table>\n"
   s += "</center></div>\n"
   s += "</form>\n"
   document.writeln(s)
}
//--------------------------------------------------------------------
function addback2gal(){
// Copyright Keith Robinson ccaakwr@ucl.ac.uk
// get back gallery cookie
   var backgal=getCookie("backgal")
   if (!backgal) {
      var s = ""
   } else {
      var s = "<center><p><a href=\"/"+backgal+"\" target=\"_top\">Back to Galleries</a></p></center>\n"
      document.writeln(s)
   }
}
//--------------------------------------------------------------------
function nextpreview(nxpic){
// Copyright Keith Robinson ccaakwr@ucl.ac.uk
   document.nextprev.nextpic.value=nxpic
   document.nextprev.submit()
}
//--------------------------------------------------------------------
function refreshgal(){
var numimages=document.images.length
for (var i=0; i < numimages;i++){
   var n = document.images[i].name
   var m = n.charAt(0)
   if (m=="a"){
      var match=""
      var boxes = getCookie("boxes")
      if (!boxes){
      } else {
         var bo = boxes.split("#")
         var l = bo.length
         for (ii=0;ii < l;ii++){
            var box = bo[ii]
            var c = getCookie(box)
            if (!c) { 
            } else {
// split into pictures
               var p= c.split("#");
               for(var j=0; j < p.length; j++) {
                  var q=p[j].split("@")
// check if mypic in list of images
                  if ("a"+q[0] == n){
                     var buc = box.substr(0,1)
                     buc = buc.toUpperCase()
                     var l2 = box.length
                     buc += box.substr(1,l2-1)
                     match=buc
                     document.images[i].src="/images/added.gif"
                     document.images[i].alt="Added to "+match
                  }
               }
            }
         }
      }
   }
}
}
//------------------------------------------------------------------------------
function gohome(){
// replaces use of home.htm to change to welcome screen
s = "http://www.arcticphoto.co.uk/welcome/"
var w = getCookie("welcome")
if (!w) {
   var n = (Math.round((Math.random()*21)+0))
} else {
   var n = w
}
s += n+"/index.htm"
win2=window.open(s,"_top")
}
//--------------------------------------------------------------------

