var 
    LomoWallVersion="LomoWall by Marc II (markus.petz@kfunigraz.ac.at) v2.1 20000914";
    LomoWallText="Feel free to use and share this little script whenever you want (please contact me if you do so / want technical support / have suggestions for modifications). LOMO the world!";
    img = new Array("01/1", "01/2","01/3","02/1","02/3","02/4","02/5","02/6","02/7","02/8","03/1","03/2","03/3","03/4","03/5","03/6","03/7","03/8","03/9","03/10","03/11","03/12","04/1","04/2","04/3","04/4","04/5","09/1","09/2","09/3","09/4","09/5","09/6","10/1","10/2","10/3","10/4","10/5","10/6","10/7","10/8","10/9","10/10","10/11","10/12","11/1","11/2","11/3","11/4","11/5","11/6","11/7","11/8","11/9","11/10","11/11","11/12","13/1","13/2","13/3","13/4","13/5","13/6","14/1","14/2","14/3","14/4","14/5","16/1","16/2","17/1","18/1","18/2","18/3","18/4","18/5","18/6","18/7","18/8","18/9","18/10","19/1","19/2","19/3","19/4","19/5","19/6","19/7","20/1","20/2","20/3","20/4","20/5","21/1","21/2","21/3","21/4","21/5","21/6","21/7","21/9","22/1","22/2","22/3","22/4","22/5","22/6","22/7","22/8","23/1","23/2","23/3","23/4","23/5","23/6","23/7","23/8","24/1","24/2","24/3","24/4","24/5","24/6","24/7","24/8","24/9","24/10","25/1","25/2","25/3","25/4","25/5","25/6","25/7","25/8","25/9","26/1","26/2","26/3","26/4","26/5","26/6","27/1","27/2","27/3","28/1","28/2","28/3","28/4","29/1","29/2","29/3","29/4","29/5","29/6","29/7","29/8","30/1","30/2","30/3","30/4","030406/2","030406/3","030406/4","030406/5","030406/6","030406/7","030406/8","030406/9","030406/10","030406/11","030406/12","030407/2","030407/3","030407/4","030407/5","030408/2","030408/3","030408/4","030408/5","030408/6","030408/7","030408/8","030408/9","030408/10","030408/11","030408/12","030408/13","030408/14","030408/15","030408/16","030408/17","030408/18","030408/19","030408/20","030408/21","030408/22","030408/23","030408/24","030408/25","030408/27","030408/28","030408/29","030409/2","030409/3","030409/4","030409/5","030409/6","030409/8","030409/9","030409/10","030409/11","030409/12","030409/13","030409/14","030409/15","030409/16","030409/17","030409/18","030409/19","030409/20","030409/21","030409/22","030409/23","030409/24","030409/25","030409/26","030409/27","030409/28","030409/29","030409/30","030409/31","030409/32","030409/33","030409/34","030410/2","030410/3","030410/4","030410/5","030410/6","030410/7","030410/8","030410/9","030410/10","030410/11","030410/12","030410/13","030410/14","030410/15","030410/16","030410/17","030410/18","030410/19","030411/2","030411/3","030411/4","030411/5","030411/6","030411/7","030411/8","030411/9","030411/10","030411/11","030411/12","030411/13","030411/14","030411/15","030411/16","030411/17","030411/18","030411/19","030411/20","030411/21","030411/22","030412/2","030412/3","030412/5","030412/6","030412/7","030412/8","030412/9","030412/10","030412/11","030412/12","030412/13","030412/14","030412/15","030412/16","030412/17","030412/18","030412/19","030412/20","030412/21","030412/22","31/1","31/2","32/1","32/2","32/3","33/1","33/2","33/3","34/1","34/2","34/3","../../photo/image/mammoth2004/1","../../photo/image/mammoth2004/2","../../photo/image/mammoth2004/3","../../photo/image/mammoth2004/4","../../photo/image/mammoth2004/5","../../photo/image/mammoth2004/6","../../photo/image/mammoth2004/7","../../photo/image/mammoth2004/8","../../photo/image/mammoth2004/9","../../photo/image/mammoth2004/10","../../photo/image/mammoth2004/11","../../photo/image/mammoth2004/12","../../photo/image/mammoth2004/13","../../photo/image/mammoth2004/14","../../photo/image/mammoth2004/15","../../photo/image/mammoth2004/16","../../photo/image/mammoth2004/17","../../photo/image/mammoth2004/18","../../photo/image/mammoth2004/19","../../photo/image/mammoth2004/20","../../photo/image/mammoth2004/21","../../photo/image/mammoth2004/22","../../photo/image/mammoth2004/23","../../photo/image/mammoth2004/24","../../photo/image/mammoth2004/25","../../photo/image/mammoth2004/26","../../photo/image/mammoth2004/27","../../photo/image/mammoth2004/28","../../photo/image/mammoth2004/29","../../photo/image/mammoth2004/30","../../photo/image/mammoth2004/31","../../photo/image/mammoth2004/32","../../photo/image/mammoth2004/33","../../photo/image/mammoth2004/34","../../photo/image/mammoth2004/35","../../photo/image/mammoth2004/36","../../photo/image/mammoth2004/37","../../photo/image/mammoth2004/38","../../photo/image/mammoth2004/39","../../photo/image/mammoth2004/40","../../photo/image/mammoth2004/41","../../photo/image/mammoth2004/42","../../photo/image/mammoth2004/43","../../photo/image/mammoth2004/44","../../photo/image/mammoth2004/45","../../photo/image/mammoth2004/46","../../photo/image/mammoth2004/47","../../photo/image/mammoth2004/48","../../photo/image/mammoth2004/49","../../photo/image/mammoth2004/50","../../photo/image/mammoth2004/51","../../photo/image/mammoth2004/52","../../photo/image/mammoth2004/53","../../photo/image/mammoth2004/54","../../photo/image/mammoth2004/55","../../photo/image/mammoth2004/56","../../photo/image/mammoth2004/57");
    ImgFolder = "http://bkzzang.com/lomo/";
    ImgExtension = ".jpg";

    PopUpLargeImg = "on"
    LargeImgSuffix = "";
    PopUpWinWidth = 376;
    PopUpWinHeight = 256;

    LomoWallReload = "on";
    ReloadAfterSeconds = 10;
    PreLoad = "on";
    UseStyles = new Array("diffuse","lines1","lines2","spots","paths1","paths2"); /* valid values: "diffuse","lines1","lines2","spots","paths1","paths2" */
    LinesRepeat = 2;
    TableHeight = 6;
    TableWidth = 6;
    CountImgAtOnce = 5;
    MaxCountSingleImg = 8;
    CountBeforeDouble = 12;

    //DO NOT CHANGE the following values:
    CountTableImg = TableHeight*TableWidth;
    CountTotalImg = img.length;
    ImgsToDisplay = new Array(CountImgAtOnce);
    CountImgDisplayed = new Array(CountImgAtOnce);
    AlreadyChosen = new Array(CountTotalImg);
    DiagStart1x = new Array(TableHeight+TableWidth-1);
    DiagStart1y = new Array(TableHeight+TableWidth-1);
    DiagStart2x = new Array(TableHeight+TableWidth-1);
    DiagStart2y = new Array(TableHeight+TableWidth-1);
    CellsFilled = new Array(CountTableImg);
    CountLoaded = CountImgAtOnce;
    TempImg = new Array(CountImgAtOnce);
    TableStartImg = 0;
    CountReloads = 0;
    CountRetries = 0;
    BrowserName = navigator.appName;


  function SetDiffuse() {
    for (i1=0; i1<CountImgAtOnce; ++i1)
      CountImgDisplayed[i1]=0;

    for (i1=0; i1<CountTableImg; ++i1) {
      NextImg=Math.floor(Math.random()*CountImgAtOnce);
      while (CountImgDisplayed[NextImg] >= MaxCountSingleImg) {   
        NextImg=Math.floor(Math.random()*CountImgAtOnce);
      }
      CountImgDisplayed[NextImg]++;
      document.images[TableStartImg+i1].src=ImgFolder + img[ImgsToDisplay[NextImg]] + ImgExtension;
    }
  } /*SetDiffuse*/

  function SetDiagonal1() {
    i3=0;
    NextImg=0;
    for (i1=0; i1<DiagStart1x.length; ++i1) {
      x=DiagStart1x[i1];
      y=DiagStart1y[i1];
      while (x<TableWidth && y<TableHeight) {
        i2=TableStartImg+x+(y*TableWidth);
        document.images[i2].src=ImgFolder + img[ImgsToDisplay[NextImg]] + ImgExtension;
        x++;
        y++;
      }

      i3++;
      if (i3==LinesRepeat) {
        NextImg++;
        i3=0;
      }
      if (NextImg>=CountImgAtOnce) NextImg=0;
    }
  } /*setDiagonal1*/

  function SetDiagonal2() {
    i3=0;
    NextImg=0;
    for (i1=0; i1<DiagStart2x.length; ++i1) {
      x=DiagStart2x[i1];
      y=DiagStart2y[i1];
      while (x>=0 && y<TableHeight) {
        i2=TableStartImg+x+(y*TableWidth);
        document.images[i2].src=ImgFolder + img[ImgsToDisplay[NextImg]] + ImgExtension;
        x--;
        y++;
      }

      i3++;
      if (i3==LinesRepeat) {
        NextImg++;
        i3=0;
      }
      if (NextImg>=CountImgAtOnce) NextImg=0;
    }
  } /*setDiagonal2*/

  function SetSpot() {
    for (i1=0; i1<CountImgAtOnce; ++i1)
      CountImgDisplayed[i1]=0;
    for (i1=0; i1<CountTableImg; ++i1)
      CellsFilled[i1]=0;
    i2=0;
    i3=0;

    while (i3<CountTableImg) {
      x0=Math.floor(Math.random()*TableWidth);
      y0=Math.floor(Math.random()*TableHeight);
      for (i1=CountImgDisplayed[i2]; i1<MaxCountSingleImg; ++i1) {
        r=Math.random()*2;
        p=Math.random()*2*Math.PI;
        x=x0+Math.floor(Math.cos(p)*r);
        y=y0+Math.floor(Math.sin(p)*r);
        if (x>=0 && x<TableWidth && y>=0 && y<TableHeight && CellsFilled[x+y*TableWidth]==0) {
          document.images[TableStartImg+x+y*TableWidth].src=ImgFolder + img[ImgsToDisplay[i2]] + ImgExtension;
          CellsFilled[x+y*TableWidth]=1;
          CountImgDisplayed[i2]++;
          i3++;
        }
      }
      i2++;
      if (i2==CountImgAtOnce) i2=0;
    }
  } /*SetSpot*/

  function SetPath1() {
    for (i1=0; i1<CountImgAtOnce; ++i1)
      CountImgDisplayed[i1]=0;
    for (i1=0; i1<CountTableImg; ++i1)
      CellsFilled[i1]=0;
    i2=0;
    i3=0;

    while (i3<CountTableImg) {
      x=Math.floor(Math.random()*TableWidth);
      y=Math.floor(Math.random()*TableHeight);
      for (i1=0; i1<MaxCountSingleImg; ++i1) {
        x1=x;
        y1=y;
        if (Math.random()<0.5) {
          if (Math.random()<0.5) x++;
          else x--;
        }
        else {
          if (Math.random()<0.5) y++;
          else y--;
        }
        if (x>=0 && x<TableWidth && y>=0 && y<TableHeight && CellsFilled[x+y*TableWidth]==0) {
          document.images[TableStartImg+x+y*TableWidth].src=ImgFolder + img[ImgsToDisplay[i2]] + ImgExtension;
          CellsFilled[x+y*TableWidth]=1;
          CountImgDisplayed[i2]++;
          i3++;
        }
        else {
          x=x1;
          y=y1;
        }
      }
      i2++;
      if (i2==CountImgAtOnce) i2=0;
    }
  } /*SetPath1*/

  function SetPath2() {
    for (i1=0; i1<CountImgAtOnce; ++i1)
      CountImgDisplayed[i1]=0;
    for (i1=0; i1<CountTableImg; ++i1)
      CellsFilled[i1]=0;
    i2=0;
    i3=0;
    i4=0; 
    dx=1;
    dy=0;
    dz=1;

    while (i3<CountTableImg) {
      x=Math.floor(Math.random()*TableWidth);
      y=Math.floor(Math.random()*TableHeight);
      if (Math.random()<0.5) dz=-1;
      else dz=1;
      for (i1=CountImgDisplayed[i2]; i1<MaxCountSingleImg; ++i1) {
        if (Math.random()<.5) {
          if (Math.random()<0.5) {
            dx=1;
            dy=0;
          } 
          else {
            dx=0;
            dy=1;
          }
        }
        x=x+dz*dx;
        y=y+dz*dy;

        if (x>=0 && x<TableWidth && y>=0 && y<TableHeight && CellsFilled[x+y*TableWidth]==0) {
          document.images[TableStartImg+x+y*TableWidth].src=ImgFolder + img[ImgsToDisplay[i2]] + ImgExtension;
          CellsFilled[x+y*TableWidth]=1;
          CountImgDisplayed[i2]++;
          i3++;      
          i4=0;
        }
        else {
          i4++;
          if (i4<4) i1--;
          x=x-dz*dx;
          y=y-dz*dx;
        }
      }
      i2++;
      if (i2==CountImgAtOnce) i2=0;
    }
  } /*SetPath2*/


  function ChooseNextImages() {
    for (i1=0; i1<CountImgAtOnce; ++i1) {
      ImgsToDisplay[i1]=Math.floor(Math.random()*CountTotalImg);
      while (AlreadyChosen[ImgsToDisplay[i1]]>0) {
        ImgsToDisplay[i1]=Math.floor(Math.random()*CountTotalImg);
      }
      AlreadyChosen[ImgsToDisplay[i1]]=CountBeforeDouble;
      if (PreLoad=="on") TempImg[i1].src=ImgFolder + img[ImgsToDisplay[i1]] + ImgExtension;
    }
    for (i1=0; i1<CountTotalImg; ++i1) AlreadyChosen[i1]-=CountImgAtOnce;
  } /*ChooseNextImages*/


  function RandomizeImages(SetTimer) {
    if (PreLoad=="on" && SetTimer>0 && CountReloads>0 && BrowserName=="Microsoft Internet Explorer" && navigator.appVersion.substring(0,1)>="4") {
      CountLoaded=0;
      for (i1=0; i1<CountImgAtOnce; ++i1) {
        if (TempImg[i1].complete==true) CountLoaded++;
      }
    }
    if (CountRetries>15 && CountLoaded==0) CountLoaded=CountImgAtOnce;

    if (CountLoaded==CountImgAtOnce) {
      CountRetries=0;
      ++CountReloads;
      i1=Math.floor(Math.random()*UseStyles.length);
      if (UseStyles[i1]=="diffuse") SetDiffuse();
      if (UseStyles[i1]=="lines1") SetDiagonal1();
      if (UseStyles[i1]=="lines2") SetDiagonal2();
      if (UseStyles[i1]=="spots") SetSpot();
      if (UseStyles[i1]=="paths1") SetPath1();
      if (UseStyles[i1]=="paths2") SetPath2();
      ChooseNextImages();
      if (LomoWallReload=="on" && SetTimer>0)
        ReloadTimer1=window.setTimeout("RandomizeImages(1)",ReloadAfterSeconds*1000);
    }
    else {
      ++CountRetries;
      ReloadTimer1=window.setTimeout("RandomizeImages(1)",2000);
    }
  } /*RandomizeImages*/


  function InitLomoWall() {
    while (document.images[TableStartImg].name!="tablestart") TableStartImg++;
    window.defaultStatus="";

    if ((CountImgAtOnce*MaxCountSingleImg)<(TableWidth*TableHeight)) MaxCountSingleImg=math.ceil((TableWidth*TableHeight)/CountImgAtOnce);
    if (CountBeforeDouble>=CountTotalImg-CountImgAtOnce) CountBeforeDouble=CountTotalImg-CountImgAtOnce-1;

    for (i1=0; i1<CountTotalImg; ++i1)
      AlreadyChosen[i1]=0;

    for (i1=0; i1<TableHeight; ++i1) {
      DiagStart1x[i1]=0;
      DiagStart1y[i1]=TableHeight-i1-1;
    }
    for (i1=1; i1<TableWidth; ++i1) {
      DiagStart1x[i1+TableHeight-1]=i1;
      DiagStart1y[i1+TableHeight-1]=0;
    }

    for (i1=0; i1<TableWidth; ++i1) {
      DiagStart2x[i1]=i1;
      DiagStart2y[i1]=0;
    }
    for (i1=1; i1<TableHeight; ++i1) {
      DiagStart2x[i1+TableWidth-1]=TableWidth-1;
      DiagStart2y[i1+TableWidth-1]=i1;
    }

    for (i1=0; i1<CountImgAtOnce; ++i1) {
      TempImg[i1]=new Image()
    }

    ChooseNextImages(); 
    RandomizeImages(1);
  } /*InitLomoWall*/


  function ClickOnTableImg(num) {
    if (PopUpLargeImg=="on") {
      i1=document.images[num+TableStartImg-1].src.lastIndexOf(ImgExtension);
      LImgSrc=document.images[num+TableStartImg-1].src.substring(0,i1)+LargeImgSuffix+ImgExtension;
		document.BigLomo.src=LImgSrc;
    }
    else RandomizeImages(0);
  } /*ClickOnTableImg*/


  function CreateTable(imgw,imgh) {
    i1=1;
    for (row=1; row<=TableHeight; ++row) {
      document.write("<tr>");
      for (col=1; col<=TableWidth; ++col) {
        txt="<td><a href='javascript:ClickOnTableImg("+i1+")'><img width="+imgw+" height="+imgh+" border=0></a></td>";
        if (i1==1) txt="<td><a href='javascript:ClickOnTableImg("+i1+")'><img width="+imgw+" height="+imgh+" border=0 name='tablestart'></a></td>";
        document.write(txt);
        ++i1;
      }
      document.write("</tr>");
    }
  } /*CreateTable*/
