

var 
//** Slide show vars
photoArray,
textArray,
voArray = "",
preLoadArray,
routeMap,                 // hold JPG of routemap
numPhotos,                // number of photos
photoNumber       = 1,
crossFadeDuration = 2,    // Set the duration of crossfade (in seconds)
loadedPictures    = 1,

//** color setting vars
globBgColor,               // background color
globFgColor,               // foreground color
globLkColor,               // link color
globALkColor,              // alink color
globVLkColor,              // vlink color
globNavOn,                 // navigation ON

/** Progress bar vars   **/
barheight         = 30,     // in pixels                                             
barwidth          = 400,                                              
baranchor,                  // id of style baranchor
bar,                        // id of style bar
barbackground,              // id of style barbackground
blocksize,

/** For the seagull   **/
xpositie         = -200,
ypositie         = 0,
klokje           = null;


/** Needed for setting the cookie   **/
var expDays = 60;
var exp = new Date(); 
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));


/** last date modification route  **/
var modificationDateRoute = new Date(2004, 10, 21);




function wachtwoord()
{
  var password = prompt("Toets het wachtwoord in:", "")
  var location=password + ".html";
  this.location.href = location;
}

function initArray() 
{
   this.length = initArray.arguments.length;
   for (var i = 0; i < this.length; i++)
   this[i+1] = initArray.arguments[i];
}


var maandArray = new initArray("jan","feb","maart","april","mei","juni",
                               "juli", "aug","sep","okt","nov","dec");

function changeFormatDate(datum) 
{
   var weekdag = datum.getDay() + 1;
   var dag = datum.getDate();
   var maand = datum.getMonth() + 1;
   var jaar = datum.getYear();

   if (jaar < 70) 
   {
      var jaar4 = (jaar + 2000);
   }
   else
   {
      var jaar4 = ((jaar < 1900) ? (jaar + 1900) : (jaar));
   }

   var datumwaarde = dag + " " + maandArray[maand] + " " + jaar4;
   return datumwaarde;
}

/****************************************************************/
/***     display on HTML-page                                 ***/
/****************************************************************/
function displayModificationDate(fontType, text) 
{
//var modificationDate = new Date(document.lastModified);
//var modDateInFormat = changeFormatDate(modificationDate);

var modDateInFormat = changeFormatDate(modificationDateRoute);
document.write(fontType + text + modDateInFormat + fontType);

}




function getStyle( layer ) 
{
  if( document.getElementById )
  {
    return document.getElementById( layer ).style
  }
  else if( document.all )
  {
     return document.all[layer].style
  }
  else
  {
     return document[layer]
  }
}

function vlieg()
{
   if ( xpositie < 2000 )
   {
   	xpositie = xpositie + 5

        if (xpositie > 650)
        {
             getStyle('vogel').top = ypositie
             ypositie = ypositie - 1
     
        }

  	getStyle('vogel').left = xpositie

  	klokje = setTimeout( 'vlieg()', 10 )
   }
   else
   {
      xpositie = -200
      ypositie = 0
   }
}

/*
function stop() 
{
   clearTimeout( klokje )
}
*/

// var iss;
var i = 0;
// var pss = photoArray.length-1;

/*******************************************************/
/*******  control()                           **********/
/*******************************************************/
function control(how)
{
if (how=="H") photoNumber = 1;
if (how=="F") photoNumber = photoNumber + 1;
if (how=="B") photoNumber = photoNumber - 1;
if (photoNumber > (numPhotos)) photoNumber=1;
if (photoNumber < 1) photoNumber = numPhotos;
if (document.all)
{
   document.images.PictureBox.style.filter="blendTrans(duration=2)";
   document.images.PictureBox.style.filter="blendTrans(duration=CrossFadeDuration)";
   document.images.PictureBox.filters.blendTrans.Apply();
}

document.images.PictureBox.src = preLoadArray[photoNumber].src;

if (document.getElementById) 
{
	document.getElementById("photoNumBox").innerHTML= photoNumber;// + ". " ;
    document.getElementById("CaptionBox").innerHTML = textArray[photoNumber];
}
if (document.all) document.images.PictureBox.filters.blendTrans.Play();
}


