
   var isIE = (window.navigator.userAgent.indexOf("MSIE") > 0);

   if (! isIE) {
      HTMLElement.prototype.__defineGetter__("innerText", 
              function () { return(this.textContent); });
      HTMLElement.prototype.__defineSetter__("innerText", 
              function (txt) { this.textContent = txt; });
   }
   
var currentimage = -1;
var timeoutid = -1;      
   
function Startslideshow(imagecount){ 

if (currentimage < 0){

    if (imagecount == -1) {
        imagecount = currentimage;
    }else if (imagecount == -2){
        imagecount = -1;    
    }
}else{
    imagecount = currentimage;
    //alert('start: ' + currentimage);
}    
    //var test = "Showfoto(" + (imagecount+1) + ",'volgende')";
    var aantal  = imagearray.length ;
    var href = document.getElementById('slideshow')
   
    
    href.innerText = 'Stop Diashow';
    href.href = "javascript:stopdiashow(" + imagecount + ")";
    
    if (aantal <= (imagecount+1)) {
        clearTimeout(timeoutid);
        stopdiashow(0);
    }else{
    document.getElementById('controls').style.display = 'none' ;
    Showfoto(imagecount+1,'volgende') ;
    timeoutid = setTimeout(("Startslideshow(" + (imagecount+1) + ")"), 6000);
    }
}

function stopdiashow(imagecount){
    var aantal = imagearray.length ;
    if (currentimage == (aantal-1)) {
        imagecount = -2 ;
    }else{
        imagecount = -1 ;
    }       
    clearTimeout(timeoutid);
    var href = document.getElementById('slideshow');
    href.innerText = 'Start Diashow';
    href.href = 'javascript:Startslideshow(' + imagecount + ')';
    document.getElementById('controls').style.display = 'block' ;
    //Showfoto(imagecount);
    
}

function terugoverzicht() {
    if (timeoutid != -1 ) {
    clearTimeout(timeoutid);
    }
    var href = document.getElementById('slideshow');
    href.innerText = 'Start slideshow';
    href.href = 'javascript:Startslideshow(-2)';
    
    document.getElementById('fotogallerijdiv').style.display = 'block';
    document.getElementById('fotodiv').style.display = 'none';
    document.getElementById('terugalbum').style.display = 'block'
    document.getElementById('terugoverzicht').style.display = 'none'
    var fotogroot = document.getElementById('fotogroot');
    fotogroot.removeAttribute('src');
    //document.getElementById('slideshowdiv').style.display = 'block'
}

function Showfoto(imagecount,directie){
    var divfotoalbum = document.getElementById('fotogallerijdiv') ;
    var foto = document.getElementById('fotodiv') ;
    //window.scrollTo('0','90');    
    divfotoalbum.style.display = 'none';
    document.getElementById('terugoverzicht').style.display = 'block'
    document.getElementById('terugalbum').style.display = 'none'
    //document.getElementById('slideshowdiv').style.display = 'block'
    var fotogroot = document.getElementById('fotogroot');
    var url = imagearray[imagecount];
    var result = url.split('|');
    if (fotogroot.src == '') {
        fotogroot.src = result[0];
    }else{
        var margin = ''
        var margin2 = '' 
        if (directie == 'volgende') {
             margin = "-1000px";
             margin2 = "1000px";
        }
        if (directie == 'vorige') {
            margin = "1000px";
            margin2 = "-1000px";
        }
        
        $('#fotogroot').animate({marginLeft:margin}, "slow", null, function(){
               fotogroot.src = result[0];
            $('#fotogroot').css("margin-left",margin2);
           $('#fotogroot').animate({marginLeft:"0px"}, "slow");
        }
        );
    }
    var longdesc = document.getElementById('longdesc');
    var fototext = document.getElementById('lblfoto');
    var fotonummer = 'foto ' + (imagecount+1) + '/' + imagearray.length + '' ;
    //alert(result[1]);
    if (result[3] == '-') {
        longdesc.innerText = 'Geen beschrijving';
    }else{
        longdesc.innerText = (result[2]);
    }
 //   if (result[1] == '-') {
   //     fototext.innerText = 'geen naam';
    //}else{
      //  fototext.innerText = (result[1] );
    //}
    foto.style.display = 'block' ;
    var vorige = document.getElementById('vorige');
    var volgende = document.getElementById('volgende');
   
   if (document.getElementById('slideshow').innerText != 'Stop Diashow'){
     document.getElementById('controls').style.display = 'block' ;
   }
     
    if ((imagecount+1) < (imagearray.length)) {
        volgende.href = 'javascript:Showfoto(' + (imagecount+1) + ',\'volgende\'' + ')';
        volgende.style.display = 'inline-block' ;
        volgende.style.visibility = 'visible';
    }else{
        volgende.style.display = 'inline-block' ;
        volgende.style.visibility = 'hidden';
    }
    if ((imagecount-1) >= 0 ) {
        vorige.href = 'javascript:Showfoto(' + (imagecount-1) + ',\'vorige\'' + ')';
        vorige.style.display = 'inline-block' ;
         vorige.style.visibility = 'visible';
    }else{
        vorige.style.display = 'inline-block' ;
        vorige.style.visibility = 'hidden';  
    }
    currentimage = imagecount;
    
    
}

