//MVVM, 62.39.3-66.40.5, JS/FotoBlok.js                                           -->


//document.write('<link rel="stylesheet" href="',PathS,'CSS/FotoBlok.css" type="text/css" />');

PicsA = new Array();  // global array for all photo blocks

phS=document.location.search;
if (phS.substring(0,5)=='?phS=') phS=phS.substring(5);  // first 5 for '?phS='

instructionS="<span title='Ba3 ni3 xuan3ze2 de zhao4pian4 fang4 zai4 zhe4li'>"+
  "[&nbsp;&#25226;&#20320;&#36873;&#25321;&#30340;&#29031;&#29255;&#25918;&#22312;&#36825;&#37324;</span>&nbsp;/"+
  "<span lang='en'>&nbsp;put a photo of your choice here&nbsp;</span>]";
blockAlertS="Click one of the above miniatures and a copy of 515 "+
  "by 384 pixels will be shown here,\n"+
  "both on the screen and on paper (sometimes a copy of 512 pixels "+
  "wide or high).\n"+
  "Then keep it, hide it, click a miniature for a different enlargement "+
  "or remove both the miniature and\n"+
  "the enlargement. (There is a link at the bottom to get this page back with "+
  "all its miniatures.)\n"+
  "By clicking the enlargement itself the beginning of the series of miniatures "+
  "it belongs to will be shown\n"+
  "(again) at the top of the screen.\n"+
  "If you deleted the photo block, it will come back by clicking one of the "+
  "(remaining) miniatures in this \n"+
  "series, but not by clicking a miniature in a different series.";

function getBlockC_O(N,T)  // max is 7 (photo or text) blocks: A-G
 {
  var C="ABCDEFG".charAt(N-1);

  if (!T) C=C.toLowerCase();

  return(C)
 }

ShownT=new Array(7);  // initial display values for 7 blocks
for (var I=1; I<8; I++)
 {
  var J=phS.indexOf(getBlockC_O(I,true));
  if (J==-1) ShownT[I-1]=false;
   else ShownT[I-1]=true;
 }

function getPhotO(N)
 {
  var S="";
  var I=phS.indexOf(getBlockC_O(N,true));

  if (phS=="") S="a0000000";   // code for pic not yet selected
   else
    {
     if (I==-1)
      { I=phS.indexOf(getBlockC_O(N,false));
        if (phS.substring(I+1,I+3)=="00") S="a0a0a000";
      }            // code for pic selected and removed
     if (I==-1) S="a0000000";
     if (S=="")
      { S=phS.substring(I+1,I+3);
        I=parseInt(S,10);  // use 10, because default is octal=8!
        S=PicsA[N-1][I-1]
      }
    }

  return(S)
 }

function togglHideShO(idN)
 {
  var begS = "document.getElementById('";
  var midS = "Block_"+idN+"').style.display=";
  var I=-1;

  if (ShownT[idN-1]==false)
   {
    eval(begS+"Hide"+midS+"'block'");
    eval(begS+"Show"+midS+"'none'");
    eval(begS+"Text"+midS+"'block'");
    ShownT[idN-1]=true;
    I=phS.indexOf(getBlockC_O(idN,false))
    phS=phS.substring(0,I)+getBlockC_O(idN,true)+phS.substring(I+1);
   }
   else
   {
    eval(begS+"Hide"+midS+"'none'");
    eval(begS+"Show"+midS+"'block'");
    eval(begS+"Text"+midS+"'none'");
    ShownT[idN-1]=false;
    I=phS.indexOf(getBlockC_O(idN,true))
    phS=phS.substring(0,I)+getBlockC_O(idN,false)+phS.substring(I+1);
   }

  return false
 }

function writeRemovO(blockN,docS)
 {
  var I=phS.indexOf(getBlockC_O(blockN,true));
  var S=phS.substring(0,I)+getBlockC_O(blockN,false)+"00"+phS.substring(I+1);

document.write('<a href="',docS,'?phS=',S);
document.write('#Series',blockN,'" class="PhtBlTog">');
  // changes in phS after the creation of this link (such as hiding a
  // photo in a different series) will not be taken into account anymore
document.write('[remove photo]');
document.write('</a>')
 }

function writePhotoBlockO(blockN,dirS)
 {
  var picS=getPhotO(blockN);
  var docS="Beibian.htm";  // only doc in a lower-level dir
  var I=-1;

  if (document.URL.indexOf("Beibian.htm")==-1) 
   { docS=dirS.substring(9); I=docS.indexOf("/");
     docS=docS.substring(0,I)+".htm" }
  if ((docS=="Huoche.htm") || (docS=="Feiji.htm")) docS="HuoFei.htm";

  if ((picS<"a0000000") || (picS>"a0a0a000"))
   {
    if (ShownT[blockN-1]) shoS="block"; else shoS="none";
document.write('<div style="display:',shoS,'" id="HideBlock_',blockN,'"><span style="background:#8080ff">');
document.write('<a href="',docS,'" onclick="return togglHideShO(',blockN,')" class="PhtBlTog">');
document.write('[hide]');
document.write('</a>');
    writeRemovO(blockN,docS)
document.write('</span></div>');
    if (ShownT[blockN-1]) shoS="none"; else shoS="block";
document.write('<div style="display:',shoS,'" id="ShowBlock_',blockN,'"><span style="background:#8080ff">');
document.write('<a href="',docS,'" onclick="return togglHideShO(',blockN,')" class="PhtBlTog">');
document.write('[show]');
document.write('</a>');
    writeRemovO(blockN,docS);
document.write('</span></div>');
   }

document.write('<font size="-2"><br /></font>');

    if ((ShownT[blockN-1]) || (picS=="a0000000")) shoS="block"; else shoS="none";
document.write('<div style="display:',shoS,'" class="TxtBl" id="TextBlock_',blockN,'">');
  if (picS=="a0a0a000")
document.write('<table cellpadding="0" cellspacing="0" border="0">');
   else
document.write('<table cellpadding="4" cellspacing="0" border="0">');
document.write('<tr id="PhotoRow_',blockN,'"><td align="center">');
  if ((picS<"a0000000") || (picS>"a0a0a000"))
    { picS=picS.substring(0,8).toUpperCase(); // no V[ert.] or small letters 
document.write('<a href="#Series',blockN,'">');
document.write('<img src="',PathS+dirS+picS,'.jpg" alt="',picS,'"/ >');
document.write('</a>');
    }
   else
    {
     if (picS=="a0000000")
      {
document.write('<a href="javascript:alert(blockAlertS)" class="Instruct">');
document.write(instructionS);
document.write('</a>');
      }
    }
document.write('</td></tr></table>');
document.write('</div>');
 }