/*******************************************************/
/*******  text_route()                        **********/
/*******************************************************/
function text_route()
{
    var loop1;

    //var modificationDate = new Date(document.lastModified);
    var modDateInFormat = changeFormatDate(modificationDateRoute);

    numPhotos = photoArray.length-1;

    myWin = window.open('', 'Route','width=700, height=1000, left=0,screenX=0,top=0,screenY=0,resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no');  

    myWin.document.open();
    myWin.document.write('<html><head><title>Route beschrijving</title>');
    myWin.document.write('<style type="text/css">');
    myWin.document.write('li {font-family: "Comic Sans MS"; font-size: 18px; font-weight: normal; color: #000000;}');
    myWin.document.write('h2 {font-family: "Comic Sans MS"; font-size: 18px; font-weight: normal; color: #000000;}');
    myWin.document.write('h4 {font-family: "Comic Sans MS"; font-size: 24px; font-weight: normal; color: #000000;}');
    myWin.document.write('</style>');

    myWin.document.write('</head><body>');
    myWin.document.write('<form><input type="button" Value="Start printen" onClick="window.print()">');
    myWin.document.write('&nbsp;&nbsp;&nbsp;');
    myWin.document.write('<input type="button" Value="Sluit venster" onClick="self.close()">');
    myWin.document.write('&nbsp;&nbsp;&nbsp;&nbsp;laatste update route: ' + modDateInFormat);
    myWin.document.write('</form>');
    myWin.document.writeln( '<h4>' + textArray[0]+ '</h4>'); 

    myWin.document.writeln('<ol>');
    for (loop1 = 1; loop1 <= numPhotos; loop1++)
    {
        myWin.document.writeln( '<li>' + textArray[loop1] + '</li>');
    }
    myWin.document.write('</ol>');


    if ( voArray.length > 0)
    {
        myWin.document.writeln( '<h2>' + voArray[0] + '</h2>');
    
        myWin.document.writeln('<ol>');
    
        for (loop1 = 1; loop1 < voArray.length; loop1++)
        {
            myWin.document.writeln( '<li>' + voArray[loop1] + '</li>');
        }

        myWin.document.write('</ol>');
    
    }
    myWin.document.write('</body></html>');
    myWin.document.close();
}


/*******************************************************/
/*******  text_route_plus_fotos()             **********/
/*******************************************************/
function text_route_plus_fotos()
{
    var 
	loop1,
	row;
	
	//document.write( window.screen.width + " x " + window.screen.height );
    
	
//    myWin = window.open('', 'Route','width=300,height=650, screenTop=0,screenLeft=0,resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no');  
    myWin = window.open('', 'Route','width=700, height=1000, left=0,screenX=0,top=0,screenY=0,resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no');  
    myWin.document.open();
	// window.resizeTo(300, 1000);

	myWin.document.write('<html><head><title>Route beschrijving</title>');
    myWin.document.write('<style type="text/css">');
    myWin.document.write('table td {vertical-align: top; padding-top: 5mm;	padding-right: 5mm;	padding-bottom: 5mm; padding-left: 5mm; font-family: "Comic Sans MS"; font-size: 18px; font-weight: normal; color: #000000;}');
    myWin.document.write('h4 {font-family: "Comic Sans MS"; font-size: 24px; font-weight: normal; color: #000000;}');
    myWin.document.write('</style>');
    myWin.document.write('</head><body>');
    //myWin.document.fgColor="yellow";
    //myWin.document.bgColor="black";

    myWin.document.write('<form><input type="button" Value="Start printen" onClick="window.print()">');
    myWin.document.write('&nbsp&nbsp&nbsp');
    myWin.document.write('<input type="button" Value="Sluit venster" onClick="self.close()"></form>');
    myWin.document.writeln( '<h4>' + textArray[0]+ '</h4>'); 
    myWin.document.writeln('<br>');
    myWin.document.writeln('<table>');
    //myWin.document.writeln('<br>');
	
    for (loop1 = 1; loop1 <= numPhotos; loop1++)
    {
	   row =  '<tr>' + '<td>' + loop1 + '</td>';
       row += '<td>' + textArray[loop1] + '</td>';
       row += '<td><img  src="' + photoArray[loop1] + '"  width=320 height=200></td>';
       row += '</tr>';
       myWin.document.writeln(row);
    }
	
    myWin.document.write('</table></body></html>');
    myWin.document.close(); // jw
}



