// MVVM, 56.14.2-65.36.3, JS/BodyFnct.js at MVVM/IN = mvvm.net

/*
This JS file is only used by old HTML files.
Up-to-date HTML files make use of HeadObjs.js, which, in turn,
refers to other external files, such as BodyObjs.js. 
*/

//===start browser sniffer===
// NetscapeT = navigator.appName.indexOf("Netscape")!=-1;
// if (NetscapeT)
//  { if (navigator.appVersion<"4.5") Netsc45T=false; else Netsc45T=true };

function SnifF(globvarT)
 {
  var agtS = navigator.userAgent.toLowerCase();
  var majorI = parseInt(navigator.appVersion);
  var ieT = (agtS.indexOf("msie")!=-1);
  var navT = ((agtS.indexOf("mozilla")!=-1) && (agtS.indexOf("spoofer")==-1)
   && (agtS.indexOf("compatible")==-1) && (agtS.indexOf("opera")==-1)
   && (agtS.indexOf("webtv")==-1));
  var len;
  IE4UpT = ( ieT && (majorI>=4));
  Nav4UpT = ( navT && (majorI>=4));
  Nav5UpT = ( navT && (majorI>=5));  // added on 61.31.4

//  if ((!globvarT)&&(Nav4UpT))
//   { len=document.cookie.length;
//     if (document.cookie.substring(len-3,len)!="CSS")
//      { if (!window.confirm("Press OK if your browser has a style "+
//"sheet facility and style sheets are enabled; otherwise press CANCEL. "+
//"(Some Netscape browsers that cannot cope with boxes defined in style "+
//"sheets may give an error message; with older systems the program may "+
//"even stop running completely when trying to use style sheets in this way.)"))
//          document.cookie="noCSS";
//         else document.cookie="okCSS";
//      }
//     len=document.cookie.length;
//     if (document.cookie.substring(len-5,len)=="noCSS") Nav4UpT=false
//   }

 }

//===end browser sniffer===

function Get_PathS()
 {
  var urlS=document.URL.toLowerCase(); var endS='';
  var n=0;
  PathS=''; TRINPathS=''  // global variables

  for (n=0;n<urlS.length;n++)
  { if (urlS.charAt(n)=="\\")
     urlS=urlS.substring(0,n)+"/"+urlS.substring(n+1) };
  if ((urlS.indexOf('http://')>-1) || (urlS.indexOf('www.')>-1))
    { PathS='http://www.xs4all.nl/~in/';
      MVVMPathS='http://mvvm.net/';  // now defined in HeadObjs.js
      TRINPathS='http://www.trinp.org/' }
   else
   {
    n=urlS.length-1
    while (n>-1)
    {
     endS=urlS.substring(n);
     if ((endS.indexOf('/en/')>-1) || (endS.indexOf('/game/')>-1) ||
         (endS.indexOf('/nl/')>-1) || (endS.indexOf('/poet/')>-1))
        {
         PathS=urlS.substring(0,n+1); MVVMPathS=PathS;
         if (n>1) TRINPathS=urlS.substring(0,n-2)+'TRINP/';
          // TRINPathS works only if using TRINP directory
          // and two-letter name like IN for IN directory  
         n=-1
        }
      else { n-- }
    } 
    if (PathS=='')
     alert('JavaScript links such as those in the floating menus will not '+
           'work because of a change in the off-line directory structure '+
           'or names. (Put the MVVM files in an IN and the TRINPsite files '+
           'in a TRINP directory.)'); 
   }
 }

function Get_FileChar()
 {
  var urlS=document.URL;
  fileC="0"; 
  if ((urlS.indexOf("En")>0) || (urlS.indexOf("Poet")>0))
   { if (urlS.indexOf(".HTM")>0) fileC="6"; else fileC="1" };
  if (urlS.indexOf("Nl")>0) // does not include 'nl' in 'xs4all.nl'
   { if (urlS.indexOf(".HTM")>0) fileC="8"; else fileC="3" };
  if (fileC=="0")  // rest bilingual documents
   { if (urlS.indexOf(".HTM")>0) fileC="7"; else fileC="2" };
 }