function renewPageO(S1,N1,N2)
 { // S1: htm file; N1: block/series number; N2: pic number
  var newPageS=S1+".htm";
  var I=-1;

  if (N2<10) N2="0"+N2;
  I=phS.indexOf(getBlockC_O(N1,true));
  if (I==-1) I=phS.indexOf(getBlockC_O(N1,false));
  if (I==-1) phS=phS+getBlockC_O(N1,true)+N2;
   else phS=phS.substring(0,I)+getBlockC_O(N1,true)+N2+phS.substring(I+3);
  newPageS=S1+".htm?phS="+phS+"#Block"+N1;

  window.location.replace(newPageS)
 }

function showMiniaturesO(blockN,S,wideT) 
 {
 var I=-1; var N=0; var delS="";
 var widthN=80; var heightN=60;
 var pageWidthN=540; var tot_widthN=0;  // 550;
 var dirS=S+"/";
 var pageSS="'Beibian'";  // Beibian.htm only doc in a lower-level dir
 var blockNS="'"+blockN+"'";
 var picS=""; var picNS="''";
 var posBlockC_N=0; var miniatureN=PicsA[blockN-1].length; var reloadPhS="";
 var miniaT=false;  // no miniature shown

 if ((S=="Zhongguo/Huoche") || (S=="Zhongguo/Feiji")) S="Zhongguo/HuoFei";
 if (S.indexOf("Beibian")==-1) 
  { S=S.substring(9);  // for docs in Zhongguo/ dir only!
    I=S.indexOf("/");
    if (I==-1) pageSS=S; else pageSS=S.substring(0,I);
    pageSS="'"+pageSS+"'" }

document.write('<table width="100%" border="0"><tr><td align="center">');

 for (N=1; N<=PicsA[blockN-1].length; N++)
  {
   I=phS.indexOf(getBlockC_O(blockN,true));
   if (I==-1) I=phS.indexOf(getBlockC_O(blockN,false));
   if (I>-1) { posBlockC_N=I; delS=phS.substring(I+3);
      for (I=0; I<99; I++)  // max number of deleted pics in a series 99
       {
        if ((delS.substring(2*I,2*I+2)=="") ||
            (delS.charAt(2*I)<"0") || (delS.charAt(2*I)>"9")) break;
         else
        if (parseInt(delS.substring(2*I,2*I+2),10)==N)  // use 10!
         { delS="deleted!"; break }
       }
    }
   if (delS!="deleted!")
    {
     picS=PicsA[blockN-1][N-1];
     if (picS.charAt(8)=="V") { widthN=60; heightN=80 }
      else { widthN=80; heightN=60 }
     tot_widthN+=widthN;
     if (!wideT) pageWidthN=480;  // 500;
     if (tot_widthN>pageWidthN)
      { document.write('<br />'); tot_widthN=widthN }
     picNS="'"+N+"'";
document.write('<a href="javascript:renewPageO(',pageSS,',',blockNS,',',picNS,')">');
     picS=picS.charAt(0)+"6"+picS.substring(2,8);
document.write('<img src="',PathS+dirS+picS,'.jpg" width="',widthN,'" height="',heightN,'" alt="',picS,'"/ >');
document.write('</a>');
     miniaT=true;
    }
  }
   if (!miniaT)
    {  // phS value may change after this link has been created!
     reloadPhS=phS.substring(0,posBlockC_N+3)+phS.substring(posBlockC_N+miniatureN*2+3);
document.write('<font color="#808080">[ <a href="?phS=',reloadPhS,'#Series',blockN,'">');
document.write('<font color="#808080">',miniatureN,' miniatures</font>');
document.write('</a> ]</font>');
    }
document.write('</td></tr></table>')
 }

function writeSeriesBlockO(blockN,S,wideT)
 {
document.write('<table width="600" bgcolor="#000000" background="">');
document.write('<tr><td align="center">');
  showMiniaturesO(blockN,S,wideT);
document.write('</td></tr>');
document.write('</table>');
document.write('<font size="-2"><br /></font>');
document.write('<a name="Block',blockN,'"> </a>');
  writePhotoBlockO(blockN,S+"/")
 }

FotoBlokT=true  // checks whether contents have been transferred
                // (on-line) and script (can be) executed


//Copyright 62-63 aSWW, M.Vincent van Mechelen, Amsterdam, NL