/*******************************************************/
/*******  route_kaart()                       **********/
/*******************************************************/
function route_kaart(route)
{
    var nameMap;

    //nameMap = "kaart_" + route + ".jpg";

    if (route == 'lbs'|| route == 'sle' || route == 'kee')
          nameMap = "kaart_" + route + ".gif";
    else
          nameMap = "kaart_" + route + ".jpg";

    //alert('nameMap = ' + nameMap );

    myWin = window.open('', 'Route','width=700, height=1000, left=0,screenX=0,top=0,screenY=0,resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no');  

    myWin.document.open();
    myWin.document.write('<html><head><title>Routekaart');
    myWin.document.write("   " + route);
    myWin.document.write('</title></head><body>');
    //myWin.document.fgColor="yellow";
    //myWin.document.bgColor="black";

    myWin.document.write('<form><input type="button" Value="Start printen" onClick="window.print()">');
    myWin.document.write('&nbsp&nbsp&nbsp');
    myWin.document.write('<input type="button" Value="Sluit venster" onClick="self.close()"></form>');

    myWin.document.write('<img src=geen_foto.jpg name=kaartjeBox height=850>');
    //myWin.document.write('<img src=geen_foto.jpg name=kaartjeBox>');

    routeMap                            = new Image();         
    routeMap.src                        = nameMap;
    myWin.document.kaartjeBox.src       = routeMap.src;

    myWin.document.write('</body></html>');
    myWin.document.close();
}


/*******************************************************/
/*******  initProgressBar()                   **********/
/*******************************************************/
function initProgressBar()
{
    document.write('<div id="baranchor"     style="position:relative; left:70; top:-400;  width:400px;height:30px;visibility:hidden; background-color:red;">')
    document.write('<div id="barbackground" style="position:absolute; left:0;  top:0;     width:400px;height:30px;z-index:9; background-color:black;"> <center>Fotos laden......&nbsp;even geduld s.v.p.</center></div>')
    document.write('<div id="bar"           style="position:absolute; left:0;  top:0;     width:400px;height:30px;z-index:10;background-color:blue;">  <center>Fotos laden......&nbsp;even geduld s.v.p.</center></div>')
    document.write('</div>')

    //bar.style.clip = 'rect(0 0 '+barheight+' 0)';
}


/*******************************************************/
/*******  preLoadPictures()                   **********/
/*******************************************************/
function preLoadPictures()
{
    var loop2;

    numPhotos = photoArray.length-1;

    //alert('numPhotos = ' + numPhotos );

    preLoadArray  = new Array(photoArray.length);

    //  deze statements zijn nodig
	if (document.all)
    {
       baranchor     = document.all.baranchor;
       barbackground = document.all.barbackground;
       bar           = document.all.bar;

       bar.style.clip            = 'rect(0 0 '+barheight+' 0)';
       //barbackground.style.clip  = 'rect(0 400 '+barheight+' 0)';

       baranchor.style.visibility = "visible";
    }
	
    //bar.style.background-color = blue;

    for (loop2 = 1; loop2 <= numPhotos; loop2++)
    {
        preLoadArray[loop2]       = new Image();
        preLoadArray[loop2].src   = photoArray[loop2];
        setTimeout('checkload('+loop2+')' ,loop2*100);
    }
}

/*******************************************************/
/*******   checkload()                        **********/
/*******************************************************/
function checkload(index)
{
    (preLoadArray[index].complete) ? displayBar() : setTimeout('checkload('+index+')', 100);
}


