// MVVM, 57.26.6-64.12.6 JS/HeadObjs.js at MVVM=mvvm.net and IN=www.xs4all.nl/~in/

/*
For JavaScript objects and files to be used inside the HTML head statement.
*/

function writeIncompletO(verS)  // verS not (yet) used
{
 var alertS="This page is not complete, due to a bad connection, an illicit "+
            "address, (an) external file(s) missing or a system failure!\n"+
            "If the address contains 'xs4all', the missing file(s) may be at mvvm.net.\n"+
            "Please, try again at mvvm.net/ or www.xs4all.nl/~in/ .";
 alert(alertS);
document.write('<br /><br /><font color="#000000">&nbsp;['+alertS+']&nbsp;</font>');
}

function SnifF()
//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));  // for Netscape 7
    // same as ( Nav4UpT && document.getElementById )

//  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 URL_S=document.URL;
  var url_S=URL_S; var endS='  ';
  var n=0;
  PathS='';
  MVVMPathS='http://mvvm.net/';
  INPathS='http://www.xs4all.nl/~in/';
  TRINPathS='http://www.trinp.org/';

  for (n=0;n<URL_S.length;n++)
  { if (URL_S.charAt(n)=="\\")
     URL_S=URL_S.substring(0,n)+"/"+URL_S.substring(n+1) };
  url_S=URL_S.toLowerCase()

  if ((url_S.indexOf('http://')>-1) || (url_S.indexOf('www.')>-1))
   {
   if (url_S.indexOf('www.xs4all.nl')>-1) PathS=INPathS; else PathS=MVVMPathS;
   }
   else  // off-line
   {
    n=url_S.length-1
    while (n>-1)
    {
     endS=url_S.substring(n);
     if ((endS.indexOf('/art/')>-1) ||
         (endS.indexOf('/en/')>-1) || (endS.indexOf('/en.htm')>-1) ||
         (endS.indexOf('/game/')>-1) ||
         (endS.indexOf('/info/')>-1) ||
         (endS.indexOf('/nl/')>-1) || (endS.indexOf('/nl.htm')>-1) ||
         (endS.indexOf('/poet/')>-1) ||
         (endS.indexOf('/sound/')>-1) || (endS.indexOf('/sound.htm')>-1) ||
         (endS.indexOf('/tong/')>-1) ||
         (endS.indexOf('/zhongguo/')>-1))
        {
         PathS=URL_S.substring(0,n+1); MVVMPathS=PathS; INPathS=PathS;
         if (n>1) TRINPathS=URL_S.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 defineBaseO()  // call this function from below when desired
{
 var localI=document.URL.toLowerCase().indexOf("/~in/")

 if (localI==-1) localI=document.URL.toLowerCase().indexOf("\\~in\\");
 if (localI>-1)  // 'contacT' at this stage still (always) false
  {
document.write('<base href="http://mvvm.net/',document.URL.substring(localI+5),'">')
  // for relative links (which do not make use of a variable such as 'PathS')
  // absolute links with PathS will be taken care of in BodyObjs.js
  }
}

function Get_FileChar()
 {
  var urlS=document.URL;
  fileC="0"; 
  if ((urlS.indexOf("En")>0) || (urlS.indexOf("ThL")>0))
      // in BodyFnct.js together with "Poet"
   { if (urlS.indexOf(".HTM")>0) fileC="6"; else fileC="1" };
  if ((urlS.indexOf("Dict")>0) || (urlS.indexOf("VocA")>0))  // temporary assignments
   { if (urlS.indexOf(".HTM")>0) fileC="9"; else fileC="4" };
  if ((urlS.indexOf("Nl")>0) || (urlS.indexOf("DzT")>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 adjustTitlO()
 {
  var titleS=document.title;  // should end with '&nbsp;' for spaces
  if (titleS.substring(0,6)=='MVVM: ') titleS=titleS.substring(6);
  if (titleS.substring(0,28)=='Vocabulary of Alliteration: ') titleS=titleS.substring(28);
   // name site/Vocabulary and lower case for search engines, not for site itself 
  var leftBrI=titleS.indexOf(' ('); var rightBrI=titleS.indexOf(') ');
  var bracketS=''; 
  if ((leftBrI>0) && (rightBrI>leftBrI+3))  // bracketed notes not to be capitalized
   { bracketS=titleS.substring(leftBrI); titleS=titleS.substring(0,leftBrI) }
  titleS=titleS.toUpperCase()+bracketS;
  var lenI=titleS.length;
  var spaC=titleS.substring(lenI-1);  // here '&nbsp;' not read as space

  document.title=titleS;
 }

function show_in_whole_windO()
 {
  var URL_S=document.URL;

  var n=URL_S.indexOf('VocALeft.htm');
  if (n>-1) URL_S=URL_S.substring(0,n)+'VocAll.htm';

  if (window.parent.frames.length==0) 
    window.location.href=URL_S;
   else window.parent.expandO(URL_S)
 }

function Write_HeadObjs()
 {
  var CSSVarS=""; var iconS="";
  var localI=document.URL.toLowerCase().indexOf("/~in/");

  if (fileC=="1") { CSSVarS=PathS+"CSS/GenNodal.css"; iconS=PathS+"En/MVVMEnO1.ico" };
  if (fileC=="2") { CSSVarS=PathS+"CSS/GenNodal.css"; iconS=PathS+"MVVMBiO1.ico" };
  if (fileC=="3") { CSSVarS=PathS+"CSS/GenNodal.css"; iconS=PathS+"Nl/MVVMNlO1.ico" };
  if (fileC=="4") { CSSVarS=PathS+"CSS/GenNodal.css";
      iconS=PathS+"Poet/VocAll/VoAT1.ico"; fileC="1" }
  if (fileC=="6") { CSSVarS=PathS+"CSS/GenBasic.css"; iconS=PathS+"En/MVVMEnO1.ico" };
  if (fileC=="7") { CSSVarS=PathS+"CSS/GenBasic.css"; iconS=PathS+"MVVMBiO1.ico" };
  if (fileC=="8") { CSSVarS=PathS+"CSS/GenBasic.css"; iconS=PathS+"Nl/MVVMNlO1.ico" };
  if (fileC=="9") { CSSVarS=PathS+"CSS/Dict.css";
      iconS=PathS+"Poet/VocAll/VoAT1.ico"; fileC="6" }

document.write('<link rel="Start" href="http://mvvm.net/index.htm" />');
document.write('<link rel="stylesheet" href="',PathS,'CSS/AllPages.css" type="text/css" />');
document.write('<link rel="stylesheet" href="',CSSVarS,'" type="text/css" />');
document.write('<link rel="shortcut icon" href="',iconS,'">');

  contacT=false; 
document.write('<script src="http://mvvm.net/JS/ContMVVM.js" type="text/javascript" language="JavaScript"></script>');
  // real 'contacT' value (T/F) not aquired until executing BodyObjs.js

document.write('<script src="',PathS,'JS/BodyObjs.js" type="text/javascript" language="JavaScript"></script>');
document.write('<script src="',PathS,'JS/PrePage.js" type="text/javascript" language="JavaScript"></script>');
document.write('<script src="',PathS,'JS/TopPart.js" type="text/javascript" language="JavaScript"></script>');
document.write('<script src="',PathS,'JS/FramSub.js" type="text/javascript" language="JavaScript"></script>');
document.write('<script src="',PathS,'JS/BotPart.js" type="text/javascript" language="JavaScript"></script>');
document.write('<script src="',PathS,'JS/PostPage.js" type="text/javascript" language="JavaScript"></script>');
 }

SnifF(); Get_PathS(); Get_FileChar(); adjustTitlO();
defineBaseO();  // should only be called, if it will turn out that contacT=true,
Write_HeadObjs();
document.ondblclick=show_in_whole_windO;

HeadObjsT=true  // checks whether contents have been transferred
                // (on-line) and scripts (can be) executed

// Copyright 57-64 ASWW, M.Vincent van Mechelen, Amsterdam, Netherlands