function CopyrightF(S) // parameter S not (yet) used
 {
  var enS = "The initials MVVM stand for M. Vincent van Mechelen, "+
"the letters ASWW stand for (the number of years) after the Second World War. "+
"For more information go to the index page and click on 'Personal data' or "+
"click on the (Metric) date at the top of this page.";
  var nlS = "De initialen MVVM staan voor M. Vincent van Mechelen, "+
"de letters NTWO staan voor (het aantal jaren) na de Tweede Wereldoorlog. "+
"Voor meer informatie ga naar de indekspagina en klik op 'Persoonlijke "+
"gegevens' of klik op de (Metrische) datum bovenaan deze pagina.";

  if ((fileC=='1') || (fileC=='6')) alert(enS);
   else
   { if ((fileC=='3') || (fileC=='8')) alert (nlS);
      else alert(enS+'\n\n'+nlS) }
 }

function withoutVarO(S)  // added on 65.36.3, from BodyObjs.js
{
 var N=S.indexOf('?');

 if (N>0) S=S.substring(0,N);
 N=S.indexOf('#');
 if (N>0) S=S.substring(0,N);

 return S
}

//===start source code for StatWind(T)===
/*
Copyright (C) 53-56 ASWW, M. Vincent van Mechelen. All Rights Reserved.
This script may be re-used for non-commercial puposes, if credit is
given to the author and to TRINPsite in the source code.
*/

function Greg_to_Metr(yChrEI,mGregI,dGregI)
{
 this.year=yChrEI-1945;
 if (mGregI==1) add_days=10;    if (mGregI==2) add_days=41;
 if (mGregI==3) add_days=69;    if (mGregI==4) add_days=100;
 if (mGregI==5) add_days=130;   if (mGregI==6) add_days=161;
 if (mGregI==7) add_days=191;   if (mGregI==8) add_days=222;
 if (mGregI==9) add_days=253;   if (mGregI==10) add_days=283;
 if (mGregI==11) add_days=314;
 if (mGregI==12)
  { if (dGregI<22) yr_day=344+dGregI;
     else { this.year=this.year+1; yr_day=dGregI-21 }
  }
  else  yr_day=dGregI+add_days;

 this.day=0;
 if (yChrEI%4==0)  // Gregorian leap year
  { if (yr_day>69 && mGregI>2)
     { yr_day=yr_day+1;
       if (yr_day==366) { this.week=52; this.day=8 }
     }
  }

 if (yr_day==183) { this.week=26; this.day=8 };
 if (this.day==0)
 { if (yr_day>182) yr_day=yr_day-1;
   this.day=1+((yr_day-1)%7);
   this.week=1+((yr_day-this.day)/7) }

 this.month=Math.floor((this.week+3)/4);
}
function two_digitS(number)
{
 numberS=number;
 if (number<10) numberS="0"+numberS
 return(numberS)
}
function TodayF()
{
 today=new Date();
 yChrE=today.getYear();
 if (yChrE<2000)
 { if (yChrE>99) yChrE=yChrE+1900;
    else yChrE=yChrE+2000 }
 mGreg=today.getMonth()+1; dGreg=today.getDate();
 Today= new Greg_to_Metr(yChrE,mGreg,dGreg);
 yNow=Today.year;
 mNow=Today.month; month_noS=two_digitS(mNow);
 wNow=Today.week; week_noS=two_digitS(wNow);
 dNow=Today.day;
}

function StatWind(T)
{
 TodayF();
 if ((fileC=="3") || (fileC==8)) { beginS="Vandaag is het " }
  else { beginS="Today's date is " }
 dateS=yNow+"."+week_noS+"."+dNow;
 endS="";
  if ((week_noS=="01")&&(dNow==1)) endS=".  HAPPY NEW YEAR!"
// if (T)
   window.defaultStatus=beginS+dateS+endS;
//  else document.write(dateS);
}
//===end source code for StatWind(T)===