/*******************************************************/
/*******    displayBar()                      **********/
/*******************************************************/
function displayBar()
{
    loadedPictures ++;

    blocksize = barwidth/(photoArray.length);

    bar.style.clip = 'rect(0 '+blocksize*loadedPictures+' '+barheight+' 0)';

    if ( loadedPictures >= photoArray.length-1)  setTimeout('hidebaranchor()', 800);
}



/*******************************************************/
/*******  hidebaranchor()                     **********/
/*******************************************************/
function hidebaranchor()
{
    baranchor.style.visibility   = "hidden";
}


function setBackgroundColor(Color)
{
   document.bgColor = Color;
}

function setForegroundColor(Color)
{
   document.fgColor = Color;
}

function setLinkColor(Color)
{
   document.linkColor  = Color;
   document.alinkColor = Color;
   document.vlinkColor = Color;   // deze heeft effect
}


function readCookieAndSetColors()
{
   var globBgColor  = GetCookie('achtergrondkleur');
   var globFgColor  = GetCookie('voorgrondkleur');
   var globLkColor  = GetCookie('linkkleur');
   var globALkColor = GetCookie('alinkkleur');
   var globVLkColor = GetCookie('vlinkkleur');

   if (globBgColor == null)  document.bgColor    = 'black';
   else                      document.bgColor    = globBgColor;
   
   if (globFgColor == null)  document.fgColor    = 'silver';
   else                      document.fgColor    = globFgColor;
   
   if (globLkColor == null)  document.linkColor  = 'lightgreen';
   else                      document.linkColor  = globLkColor;
   
   if (globALkColor == null) document.alinkColor = 'lightgreen';
   else                      document.alinkColor = globALkColor;
   
   if (globVLkColor == null) document.vlinkColor = 'lightgreen';
   else                      document.vlinkColor = globVLkColor;
   
   
   return;
}


function onUnloadConfig () 
{ 
    globFgColor   = document.fgColor;
    globBgColor   = document.bgColor;
    globLkColor   = document.linkColor;
    globALkColor  = document.alinkColor;
    globVLkColor  = document.vlinkColor;

    //alert('globBgColor = ' + globBgColor );

    // initCookie();

    SetCookie('achtergrondkleur',  globBgColor, exp);
    SetCookie('voorgrondkleur',    globFgColor, exp);
    SetCookie('linkkleur',         globLkColor, exp);
    SetCookie('alinkkleur',        globALkColor, exp);
    SetCookie('vlinkkleur',        globVLkColor, exp);
    SetCookie('navigatiebalk',     globNavOn, exp);
    return;
}


function getCookieVal (offset)
{  
   var endstr = document.cookie.indexOf (";", offset);  
   if (endstr == -1)    
   endstr = document.cookie.length;  
   return unescape(document.cookie.substring(offset, endstr));
}


function GetCookie (name) 
{  
var arg = name + "=";  
var alen = arg.length;  
var clen = document.cookie.length;  
var i = 0;  
while (i < clen)
{    
   var j = i + alen;    
   if (document.cookie.substring(i, j) == arg)      
   return getCookieVal (j);

   i = document.cookie.indexOf(" ", i) + 1;    
   if (i == 0) break;   
}  
return null;
}


function initCookie() 
{
   var expDays = 30;
   var exp = new Date(); 
   exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
}


function SetCookie (name, value) 
{  
var argv = SetCookie.arguments;  
var argc = SetCookie.arguments.length;  
var expires = (argc > 2) ? argv[2] : null;  
var path = (argc > 3) ? argv[3] : null;  
var domain = (argc > 4) ? argv[4] : null;  
var secure = (argc > 5) ? argv[5] : false;

document.cookie = name + "=" + escape (value) + 
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
((path == null) ? "" : ("; path=" + path)) +  
((domain == null) ? "" : ("; domain=" + domain)) +    
((secure == true) ? "; secure" : "");
}



function DeleteCookie (name)  /** not used   **/
{  
   var exp = new Date();  
   exp.setTime (exp.getTime() - 1);  
   var cval = GetCookie (name);  
   document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

function test ()  /** not used   **/
{  
   //var =0
}