function PrintPage(){
    var url = window.location.href;
    if (url.indexOf("#") != -1 ) {
      url = url.replace("#","&")
    } 	
	if (url.indexOf("?") == -1 ) { 
	openwin(url + '?mode=print',600,800);
	}else{
	  openwin(url + '&mode=print',600,800);  
	 }

}

function Printreis() {
    var url = window.location.href;
    if (url.indexOf("#") != -1) {
        url = url.replace("#", "&")
    }
    if (url.indexOf("?") == -1) {
        openwin(url + '?mode=printreis', 600, 800);
    } else {
        openwin(url + '&mode=printreis', 600, 800);
    }

}

function openwin(url, tmp3, tmp4){
	scn_w = screen.availwidth;
	scn_h = screen.availheight;
	pos_x = (scn_w - tmp3)/2 - 20;
	pos_y = (scn_h - tmp4)/2;
	show3 = window.open( url,'popup','width='+ tmp3 +',height='+ tmp4 +',top='+ pos_y +',left='+ pos_x +',resizable=0,scrollbars=auto,directories=0,toolbar=0,menubar=0');
	window.show3.focus();
}
var status = new Array();
status['expLanden'] = 1;
status['expPeriode'] = 0;
status['expThema'] = 0;
status['expNiveau'] = 0;

function showHide() {
    $('div.expandable').hide();
    $('div.expandable').prev('h3').addClass('uitklapper');
    $('div.expandable').prev('h3').addClass('plus');
    $('div.expandable').prev('h3').click(function() {
        $(this).next('div.expandable').toggle("slow");

        if ($(this).is('.plus')) {
            $(this).removeClass('plus');
            $(this).addClass('min');
            status[$(this).next('div.expandable').attr("id")] = 1;
        }
        else {
            $(this).removeClass('min');
            $(this).addClass('plus');
            status[$(this).next('div.expandable').attr("id")] = 0;
        }
    })

    //expanddiv("expLanden");
}

function expanddiv(divID) {
    status[divID] = 1;
    divID = "#" + divID;
    $(divID).show();
    $(divID).prev('h3').removeClass('plus');
    $(divID).prev('h3').addClass('min');  
}
function hidediv(divID) {
    status[divID] = 0;
    
    divID = "#" + divID;
    $(divID).hide();
    $(divID).prev('h3').removeClass('min');
    $(divID).prev('h3').addClass('plus');    
}



function ReloadStatus() {
    showHide();
    
    if (status['expLanden'] == 1) { expanddiv('expLanden'); }
    else { hidediv('expLanden'); }

    if (status['expPeriode'] == 1) { expanddiv('expPeriode'); }
    else { hidediv('expPeriode'); }

    if (status['expThema'] == 1) { expanddiv('expThema'); }
    else { hidediv('expThema'); }

    if (status['expNiveau'] == 1) { expanddiv('expNiveau'); }
    else { hidediv('expNiveau'); }

//    if (status[""] == 1) {
//        expanddiv(expLanden);
//    } else {
//        hidediv(expLanden);
//    }
}