//===start source code for MenuF()===

 function Get_Variables()
 {
  if (Nav4UpT)
   { topS = ".top="; lftS = ".left="; docS = "document."; stlS = "";
     xS = "window.pageXOffset"; yS = "window.pageYOffset";
     x_inner = eval("window.innerWidth") - 116;
//     eval(docS + "HeadRight" + stlS + ".width=116")
   }
   else
   { topS=".pixelTop="; lftS=".pixelLeft="; docS="document.all.";
     stlS=".style";
     xS = "document.documentElement.scrollLeft";
     yS = "document.documentElement.scrollTop";
     x_inner = eval("document.body.clientWidth") - 100 }
  x0=eval(xS); y0=eval(yS);
  objectL="HeadLeft"; objectR = "HeadRight"
 }

 function Locate_Boxes()
 {
  if ((Nav4UpT) || (eval(yS)>0)) ydiff = y0 - eval(yS);
   else ydiff = y0 - eval("document.body.scrollTop");
    // for browsers for which 'documentElement' is always 0 or undefined
  if (ydiff<0) ydiff = ydiff-5; else ydiff = ydiff+4;
  if ((ydiff < -1) || (ydiff >1))
   { movey = Math.round(ydiff/10); y0 = y0 - movey };

  if (moveLefT) eval(docS + objectL + stlS + topS + y0);
   else eval(docS + objectL + stlS + topS + 0);
  eval(docS + objectL + stlS + lftS + 0);
  if (moveRighT) eval(docS + objectR + stlS + topS + y0);
   else eval(docS + objectR + stlS + topS + 0);
  eval(docS + objectR + stlS + lftS + (x0 + x_inner));

  setTimeout("Locate_Boxes()", 10);
 }

 function MenuF(S) // no use is made (yet) of the (string) parameter
 {
  var topS=""; var lftS=""; var docS=""; var stlS="";
  var xS=""; var yS=""; var x0=0; var y0=0; var ydiff=0; var movey=0;
  moveLefT=true; moveRighT=true;

  Get_Variables(); Locate_Boxes();
 }

 function Turn_Menu(lefT,onT) // 'false, false'='right off'
 {
  var SideS="Left"; if (!lefT) SideS="Right";
  var VisS="Menu"; var HidS="Head";
  if (!onT) { VisS="Head"; HidS="Menu" }
  eval(docS + HidS+SideS + stlS + ".visibility='hidden'");
  eval(docS + VisS+SideS + stlS + ".visibility='visible'");
  if (lefT) objectL=VisS+"Left";
   else { objectR=VisS+"Right"; if (Nav4UpT)
           eval(docS + objectR + stlS + ".width=116") }
 }
function turnMenuL(T) { Turn_Menu(true,T) }  // for use in onmouseover="..." & onmouseout="...";
function turnMenuR(T) { Turn_Menu(false,T) }  // otherwise error message when using VBScript too

 function Switch_Move(SideS)
 {
  if (SideS=="Left")
   { if (moveLefT) moveLefT=false; else moveLefT=true };
  if (SideS=="Right")
   { if (moveRighT) moveRighT=false; else moveRighT=true };
 }

//===end source code for MenuF(S)===

//===start source code for Load_Images() and Show_Pic(S,T)===

function Load_ImgTopC()
 {
  AdTopC_On = new Image(570,45);
  AdTopC_On.src = PathS+"Graf/VLP/ArrTopC"+fileC+".gif";
  AdTopC_Off = new Image(570,45);
  AdTopC_Off.src = PathS+"Graf/VLP/NewTopC"+fileC+".gif";
 }
function Load_ImgBotL()
 {
  AdBotL_On = new Image(200,100);
  AdBotL_On.src = PathS+"Graf/VLP/ArrBotL"+fileC+".gif";
  AdBotL_Off = new Image(200,100);
  AdBotL_Off.src = PathS+"Graf/VLP/NewBotL"+fileC+".gif";
 }
function Load_ImgBotR()
 {
  AdBotR_On = new Image(200,100);
  AdBotR_On.src = PathS+"Graf/VLP/ArrBotR"+fileC+".gif";
  AdBotR_Off = new Image(200,100);
  AdBotR_Off.src = PathS+"Graf/VLP/NewBotR"+fileC+".gif";
 }
function Load_Images()
 {
 Load_ImgTopC(); Load_ImgBotL(); Load_ImgBotR();
 }

function Show_Pic(plaS,onT)
{
 var addrS="";
 if (plaS.length==5) plaS=plaS.substring(0,4); 
                     // new plaS value does not have a fileC at end anymore!
 if (plaS=="TopC") { OnS=AdTopC_On.src; OffS=AdTopC_Off.src }
 if (plaS=="BotL") { OnS=AdBotL_On.src; OffS=AdBotL_Off.src }
 if (plaS=="BotR") { OnS=AdBotR_On.src; OffS=AdBotR_Off.src }
                      // place of picture in image table depends on browser!
 for (n=0; n<document.images.length; n++)
 { addrS=document.images[n].src; lI=addrS.length;
   addrS=addrS.substring(lI-9);
   if (addrS==plaS+fileC+".gif")
    { if (onT) document.images[n].src=OnS;
       else document.images[n].src=OffS;
      break }
 }
}
function showPicTC(T) { Show_Pic('TopC',T) }  // for use in onmouseover="..." &
function showPicBL(T) { Show_Pic('BotL',T) }  // onmouseout="..."; otherwise error
function showPicBR(T) { Show_Pic('BotR',T) }  // message when using VBScript too

//===end source code for Load_Images() and Show_Pic(S,T)===

function determine_DimensiO()
{  // global total structure variables (from BodyObjs.js)
 var searchS=document.location.search;
 hypoResolutioN=0;  // hypothetical resolution width (0, if not given)
 displayWidN=640;
   // display width = print width for real resolution of '1024' (1003-1007)
 windoWidthN=(2*displayWidN)+52  // ideally (display+16+display+20+16)
 iFrameT=true;  // one or more iframes by default
 puzzlT=false;  // by default not a puzzle (with always one iframe)

 if (Nav4UpT) displayWidN=670;
   // centering only without iframes on screen
   // for XP system 720 pixels instead of 670

 if (searchS.indexOf('iFrameT=false')>0) iFrameT=false;
  else { if (searchS.indexOf('iFrameT=true')>0) iFrameT=true }

 if (Nav4UpT) windoWidthN = eval("window.innerWidth")-20;
    // 17-20 for scrollbar at right; otherwise scrollbar at bottom
  else
   { windoWidthN = eval("document.body.clientWidth")-4;
     if (navigator.appVersion.indexOf("MSIE 8")>-1)
      windoWidthN=windoWidthN-13 }

 hypoResolutioN=windoWidthN;
 if (hypoResolutioN<600) hypoResolutioN=600;

 if (hypoResolutioN>1050)
  {
   if (hypoResolutioN<1301)
     displayWidN=650+Math.ceil((hypoResolutioN-1050)/50)*50;
    else displayWidN=900;  // max display width: 100+50+600+150
  }
}

function InsLoad(S) // here variables not global for whole document!
{
 var verS=S;
 if (verS<"56454")
  { iFrameT=false; puzzlT=false; hearT=false }

 StatWind(true) // for Metric date and/or message in status window
 SnifF(false);

 if ((verS>"56156") && (IE4UpT || Nav4UpT)) MenuF(S);
  // for menu boxes at top left and top right
}

function InsUnLd(S) {  }

function OutsLoad(S) // here variables may be global for whole document
{
 var urlS=document.URL.toLowerCase();
 var x_inner=0;
 contacT=true;  // this old file is not used with new HeadObjs.js
 iFrameT=false;  // may be made true below

 SnifF(true); Get_PathS(); Get_FileChar();

 if ((urlS.indexOf('http://mvvm.net')>-1) || (PathS.indexOf('/IN/')>-1)) 
  {
   if (Nav4UpT) x_inner = eval("window.innerWidth");
    else  x_inner = eval("document.body.clientWidth");
   if (x_inner>900) iFrameT=true
  }
   // added on 60.40.4-61.31.3, because error message without new BodyObjs.js   

 Load_Images() // for 3 interactive top and bottom images in threefold
}

function OutsUnLd(S) {  }

HeadObjsT=false; BodyObjsT=false;  // HTML files using BodyFnct.js did not
                            // yet make use of HeadObjs.js and BodyObjs.js

//Copyright 56-65 asWW, M.Vincent van Mechelen, Amsterdam, Netherlands